diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml
index e519415b3..29163d8c5 100644
--- a/.github/workflows/golangci-lint.yml
+++ b/.github/workflows/golangci-lint.yml
@@ -3,7 +3,7 @@ name: Linter
# Run on every main merge and on PRs.
on:
push:
- branches: ["main"]
+ branches: ["main", "v0.50.6b"]
paths: ["**.go", "**.proto", "go.mod", "go.sum", "**go.mod", "**go.sum"]
pull_request:
paths: ["**.go", "**.proto", "go.mod", "go.sum", "**go.mod", "**go.sum"]
diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml
index 2f318fe89..7f73bba49 100644
--- a/.github/workflows/integration-tests.yml
+++ b/.github/workflows/integration-tests.yml
@@ -5,7 +5,7 @@ on:
schedule:
- cron: "0 0 * * *" # Runs automatically every day
push:
- branches: ["main"]
+ branches: ["main", "v0.50.6b"]
pull_request:
# paths makes the action run only when the given paths are changed
paths: ["**.go", "**.proto", "go.mod", "go.sum", "**go.mod", "**go.sum"]
diff --git a/.github/workflows/simulation-tests.yml b/.github/workflows/simulation-tests.yml
index fa5888834..dae8affd7 100644
--- a/.github/workflows/simulation-tests.yml
+++ b/.github/workflows/simulation-tests.yml
@@ -5,6 +5,7 @@ on:
branches:
# every push to default branch
- main
+ - v0.50.6b
schedule:
# once per day
- cron: "0 0 * * *"
@@ -56,4 +57,4 @@ jobs:
cache: true
- name: TestAppSimulationAfterImport
run: |
- make test-sim-after-import
\ No newline at end of file
+ make test-sim-after-import
diff --git a/app/ante.go b/app/ante.go
index a0d70a1bc..362db96ea 100644
--- a/app/ante.go
+++ b/app/ante.go
@@ -1,29 +1,29 @@
package app
import (
+ corestoretypes "cosmossdk.io/core/store"
sdkerrors "cosmossdk.io/errors"
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"
- devgaskeeper "github.com/NibiruChain/nibiru/x/devgas/v1/keeper"
+ // devgasante "github.com/NibiruChain/nibiru/x/devgas/v1/ante"
+ // devgaskeeper "github.com/NibiruChain/nibiru/x/devgas/v1/keeper"
)
type AnteHandlerOptions struct {
sdkante.HandlerOptions
- IBCKeeper *ibckeeper.Keeper
- DevGasKeeper *devgaskeeper.Keeper
- DevGasBankKeeper devgasante.BankKeeper
+ IBCKeeper *ibckeeper.Keeper
+ // DevGasKeeper *devgaskeeper.Keeper
+ // DevGasBankKeeper devgasante.BankKeeper
- TxCounterStoreKey types.StoreKey
- WasmConfig *wasmtypes.WasmConfig
+ TXCounterStoreService corestoretypes.KVStoreService
+ WasmConfig *wasmtypes.WasmConfig
}
// NewAnteHandler returns and AnteHandler that checks and increments sequence
@@ -37,19 +37,19 @@ func NewAnteHandler(options AnteHandlerOptions) (sdk.AnteHandler, error) {
anteDecorators := []sdk.AnteDecorator{
sdkante.NewSetUpContextDecorator(),
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
- wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey),
+ wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService),
sdkante.NewExtensionOptionsDecorator(nil),
sdkante.NewValidateBasicDecorator(),
sdkante.NewTxTimeoutHeightDecorator(),
sdkante.NewValidateMemoDecorator(options.AccountKeeper),
- ante.NewPostPriceFixedPriceDecorator(),
+ // ante.NewPostPriceFixedPriceDecorator(),
ante.AnteDecoratorStakingCommission{},
sdkante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
// Replace fee ante from cosmos auth with a custom one.
sdkante.NewDeductFeeDecorator(
options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
- devgasante.NewDevGasPayoutDecorator(
- options.DevGasBankKeeper, options.DevGasKeeper),
+ // devgasante.NewDevGasPayoutDecorator(
+ // options.DevGasBankKeeper, options.DevGasKeeper),
// SetPubKeyDecorator must be called before all signature verification decorators
sdkante.NewSetPubKeyDecorator(options.AccountKeeper),
sdkante.NewValidateSigCountDecorator(options.AccountKeeper),
@@ -78,9 +78,9 @@ func (opts *AnteHandlerOptions) ValidateAndClean() error {
if opts.WasmConfig == nil {
return AnteHandlerError("wasm config")
}
- if opts.DevGasKeeper == nil {
- return AnteHandlerError("devgas keeper")
- }
+ // if opts.DevGasKeeper == nil {
+ // return AnteHandlerError("devgas keeper")
+ // }
if opts.IBCKeeper == nil {
return AnteHandlerError("ibc keeper")
}
diff --git a/app/ante/commission.go b/app/ante/commission.go
index a0fca11da..affae481b 100644
--- a/app/ante/commission.go
+++ b/app/ante/commission.go
@@ -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)
diff --git a/app/ante/commission_test.go b/app/ante/commission_test.go
index db96b5776..c04ed4d76 100644
--- a/app/ante/commission_test.go
+++ b/app/ante/commission_test.go
@@ -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{
@@ -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
@@ -120,6 +120,7 @@ func (s *AnteTestSuite) TestAnteDecoratorStakingCommission() {
WithFees(txGasCoins.String()).
WithChainID(s.ctx.ChainID()).
WithTxConfig(encCfg.TxConfig).
+ WithChainID("nibi-test-chain").
BuildUnsignedTx(tc.txMsgs...)
s.NoError(err)
diff --git a/app/ante/errors.go b/app/ante/errors.go
index 5e5ef2bdc..4f4e48865 100644
--- a/app/ante/errors.go
+++ b/app/ante/errors.go
@@ -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
@@ -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())
}
diff --git a/app/ante/fixed_gas.go b/app/ante/fixed_gas.go
index d1f4ca7ad..e013c3656 100644
--- a/app/ante/fixed_gas.go
+++ b/app/ante/fixed_gas.go
@@ -1,56 +1,49 @@
package ante
-import (
- sdkerrors "cosmossdk.io/errors"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-const OracleMessageGas = 500
-
-var _ sdk.AnteDecorator = EnsureSinglePostPriceMessageDecorator{}
-
-// EnsureSinglePostPriceMessageDecorator ensures that there is only one oracle vote message in the transaction
-// and sets the gas meter to a fixed value.
-type EnsureSinglePostPriceMessageDecorator struct{}
-
-func NewPostPriceFixedPriceDecorator() EnsureSinglePostPriceMessageDecorator {
- return EnsureSinglePostPriceMessageDecorator{}
-}
-
-func (gd EnsureSinglePostPriceMessageDecorator) AnteHandle(
- ctx sdk.Context,
- tx sdk.Tx,
- simulate bool,
- next sdk.AnteHandler,
-) (newCtx sdk.Context, err error) {
- hasOracleVoteMsg := false
- hasOraclePreVoteMsg := false
-
- msgs := tx.GetMsgs()
- for _, msg := range msgs {
- switch msg.(type) {
- case *oracletypes.MsgAggregateExchangeRatePrevote:
- hasOraclePreVoteMsg = true
- case *oracletypes.MsgAggregateExchangeRateVote:
- hasOracleVoteMsg = true
- }
- }
-
- if hasOracleVoteMsg && hasOraclePreVoteMsg {
- if len(msgs) > 2 {
- return ctx, sdkerrors.Wrap(ErrOracleAnte, "a transaction cannot have more than a single oracle vote and prevote message")
- }
-
- ctx = ctx.WithGasMeter(NewFixedGasMeter(OracleMessageGas))
- } else if hasOraclePreVoteMsg || hasOracleVoteMsg {
- if len(msgs) > 1 {
- return ctx, sdkerrors.Wrap(ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages")
- }
-
- ctx = ctx.WithGasMeter(NewFixedGasMeter(OracleMessageGas))
- }
-
- return next(ctx, tx, simulate)
-}
+// const OracleMessageGas = 500
+
+// var _ sdk.AnteDecorator = EnsureSinglePostPriceMessageDecorator{}
+
+// // EnsureSinglePostPriceMessageDecorator ensures that there is only one oracle vote message in the transaction
+// // and sets the gas meter to a fixed value.
+// type EnsureSinglePostPriceMessageDecorator struct{}
+
+// func NewPostPriceFixedPriceDecorator() EnsureSinglePostPriceMessageDecorator {
+// return EnsureSinglePostPriceMessageDecorator{}
+// }
+
+// func (gd EnsureSinglePostPriceMessageDecorator) AnteHandle(
+// ctx sdk.Context,
+// tx sdk.Tx,
+// simulate bool,
+// next sdk.AnteHandler,
+// ) (newCtx sdk.Context, err error) {
+// hasOracleVoteMsg := false
+// hasOraclePreVoteMsg := false
+
+// msgs := tx.GetMsgs()
+// for _, msg := range msgs {
+// switch msg.(type) {
+// case *oracletypes.MsgAggregateExchangeRatePrevote:
+// hasOraclePreVoteMsg = true
+// case *oracletypes.MsgAggregateExchangeRateVote:
+// hasOracleVoteMsg = true
+// }
+// }
+
+// if hasOracleVoteMsg && hasOraclePreVoteMsg {
+// if len(msgs) > 2 {
+// return ctx, sdkerrors.Wrap(ErrOracleAnte, "a transaction cannot have more than a single oracle vote and prevote message")
+// }
+
+// ctx = ctx.WithGasMeter(NewFixedGasMeter(OracleMessageGas))
+// } else if hasOraclePreVoteMsg || hasOracleVoteMsg {
+// if len(msgs) > 1 {
+// return ctx, sdkerrors.Wrap(ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages")
+// }
+
+// ctx = ctx.WithGasMeter(NewFixedGasMeter(OracleMessageGas))
+// }
+
+// return next(ctx, tx, simulate)
+// }
diff --git a/app/ante/fixed_gas_test.go b/app/ante/fixed_gas_test.go
index 264a66ab6..46249c038 100644
--- a/app/ante/fixed_gas_test.go
+++ b/app/ante/fixed_gas_test.go
@@ -1,261 +1,241 @@
package ante_test
-import (
- "testing"
+// func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
+// priv1, addr := testutil.PrivKey()
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
+// tests := []struct {
+// name string
+// messages []sdk.Msg
+// expectedGas storetypes.Gas
+// expectedErr error
+// }{
+// {
+// name: "Oracle Prevote Transaction",
+// messages: []sdk.Msg{
+// &oracletypes.MsgAggregateExchangeRatePrevote{
+// Hash: "dummyData",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// },
+// expectedGas: ante.OracleMessageGas,
+// expectedErr: nil,
+// },
+// {
+// name: "Oracle Vote Transaction",
+// messages: []sdk.Msg{
+// &oracletypes.MsgAggregateExchangeRateVote{
+// Salt: "dummySalt",
+// ExchangeRates: "someData",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// },
+// expectedGas: ante.OracleMessageGas,
+// expectedErr: nil,
+// },
+// {
+// name: "Two messages in a transaction, one of them is an oracle vote message should fail (with MsgAggregateExchangeRatePrevote)",
+// messages: []sdk.Msg{
+// &oracletypes.MsgAggregateExchangeRatePrevote{
+// Hash: "",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// &types.MsgSend{
+// FromAddress: addr.String(),
+// ToAddress: addr.String(),
+// Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
+// },
+// },
+// expectedGas: 1042,
+// expectedErr: sdkioerrors.Wrap(ante.ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages"),
+// },
+// {
+// name: "Two messages in a transaction, one of them is an oracle vote message should fail (with MsgAggregateExchangeRatePrevote) permutation 2",
+// messages: []sdk.Msg{
+// &types.MsgSend{
+// FromAddress: addr.String(),
+// ToAddress: addr.String(),
+// Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
+// },
+// &oracletypes.MsgAggregateExchangeRatePrevote{
+// Hash: "",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// },
+// expectedGas: 1042,
+// expectedErr: sdkioerrors.Wrap(ante.ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages"),
+// },
+// {
+// name: "Two messages in a transaction, one of them is an oracle vote message should fail (with MsgAggregateExchangeRateVote)",
+// messages: []sdk.Msg{
+// &oracletypes.MsgAggregateExchangeRateVote{
+// Salt: "dummySalt",
+// ExchangeRates: "someData",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// &types.MsgSend{
+// FromAddress: addr.String(),
+// ToAddress: addr.String(),
+// Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
+// },
+// },
+// expectedGas: 1042,
+// expectedErr: sdkioerrors.Wrap(ante.ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages"),
+// },
+// {
+// name: "Two messages in a transaction, one of them is an oracle vote message should fail (with MsgAggregateExchangeRateVote) permutation 2",
+// messages: []sdk.Msg{
+// &types.MsgSend{
+// FromAddress: addr.String(),
+// ToAddress: addr.String(),
+// Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
+// },
+// &oracletypes.MsgAggregateExchangeRateVote{
+// Salt: "dummySalt",
+// ExchangeRates: "someData",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// },
+// expectedGas: 1042,
+// expectedErr: sdkioerrors.Wrap(ante.ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages"),
+// },
+// {
+// name: "Two messages in a transaction, one is oracle vote, the other oracle pre vote: should work with fixed price",
+// messages: []sdk.Msg{
+// &oracletypes.MsgAggregateExchangeRatePrevote{
+// Hash: "",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// &oracletypes.MsgAggregateExchangeRateVote{
+// Salt: "dummySalt",
+// ExchangeRates: "someData",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// },
+// expectedGas: ante.OracleMessageGas,
+// expectedErr: nil,
+// },
+// {
+// name: "Two messages in a transaction, one is oracle vote, the other oracle pre vote: should work with fixed price permutation 2",
+// messages: []sdk.Msg{
+// &oracletypes.MsgAggregateExchangeRateVote{
+// Salt: "dummySalt",
+// ExchangeRates: "someData",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// &oracletypes.MsgAggregateExchangeRatePrevote{
+// Hash: "",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// },
+// expectedGas: ante.OracleMessageGas,
+// expectedErr: nil,
+// },
+// {
+// name: "Three messages in tx, two related to oracle, but other one is not: should fail",
+// messages: []sdk.Msg{
+// &oracletypes.MsgAggregateExchangeRateVote{
+// Salt: "dummySalt",
+// ExchangeRates: "someData",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// &types.MsgSend{
+// FromAddress: addr.String(),
+// ToAddress: addr.String(),
+// Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
+// },
+// &oracletypes.MsgAggregateExchangeRatePrevote{
+// Hash: "",
+// Feeder: addr.String(),
+// Validator: addr.String(),
+// },
+// },
+// expectedGas: 1042,
+// expectedErr: sdkioerrors.Wrap(ante.ErrOracleAnte, "a transaction cannot have more than a single oracle vote and prevote message"),
+// },
+// {
+// name: "Other two messages",
+// messages: []sdk.Msg{
+// &types.MsgSend{
+// FromAddress: addr.String(),
+// ToAddress: addr.String(),
+// Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
+// },
+// &types.MsgSend{
+// FromAddress: addr.String(),
+// ToAddress: addr.String(),
+// Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 200)),
+// },
+// },
+// expectedGas: 67193,
+// expectedErr: nil,
+// },
+// }
- sdkioerrors "cosmossdk.io/errors"
- "cosmossdk.io/math"
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
- "github.com/cosmos/cosmos-sdk/testutil/testdata"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/x/auth/signing"
- "github.com/cosmos/cosmos-sdk/x/bank/types"
+// for _, tc := range tests {
+// tc := tc
+// suite.T().Run(tc.name, func(t *testing.T) {
+// suite.SetupTest() // setup
+// suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder()
- "github.com/NibiruChain/nibiru/app/ante"
- "github.com/NibiruChain/nibiru/app/appconst"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
-)
+// // msg and signatures
+// feeAmount := sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 150))
+// gasLimit := testdata.NewTestGasLimit()
+// suite.txBuilder.SetFeeAmount(feeAmount)
+// suite.txBuilder.SetGasLimit(gasLimit)
+// suite.txBuilder.SetMemo("some memo")
-func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
- priv1, addr := testutil.PrivKey()
+// suite.NoError(suite.txBuilder.SetMsgs(tc.messages...))
- tests := []struct {
- name string
- messages []sdk.Msg
- expectedGas sdk.Gas
- expectedErr error
- }{
- {
- name: "Oracle Prevote Transaction",
- messages: []sdk.Msg{
- &oracletypes.MsgAggregateExchangeRatePrevote{
- Hash: "dummyData",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- },
- expectedGas: ante.OracleMessageGas,
- expectedErr: nil,
- },
- {
- name: "Oracle Vote Transaction",
- messages: []sdk.Msg{
- &oracletypes.MsgAggregateExchangeRateVote{
- Salt: "dummySalt",
- ExchangeRates: "someData",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- },
- expectedGas: ante.OracleMessageGas,
- expectedErr: nil,
- },
- {
- name: "Two messages in a transaction, one of them is an oracle vote message should fail (with MsgAggregateExchangeRatePrevote)",
- messages: []sdk.Msg{
- &oracletypes.MsgAggregateExchangeRatePrevote{
- Hash: "",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- &types.MsgSend{
- FromAddress: addr.String(),
- ToAddress: addr.String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
- },
- },
- expectedGas: 1042,
- expectedErr: sdkioerrors.Wrap(ante.ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages"),
- },
- {
- name: "Two messages in a transaction, one of them is an oracle vote message should fail (with MsgAggregateExchangeRatePrevote) permutation 2",
- messages: []sdk.Msg{
- &types.MsgSend{
- FromAddress: addr.String(),
- ToAddress: addr.String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
- },
- &oracletypes.MsgAggregateExchangeRatePrevote{
- Hash: "",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- },
- expectedGas: 1042,
- expectedErr: sdkioerrors.Wrap(ante.ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages"),
- },
- {
- name: "Two messages in a transaction, one of them is an oracle vote message should fail (with MsgAggregateExchangeRateVote)",
- messages: []sdk.Msg{
- &oracletypes.MsgAggregateExchangeRateVote{
- Salt: "dummySalt",
- ExchangeRates: "someData",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- &types.MsgSend{
- FromAddress: addr.String(),
- ToAddress: addr.String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
- },
- },
- expectedGas: 1042,
- expectedErr: sdkioerrors.Wrap(ante.ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages"),
- },
- {
- name: "Two messages in a transaction, one of them is an oracle vote message should fail (with MsgAggregateExchangeRateVote) permutation 2",
- messages: []sdk.Msg{
- &types.MsgSend{
- FromAddress: addr.String(),
- ToAddress: addr.String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
- },
- &oracletypes.MsgAggregateExchangeRateVote{
- Salt: "dummySalt",
- ExchangeRates: "someData",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- },
- expectedGas: 1042,
- expectedErr: sdkioerrors.Wrap(ante.ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages"),
- },
- {
- name: "Two messages in a transaction, one is oracle vote, the other oracle pre vote: should work with fixed price",
- messages: []sdk.Msg{
- &oracletypes.MsgAggregateExchangeRatePrevote{
- Hash: "",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- &oracletypes.MsgAggregateExchangeRateVote{
- Salt: "dummySalt",
- ExchangeRates: "someData",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- },
- expectedGas: ante.OracleMessageGas,
- expectedErr: nil,
- },
- {
- name: "Two messages in a transaction, one is oracle vote, the other oracle pre vote: should work with fixed price permutation 2",
- messages: []sdk.Msg{
- &oracletypes.MsgAggregateExchangeRateVote{
- Salt: "dummySalt",
- ExchangeRates: "someData",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- &oracletypes.MsgAggregateExchangeRatePrevote{
- Hash: "",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- },
- expectedGas: ante.OracleMessageGas,
- expectedErr: nil,
- },
- {
- name: "Three messages in tx, two related to oracle, but other one is not: should fail",
- messages: []sdk.Msg{
- &oracletypes.MsgAggregateExchangeRateVote{
- Salt: "dummySalt",
- ExchangeRates: "someData",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- &types.MsgSend{
- FromAddress: addr.String(),
- ToAddress: addr.String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
- },
- &oracletypes.MsgAggregateExchangeRatePrevote{
- Hash: "",
- Feeder: addr.String(),
- Validator: addr.String(),
- },
- },
- expectedGas: 1042,
- expectedErr: sdkioerrors.Wrap(ante.ErrOracleAnte, "a transaction cannot have more than a single oracle vote and prevote message"),
- },
- {
- name: "Other two messages",
- messages: []sdk.Msg{
- &types.MsgSend{
- FromAddress: addr.String(),
- ToAddress: addr.String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 100)),
- },
- &types.MsgSend{
- FromAddress: addr.String(),
- ToAddress: addr.String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 200)),
- },
- },
- expectedGas: 67193,
- expectedErr: nil,
- },
- }
+// privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{11}, []uint64{0}
+// 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())
- for _, tc := range tests {
- tc := tc
- suite.T().Run(tc.name, func(t *testing.T) {
- suite.SetupTest() // setup
- suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder()
+// err = testapp.FundAccount(
+// suite.app.BankKeeper, suite.ctx, addr,
+// sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 1000)),
+// )
+// suite.Require().NoError(err)
- // msg and signatures
- feeAmount := sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 150))
- gasLimit := testdata.NewTestGasLimit()
- suite.txBuilder.SetFeeAmount(feeAmount)
- suite.txBuilder.SetGasLimit(gasLimit)
- suite.txBuilder.SetMemo("some memo")
+// suite.ctx, err = suite.anteHandler(
+// suite.ctx,
+// tx,
+// /*simulate*/ true,
+// )
+// if tc.expectedErr != nil {
+// suite.Error(err)
+// suite.Contains(err.Error(), tc.expectedErr.Error())
+// } else {
+// suite.NoError(err)
+// }
+// want := math.NewInt(int64(tc.expectedGas))
+// got := math.NewInt(int64(suite.ctx.GasMeter().GasConsumed()))
+// suite.Equal(want.String(), got.String())
+// })
+// }
+// }
- suite.NoError(suite.txBuilder.SetMsgs(tc.messages...))
+// func (s *AnteTestSuite) ValidateTx(tx signing.Tx, t *testing.T) {
+// memoTx, ok := tx.(sdk.TxWithMemo)
+// if !ok {
+// s.Fail(sdkioerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type").Error(), "memoTx: %t", memoTx)
+// }
- privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{11}, []uint64{0}
- tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID())
- suite.NoErrorf(err, "tx: %v", tx)
- suite.NoError(tx.ValidateBasic())
- suite.ValidateTx(tx, suite.T())
+// params := s.app.AccountKeeper.GetParams(s.ctx)
+// s.EqualValues(256, params.MaxMemoCharacters)
- err = testapp.FundAccount(
- suite.app.BankKeeper, suite.ctx, addr,
- sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 1000)),
- )
- suite.Require().NoError(err)
-
- suite.ctx, err = suite.anteHandler(
- suite.ctx,
- tx,
- /*simulate*/ true,
- )
- if tc.expectedErr != nil {
- suite.Error(err)
- suite.Contains(err.Error(), tc.expectedErr.Error())
- } else {
- suite.NoError(err)
- }
- want := math.NewInt(int64(tc.expectedGas))
- got := math.NewInt(int64(suite.ctx.GasMeter().GasConsumed()))
- suite.Equal(want.String(), got.String())
- })
- }
-}
-
-func (s *AnteTestSuite) ValidateTx(tx signing.Tx, t *testing.T) {
- memoTx, ok := tx.(sdk.TxWithMemo)
- if !ok {
- s.Fail(sdkioerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type").Error(), "memoTx: %t", memoTx)
- }
-
- params := s.app.AccountKeeper.GetParams(s.ctx)
- s.EqualValues(256, params.MaxMemoCharacters)
-
- memoLen := len(memoTx.GetMemo())
- s.True(memoLen < int(params.MaxMemoCharacters))
-}
+// memoLen := len(memoTx.GetMemo())
+// s.True(memoLen < int(params.MaxMemoCharacters))
+// }
diff --git a/app/ante/gas.go b/app/ante/gas.go
index 7b4c2da98..591e5f93d 100644
--- a/app/ante/gas.go
+++ b/app/ante/gas.go
@@ -3,31 +3,29 @@ 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
}
@@ -35,8 +33,8 @@ 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
diff --git a/app/ante/testutil_test.go b/app/ante/testutil_test.go
index 071415826..0a9bd6125 100644
--- a/app/ante/testutil_test.go
+++ b/app/ante/testutil_test.go
@@ -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"
@@ -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(),
@@ -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())
@@ -66,7 +68,7 @@ func (suite *AnteTestSuite) SetupTest() {
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(suite.app.AccountKeeper),
- nibiruante.NewPostPriceFixedPriceDecorator(),
+ // nibiruante.NewPostPriceFixedPriceDecorator(),
nibiruante.AnteDecoratorStakingCommission{},
ante.NewConsumeGasForTxSizeDecorator(suite.app.AccountKeeper),
ante.NewDeductFeeDecorator(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.FeeGrantKeeper, nil), // Replace fee ante from cosmos auth with a custom one.
@@ -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],
@@ -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
}
diff --git a/app/app.go b/app/app.go
index 8245208cf..bf4c3a454 100644
--- a/app/app.go
+++ b/app/app.go
@@ -13,22 +13,21 @@ import (
"github.com/NibiruChain/nibiru/app/wasmext"
- dbm "github.com/cometbft/cometbft-db"
+ "cosmossdk.io/log"
+ storetypes "cosmossdk.io/store/types"
abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cometbft/cometbft/libs/log"
tmos "github.com/cometbft/cometbft/libs/os"
+ dbm "github.com/cosmos/cosmos-db"
"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"
@@ -36,12 +35,12 @@ import (
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"
@@ -79,6 +78,7 @@ type NibiruApp struct {
*baseapp.BaseApp
legacyAmino *codec.LegacyAmino
appCodec codec.Codec
+ txConfig client.TxConfig
interfaceRegistry codectypes.InterfaceRegistry
// keys to access the substores
@@ -190,11 +190,11 @@ func NewNibiruApp(
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: authante.DefaultSigVerificationGasConsumer,
},
- IBCKeeper: app.ibcKeeper,
- TxCounterStoreKey: keys[wasmtypes.StoreKey],
- WasmConfig: &wasmConfig,
- DevGasKeeper: &app.DevGasKeeper,
- DevGasBankKeeper: app.BankKeeper,
+ IBCKeeper: app.ibcKeeper,
+ TXCounterStoreService: runtime.NewKVStoreService(keys[wasmtypes.StoreKey]),
+ WasmConfig: &wasmConfig,
+ // DevGasKeeper: &app.DevGasKeeper,
+ // DevGasBankKeeper: app.BankKeeper,
})
if err != nil {
panic(fmt.Errorf("failed to create sdk.AnteHandler: %s", err))
@@ -242,18 +242,20 @@ func NewNibiruApp(
// Name returns the name of the App
func (app *NibiruApp) Name() string { return app.BaseApp.Name() }
-// BeginBlocker application updates every begin block
-func (app *NibiruApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
- return app.ModuleManager.BeginBlock(ctx, req)
+// BeginBlocker runs the Tendermint ABCI BeginBlock logic. It executes state changes at the beginning
+// of the new block for every registered module. If there is a registered fork at the current height,
+// BeginBlocker will schedule the upgrade plan and perform the state migration (if any).
+func (app *NibiruApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) {
+ return app.ModuleManager.BeginBlock(ctx)
}
-// EndBlocker application updates every end block
-func (app *NibiruApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
- return app.ModuleManager.EndBlock(ctx, req)
+// EndBlocker updates every end block
+func (app *NibiruApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) {
+ return app.ModuleManager.EndBlock(ctx)
}
// InitChainer application update at chain initialization
-func (app *NibiruApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
+func (app *NibiruApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
var genesisState GenesisState
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
@@ -267,8 +269,8 @@ func (app *NibiruApp) LoadHeight(height int64) error {
return app.LoadVersion(height)
}
-func (app *NibiruApp) RegisterNodeService(clientCtx client.Context) {
- node.RegisterNodeService(clientCtx, app.GRPCQueryRouter())
+func (app *NibiruApp) RegisterNodeService(clientCtx client.Context, config config.Config) {
+ node.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), config)
}
// ModuleAccountAddrs returns all the app's module account addresses.
@@ -346,7 +348,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)
@@ -366,7 +368,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,
diff --git a/app/codec/codec.go b/app/codec/codec.go
index a80f74525..ab53862f4 100644
--- a/app/codec/codec.go
+++ b/app/codec/codec.go
@@ -1,10 +1,14 @@
package codec
import (
+ "cosmossdk.io/x/tx/signing"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
+ "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/codec/types"
+ sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
+ "github.com/cosmos/gogoproto/proto"
)
// EncodingConfig specifies the concrete encoding types to use for a given app.
@@ -18,8 +22,31 @@ type EncodingConfig struct {
// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration.
func MakeEncodingConfig() EncodingConfig {
+ signingOptions := signing.Options{
+ AddressCodec: address.Bech32Codec{
+ Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(),
+ },
+ ValidatorAddressCodec: address.Bech32Codec{
+ Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(),
+ },
+ }
+
+ // Might need
+ // evm/MsgEthereumTx, erc20/MsgConvertERC20
+ // signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2)
+ // signingOptions.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2)
+
+ options := types.InterfaceRegistryOptions{
+ ProtoFiles: proto.HybridResolver,
+ SigningOptions: signingOptions,
+ }
+
amino := codec.NewLegacyAmino()
- interfaceRegistry := types.NewInterfaceRegistry()
+ interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(options)
+ if err != nil {
+ panic(err)
+ }
+
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)
diff --git a/app/export.go b/app/export.go
index 7a9a5ed6a..fd927444d 100644
--- a/app/export.go
+++ b/app/export.go
@@ -4,7 +4,7 @@ import (
"encoding/json"
"log"
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
+ storetypes "cosmossdk.io/store/types"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -19,7 +19,7 @@ func (app *NibiruApp) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string,
) (servertypes.ExportedApp, error) {
// as if they could withdraw from the start of the next block
- ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
+ ctx := app.NewContext(true)
// We export at last height + 1, because that's the height at which
// Tendermint will start InitChain.
@@ -29,7 +29,11 @@ func (app *NibiruApp) ExportAppStateAndValidators(
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
}
- genState := app.ModuleManager.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
+ genState, err := app.ModuleManager.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
+ if err != nil {
+ return servertypes.ExportedApp{}, err
+ }
+
appState, err := json.MarshalIndent(genState, "", " ")
if err != nil {
return servertypes.ExportedApp{}, err
@@ -73,12 +77,19 @@ func (app *NibiruApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
// withdraw all validator commission
app.stakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
- _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
+ valBz, err := app.stakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
+ if err != nil {
+ panic(err)
+ }
+ _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz)
return false
})
// withdraw all delegator rewards
- dels := app.stakingKeeper.GetAllDelegations(ctx)
+ dels, err := app.stakingKeeper.GetAllDelegations(ctx)
+ if err != nil {
+ panic(err)
+ }
for _, delegation := range dels {
valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress)
if err != nil {
@@ -104,14 +115,25 @@ func (app *NibiruApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
// reinitialize all validators
app.stakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
+ valBz, err := app.stakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
+ if err != nil {
+ panic(err)
+ }
// donate any unwithdrawn outstanding reward fraction tokens to the community pool
- scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator())
- feePool := app.DistrKeeper.GetFeePool(ctx)
+ scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valBz)
+ if err != nil {
+ panic(err)
+ }
+ feePool, err := app.DistrKeeper.FeePool.Get(ctx)
+ if err != nil {
+ panic(err)
+ }
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
- app.DistrKeeper.SetFeePool(ctx, feePool)
+ if err := app.DistrKeeper.FeePool.Set(ctx, feePool); err != nil {
+ panic(err)
+ }
- err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
- if err != nil {
+ if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, valBz); err != nil {
panic(err)
}
return false
@@ -163,13 +185,13 @@ func (app *NibiruApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
// Iterate through validators by power descending, reset bond heights, and
// update bond intra-tx counters.
store := ctx.KVStore(app.keys[stakingtypes.StoreKey])
- iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey)
+ iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey)
counter := int16(0)
for ; iter.Valid(); iter.Next() {
addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key()))
- validator, found := app.stakingKeeper.GetValidator(ctx, addr)
- if !found {
+ validator, err := app.stakingKeeper.GetValidator(ctx, addr)
+ if err != nil {
panic("expected validator, not found")
}
@@ -182,9 +204,12 @@ func (app *NibiruApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
counter++
}
- iter.Close()
+ if err := iter.Close(); err != nil {
+ app.Logger().Error("error while closing the key-value store reverse prefix iterator: ", err)
+ return
+ }
- _, err := app.stakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
+ _, err = app.stakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
if err != nil {
log.Fatal(err)
}
diff --git a/app/genesis.go b/app/genesis.go
index 0710a5b9a..7410d6435 100644
--- a/app/genesis.go
+++ b/app/genesis.go
@@ -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 {
diff --git a/app/ibc_test.go b/app/ibc_test.go
index 5e16338c1..105dfb4ab 100644
--- a/app/ibc_test.go
+++ b/app/ibc_test.go
@@ -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"
diff --git a/app/keepers.go b/app/keepers.go
index e5ed3f5c6..9cdb3eb88 100644
--- a/app/keepers.go
+++ b/app/keepers.go
@@ -4,26 +4,38 @@ import (
"path/filepath"
"strings"
- ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
- icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller"
- icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
- icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
- icahost "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host"
- icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
- icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
-
+ "github.com/cosmos/cosmos-sdk/client"
+ sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
+ authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
+ "github.com/cosmos/cosmos-sdk/x/auth/tx"
+ txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
+ ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
+ icacontroller "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller"
+ icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper"
+ icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
+ icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host"
+ icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
+ icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
+
+ "github.com/NibiruChain/nibiru/app/appconst"
+
+ "cosmossdk.io/store/types"
+ storetypes "cosmossdk.io/store/types"
+ "cosmossdk.io/x/evidence"
+ evidencekeeper "cosmossdk.io/x/evidence/keeper"
+ evidencetypes "cosmossdk.io/x/evidence/types"
+ "cosmossdk.io/x/feegrant"
+ feegrantkeeper "cosmossdk.io/x/feegrant/keeper"
+ feegrantmodule "cosmossdk.io/x/feegrant/module"
wasmdapp "github.com/CosmWasm/wasmd/app"
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
- _ "github.com/cosmos/cosmos-sdk/client/docs/statik"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
+ "github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
- "github.com/cosmos/cosmos-sdk/store/types"
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
@@ -37,23 +49,13 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
- "github.com/cosmos/cosmos-sdk/x/capability"
- capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
- capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
- "github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
- "github.com/cosmos/cosmos-sdk/x/evidence"
- evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"
- evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
- "github.com/cosmos/cosmos-sdk/x/feegrant"
- feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
- feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"
@@ -62,6 +64,9 @@ import (
govv1types "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1types "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
+ "github.com/cosmos/ibc-go/modules/capability"
+ capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
+ capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
@@ -76,61 +81,54 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
- "github.com/cosmos/cosmos-sdk/x/upgrade"
- upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
- upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
- upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
+ "cosmossdk.io/x/upgrade"
+ upgradekeeper "cosmossdk.io/x/upgrade/keeper"
+ upgradetypes "cosmossdk.io/x/upgrade/types"
// ---------------------------------------------------------------
// IBC imports
- icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper"
- ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee"
- ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper"
- ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
- ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
- ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper"
- ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
- ibc "github.com/cosmos/ibc-go/v7/modules/core"
- ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client"
- ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client"
- ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
- porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
- ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
- ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
- ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
- ibcmock "github.com/cosmos/ibc-go/v7/testing/mock"
+ icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper"
+ ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee"
+ ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
+ ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
+ ibctransfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer"
+ ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
+ ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
+ ibc "github.com/cosmos/ibc-go/v8/modules/core"
+ ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client"
+ ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
+ porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
+ ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
+ ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
+ ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
+ ibcmock "github.com/cosmos/ibc-go/v8/testing/mock"
"github.com/spf13/cast"
-
// ---------------------------------------------------------------
// Nibiru Custom Modules
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/x/common"
- "github.com/NibiruChain/nibiru/x/devgas/v1"
- devgaskeeper "github.com/NibiruChain/nibiru/x/devgas/v1/keeper"
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
- "github.com/NibiruChain/nibiru/x/epochs"
- epochskeeper "github.com/NibiruChain/nibiru/x/epochs/keeper"
- epochstypes "github.com/NibiruChain/nibiru/x/epochs/types"
- "github.com/NibiruChain/nibiru/x/evm"
- "github.com/NibiruChain/nibiru/x/evm/evmmodule"
- evmkeeper "github.com/NibiruChain/nibiru/x/evm/keeper"
- "github.com/NibiruChain/nibiru/x/genmsg"
- "github.com/NibiruChain/nibiru/x/inflation"
- inflationkeeper "github.com/NibiruChain/nibiru/x/inflation/keeper"
- inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
- oracle "github.com/NibiruChain/nibiru/x/oracle"
- oraclekeeper "github.com/NibiruChain/nibiru/x/oracle/keeper"
- oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
-
- "github.com/NibiruChain/nibiru/x/sudo"
- "github.com/NibiruChain/nibiru/x/sudo/keeper"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
-
- tokenfactory "github.com/NibiruChain/nibiru/x/tokenfactory"
- tokenfactorykeeper "github.com/NibiruChain/nibiru/x/tokenfactory/keeper"
- tokenfactorytypes "github.com/NibiruChain/nibiru/x/tokenfactory/types"
+ // "github.com/NibiruChain/nibiru/x/common"
+ // "github.com/NibiruChain/nibiru/x/devgas/v1"
+ // devgaskeeper "github.com/NibiruChain/nibiru/x/devgas/v1/keeper"
+ // devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
+ // "github.com/NibiruChain/nibiru/x/epochs"
+ // epochskeeper "github.com/NibiruChain/nibiru/x/epochs/keeper"
+ // epochstypes "github.com/NibiruChain/nibiru/x/epochs/types"
+ // "github.com/NibiruChain/nibiru/x/evm"
+ // "github.com/NibiruChain/nibiru/x/evm/evmmodule"
+ // evmkeeper "github.com/NibiruChain/nibiru/x/evm/keeper"
+ // "github.com/NibiruChain/nibiru/x/genmsg"
+ // "github.com/NibiruChain/nibiru/x/inflation"
+ // inflationkeeper "github.com/NibiruChain/nibiru/x/inflation/keeper"
+ // inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
+ // oracle "github.com/NibiruChain/nibiru/x/oracle"
+ // oraclekeeper "github.com/NibiruChain/nibiru/x/oracle/keeper"
+ // oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
+ // "github.com/NibiruChain/nibiru/x/sudo"
+ // "github.com/NibiruChain/nibiru/x/sudo/keeper"
+ // sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
+ // tokenfactory "github.com/NibiruChain/nibiru/x/tokenfactory"
+ // tokenfactorykeeper "github.com/NibiruChain/nibiru/x/tokenfactory/keeper"
+ // tokenfactorytypes "github.com/NibiruChain/nibiru/x/tokenfactory/types"
)
type AppKeepers struct {
@@ -144,8 +142,8 @@ type AppKeepers struct {
/* DistrKeeper is the keeper of the distribution store */
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
- crisisKeeper crisiskeeper.Keeper
- upgradeKeeper upgradekeeper.Keeper
+ crisisKeeper *crisiskeeper.Keeper
+ upgradeKeeper *upgradekeeper.Keeper
paramsKeeper paramskeeper.Keeper
authzKeeper authzkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
@@ -181,13 +179,13 @@ type AppKeepers struct {
// ---------------
// Nibiru keepers
// ---------------
- EpochsKeeper epochskeeper.Keeper
- OracleKeeper oraclekeeper.Keeper
- InflationKeeper inflationkeeper.Keeper
- SudoKeeper keeper.Keeper
- DevGasKeeper devgaskeeper.Keeper
- TokenFactoryKeeper tokenfactorykeeper.Keeper
- EvmKeeper evmkeeper.Keeper
+ // EpochsKeeper epochskeeper.Keeper
+ // OracleKeeper oraclekeeper.Keeper
+ // InflationKeeper inflationkeeper.Keeper
+ // SudoKeeper keeper.Keeper
+ // DevGasKeeper devgaskeeper.Keeper
+ // TokenFactoryKeeper tokenfactorykeeper.Keeper
+ // EvmKeeper evmkeeper.Keeper
// WASM keepers
WasmKeeper wasmkeeper.Keeper
@@ -199,7 +197,7 @@ func initStoreKeys() (
tkeys map[string]*types.TransientStoreKey,
memKeys map[string]*types.MemoryStoreKey,
) {
- keys = sdk.NewKVStoreKeys(
+ keys = storetypes.NewKVStoreKeys(
authtypes.StoreKey,
banktypes.StoreKey,
stakingtypes.StoreKey,
@@ -223,18 +221,18 @@ func initStoreKeys() (
icacontrollertypes.StoreKey,
// nibiru x/ keys
- oracletypes.StoreKey,
- epochstypes.StoreKey,
- inflationtypes.StoreKey,
- sudotypes.StoreKey,
+ // oracletypes.StoreKey,
+ // epochstypes.StoreKey,
+ // inflationtypes.StoreKey,
+ // sudotypes.StoreKey,
wasmtypes.StoreKey,
- devgastypes.StoreKey,
- tokenfactorytypes.StoreKey,
+ // devgastypes.StoreKey,
+ // tokenfactorytypes.StoreKey,
- evm.StoreKey,
+ // evm.StoreKey,
)
- tkeys = sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
- memKeys = sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
+ tkeys = storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
+ memKeys = storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
return keys, tkeys, memKeys
}
@@ -256,8 +254,13 @@ func (app *NibiruApp) InitKeepers(
)
// set the BaseApp's parameter store
- app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], govModuleAddr)
- bApp.SetParamStore(&app.ConsensusParamsKeeper)
+ app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(
+ appCodec,
+ runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]),
+ govModuleAddr,
+ runtime.EventService{},
+ )
+ bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore)
/* Add capabilityKeeper and ScopeToModule for the ibc module
This allows authentication of object-capability permissions for each of
@@ -285,29 +288,53 @@ func (app *NibiruApp) InitKeepers(
// to ProtoBaseAccount replacement.
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec,
- keys[authtypes.StoreKey],
- eth.ProtoBaseAccount,
+ runtime.NewKVStoreService(keys[authtypes.StoreKey]),
+ authtypes.ProtoBaseAccount,
maccPerms,
- sdk.GetConfig().GetBech32AccountAddrPrefix(),
+ authcodec.NewBech32Codec(appconst.AccountAddressPrefix),
+ appconst.AccountAddressPrefix,
govModuleAddr,
)
+
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
- keys[banktypes.StoreKey],
+ runtime.NewKVStoreService(keys[banktypes.StoreKey]),
app.AccountKeeper,
BlockedAddresses(),
govModuleAddr,
+ app.Logger().With("module", "x/bank"),
)
+
+ // optional: enable sign mode textual by overwriting the default tx config (after setting the bank keeper)
+ enabledSignModes := append(tx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL)
+ txConfigOpts := tx.ConfigOptions{
+ EnabledSignModes: enabledSignModes,
+ TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper),
+ }
+ txConfig, err := tx.NewTxConfigWithOptions(
+ appCodec,
+ txConfigOpts,
+ )
+ if err != nil {
+ panic(err)
+ }
+ app.txConfig = txConfig
+
+ validatorAddressPrefix := appconst.AccountAddressPrefix + "valoper"
+ consNodeAddressPrefix := appconst.AccountAddressPrefix + "valcons"
app.stakingKeeper = stakingkeeper.NewKeeper(
appCodec,
- keys[stakingtypes.StoreKey],
+ runtime.NewKVStoreService(keys[stakingtypes.StoreKey]),
app.AccountKeeper,
app.BankKeeper,
govModuleAddr,
+ authcodec.NewBech32Codec(validatorAddressPrefix),
+ authcodec.NewBech32Codec(consNodeAddressPrefix),
)
+
app.DistrKeeper = distrkeeper.NewKeeper(
appCodec,
- keys[distrtypes.StoreKey],
+ runtime.NewKVStoreService(keys[distrtypes.StoreKey]),
app.AccountKeeper,
app.BankKeeper,
app.stakingKeeper,
@@ -316,16 +343,21 @@ func (app *NibiruApp) InitKeepers(
)
invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod))
- app.crisisKeeper = *crisiskeeper.NewKeeper(
+ app.crisisKeeper = crisiskeeper.NewKeeper(
appCodec,
- keys[crisistypes.StoreKey],
+ runtime.NewKVStoreService(keys[crisistypes.StoreKey]),
invCheckPeriod,
app.BankKeeper,
authtypes.FeeCollectorName,
govModuleAddr,
+ app.AccountKeeper.AddressCodec(),
)
- app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
+ app.FeeGrantKeeper = feegrantkeeper.NewKeeper(
+ appCodec,
+ runtime.NewKVStoreService(keys[feegrant.StoreKey]),
+ app.AccountKeeper,
+ )
// get skipUpgradeHeights from the app options
skipUpgradeHeights := map[int64]bool{}
@@ -335,9 +367,9 @@ func (app *NibiruApp) InitKeepers(
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
/*upgradeKeeper must be created before ibcKeeper. */
- app.upgradeKeeper = *upgradekeeper.NewKeeper(
+ app.upgradeKeeper = upgradekeeper.NewKeeper(
skipUpgradeHeights,
- keys[upgradetypes.StoreKey],
+ runtime.NewKVStoreService(keys[upgradetypes.StoreKey]),
appCodec,
homePath,
app.BaseApp,
@@ -349,7 +381,7 @@ func (app *NibiruApp) InitKeepers(
app.slashingKeeper = slashingkeeper.NewKeeper(
appCodec,
legacyAmino,
- keys[slashingtypes.StoreKey],
+ runtime.NewKVStoreService(keys[slashingtypes.StoreKey]),
app.stakingKeeper,
govModuleAddr,
)
@@ -359,7 +391,7 @@ func (app *NibiruApp) InitKeepers(
)
app.authzKeeper = authzkeeper.NewKeeper(
- keys[authzkeeper.StoreKey],
+ runtime.NewKVStoreService(keys[authzkeeper.StoreKey]),
appCodec,
app.BaseApp.MsgServiceRouter(),
app.AccountKeeper,
@@ -367,40 +399,40 @@ func (app *NibiruApp) InitKeepers(
// ---------------------------------- Nibiru Chain x/ keepers
- app.SudoKeeper = keeper.NewKeeper(
- appCodec, keys[sudotypes.StoreKey],
- )
-
- app.OracleKeeper = oraclekeeper.NewKeeper(appCodec, keys[oracletypes.StoreKey],
- app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.stakingKeeper, app.slashingKeeper,
- app.SudoKeeper,
- distrtypes.ModuleName,
- )
-
- app.EpochsKeeper = epochskeeper.NewKeeper(
- appCodec, keys[epochstypes.StoreKey],
- )
-
- app.InflationKeeper = inflationkeeper.NewKeeper(
- appCodec, keys[inflationtypes.StoreKey], app.GetSubspace(inflationtypes.ModuleName),
- app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.stakingKeeper, app.SudoKeeper, authtypes.FeeCollectorName,
- )
-
- app.EpochsKeeper.SetHooks(
- epochstypes.NewMultiEpochHooks(
- app.InflationKeeper.Hooks(),
- app.OracleKeeper.Hooks(),
- ),
- )
-
- app.EvmKeeper = evmkeeper.NewKeeper(
- appCodec,
- keys[evm.StoreKey],
- tkeys[evm.TransientKey],
- authtypes.NewModuleAddress(govtypes.ModuleName),
- app.AccountKeeper,
- app.BankKeeper,
- )
+ // app.SudoKeeper = keeper.NewKeeper(
+ // appCodec, keys[sudotypes.StoreKey],
+ // )
+
+ // app.OracleKeeper = oraclekeeper.NewKeeper(appCodec, keys[oracletypes.StoreKey],
+ // app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.stakingKeeper, app.slashingKeeper,
+ // app.SudoKeeper,
+ // distrtypes.ModuleName,
+ // )
+
+ // app.EpochsKeeper = epochskeeper.NewKeeper(
+ // appCodec, keys[epochstypes.StoreKey],
+ // )
+
+ // app.InflationKeeper = inflationkeeper.NewKeeper(
+ // appCodec, keys[inflationtypes.StoreKey], app.GetSubspace(inflationtypes.ModuleName),
+ // app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.stakingKeeper, app.SudoKeeper, authtypes.FeeCollectorName,
+ // )
+
+ // app.EpochsKeeper.SetHooks(
+ // epochstypes.NewMultiEpochHooks(
+ // app.InflationKeeper.Hooks(),
+ // app.OracleKeeper.Hooks(),
+ // ),
+ // )
+
+ // app.EvmKeeper = evmkeeper.NewKeeper(
+ // appCodec,
+ // keys[evm.StoreKey],
+ // tkeys[evm.TransientKey],
+ // authtypes.NewModuleAddress(govtypes.ModuleName),
+ // app.AccountKeeper,
+ // app.BankKeeper,
+ // )
// ---------------------------------- IBC keepers
@@ -411,6 +443,7 @@ func (app *NibiruApp) InitKeepers(
app.stakingKeeper,
app.upgradeKeeper,
app.ScopedIBCKeeper,
+ govModuleAddr,
)
// IBC Fee Module keeper
@@ -418,7 +451,7 @@ func (app *NibiruApp) InitKeepers(
appCodec, keys[ibcfeetypes.StoreKey],
app.ibcKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.ibcKeeper.ChannelKeeper,
- &app.ibcKeeper.PortKeeper,
+ app.ibcKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
)
@@ -429,10 +462,11 @@ func (app *NibiruApp) InitKeepers(
/* paramSubspace */ app.GetSubspace(ibctransfertypes.ModuleName),
/* ibctransfertypes.ICS4Wrapper */ app.ibcFeeKeeper,
/* ibctransfertypes.ChannelKeeper */ app.ibcKeeper.ChannelKeeper,
- /* ibctransfertypes.PortKeeper */ &app.ibcKeeper.PortKeeper,
+ /* ibctransfertypes.PortKeeper */ app.ibcKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
app.ScopedTransferKeeper,
+ govModuleAddr,
)
app.icaControllerKeeper = icacontrollerkeeper.NewKeeper(
@@ -440,9 +474,10 @@ func (app *NibiruApp) InitKeepers(
app.GetSubspace(icacontrollertypes.SubModuleName),
app.ibcFeeKeeper,
app.ibcKeeper.ChannelKeeper,
- &app.ibcKeeper.PortKeeper,
+ app.ibcKeeper.PortKeeper,
app.ScopedICAControllerKeeper,
app.MsgServiceRouter(),
+ govModuleAddr,
)
app.icaHostKeeper = icahostkeeper.NewKeeper(
@@ -451,16 +486,17 @@ func (app *NibiruApp) InitKeepers(
app.GetSubspace(icahosttypes.SubModuleName),
app.ibcFeeKeeper,
app.ibcKeeper.ChannelKeeper,
- &app.ibcKeeper.PortKeeper,
+ app.ibcKeeper.PortKeeper,
app.AccountKeeper,
app.ScopedICAHostKeeper,
app.MsgServiceRouter(),
+ govModuleAddr,
)
app.ScopedWasmKeeper = app.capabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
wasmDir := filepath.Join(homePath, "data")
- wasmConfig, err := wasm.ReadWasmConfig(appOpts)
+ wasmConfig, err = wasm.ReadWasmConfig(appOpts)
if err != nil {
panic("error while reading wasm config: " + err.Error())
}
@@ -476,14 +512,14 @@ func (app *NibiruApp) InitKeepers(
supportedFeatures := strings.Join(wasmdapp.AllCapabilities(), ",")
app.WasmKeeper = wasmkeeper.NewKeeper(
appCodec,
- keys[wasmtypes.StoreKey],
+ runtime.NewKVStoreService(keys[wasmtypes.StoreKey]),
app.AccountKeeper,
app.BankKeeper,
app.stakingKeeper,
distrkeeper.NewQuerier(app.DistrKeeper),
app.ibcFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.ibcKeeper.ChannelKeeper,
- &app.ibcKeeper.PortKeeper,
+ app.ibcKeeper.PortKeeper,
app.ScopedWasmKeeper,
app.ibcTransferKeeper,
app.MsgServiceRouter(),
@@ -495,33 +531,37 @@ func (app *NibiruApp) InitKeepers(
GetWasmOpts(*app, appOpts)...,
)
- // DevGas uses WasmKeeper
- app.DevGasKeeper = devgaskeeper.NewKeeper(
- keys[devgastypes.StoreKey],
- appCodec,
- app.BankKeeper,
- app.WasmKeeper,
- app.AccountKeeper,
- authtypes.FeeCollectorName,
- govModuleAddr,
- )
-
- app.TokenFactoryKeeper = tokenfactorykeeper.NewKeeper(
- keys[tokenfactorytypes.StoreKey],
- appCodec,
- app.BankKeeper,
- app.AccountKeeper,
- app.DistrKeeper,
- govModuleAddr,
- )
+ // // DevGas uses WasmKeeper
+ // app.DevGasKeeper = devgaskeeper.NewKeeper(
+ // keys[devgastypes.StoreKey],
+ // appCodec,
+ // app.BankKeeper,
+ // app.WasmKeeper,
+ // app.AccountKeeper,
+ // authtypes.FeeCollectorName,
+ // govModuleAddr,
+ // )
+
+ // app.TokenFactoryKeeper = tokenfactorykeeper.NewKeeper(
+ // keys[tokenfactorytypes.StoreKey],
+ // appCodec,
+ // app.BankKeeper,
+ // app.AccountKeeper,
+ // app.DistrKeeper,
+ // govModuleAddr,
+ // )
// register the proposal types
// Create evidence keeper.
// This keeper automatically includes an evidence router.
app.evidenceKeeper = *evidencekeeper.NewKeeper(
- appCodec, keys[evidencetypes.StoreKey], app.stakingKeeper,
+ appCodec,
+ runtime.NewKVStoreService(keys[evidencetypes.StoreKey]),
+ app.stakingKeeper,
app.slashingKeeper,
+ app.AccountKeeper.AddressCodec(),
+ runtime.ProvideCometInfoService(),
)
// Mock Module setup for testing IBC and also acts as the interchain accounts authentication module
@@ -590,20 +630,22 @@ func (app *NibiruApp) InitKeepers(
govRouter.
AddRoute(govtypes.RouterKey, govv1beta1types.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
- AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.upgradeKeeper)).
+ // AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.upgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper))
govConfig := govtypes.DefaultConfig()
govKeeper := govkeeper.NewKeeper(
appCodec,
- keys[govtypes.StoreKey],
+ runtime.NewKVStoreService(keys[govtypes.StoreKey]),
app.AccountKeeper,
app.BankKeeper,
app.stakingKeeper,
+ app.DistrKeeper,
app.MsgServiceRouter(),
govConfig,
- govModuleAddr,
+ authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
+
govKeeper.SetLegacyRouter(govRouter)
app.GovKeeper = *govKeeper.SetHooks(
@@ -616,14 +658,15 @@ func (app *NibiruApp) InitKeepers(
func (app *NibiruApp) initAppModules(
encodingConfig EncodingConfig,
skipGenesisInvariants bool,
+ txConfig client.TxConfig,
) []module.AppModule {
appCodec := app.appCodec
return []module.AppModule{
// core modules
genutil.NewAppModule(
- app.AccountKeeper, app.stakingKeeper, app.BaseApp.DeliverTx,
- encodingConfig.TxConfig,
+ app.AccountKeeper, app.stakingKeeper, app,
+ txConfig,
),
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)),
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
@@ -631,19 +674,19 @@ func (app *NibiruApp) initAppModules(
capability.NewAppModule(appCodec, *app.capabilityKeeper, false),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
- slashing.NewAppModule(appCodec, app.slashingKeeper, app.AccountKeeper, app.BankKeeper, app.stakingKeeper, app.GetSubspace(slashingtypes.ModuleName)),
+ slashing.NewAppModule(appCodec, app.slashingKeeper, app.AccountKeeper, app.BankKeeper, app.stakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.stakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
staking.NewAppModule(appCodec, app.stakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
- upgrade.NewAppModule(&app.upgradeKeeper),
+ upgrade.NewAppModule(app.upgradeKeeper, app.AccountKeeper.AddressCodec()),
params.NewAppModule(app.paramsKeeper),
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
// Nibiru modules
- oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper),
- epochs.NewAppModule(appCodec, app.EpochsKeeper),
- inflation.NewAppModule(app.InflationKeeper, app.AccountKeeper, *app.stakingKeeper),
- sudo.NewAppModule(appCodec, app.SudoKeeper),
- genmsg.NewAppModule(app.MsgServiceRouter()),
+ // oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper),
+ // epochs.NewAppModule(appCodec, app.EpochsKeeper),
+ // inflation.NewAppModule(app.InflationKeeper, app.AccountKeeper, *app.stakingKeeper),
+ // sudo.NewAppModule(appCodec, app.SudoKeeper),
+ // genmsg.NewAppModule(app.MsgServiceRouter()),
// ibc
evidence.NewAppModule(app.evidenceKeeper),
@@ -652,21 +695,27 @@ func (app *NibiruApp) initAppModules(
ibcfee.NewAppModule(app.ibcFeeKeeper),
ica.NewAppModule(&app.icaControllerKeeper, &app.icaHostKeeper),
- evmmodule.NewAppModule(&app.EvmKeeper, app.AccountKeeper),
+ // evmmodule.NewAppModule(&app.EvmKeeper, app.AccountKeeper),
// wasm
wasm.NewAppModule(
- appCodec, &app.WasmKeeper, app.stakingKeeper, app.AccountKeeper,
- app.BankKeeper, app.MsgServiceRouter(),
+ appCodec,
+ &app.WasmKeeper,
+ app.stakingKeeper,
+ app.AccountKeeper,
+ app.BankKeeper,
+ app.MsgServiceRouter(),
app.GetSubspace(wasmtypes.ModuleName)),
- devgas.NewAppModule(
- app.DevGasKeeper, app.AccountKeeper,
- app.GetSubspace(devgastypes.ModuleName)),
- tokenfactory.NewAppModule(
- app.TokenFactoryKeeper, app.AccountKeeper,
- ),
-
- crisis.NewAppModule(&app.crisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
+ // devgas.NewAppModule(
+ // app.DevGasKeeper,app.AccountKeeper,app.GetSubspace(devgastypes.ModuleName)),
+ // tokenfactory.NewAppModule(
+ // app.TokenFactoryKeeper,
+ // app.AccountKeeper,
+ // ),
+ // crisis.NewAppModule(
+ // app.crisisKeeper,
+ // skipGenesisInvariants,
+ // app.GetSubspace(crisistypes.ModuleName)),
}
}
@@ -711,10 +760,10 @@ func orderedModuleNames() []string {
// --------------------------------------------------------------------
// Native x/ Modules
- epochstypes.ModuleName,
- oracletypes.ModuleName,
- inflationtypes.ModuleName,
- sudotypes.ModuleName,
+ // epochstypes.ModuleName,
+ // oracletypes.ModuleName,
+ // inflationtypes.ModuleName,
+ // sudotypes.ModuleName,
// --------------------------------------------------------------------
// IBC modules
@@ -724,16 +773,16 @@ func orderedModuleNames() []string {
icatypes.ModuleName,
// --------------------------------------------------------------------
- evm.ModuleName,
+ // evm.ModuleName,
// --------------------------------------------------------------------
// CosmWasm
wasmtypes.ModuleName,
- devgastypes.ModuleName,
- tokenfactorytypes.ModuleName,
+ // devgastypes.ModuleName,
+ // tokenfactorytypes.ModuleName,
// Everything else should be before genmsg
- genmsg.ModuleName,
+ // genmsg.ModuleName,
}
}
@@ -758,7 +807,7 @@ func (app *NibiruApp) initModuleManager(
skipGenesisInvariants bool,
) {
app.ModuleManager = module.NewManager(
- app.initAppModules(encodingConfig, skipGenesisInvariants)...,
+ app.initAppModules(encodingConfig, skipGenesisInvariants, app.txConfig)...,
)
orderedModules := orderedModuleNames()
@@ -770,7 +819,7 @@ func (app *NibiruApp) initModuleManager(
// Uncomment if you want to set a custom migration order here.
// app.mm.SetOrderMigrations(custom order)
- app.ModuleManager.RegisterInvariants(&app.crisisKeeper)
+ app.ModuleManager.RegisterInvariants(app.crisisKeeper)
app.configurator = module.NewConfigurator(
app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.ModuleManager.RegisterServices(app.configurator)
@@ -809,10 +858,11 @@ func ModuleBasicManager() module.BasicManager {
distr.AppModuleBasic{},
NewGovModuleBasic(
paramsclient.ProposalHandler,
- upgradeclient.LegacyProposalHandler,
- upgradeclient.LegacyCancelProposalHandler,
- ibcclientclient.UpdateClientProposalHandler,
- ibcclientclient.UpgradeProposalHandler,
+ // upgradeclient.LegacyProposalHandler,
+ // upgradeclient.LegacyCancelProposalHandler,
+ // seems to be removed per https://github.com/cosmos/ibc-go/pull/4620
+ // ibcclientclient.UpdateClientProposalHandler,
+ // ibcclientclient.UpgradeProposalHandler,
),
params.AppModuleBasic{},
CrisisModule{},
@@ -829,38 +879,38 @@ func ModuleBasicManager() module.BasicManager {
ibctm.AppModuleBasic{},
ica.AppModuleBasic{},
// native x/
- evmmodule.AppModuleBasic{},
- oracle.AppModuleBasic{},
- epochs.AppModuleBasic{},
- inflation.AppModuleBasic{},
- sudo.AppModuleBasic{},
+ // evmmodule.AppModuleBasic{},
+ // oracle.AppModuleBasic{},
+ // epochs.AppModuleBasic{},
+ // inflation.AppModuleBasic{},
+ // sudo.AppModuleBasic{},
wasm.AppModuleBasic{},
- devgas.AppModuleBasic{},
- tokenfactory.AppModuleBasic{},
+ // devgas.AppModuleBasic{},
+ // tokenfactory.AppModuleBasic{},
ibcfee.AppModuleBasic{},
- genmsg.AppModule{},
+ // genmsg.AppModule{},
)
}
func ModuleAccPerms() map[string][]string {
return map[string][]string{
- authtypes.FeeCollectorName: nil,
- distrtypes.ModuleName: nil,
- inflationtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
+ authtypes.FeeCollectorName: nil,
+ distrtypes.ModuleName: nil,
+ // inflationtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
- oracletypes.ModuleName: {},
- ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
- ibcfeetypes.ModuleName: {},
- icatypes.ModuleName: {},
-
- evm.ModuleName: {authtypes.Minter, authtypes.Burner},
- epochstypes.ModuleName: {},
- sudotypes.ModuleName: {},
- common.TreasuryPoolModuleAccount: {},
- wasmtypes.ModuleName: {authtypes.Burner},
- tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
+ // oracletypes.ModuleName: {},
+ ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
+ ibcfeetypes.ModuleName: {},
+ icatypes.ModuleName: {},
+
+ // evm.ModuleName: {authtypes.Minter, authtypes.Burner},
+ // epochstypes.ModuleName: {},
+ // sudotypes.ModuleName: {},
+ // common.TreasuryPoolModuleAccount: {},
+ wasmtypes.ModuleName: {authtypes.Burner},
+ // tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}
}
@@ -878,8 +928,8 @@ func initParamsKeeper(
paramsKeeper.Subspace(govtypes.ModuleName)
paramsKeeper.Subspace(crisistypes.ModuleName)
// Nibiru core params keepers | x/
- paramsKeeper.Subspace(epochstypes.ModuleName)
- paramsKeeper.Subspace(inflationtypes.ModuleName)
+ // paramsKeeper.Subspace(epochstypes.ModuleName)
+ // paramsKeeper.Subspace(inflationtypes.ModuleName)
// ibc params keepers
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
@@ -888,7 +938,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(icahosttypes.SubModuleName)
// wasm params keepers
paramsKeeper.Subspace(wasmtypes.ModuleName)
- paramsKeeper.Subspace(devgastypes.ModuleName)
+ // paramsKeeper.Subspace(devgastypes.ModuleName)
return paramsKeeper
}
diff --git a/app/server/config/server_config.go b/app/server/config/server_config.go
index 18ad43d93..a468033c7 100644
--- a/app/server/config/server_config.go
+++ b/app/server/config/server_config.go
@@ -7,6 +7,7 @@ import (
"path"
"time"
+ "github.com/cosmos/rosetta"
"github.com/spf13/viper"
"github.com/cometbft/cometbft/libs/strings"
@@ -108,6 +109,7 @@ type Config struct {
EVM EVMConfig `mapstructure:"evm"`
JSONRPC JSONRPCConfig `mapstructure:"json-rpc"`
TLS TLSConfig `mapstructure:"tls"`
+ Rosetta RosettaConfig `mapstructure:"rosetta"`
}
// EVMConfig defines the application configuration values for the EVM.
@@ -119,6 +121,14 @@ type EVMConfig struct {
MaxTxGasWanted uint64 `mapstructure:"max-tx-gas-wanted"`
}
+// RosettaConfig defines the application configuration values for the Rosetta API.
+type RosettaConfig struct {
+ // Enable defines if the Rosetta API server should be enabled.
+ Enable bool `mapstructure:"enable"`
+ // Config defines the Rosetta configuration.
+ Config rosetta.Config `mapstructure:"config"`
+}
+
// JSONRPCConfig defines configuration for the EVM RPC server.
type JSONRPCConfig struct {
// API defines a list of JSON-RPC namespaces that should be enabled
@@ -201,7 +211,6 @@ func DefaultConfig() *Config {
defaultSDKConfig.API.Enable = DefaultAPIEnable
defaultSDKConfig.GRPC.Enable = DefaultGRPCEnable
defaultSDKConfig.GRPCWeb.Enable = DefaultGRPCWebEnable
- defaultSDKConfig.Rosetta.Enable = DefaultRosettaEnable
defaultSDKConfig.Telemetry.Enabled = DefaultTelemetryEnable
return &Config{
@@ -209,6 +218,7 @@ func DefaultConfig() *Config {
EVM: *DefaultEVMConfig(),
JSONRPC: *DefaultJSONRPCConfig(),
TLS: *DefaultTLSConfig(),
+ Rosetta: *DefaultRosettaConfig(),
}
}
@@ -220,6 +230,14 @@ func DefaultEVMConfig() *EVMConfig {
}
}
+// DefaultRosettaConfig returns the default Rosetta configuration
+func DefaultRosettaConfig() *RosettaConfig {
+ return &RosettaConfig{
+ Enable: false,
+ Config: rosetta.Config{},
+ }
+}
+
// Validate returns an error if the tracer type is invalid.
func (c EVMConfig) Validate() error {
if c.Tracer != "" && !strings.StringInSlice(c.Tracer, evmTracers) {
diff --git a/app/server/json_rpc.go b/app/server/json_rpc.go
index ae02cfe60..6a8b71c8b 100644
--- a/app/server/json_rpc.go
+++ b/app/server/json_rpc.go
@@ -1,18 +1,20 @@
package server
import (
+ "context"
+ "fmt"
"net/http"
"time"
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/rpc/rpcapi"
+ // "github.com/NibiruChain/nibiru/eth"
+ // "github.com/NibiruChain/nibiru/eth/rpc/rpcapi"
"github.com/gorilla/mux"
"github.com/rs/cors"
+ "cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
- "github.com/cosmos/cosmos-sdk/server/types"
ethlog "github.com/ethereum/go-ethereum/log"
ethrpc "github.com/ethereum/go-ethereum/rpc"
@@ -20,16 +22,17 @@ import (
)
// StartJSONRPC starts the JSON-RPC server
-func StartJSONRPC(ctx *server.Context,
+func StartJSONRPC(ctx context.Context,
clientCtx client.Context,
+ srvCtx *server.Context,
+ logger log.Logger,
tmRPCAddr,
tmEndpoint string,
config *srvconfig.Config,
- indexer eth.EVMTxIndexer,
+ // indexer eth.EVMTxIndexer,
) (*http.Server, chan struct{}, error) {
- tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, ctx.Logger)
+ // tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, logger)
- logger := ctx.Logger.With("module", "geth")
ethlog.Root().SetHandler(ethlog.FuncHandler(func(r *ethlog.Record) error {
switch r.Lvl {
case ethlog.LvlTrace, ethlog.LvlDebug:
@@ -44,21 +47,21 @@ func StartJSONRPC(ctx *server.Context,
rpcServer := ethrpc.NewServer()
- allowUnprotectedTxs := config.JSONRPC.AllowUnprotectedTxs
- rpcAPIArr := config.JSONRPC.API
+ // allowUnprotectedTxs := config.JSONRPC.AllowUnprotectedTxs
+ // rpcAPIArr := config.JSONRPC.API
- apis := rpcapi.GetRPCAPIs(ctx, clientCtx, tmWsClient, allowUnprotectedTxs, indexer, rpcAPIArr)
+ // apis := rpcapi.GetRPCAPIs(srvCtx, clientCtx, tmWsClient, allowUnprotectedTxs, indexer, rpcAPIArr)
- for _, api := range apis {
- if err := rpcServer.RegisterName(api.Namespace, api.Service); err != nil {
- ctx.Logger.Error(
- "failed to register service in JSON RPC namespace",
- "namespace", api.Namespace,
- "service", api.Service,
- )
- return nil, nil, err
- }
- }
+ // for _, api := range apis {
+ // if err := rpcServer.RegisterName(api.Namespace, api.Service); err != nil {
+ // logger.Error(
+ // "failed to register service in JSON RPC namespace",
+ // "namespace", api.Namespace,
+ // "service", api.Service,
+ // )
+ // return nil, nil, err
+ // }
+ // }
r := mux.NewRouter()
r.HandleFunc("/", rpcServer.ServeHTTP).Methods("POST")
@@ -85,30 +88,37 @@ func StartJSONRPC(ctx *server.Context,
errCh := make(chan error)
go func() {
- ctx.Logger.Info("Starting JSON-RPC server", "address", config.JSONRPC.Address)
+ logger.Info("Starting JSON-RPC server", "address", config.JSONRPC.Address)
if err := httpSrv.Serve(ln); err != nil {
if err == http.ErrServerClosed {
close(httpSrvDone)
return
}
- ctx.Logger.Error("failed to start JSON-RPC server", "error", err.Error())
+ logger.Error("failed to start JSON-RPC server", "error", err.Error())
errCh <- err
}
}()
select {
case err := <-errCh:
- ctx.Logger.Error("failed to boot JSON-RPC server", "error", err.Error())
+ logger.Error("failed to boot JSON-RPC server", "error", err.Error())
return nil, nil, err
- case <-time.After(types.ServerStartTime): // assume JSON RPC server started successfully
+
+ case <-ctx.Done():
+ // The calling process canceled or closed the provided context, so we must
+ // gracefully stop the gRPC server.
+ logger.Info("stopping gRPC server...", "address", config.GRPC.Address)
+
+ return nil, nil, fmt.Errorf("gRPC server stopped")
+ case <-time.After(ServerStartTime): // assume JSON RPC server started successfully
}
- ctx.Logger.Info("Starting JSON WebSocket server", "address", config.JSONRPC.WsAddress)
+ logger.Info("Starting JSON WebSocket server", "address", config.JSONRPC.WsAddress)
// allocate separate WS connection to Tendermint
- tmWsClient = ConnectTmWS(tmRPCAddr, tmEndpoint, ctx.Logger)
- wsSrv := rpcapi.NewWebsocketsServer(clientCtx, ctx.Logger, tmWsClient, config)
- wsSrv.Start()
+ // tmWsClient = ConnectTmWS(tmRPCAddr, tmEndpoint, logger)
+ // wsSrv := rpcapi.NewWebsocketsServer(clientCtx, logger, tmWsClient, config)
+ // wsSrv.Start()
return httpSrv, httpSrvDone, nil
}
diff --git a/app/server/start.go b/app/server/start.go
index 274f31fa6..1cc73bd8b 100644
--- a/app/server/start.go
+++ b/app/server/start.go
@@ -5,56 +5,57 @@ import (
"fmt"
"io"
"net"
- "net/http"
"os"
- "os/signal"
"path/filepath"
"regexp"
"runtime/pprof"
"strings"
- "syscall"
"time"
+ cmtcfg "github.com/cometbft/cometbft/config"
+
+ "github.com/cometbft/cometbft/node"
+ "github.com/cometbft/cometbft/p2p"
+ pvm "github.com/cometbft/cometbft/privval"
+ "github.com/cometbft/cometbft/proxy"
+ rpchttp "github.com/cometbft/cometbft/rpc/client/http"
+ cmttypes "github.com/cometbft/cometbft/types"
+ "github.com/hashicorp/go-metrics"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/credentials/insecure"
+
+ "golang.org/x/sync/errgroup"
+
"github.com/NibiruChain/nibiru/app/server/config"
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/indexer"
+
+ // "github.com/NibiruChain/nibiru/eth/indexer"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
+ "github.com/cosmos/cosmos-sdk/server/api"
+ servercmtlog "github.com/cosmos/cosmos-sdk/server/log"
"github.com/cosmos/cosmos-sdk/telemetry"
+ "github.com/cosmos/cosmos-sdk/version"
"github.com/spf13/cobra"
- "google.golang.org/grpc"
- "google.golang.org/grpc/credentials/insecure"
-
- dbm "github.com/cometbft/cometbft-db"
abciserver "github.com/cometbft/cometbft/abci/server"
tcmd "github.com/cometbft/cometbft/cmd/cometbft/commands"
- tmos "github.com/cometbft/cometbft/libs/os"
- "github.com/cometbft/cometbft/node"
- "github.com/cometbft/cometbft/p2p"
- pvm "github.com/cometbft/cometbft/privval"
- "github.com/cometbft/cometbft/proxy"
"github.com/cometbft/cometbft/rpc/client/local"
+ dbm "github.com/cosmos/cosmos-db"
+ servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
- "cosmossdk.io/tools/rosetta"
- crgserver "cosmossdk.io/tools/rosetta/lib/server"
-
- ethmetricsexp "github.com/ethereum/go-ethereum/metrics/exp"
-
- errorsmod "cosmossdk.io/errors"
+ pruningtypes "cosmossdk.io/store/pruning/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
- "github.com/cosmos/cosmos-sdk/server/api"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
- servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
"github.com/cosmos/cosmos-sdk/server/types"
- pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
+ genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)
+const ServerStartTime = 5 * time.Second
+
// StartOptions defines options that can be customized in `StartCmd`
type StartOptions struct {
AppCreator types.AppCreator
@@ -74,23 +75,33 @@ func openDB(rootDir string, backendType dbm.BackendType) (dbm.DB, error) {
return dbm.NewDB("application", backendType, dataDir)
}
+// StartCmd runs the service passed in, either stand-alone or in-process with
+// CometBFT.
+func StartCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command {
+ return StartCmdWithOptions(appCreator, defaultNodeHome, server.StartCmdOptions{})
+}
+
// StartCmd runs the service passed in, either stand-alone or in-process with
// Tendermint.
-func StartCmd(opts StartOptions) *cobra.Command {
+func StartCmdWithOptions(appCreator types.AppCreator, defaultNodeHome string, opts server.StartCmdOptions) *cobra.Command {
+ if opts.StartCommandHandler == nil {
+ opts.StartCommandHandler = start
+ }
+
cmd := &cobra.Command{
Use: "start",
Short: "Run the full node",
- Long: `Run the full node application with Tendermint in or out of process. By
-default, the application will run with Tendermint in process.
+ Long: `Run the full node application with CometBFT in or out of process. By
+default, the application will run with CometBFT in process.
Pruning options can be provided via the '--pruning' flag or alternatively with '--pruning-keep-recent',
'pruning-keep-every', and 'pruning-interval' together.
For '--pruning' the options are as follows:
-default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals
+default: the last 362880 states are kept, pruning at 10 block intervals
nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
-everything: all saved states will be deleted, storing only the current state; pruning at 10 block intervals
+everything: 2 latest states will be kept; pruning at 10 block intervals.
custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval'
Node halting configurations exist in the form of two flags: '--halt-height' and '--halt-time'. During
@@ -101,6 +112,11 @@ will not be able to commit subsequent blocks.
For profiling and benchmarking purposes, CPU profiling can be enabled via the '--cpu-profile' flag
which accepts a path for the resulting pprof file.
+
+The node may be started in a 'query only' mode where only the gRPC and JSON HTTP
+API services are enabled via the 'grpc-only' flag. In this mode, CometBFT is
+bypassed and can be used when legacy queries are needed after an on-chain upgrade
+is performed. Note, when enabled, gRPC will also be automatically enabled.
`,
PreRunE: func(cmd *cobra.Command, _ []string) error {
serverCtx := server.GetServerContextFromCmd(cmd)
@@ -122,16 +138,30 @@ which accepts a path for the resulting pprof file.
return err
}
- withTM, _ := cmd.Flags().GetBool(WithTendermint)
- if !withTM {
+ withCMT, _ := cmd.Flags().GetBool(WithTendermint)
+ if !withCMT {
serverCtx.Logger.Info("starting ABCI without Tendermint")
- return wrapCPUProfile(serverCtx, func() error {
- return startStandAlone(serverCtx, opts)
- })
}
- serverCtx.Logger.Info("Unlocking keyring")
+ serverCtx.Logger.Info("starting ABCI with Tendermint")
+ err = wrapCPUProfile(serverCtx, func() error {
+ return opts.StartCommandHandler(serverCtx, clientCtx, appCreator, withCMT, opts)
+ })
+
+ if err != nil {
+ serverCtx.Logger.Error("failed to start ABCI with Tendermint", "error", err.Error())
+ return err
+ }
+ serverCtx.Logger.Debug("received quit signal")
+ graceDuration, _ := cmd.Flags().GetDuration(server.FlagShutdownGrace)
+ if graceDuration > 0 {
+ serverCtx.Logger.Info("graceful shutdown start", server.FlagShutdownGrace, graceDuration)
+ <-time.After(graceDuration)
+ serverCtx.Logger.Info("graceful shutdown complete")
+ }
+
+ serverCtx.Logger.Info("Unlocking keyring")
// fire unlock precess for keyring
keyringBackend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend)
if keyringBackend == keyring.BackendFile {
@@ -141,367 +171,234 @@ which accepts a path for the resulting pprof file.
}
}
- serverCtx.Logger.Info("starting ABCI with Tendermint")
-
- // amino is needed here for backwards compatibility of REST routes
- err = startInProcess(serverCtx, clientCtx, opts)
- errCode, ok := err.(server.ErrorCode)
- if !ok {
- return err
- }
-
- serverCtx.Logger.Debug(fmt.Sprintf("received quit signal: %d", errCode.Code))
return nil
},
}
- cmd.Flags().String(flags.FlagHome, opts.DefaultNodeHome, "The application home directory")
- cmd.Flags().Bool(WithTendermint, true, "Run abci app embedded in-process with tendermint")
- cmd.Flags().String(Address, "tcp://0.0.0.0:26658", "Listen address")
- cmd.Flags().String(Transport, "socket", "Transport protocol: socket, grpc")
- cmd.Flags().String(TraceStore, "", "Enable KVStore tracing to an output file")
- cmd.Flags().String(server.FlagMinGasPrices, "", "Minimum gas prices to accept for transactions; Any fee in a tx must meet this minimum (e.g. 5000unibi)") //nolint:lll
- cmd.Flags().IntSlice(server.FlagUnsafeSkipUpgrades, []int{}, "Skip a set of upgrade heights to continue the old binary")
- cmd.Flags().Uint64(server.FlagHaltHeight, 0, "Block height at which to gracefully halt the chain and shutdown the node")
- cmd.Flags().Uint64(server.FlagHaltTime, 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node")
- cmd.Flags().Bool(server.FlagInterBlockCache, true, "Enable inter-block caching")
- cmd.Flags().String(CPUProfile, "", "Enable CPU profiling and write to the provided file")
- cmd.Flags().Bool(server.FlagTrace, false, "Provide full stack traces for errors in ABCI Log")
- cmd.Flags().String(server.FlagPruning, pruningtypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)")
- cmd.Flags().Uint64(server.FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')")
- cmd.Flags().Uint64(server.FlagPruningInterval, 0, "Height interval at which pruned heights are removed from disk (ignored if pruning is not 'custom')") //nolint:lll
- cmd.Flags().Uint(server.FlagInvCheckPeriod, 0, "Assert registered invariants every N blocks")
- cmd.Flags().Uint64(server.FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune Tendermint blocks")
- cmd.Flags().String(AppDBBackend, "", "The type of database for application and snapshots databases")
-
- cmd.Flags().Bool(GRPCOnly, false, "Start the node in gRPC query only mode without Tendermint process")
- cmd.Flags().Bool(GRPCEnable, config.DefaultGRPCEnable, "Define if the gRPC server should be enabled")
- cmd.Flags().String(GRPCAddress, serverconfig.DefaultGRPCAddress, "the gRPC server address to listen on")
- cmd.Flags().Bool(GRPCWebEnable, config.DefaultGRPCWebEnable, "Define if the gRPC-Web server should be enabled. (Note: gRPC must also be enabled.)")
- cmd.Flags().String(GRPCWebAddress, serverconfig.DefaultGRPCWebAddress, "The gRPC-Web server address to listen on")
-
- cmd.Flags().Bool(RPCEnable, config.DefaultAPIEnable, "Defines if Cosmos-sdk REST server should be enabled")
- cmd.Flags().Bool(EnabledUnsafeCors, false, "Defines if CORS should be enabled (unsafe - use it at your own risk)")
-
- cmd.Flags().Bool(JSONRPCEnable, config.DefaultJSONRPCEnable, "Define if the JSON-RPC server should be enabled")
- cmd.Flags().StringSlice(JSONRPCAPI, config.GetDefaultAPINamespaces(), "Defines a list of JSON-RPC namespaces that should be enabled")
- cmd.Flags().String(JSONRPCAddress, config.DefaultJSONRPCAddress, "the JSON-RPC server address to listen on")
- cmd.Flags().String(JSONWsAddress, config.DefaultJSONRPCWsAddress, "the JSON-RPC WS server address to listen on")
- cmd.Flags().Uint64(JSONRPCGasCap, config.DefaultGasCap, "Sets a cap on gas that can be used in eth_call/estimateGas unit is unibi (0=infinite)") //nolint:lll
- cmd.Flags().Float64(JSONRPCTxFeeCap, config.DefaultTxFeeCap, "Sets a cap on transaction fee that can be sent via the RPC APIs (1 = default 1 nibi)") //nolint:lll
- cmd.Flags().Int32(JSONRPCFilterCap, config.DefaultFilterCap, "Sets the global cap for total number of filters that can be created")
- cmd.Flags().Duration(JSONRPCEVMTimeout, config.DefaultEVMTimeout, "Sets a timeout used for eth_call (0=infinite)")
- cmd.Flags().Duration(JSONRPCHTTPTimeout, config.DefaultHTTPTimeout, "Sets a read/write timeout for json-rpc http server (0=infinite)")
- cmd.Flags().Duration(JSONRPCHTTPIdleTimeout, config.DefaultHTTPIdleTimeout, "Sets a idle timeout for json-rpc http server (0=infinite)")
- cmd.Flags().Bool(JSONRPCAllowUnprotectedTxs, config.DefaultAllowUnprotectedTxs, "Allow for unprotected (non EIP155 signed) transactions to be submitted via the node's RPC when the global parameter is disabled") //nolint:lll
- cmd.Flags().Int32(JSONRPCLogsCap, config.DefaultLogsCap, "Sets the max number of results can be returned from single `eth_getLogs` query")
- cmd.Flags().Int32(JSONRPCBlockRangeCap, config.DefaultBlockRangeCap, "Sets the max block range allowed for `eth_getLogs` query")
- cmd.Flags().Int(JSONRPCMaxOpenConnections, config.DefaultMaxOpenConnections, "Sets the maximum number of simultaneous connections for the server listener") //nolint:lll
- cmd.Flags().Bool(JSONRPCEnableIndexer, false, "Enable the custom tx indexer for json-rpc")
- cmd.Flags().Bool(JSONRPCEnableMetrics, false, "Define if EVM rpc metrics server should be enabled")
-
- cmd.Flags().String(EVMTracer, config.DefaultEVMTracer, "the EVM tracer type to collect execution traces from the EVM transaction execution (json|struct|access_list|markdown)") //nolint:lll
- cmd.Flags().Uint64(EVMMaxTxGasWanted, config.DefaultMaxTxGasWanted, "the gas wanted for each eth tx returned in ante handler in check tx mode") //nolint:lll
-
- cmd.Flags().String(TLSCertPath, "", "the cert.pem file path for the server TLS configuration")
- cmd.Flags().String(TLSKeyPath, "", "the key.pem file path for the server TLS configuration")
-
- cmd.Flags().Uint64(server.FlagStateSyncSnapshotInterval, 0, "State sync snapshot interval")
- cmd.Flags().Uint32(server.FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep")
-
- // add support for all Tendermint-specific command line options
- tcmd.AddNodeFlags(cmd)
+ cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
+ addStartNodeFlags(cmd, opts)
return cmd
}
-func startStandAlone(ctx *server.Context, opts StartOptions) error {
- addr := ctx.Viper.GetString(Address)
- transport := ctx.Viper.GetString(Transport)
- home := ctx.Viper.GetString(flags.FlagHome)
-
- db, err := openDB(home, server.GetAppDBBackend(ctx.Viper))
+func start(svrCtx *server.Context, clientCtx client.Context, appCreator types.AppCreator, withCmt bool, opts server.StartCmdOptions) error {
+ svrCfg, err := getAndValidateConfig(svrCtx)
if err != nil {
return err
}
- defer func() {
- if err := db.Close(); err != nil {
- ctx.Logger.Error("error closing db", "error", err.Error())
- }
- }()
-
- traceWriterFile := ctx.Viper.GetString(TraceStore)
- traceWriter, err := openTraceWriter(traceWriterFile)
-
+ app, appCleanupFn, err := startApp(svrCtx, appCreator, opts)
if err != nil {
return err
}
+ defer appCleanupFn()
- app := opts.AppCreator(ctx.Logger, db, traceWriter, ctx.Viper)
-
- conf, err := config.GetConfig(ctx.Viper)
+ metrics, err := startTelemetry(svrCfg)
if err != nil {
- ctx.Logger.Error("failed to get server config", "error", err.Error())
return err
}
- if err := conf.ValidateBasic(); err != nil {
- ctx.Logger.Error("invalid server config", "error", err.Error())
- return err
- }
+ emitServerInfoMetrics()
- _, err = startTelemetry(conf)
- if err != nil {
- return err
+ if !withCmt {
+ return startStandAlone(svrCtx, svrCfg, clientCtx, app, metrics, opts)
}
+ return startInProcess(svrCtx, svrCfg, clientCtx, app, metrics, opts)
+}
- svr, err := abciserver.NewServer(addr, transport, app)
+func startStandAlone(svrCtx *server.Context, svrCfg config.Config, clientCtx client.Context, app types.Application, metrics *telemetry.Metrics, opts server.StartCmdOptions) error {
+ addr := svrCtx.Viper.GetString(Address)
+ transport := svrCtx.Viper.GetString(Transport)
+
+ cmtApp := server.NewCometABCIWrapper(app)
+ svr, err := abciserver.NewServer(addr, transport, cmtApp)
if err != nil {
return fmt.Errorf("error creating listener: %v", err)
}
- svr.SetLogger(ctx.Logger.With("server", "abci"))
+ svr.SetLogger(servercmtlog.CometLoggerWrapper{Logger: svrCtx.Logger.With("module", "abci-server")})
- err = svr.Start()
- if err != nil {
- tmos.Exit(err.Error())
- }
+ g, ctx := getCtx(svrCtx, false)
- defer func() {
- if err = svr.Stop(); err != nil {
- tmos.Exit(err.Error())
+ // Add the tx service to the gRPC router. We only need to register this
+ // service if API or gRPC is enabled, and avoid doing so in the general
+ // case, because it spawns a new local CometBFT RPC client.
+ if svrCfg.API.Enable || svrCfg.GRPC.Enable {
+ // create tendermint client
+ // assumes the rpc listen address is where tendermint has its rpc server
+ rpcclient, err := rpchttp.New(svrCtx.Config.RPC.ListenAddress, "/websocket")
+ if err != nil {
+ return err
}
- }()
-
- // Wait for SIGINT or SIGTERM signal
- return server.WaitForQuitSignals()
-}
+ // re-assign for making the client available below
+ // do not use := to avoid shadowing clientCtx
+ clientCtx = clientCtx.WithClient(rpcclient)
-// legacyAminoCdc is used for the legacy REST API
-func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOptions) (err error) {
- cfg := ctx.Config
- home := cfg.RootDir
- logger := ctx.Logger
-
- db, err := openDB(home, server.GetAppDBBackend(ctx.Viper))
- if err != nil {
- logger.Error("failed to open DB", "error", err.Error())
- return err
+ // use the provided clientCtx to register the services
+ app.RegisterTxService(clientCtx)
+ app.RegisterTendermintService(clientCtx)
+ app.RegisterNodeService(clientCtx, svrCfg.Config)
}
- defer func() {
- if err := db.Close(); err != nil {
- ctx.Logger.With("error", err).Error("error closing db")
- }
- }()
-
- traceWriterFile := ctx.Viper.GetString(TraceStore)
- traceWriter, err := openTraceWriter(traceWriterFile)
+ grpcSrv, clientCtx, err := startGrpcServer(ctx, g, svrCfg.GRPC, clientCtx, svrCtx, app)
if err != nil {
- logger.Error("failed to open trace writer", "error", err.Error())
return err
}
- conf, err := config.GetConfig(ctx.Viper)
+ err = startAPIServer(ctx, g, svrCfg.Config, clientCtx, svrCtx, app, svrCtx.Config.RootDir, grpcSrv, metrics)
if err != nil {
- logger.Error("failed to get server config", "error", err.Error())
return err
}
- if err := conf.ValidateBasic(); err != nil {
- logger.Error("invalid server config", "error", err.Error())
- return err
+ if opts.PostSetupStandalone != nil {
+ if err := opts.PostSetupStandalone(svrCtx, clientCtx, ctx, g); err != nil {
+ return err
+ }
}
- app := opts.AppCreator(ctx.Logger, db, traceWriter, ctx.Viper)
+ g.Go(func() error {
+ if err := svr.Start(); err != nil {
+ svrCtx.Logger.Error("failed to start out-of-process ABCI server", "err", err)
+ return err
+ }
- nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
- if err != nil {
- logger.Error("failed load or gen node key", "error", err.Error())
- return err
- }
+ // Wait for the calling process to be canceled or close the provided context,
+ // so we can gracefully stop the ABCI server.
+ <-ctx.Done()
+ svrCtx.Logger.Info("stopping the ABCI server...")
+ return svr.Stop()
+ })
- genDocProvider := node.DefaultGenesisDocProviderFunc(cfg)
+ return g.Wait()
+}
- var (
- tmNode *node.Node
- gRPCOnly = ctx.Viper.GetBool(GRPCOnly)
- )
+// legacyAminoCdc is used for the legacy REST API
+func startInProcess(svrCtx *server.Context, svrCfg config.Config, clientCtx client.Context, app types.Application,
+ metrics *telemetry.Metrics, opts server.StartCmdOptions,
+) error {
+ cfg := svrCtx.Config
+
+ gRPCOnly := svrCtx.Viper.GetBool(GRPCOnly)
+
+ g, ctx := getCtx(svrCtx, true)
if gRPCOnly {
- logger.Info("starting node in query only mode; Tendermint is disabled")
- conf.GRPC.Enable = true
- conf.JSONRPC.EnableIndexer = false
+ // TODO: Generalize logic so that gRPC only is really in startStandAlone
+ svrCtx.Logger.Info("starting node in gRPC only mode; CometBFT is disabled")
+ svrCfg.GRPC.Enable = true
} else {
- logger.Info("starting node with ABCI Tendermint in-process")
-
- tmNode, err = node.NewNode(
- cfg,
- pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()),
- nodeKey,
- proxy.NewLocalClientCreator(app),
- genDocProvider,
- node.DefaultDBProvider,
- node.DefaultMetricsProvider(cfg.Instrumentation),
- ctx.Logger.With("server", "node"),
- )
+ svrCtx.Logger.Info("starting node with ABCI CometBFT in-process")
+ tmNode, cleanupFn, err := startCmtNode(ctx, cfg, app, svrCtx)
if err != nil {
- logger.Error("failed init node", "error", err.Error())
return err
}
-
- if err := tmNode.Start(); err != nil {
- logger.Error("failed start tendermint server", "error", err.Error())
- return err
+ defer cleanupFn()
+
+ // Add the tx service to the gRPC router. We only need to register this
+ // service if API or gRPC is enabled, and avoid doing so in the general
+ // case, because it spawns a new local CometBFT RPC client.
+ if svrCfg.API.Enable || svrCfg.GRPC.Enable {
+ // Re-assign for making the client available below do not use := to avoid
+ // shadowing the clientCtx variable.
+ clientCtx = clientCtx.WithClient(local.New(tmNode))
+
+ app.RegisterTxService(clientCtx)
+ app.RegisterTendermintService(clientCtx)
+ app.RegisterNodeService(clientCtx, svrCfg.Config)
}
-
- defer func() {
- if tmNode.IsRunning() {
- _ = tmNode.Stop()
- }
- }()
}
- // Add the tx service to the gRPC router. We only need to register this
- // service if API or gRPC or JSONRPC is enabled, and avoid doing so in the general
- // case, because it spawns a new local tendermint RPC client.
- if (conf.API.Enable || conf.GRPC.Enable || conf.JSONRPC.Enable || conf.JSONRPC.EnableIndexer) && tmNode != nil {
- clientCtx = clientCtx.WithClient(local.New(tmNode))
-
- app.RegisterTxService(clientCtx)
- app.RegisterTendermintService(clientCtx)
- app.RegisterNodeService(clientCtx)
+ err := startJsonServer(ctx, clientCtx, svrCfg, svrCtx)
+ if err != nil {
+ return err
}
- metrics, err := startTelemetry(conf)
+ grpcSrv, clientCtx, err := startGrpcServer(ctx, g, svrCfg.GRPC, clientCtx, svrCtx, app)
if err != nil {
return err
}
- // Enable metrics if JSONRPC is enabled and --metrics is passed
- // Flag not added in config to avoid user enabling in config without passing in CLI
- if conf.JSONRPC.Enable && ctx.Viper.GetBool(JSONRPCEnableMetrics) {
- ethmetricsexp.Setup(conf.JSONRPC.MetricsAddress)
+ err = startAPIServer(ctx, g, svrCfg.Config, clientCtx, svrCtx, app, cfg.RootDir, grpcSrv, metrics)
+ if err != nil {
+ return err
}
- var idxer eth.EVMTxIndexer
- if conf.JSONRPC.EnableIndexer {
- idxDB, err := OpenIndexerDB(home, server.GetAppDBBackend(ctx.Viper))
- if err != nil {
- logger.Error("failed to open evm indexer DB", "error", err.Error())
+ if opts.PostSetup != nil {
+ if err := opts.PostSetup(svrCtx, clientCtx, ctx, g); err != nil {
return err
}
-
- idxLogger := ctx.Logger.With("indexer", "evm")
- idxer = indexer.NewKVIndexer(idxDB, idxLogger, clientCtx)
}
+ // wait for signal capture and gracefully return
+ // we are guaranteed to be waiting for the "ListenForQuitSignals" goroutine.
+ return g.Wait()
+}
- if conf.API.Enable || conf.JSONRPC.Enable {
- genDoc, err := genDocProvider()
- if err != nil {
- return err
- }
-
- clientCtx = clientCtx.
- WithHomeDir(home).
- WithChainID(hackChainID(genDoc.ChainID))
-
- // Set `GRPCClient` to `clientCtx` to enjoy concurrent grpc query.
- // only use it if gRPC server is enabled.
- if conf.GRPC.Enable {
- _, port, err := net.SplitHostPort(conf.GRPC.Address)
- if err != nil {
- return errorsmod.Wrapf(err, "invalid grpc address %s", conf.GRPC.Address)
- }
+type cometABCIWrapper struct {
+ app types.ABCI
+}
- maxSendMsgSize := conf.GRPC.MaxSendMsgSize
- if maxSendMsgSize == 0 {
- maxSendMsgSize = serverconfig.DefaultGRPCMaxSendMsgSize
- }
+func startApp(svrCtx *server.Context, appCreator types.AppCreator, opts server.StartCmdOptions) (app types.Application, cleanupFn func(), err error) {
+ traceWriter, traceCleanupFn, err := setupTraceWriter(svrCtx)
+ if err != nil {
+ return app, traceCleanupFn, err
+ }
- maxRecvMsgSize := conf.GRPC.MaxRecvMsgSize
- if maxRecvMsgSize == 0 {
- maxRecvMsgSize = serverconfig.DefaultGRPCMaxRecvMsgSize
- }
+ home := svrCtx.Config.RootDir
+ db, err := opts.DBOpener(home, server.GetAppDBBackend(svrCtx.Viper))
+ if err != nil {
+ return app, traceCleanupFn, err
+ }
- grpcAddress := fmt.Sprintf("127.0.0.1:%s", port)
-
- // If grpc is enabled, configure grpc client for grpc gateway and json-rpc.
- grpcClient, err := grpc.Dial(
- grpcAddress,
- grpc.WithTransportCredentials(insecure.NewCredentials()),
- grpc.WithDefaultCallOptions(
- grpc.ForceCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec()),
- grpc.MaxCallRecvMsgSize(maxRecvMsgSize),
- grpc.MaxCallSendMsgSize(maxSendMsgSize),
- ),
- )
- if err != nil {
- return err
- }
+ app = appCreator(svrCtx.Logger, db, traceWriter, svrCtx.Viper)
- clientCtx = clientCtx.WithGRPCClient(grpcClient)
- ctx.Logger.Debug("gRPC client assigned to client context", "address", grpcAddress)
+ cleanupFn = func() {
+ traceCleanupFn()
+ if localErr := app.Close(); localErr != nil {
+ svrCtx.Logger.Error(localErr.Error())
}
}
+ return app, cleanupFn, nil
+}
- var apiSrv *api.Server
- if conf.API.Enable {
- apiSrv = api.New(clientCtx, ctx.Logger.With("server", "api"))
- app.RegisterAPIRoutes(apiSrv, conf.API)
+func setupTraceWriter(svrCtx *server.Context) (traceWriter io.WriteCloser, cleanup func(), err error) {
+ // clean up the traceWriter when the server is shutting down
+ cleanup = func() {}
- if conf.Telemetry.Enabled {
- apiSrv.SetTelemetry(metrics)
- }
+ traceWriterFile := svrCtx.Viper.GetString(TraceStore)
+ traceWriter, err = openTraceWriter(traceWriterFile)
+ if err != nil {
+ return traceWriter, cleanup, err
+ }
- errCh := make(chan error)
- go func() {
- if err := apiSrv.Start(conf.Config); err != nil {
- errCh <- err
+ // if flagTraceStore is not used then traceWriter is nil
+ if traceWriter != nil {
+ cleanup = func() {
+ if err = traceWriter.Close(); err != nil {
+ svrCtx.Logger.Error("failed to close trace writer", "err", err)
}
- }()
-
- select {
- case err := <-errCh:
- return err
- case <-time.After(types.ServerStartTime): // assume server started successfully
}
-
- defer apiSrv.Close()
}
- var (
- grpcSrv *grpc.Server
- grpcWebSrv *http.Server
- )
+ return traceWriter, cleanup, nil
+}
- if conf.GRPC.Enable {
- grpcSrv, err = servergrpc.StartGRPCServer(clientCtx, app, conf.GRPC)
- if err != nil {
- return err
- }
- defer grpcSrv.Stop()
- if conf.GRPCWeb.Enable {
- grpcWebSrv, err = servergrpc.StartGRPCWeb(grpcSrv, conf.Config)
- if err != nil {
- ctx.Logger.Error("failed to start grpc-web http server", "error", err.Error())
- return err
- }
+func startJsonServer(ctx context.Context, clientCtx client.Context, cfg config.Config, svrCtx *server.Context) error {
+ logger := svrCtx.Logger
+ // var idxer eth.EVMTxIndexer
- defer func() {
- if err := grpcWebSrv.Close(); err != nil {
- logger.Error("failed to close the grpc-web http server", "error", err.Error())
- }
- }()
- }
- }
+ // if cfg.JSONRPC.EnableIndexer {
+ // home := svrCtx.Config.RootDir
+ // idxDB, err := OpenIndexerDB(home, server.GetAppDBBackend(svrCtx.Viper))
+ // if err != nil {
+ // svrCtx.Logger.Error("failed to open evm indexer DB", "error", err.Error())
+ // return err
+ // }
- var (
- httpSrv *http.Server
- httpSrvDone chan struct{}
- )
+ // idxLogger := logger.With("indexer", "evm")
+ // idxer = indexer.NewKVIndexer(idxDB, idxLogger, clientCtx)
+ // }
- if conf.JSONRPC.Enable {
+ if cfg.JSONRPC.Enable {
+ genDocProvider := node.DefaultGenesisDocProviderFunc(svrCtx.Config)
genDoc, err := genDocProvider()
if err != nil {
return err
@@ -510,8 +407,8 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt
clientCtx := clientCtx.WithChainID(hackChainID(genDoc.ChainID))
tmEndpoint := "/websocket"
- tmRPCAddr := cfg.RPC.ListenAddress
- httpSrv, httpSrvDone, err = StartJSONRPC(ctx, clientCtx, tmRPCAddr, tmEndpoint, &conf, idxer)
+ tmRPCAddr := svrCtx.Config.RPC.ListenAddress
+ httpSrv, httpSrvDone, err := StartJSONRPC(ctx, clientCtx, svrCtx, logger, tmRPCAddr, tmEndpoint, &cfg)
if err != nil {
return err
}
@@ -519,9 +416,9 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt
shutdownCtx, cancelFn := context.WithTimeout(context.Background(), 10*time.Second)
defer cancelFn()
if err := httpSrv.Shutdown(shutdownCtx); err != nil {
- logger.Error("HTTP server shutdown produced a warning", "error", err.Error())
+ svrCtx.Logger.Error("HTTP server shutdown produced a warning", "error", err.Error())
} else {
- logger.Info("HTTP server shut down, waiting 5 sec")
+ svrCtx.Logger.Info("HTTP server shut down, waiting 5 sec")
select {
case <-time.Tick(5 * time.Second):
case <-httpSrvDone:
@@ -529,65 +426,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt
}
}()
}
-
- // At this point it is safe to block the process if we're in query only mode as
- // we do not need to start Rosetta or handle any Tendermint related processes.
- if gRPCOnly {
- // wait for signal capture and gracefully return
- return server.WaitForQuitSignals()
- }
-
- var rosettaSrv crgserver.Server
- if conf.Rosetta.Enable {
- offlineMode := conf.Rosetta.Offline
-
- // If GRPC is not enabled rosetta cannot work in online mode, so it works in
- // offline mode.
- if !conf.GRPC.Enable {
- offlineMode = true
- }
-
- minGasPrices, err := sdk.ParseDecCoins(conf.MinGasPrices)
- if err != nil {
- ctx.Logger.Error("failed to parse minimum-gas-prices", "error", err.Error())
- return err
- }
-
- conf := &rosetta.Config{
- Blockchain: conf.Rosetta.Blockchain,
- Network: conf.Rosetta.Network,
- TendermintRPC: ctx.Config.RPC.ListenAddress,
- GRPCEndpoint: conf.GRPC.Address,
- Addr: conf.Rosetta.Address,
- Retries: conf.Rosetta.Retries,
- Offline: offlineMode,
- GasToSuggest: conf.Rosetta.GasToSuggest,
- EnableFeeSuggestion: conf.Rosetta.EnableFeeSuggestion,
- GasPrices: minGasPrices.Sort(),
- Codec: clientCtx.Codec.(*codec.ProtoCodec),
- InterfaceRegistry: clientCtx.InterfaceRegistry,
- }
-
- rosettaSrv, err = rosetta.ServerFromConfig(conf)
- if err != nil {
- return err
- }
-
- errCh := make(chan error)
- go func() {
- if err := rosettaSrv.Start(); err != nil {
- errCh <- err
- }
- }()
-
- select {
- case err := <-errCh:
- return err
- case <-time.After(types.ServerStartTime): // assume server started successfully
- }
- }
- // Wait for SIGINT or SIGTERM signal
- return server.WaitForQuitSignals()
+ return nil
}
// OpenIndexerDB opens the custom eth indexer db, using the same db backend as the main app
@@ -596,16 +435,14 @@ func OpenIndexerDB(rootDir string, backendType dbm.BackendType) (dbm.DB, error)
return dbm.NewDB("evmindexer", backendType, dataDir)
}
-func openTraceWriter(traceWriterFile string) (w io.Writer, err error) {
+func openTraceWriter(traceWriterFile string) (w io.WriteCloser, err error) {
if traceWriterFile == "" {
return
}
-
- filePath := filepath.Clean(traceWriterFile)
return os.OpenFile(
- filePath,
+ traceWriterFile,
os.O_WRONLY|os.O_APPEND|os.O_CREATE,
- 0o600,
+ 0o666,
)
}
@@ -616,49 +453,35 @@ func startTelemetry(cfg config.Config) (*telemetry.Metrics, error) {
return telemetry.New(cfg.Telemetry)
}
-// WaitForQuitSignals waits for SIGINT and SIGTERM and returns.
-func WaitForQuitSignals() server.ErrorCode {
- sigs := make(chan os.Signal, 1)
- signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
- sig := <-sigs
- return server.ErrorCode{Code: int(sig.(syscall.Signal)) + 128}
-}
-
-// wrapCPUProfile runs callback in a goroutine, then wait for quit signals.
-func wrapCPUProfile(ctx *server.Context, callback func() error) error {
- if cpuProfile := ctx.Viper.GetString(CPUProfile); cpuProfile != "" {
+// wrapCPUProfile starts CPU profiling, if enabled, and executes the provided
+// callbackFn in a separate goroutine, then will wait for that callback to
+// return.
+//
+// NOTE: We expect the caller to handle graceful shutdown and signal handling.
+func wrapCPUProfile(svrCtx *server.Context, callbackFn func() error) error {
+ if cpuProfile := svrCtx.Viper.GetString(CPUProfile); cpuProfile != "" {
f, err := os.Create(cpuProfile)
if err != nil {
return err
}
- ctx.Logger.Info("starting CPU profiler", "profile", cpuProfile)
+ svrCtx.Logger.Info("starting CPU profiler", "profile", cpuProfile)
+
if err := pprof.StartCPUProfile(f); err != nil {
return err
}
defer func() {
- ctx.Logger.Info("stopping CPU profiler", "profile", cpuProfile)
+ svrCtx.Logger.Info("stopping CPU profiler", "profile", cpuProfile)
pprof.StopCPUProfile()
+
if err := f.Close(); err != nil {
- ctx.Logger.Info("failed to close cpu-profile file", "profile", cpuProfile, "err", err.Error())
+ svrCtx.Logger.Info("failed to close cpu-profile file", "profile", cpuProfile, "err", err.Error())
}
}()
}
- errCh := make(chan error)
- go func() {
- errCh <- callback()
- }()
-
- select {
- case err := <-errCh:
- return err
-
- case <-time.After(types.ServerStartTime):
- }
-
- return WaitForQuitSignals()
+ return callbackFn()
}
// hackChainID replaces nibiru-localnet-0 with nibirulocalnet-9000-1 which matches the standard
@@ -674,3 +497,240 @@ func hackChainID(chainID string) string {
return result
}
+
+// emitServerInfoMetrics emits server info related metrics using application telemetry.
+func emitServerInfoMetrics() {
+ var ls []metrics.Label
+
+ versionInfo := version.NewInfo()
+ if len(versionInfo.GoVersion) > 0 {
+ ls = append(ls, telemetry.NewLabel("go", versionInfo.GoVersion))
+ }
+ if len(versionInfo.CosmosSdkVersion) > 0 {
+ ls = append(ls, telemetry.NewLabel("version", versionInfo.CosmosSdkVersion))
+ }
+
+ if len(ls) == 0 {
+ return
+ }
+
+ telemetry.SetGaugeWithLabels([]string{"server", "info"}, 1, ls)
+}
+
+func startGrpcServer(ctx context.Context, g *errgroup.Group, config serverconfig.GRPCConfig,
+ clientCtx client.Context,
+ svrCtx *server.Context,
+ app types.Application) (*grpc.Server, client.Context, error) {
+ if !config.Enable {
+ return nil, clientCtx, nil
+ }
+
+ _, _, err := net.SplitHostPort(config.Address)
+ if err != nil {
+ return nil, clientCtx, err
+ }
+
+ maxSendMsgSize := config.MaxSendMsgSize
+ if maxSendMsgSize == 0 {
+ maxSendMsgSize = serverconfig.DefaultGRPCMaxSendMsgSize
+ }
+
+ maxRecvMsgSize := config.MaxRecvMsgSize
+ if maxRecvMsgSize == 0 {
+ maxRecvMsgSize = serverconfig.DefaultGRPCMaxRecvMsgSize
+ }
+
+ // if gRPC is enabled, configure gRPC client for gRPC gateway
+ grpcClient, err := grpc.Dial(
+ config.Address,
+ grpc.WithTransportCredentials(insecure.NewCredentials()),
+ grpc.WithDefaultCallOptions(
+ grpc.ForceCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec()),
+ grpc.MaxCallRecvMsgSize(maxRecvMsgSize),
+ grpc.MaxCallSendMsgSize(maxSendMsgSize),
+ ),
+ )
+ if err != nil {
+ return nil, clientCtx, err
+ }
+
+ clientCtx = clientCtx.WithGRPCClient(grpcClient)
+ svrCtx.Logger.Debug("gRPC client assigned to client context", "target", config.Address)
+
+ grpcSrv, err := servergrpc.NewGRPCServer(clientCtx, app, config)
+ if err != nil {
+ return nil, clientCtx, err
+ }
+
+ // Start the gRPC server in a goroutine. Note, the provided ctx will ensure
+ // that the server is gracefully shut down.
+ g.Go(func() error {
+ return servergrpc.StartGRPCServer(ctx, svrCtx.Logger.With("module", "grpc-server"), config, grpcSrv)
+ })
+ return grpcSrv, clientCtx, nil
+}
+
+// returns a function which returns the genesis doc from the genesis file.
+func getGenDocProvider(cfg *cmtcfg.Config) func() (*cmttypes.GenesisDoc, error) {
+ return func() (*cmttypes.GenesisDoc, error) {
+ appGenesis, err := genutiltypes.AppGenesisFromFile(cfg.GenesisFile())
+ if err != nil {
+ return nil, err
+ }
+
+ return appGenesis.ToGenesisDoc()
+ }
+}
+
+func startAPIServer(
+ ctx context.Context,
+ g *errgroup.Group,
+ svrCfg serverconfig.Config,
+ clientCtx client.Context,
+ svrCtx *server.Context,
+ app types.Application,
+ home string,
+ grpcSrv *grpc.Server,
+ metrics *telemetry.Metrics,
+) error {
+ if !svrCfg.API.Enable {
+ return nil
+ }
+
+ clientCtx = clientCtx.WithHomeDir(home)
+
+ apiSrv := api.New(clientCtx, svrCtx.Logger.With("module", "api-server"), grpcSrv)
+ app.RegisterAPIRoutes(apiSrv, svrCfg.API)
+
+ if svrCfg.Telemetry.Enabled {
+ apiSrv.SetTelemetry(metrics)
+ }
+
+ g.Go(func() error {
+ return apiSrv.Start(ctx, svrCfg)
+ })
+ return nil
+}
+
+// TODO: Move nodeKey into being created within the function.
+func startCmtNode(
+ ctx context.Context,
+ cfg *cmtcfg.Config,
+ app types.Application,
+ svrCtx *server.Context,
+) (tmNode *node.Node, cleanupFn func(), err error) {
+ nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
+ if err != nil {
+ return nil, cleanupFn, err
+ }
+
+ cmtApp := server.NewCometABCIWrapper(app)
+ tmNode, err = node.NewNodeWithContext(
+ ctx,
+ cfg,
+ pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()),
+ nodeKey,
+ proxy.NewLocalClientCreator(cmtApp),
+ getGenDocProvider(cfg),
+ cmtcfg.DefaultDBProvider,
+ node.DefaultMetricsProvider(cfg.Instrumentation),
+ servercmtlog.CometLoggerWrapper{Logger: svrCtx.Logger},
+ )
+ if err != nil {
+ return tmNode, cleanupFn, err
+ }
+
+ if err := tmNode.Start(); err != nil {
+ return tmNode, cleanupFn, err
+ }
+
+ cleanupFn = func() {
+ if tmNode != nil && tmNode.IsRunning() {
+ _ = tmNode.Stop()
+ }
+ }
+
+ return tmNode, cleanupFn, nil
+}
+
+func addStartNodeFlags(cmd *cobra.Command, opts server.StartCmdOptions) {
+ cmd.Flags().Bool(WithTendermint, true, "Run abci app embedded in-process with tendermint")
+ cmd.Flags().String(Address, "tcp://0.0.0.0:26658", "Listen address")
+ cmd.Flags().String(Transport, "socket", "Transport protocol: socket, grpc")
+ cmd.Flags().String(TraceStore, "", "Enable KVStore tracing to an output file")
+ cmd.Flags().String(server.FlagMinGasPrices, "", "Minimum gas prices to accept for transactions; Any fee in a tx must meet this minimum (e.g. 5000unibi)") //nolint:lll
+ cmd.Flags().IntSlice(server.FlagUnsafeSkipUpgrades, []int{}, "Skip a set of upgrade heights to continue the old binary")
+ cmd.Flags().Uint64(server.FlagHaltHeight, 0, "Block height at which to gracefully halt the chain and shutdown the node")
+ cmd.Flags().Uint64(server.FlagHaltTime, 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node")
+ cmd.Flags().Bool(server.FlagInterBlockCache, true, "Enable inter-block caching")
+ cmd.Flags().String(CPUProfile, "", "Enable CPU profiling and write to the provided file")
+ cmd.Flags().Bool(server.FlagTrace, false, "Provide full stack traces for errors in ABCI Log")
+ cmd.Flags().String(server.FlagPruning, pruningtypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)")
+ cmd.Flags().Uint64(server.FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')")
+ cmd.Flags().Uint64(server.FlagPruningInterval, 0, "Height interval at which pruned heights are removed from disk (ignored if pruning is not 'custom')") //nolint:lll
+ cmd.Flags().Uint(server.FlagInvCheckPeriod, 0, "Assert registered invariants every N blocks")
+ cmd.Flags().Uint64(server.FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune Tendermint blocks")
+ cmd.Flags().String(AppDBBackend, "", "The type of database for application and snapshots databases")
+
+ cmd.Flags().Bool(GRPCOnly, false, "Start the node in gRPC query only mode without Tendermint process")
+ cmd.Flags().Bool(GRPCEnable, config.DefaultGRPCEnable, "Define if the gRPC server should be enabled")
+ cmd.Flags().String(GRPCAddress, serverconfig.DefaultGRPCAddress, "the gRPC server address to listen on")
+ cmd.Flags().Bool(GRPCWebEnable, config.DefaultGRPCWebEnable, "Define if the gRPC-Web server should be enabled. (Note: gRPC must also be enabled.)")
+ cmd.Flags().String(GRPCWebAddress, serverconfig.DefaultGRPCAddress, "The gRPC-Web server address to listen on")
+
+ cmd.Flags().Bool(RPCEnable, config.DefaultAPIEnable, "Defines if Cosmos-sdk REST server should be enabled")
+ cmd.Flags().Bool(EnabledUnsafeCors, false, "Defines if CORS should be enabled (unsafe - use it at your own risk)")
+
+ cmd.Flags().Bool(JSONRPCEnable, config.DefaultJSONRPCEnable, "Define if the JSON-RPC server should be enabled")
+ cmd.Flags().StringSlice(JSONRPCAPI, config.GetDefaultAPINamespaces(), "Defines a list of JSON-RPC namespaces that should be enabled")
+ cmd.Flags().String(JSONRPCAddress, config.DefaultJSONRPCAddress, "the JSON-RPC server address to listen on")
+ cmd.Flags().String(JSONWsAddress, config.DefaultJSONRPCWsAddress, "the JSON-RPC WS server address to listen on")
+ cmd.Flags().Uint64(JSONRPCGasCap, config.DefaultGasCap, "Sets a cap on gas that can be used in eth_call/estimateGas unit is unibi (0=infinite)") //nolint:lll
+ cmd.Flags().Float64(JSONRPCTxFeeCap, config.DefaultTxFeeCap, "Sets a cap on transaction fee that can be sent via the RPC APIs (1 = default 1 nibi)") //nolint:lll
+ cmd.Flags().Int32(JSONRPCFilterCap, config.DefaultFilterCap, "Sets the global cap for total number of filters that can be created")
+ cmd.Flags().Duration(JSONRPCEVMTimeout, config.DefaultEVMTimeout, "Sets a timeout used for eth_call (0=infinite)")
+ cmd.Flags().Duration(JSONRPCHTTPTimeout, config.DefaultHTTPTimeout, "Sets a read/write timeout for json-rpc http server (0=infinite)")
+ cmd.Flags().Duration(JSONRPCHTTPIdleTimeout, config.DefaultHTTPIdleTimeout, "Sets a idle timeout for json-rpc http server (0=infinite)")
+ cmd.Flags().Bool(JSONRPCAllowUnprotectedTxs, config.DefaultAllowUnprotectedTxs, "Allow for unprotected (non EIP155 signed) transactions to be submitted via the node's RPC when the global parameter is disabled") //nolint:lll
+ cmd.Flags().Int32(JSONRPCLogsCap, config.DefaultLogsCap, "Sets the max number of results can be returned from single `eth_getLogs` query")
+ cmd.Flags().Int32(JSONRPCBlockRangeCap, config.DefaultBlockRangeCap, "Sets the max block range allowed for `eth_getLogs` query")
+ cmd.Flags().Int(JSONRPCMaxOpenConnections, config.DefaultMaxOpenConnections, "Sets the maximum number of simultaneous connections for the server listener") //nolint:lll
+ cmd.Flags().Bool(JSONRPCEnableIndexer, false, "Enable the custom tx indexer for json-rpc")
+ cmd.Flags().Bool(JSONRPCEnableMetrics, false, "Define if EVM rpc metrics server should be enabled")
+
+ cmd.Flags().String(EVMTracer, config.DefaultEVMTracer, "the EVM tracer type to collect execution traces from the EVM transaction execution (json|struct|access_list|markdown)") //nolint:lll
+ cmd.Flags().Uint64(EVMMaxTxGasWanted, config.DefaultMaxTxGasWanted, "the gas wanted for each eth tx returned in ante handler in check tx mode") //nolint:lll
+
+ cmd.Flags().String(TLSCertPath, "", "the cert.pem file path for the server TLS configuration")
+ cmd.Flags().String(TLSKeyPath, "", "the key.pem file path for the server TLS configuration")
+
+ cmd.Flags().Uint64(server.FlagStateSyncSnapshotInterval, 0, "State sync snapshot interval")
+ cmd.Flags().Uint32(server.FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep")
+
+ // add support for all Tendermint-specific command line options
+ tcmd.AddNodeFlags(cmd)
+
+ if opts.AddFlags != nil {
+ opts.AddFlags(cmd)
+ }
+}
+
+func getCtx(svrCtx *server.Context, block bool) (*errgroup.Group, context.Context) {
+ ctx, cancelFn := context.WithCancel(context.Background())
+ g, ctx := errgroup.WithContext(ctx)
+ // listen for quit signals so the calling parent process can gracefully exit
+ server.ListenForQuitSignals(g, block, cancelFn, svrCtx.Logger)
+ return g, ctx
+}
+
+func getAndValidateConfig(svrCtx *server.Context) (config.Config, error) {
+ config, err := config.GetConfig(svrCtx.Viper)
+ if err != nil {
+ return config, err
+ }
+
+ if err := config.ValidateBasic(); err != nil {
+ return config, err
+ }
+ return config, nil
+}
diff --git a/app/server/util.go b/app/server/util.go
index a604e1d13..6fec64e06 100644
--- a/app/server/util.go
+++ b/app/server/util.go
@@ -1,21 +1,26 @@
package server
import (
+ "context"
"net"
"time"
+ cmtjson "github.com/cometbft/cometbft/libs/json"
"github.com/spf13/cobra"
"golang.org/x/net/netutil"
srvconfig "github.com/NibiruChain/nibiru/app/server/config"
+ "github.com/cosmos/cosmos-sdk/client"
sdkserver "github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/version"
+ "cosmossdk.io/log"
tmcmd "github.com/cometbft/cometbft/cmd/cometbft/commands"
- tmlog "github.com/cometbft/cometbft/libs/log"
rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client"
+ "github.com/cosmos/cosmos-sdk/client/flags"
+ "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
)
// AddCommands adds server commands
@@ -40,7 +45,7 @@ func AddCommands(
sdkserver.BootstrapStateCmd(opts.AppCreator),
)
- startCmd := StartCmd(opts)
+ startCmd := StartCmd(opts.AppCreator, opts.DefaultNodeHome)
addStartFlags(startCmd)
rootCmd.AddCommand(
@@ -55,7 +60,44 @@ func AddCommands(
)
}
-func ConnectTmWS(tmRPCAddr, tmEndpoint string, logger tmlog.Logger) *rpcclient.WSClient {
+// StatusCommand returns the command to return the status of the network.
+func StatusCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "status",
+ Short: "Query remote node for status",
+ RunE: func(cmd *cobra.Command, _ []string) error {
+ clientCtx, err := client.GetClientQueryContext(cmd)
+ if err != nil {
+ return err
+ }
+
+ status, err := cmtservice.GetNodeStatus(context.Background(), clientCtx)
+ if err != nil {
+ return err
+ }
+
+ output, err := cmtjson.Marshal(status)
+ if err != nil {
+ return err
+ }
+
+ // In order to maintain backwards compatibility, the default json format output
+ outputFormat, _ := cmd.Flags().GetString(flags.FlagOutput)
+ if outputFormat == flags.OutputFormatJSON {
+ clientCtx = clientCtx.WithOutputFormat(flags.OutputFormatJSON)
+ }
+
+ return clientCtx.PrintRaw(output)
+ },
+ }
+
+ cmd.Flags().StringP(flags.FlagNode, "n", "tcp://localhost:26657", "Node to connect to")
+ cmd.Flags().StringP(flags.FlagOutput, "o", "json", "Output format (text|json)")
+
+ return cmd
+}
+
+func ConnectTmWS(tmRPCAddr, tmEndpoint string, logger log.Logger) *rpcclient.WSClient {
tmWsClient, err := rpcclient.NewWS(tmRPCAddr, tmEndpoint,
rpcclient.MaxReconnectAttempts(256),
rpcclient.ReadWait(120*time.Second),
diff --git a/app/upgrades.go b/app/upgrades.go
index 07bccfb09..7f8781ad4 100644
--- a/app/upgrades.go
+++ b/app/upgrades.go
@@ -3,7 +3,7 @@ package app
import (
"fmt"
- upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
+ upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/NibiruChain/nibiru/app/upgrades"
"github.com/NibiruChain/nibiru/app/upgrades/v1_1_0"
diff --git a/app/upgrades/types.go b/app/upgrades/types.go
index a2cdde4b5..966fcd20c 100644
--- a/app/upgrades/types.go
+++ b/app/upgrades/types.go
@@ -1,9 +1,9 @@
package upgrades
import (
- store "github.com/cosmos/cosmos-sdk/store/types"
+ store "cosmossdk.io/store/types"
+ "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/types/module"
- "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
type Upgrade struct {
diff --git a/app/upgrades/v1_1_0/constants.go b/app/upgrades/v1_1_0/constants.go
index 257ef77c5..852534d7b 100644
--- a/app/upgrades/v1_1_0/constants.go
+++ b/app/upgrades/v1_1_0/constants.go
@@ -1,13 +1,14 @@
package v1_1_0
import (
- "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
+ "context"
+
+ "cosmossdk.io/store/types"
+ upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/types/module"
- upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/NibiruChain/nibiru/app/upgrades"
- inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
+ // inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
)
const UpgradeName = "v1.1.0"
@@ -15,11 +16,12 @@ const UpgradeName = "v1.1.0"
var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler {
- return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
+ return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, cfg, fromVM)
}
},
StoreUpgrades: types.StoreUpgrades{
- Added: []string{inflationtypes.ModuleName},
+ Added: []string{},
+ // Added: []string{inflationtypes.ModuleName},
},
}
diff --git a/app/upgrades/v1_2_0/constants.go b/app/upgrades/v1_2_0/constants.go
index fea9289a7..a9578f998 100644
--- a/app/upgrades/v1_2_0/constants.go
+++ b/app/upgrades/v1_2_0/constants.go
@@ -1,10 +1,11 @@
package v1_2_0
import (
- "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
+ "context"
+
+ "cosmossdk.io/store/types"
+ upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/types/module"
- upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/NibiruChain/nibiru/app/upgrades"
)
@@ -14,7 +15,7 @@ const UpgradeName = "v1.2.0"
var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler {
- return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
+ return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, cfg, fromVM)
}
},
diff --git a/app/upgrades/v1_3_0/constants.go b/app/upgrades/v1_3_0/constants.go
index 4788dbdd6..2684f0ea3 100644
--- a/app/upgrades/v1_3_0/constants.go
+++ b/app/upgrades/v1_3_0/constants.go
@@ -1,19 +1,21 @@
package v1_3_0
import (
- "github.com/cosmos/cosmos-sdk/store/types"
+ "context"
+
+ "cosmossdk.io/store/types"
+ upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
- upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
- ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
- icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
- icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
- icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
- ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
+ ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
+ icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
+ icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
+ icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
+ ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/NibiruChain/nibiru/app/upgrades"
)
@@ -23,7 +25,7 @@ const UpgradeName = "v1.3.0"
var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler {
- return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
+ return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// set the ICS27 consensus version so InitGenesis is not run
fromVM[icatypes.ModuleName] = mm.GetVersionMap()[icatypes.ModuleName]
@@ -55,7 +57,8 @@ var Upgrade = upgrades.Upgrade{
if !correctTypecast {
panic("mm.Modules[icatypes.ModuleName] is not of type ica.AppModule")
}
- icamodule.InitModule(ctx, controllerParams, hostParams)
+ sdkCtx := sdk.UnwrapSDKContext(ctx)
+ icamodule.InitModule(sdkCtx, controllerParams, hostParams)
return mm.RunMigrations(ctx, cfg, fromVM)
}
diff --git a/app/wasmext/stargate_query.go b/app/wasmext/stargate_query.go
index 3a08dd327..c85418def 100644
--- a/app/wasmext/stargate_query.go
+++ b/app/wasmext/stargate_query.go
@@ -3,20 +3,20 @@ package wasmext
import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
- devgas "github.com/NibiruChain/nibiru/x/devgas/v1/types"
- epochs "github.com/NibiruChain/nibiru/x/epochs/types"
- inflation "github.com/NibiruChain/nibiru/x/inflation/types"
- oracle "github.com/NibiruChain/nibiru/x/oracle/types"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
- tokenfactory "github.com/NibiruChain/nibiru/x/tokenfactory/types"
+ // devgas "github.com/NibiruChain/nibiru/x/devgas/v1/types"
+ // epochs "github.com/NibiruChain/nibiru/x/epochs/types"
+ // inflation "github.com/NibiruChain/nibiru/x/inflation/types"
+ // oracle "github.com/NibiruChain/nibiru/x/oracle/types"
+ // sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
+ // tokenfactory "github.com/NibiruChain/nibiru/x/tokenfactory/types"
auth "github.com/cosmos/cosmos-sdk/x/auth/types"
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
- ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
- ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
- ibcconnectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
+ ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
+ ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
+ ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
)
/*
@@ -102,43 +102,43 @@ func WasmAcceptedStargateQueries() wasmkeeper.AcceptedStargateQueries {
"/cosmos.gov.v1.Query/Vote": new(gov.QueryVoteResponse),
// nibiru tokenfactory
- "/nibiru.tokenfactory.v1.Query/Denoms": new(tokenfactory.QueryDenomsResponse),
- "/nibiru.tokenfactory.v1.Query/Params": new(tokenfactory.QueryParamsResponse),
- "/nibiru.tokenfactory.v1.Query/DenomInfo": new(tokenfactory.QueryDenomInfoResponse),
+ // "/nibiru.tokenfactory.v1.Query/Denoms": new(tokenfactory.QueryDenomsResponse),
+ // "/nibiru.tokenfactory.v1.Query/Params": new(tokenfactory.QueryParamsResponse),
+ // "/nibiru.tokenfactory.v1.Query/DenomInfo": new(tokenfactory.QueryDenomInfoResponse),
// nibiru epochs
- "/nibiru.epochs.v1.Query/EpochInfos": new(epochs.QueryEpochInfosResponse),
- "/nibiru.epochs.v1.Query/CurrentEpoch": new(epochs.QueryCurrentEpochResponse),
+ // "/nibiru.epochs.v1.Query/EpochInfos": new(epochs.QueryEpochInfosResponse),
+ // "/nibiru.epochs.v1.Query/CurrentEpoch": new(epochs.QueryCurrentEpochResponse),
// nibiru inflation
- "/nibiru.inflation.v1.Query/Period": new(inflation.QueryPeriodResponse),
- "/nibiru.inflation.v1.Query/EpochMintProvision": new(inflation.QueryEpochMintProvisionResponse),
- "/nibiru.inflation.v1.Query/SkippedEpochs": new(inflation.QuerySkippedEpochsResponse),
- "/nibiru.inflation.v1.Query/CirculatingSupply": new(inflation.QueryCirculatingSupplyResponse),
- "/nibiru.inflation.v1.Query/InflationRate": new(inflation.QueryInflationRateResponse),
- "/nibiru.inflation.v1.Query/Params": new(inflation.QueryParamsResponse),
+ // "/nibiru.inflation.v1.Query/Period": new(inflation.QueryPeriodResponse),
+ // "/nibiru.inflation.v1.Query/EpochMintProvision": new(inflation.QueryEpochMintProvisionResponse),
+ // "/nibiru.inflation.v1.Query/SkippedEpochs": new(inflation.QuerySkippedEpochsResponse),
+ // "/nibiru.inflation.v1.Query/CirculatingSupply": new(inflation.QueryCirculatingSupplyResponse),
+ // "/nibiru.inflation.v1.Query/InflationRate": new(inflation.QueryInflationRateResponse),
+ // "/nibiru.inflation.v1.Query/Params": new(inflation.QueryParamsResponse),
// nibiru oracle
- "/nibiru.oracle.v1.Query/ExchangeRate": new(oracle.QueryExchangeRateResponse),
- "/nibiru.oracle.v1.Query/ExchangeRateTwap": new(oracle.QueryExchangeRateResponse),
- "/nibiru.oracle.v1.Query/ExchangeRates": new(oracle.QueryExchangeRatesResponse),
- "/nibiru.oracle.v1.Query/Actives": new(oracle.QueryActivesResponse),
- "/nibiru.oracle.v1.Query/VoteTargets": new(oracle.QueryVoteTargetsResponse),
- "/nibiru.oracle.v1.Query/FeederDelegation": new(oracle.QueryFeederDelegationResponse),
- "/nibiru.oracle.v1.Query/MissCounter": new(oracle.QueryMissCounterResponse),
- "/nibiru.oracle.v1.Query/AggregatePrevote": new(oracle.QueryAggregatePrevoteResponse),
- "/nibiru.oracle.v1.Query/AggregatePrevotes": new(oracle.QueryAggregatePrevotesResponse),
- "/nibiru.oracle.v1.Query/AggregateVote": new(oracle.QueryAggregateVoteResponse),
- "/nibiru.oracle.v1.Query/AggregateVotes": new(oracle.QueryAggregateVotesResponse),
- "/nibiru.oracle.v1.Query/Params": new(oracle.QueryParamsResponse),
+ // "/nibiru.oracle.v1.Query/ExchangeRate": new(oracle.QueryExchangeRateResponse),
+ // "/nibiru.oracle.v1.Query/ExchangeRateTwap": new(oracle.QueryExchangeRateResponse),
+ // "/nibiru.oracle.v1.Query/ExchangeRates": new(oracle.QueryExchangeRatesResponse),
+ // "/nibiru.oracle.v1.Query/Actives": new(oracle.QueryActivesResponse),
+ // "/nibiru.oracle.v1.Query/VoteTargets": new(oracle.QueryVoteTargetsResponse),
+ // "/nibiru.oracle.v1.Query/FeederDelegation": new(oracle.QueryFeederDelegationResponse),
+ // "/nibiru.oracle.v1.Query/MissCounter": new(oracle.QueryMissCounterResponse),
+ // "/nibiru.oracle.v1.Query/AggregatePrevote": new(oracle.QueryAggregatePrevoteResponse),
+ // "/nibiru.oracle.v1.Query/AggregatePrevotes": new(oracle.QueryAggregatePrevotesResponse),
+ // "/nibiru.oracle.v1.Query/AggregateVote": new(oracle.QueryAggregateVoteResponse),
+ // "/nibiru.oracle.v1.Query/AggregateVotes": new(oracle.QueryAggregateVotesResponse),
+ // "/nibiru.oracle.v1.Query/Params": new(oracle.QueryParamsResponse),
// nibiru sudo
- "/nibiru.sudo.v1.Query/QuerySudoers": new(sudotypes.QuerySudoersResponse),
+ // "/nibiru.sudo.v1.Query/QuerySudoers": new(sudotypes.QuerySudoersResponse),
// nibiru devgas
- "/nibiru.devgas.v1.Query/FeeShares": new(devgas.QueryFeeSharesResponse),
- "/nibiru.devgas.v1.Query/FeeShare": new(devgas.QueryFeeShareResponse),
- "/nibiru.devgas.v1.Query/Params": new(devgas.QueryParamsResponse),
- "/nibiru.devgas.v1.Query/FeeSharesByWithdrawer": new(devgas.QueryFeeSharesByWithdrawerResponse),
+ // "/nibiru.devgas.v1.Query/FeeShares": new(devgas.QueryFeeSharesResponse),
+ // "/nibiru.devgas.v1.Query/FeeShare": new(devgas.QueryFeeShareResponse),
+ // "/nibiru.devgas.v1.Query/Params": new(devgas.QueryParamsResponse),
+ // "/nibiru.devgas.v1.Query/FeeSharesByWithdrawer": new(devgas.QueryFeeSharesByWithdrawerResponse),
}
}
diff --git a/app/wasmext/stargate_query_test.go b/app/wasmext/stargate_query_test.go
index 330ccf765..a602361b4 100644
--- a/app/wasmext/stargate_query_test.go
+++ b/app/wasmext/stargate_query_test.go
@@ -12,13 +12,12 @@ import (
wasmbinding "github.com/NibiruChain/nibiru/app/wasmext"
"github.com/NibiruChain/nibiru/x/common/set"
-
- devgas "github.com/NibiruChain/nibiru/x/devgas/v1/types"
- epochs "github.com/NibiruChain/nibiru/x/epochs/types"
- inflation "github.com/NibiruChain/nibiru/x/inflation/types"
- oracle "github.com/NibiruChain/nibiru/x/oracle/types"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
- tokenfactory "github.com/NibiruChain/nibiru/x/tokenfactory/types"
+ // devgas "github.com/NibiruChain/nibiru/x/devgas/v1/types"
+ // epochs "github.com/NibiruChain/nibiru/x/epochs/types"
+ // inflation "github.com/NibiruChain/nibiru/x/inflation/types"
+ // oracle "github.com/NibiruChain/nibiru/x/oracle/types"
+ // sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
+ // tokenfactory "github.com/NibiruChain/nibiru/x/tokenfactory/types"
)
/*
@@ -39,12 +38,12 @@ deterministically.
func TestWasmAcceptedStargateQueries(t *testing.T) {
t.Log("stargateQueryPaths: Add nibiru query paths from GRPC service descriptions")
queryServiceDescriptions := []grpc.ServiceDesc{
- epochs.GrpcQueryServiceDesc(),
- devgas.GrpcQueryServiceDesc(),
- inflation.GrpcQueryServiceDesc(),
- oracle.GrpcQueryServiceDesc(),
- sudotypes.GrpcQueryServiceDesc(),
- tokenfactory.GrpcQueryServiceDesc(),
+ // epochs.GrpcQueryServiceDesc(),
+ // devgas.GrpcQueryServiceDesc(),
+ // inflation.GrpcQueryServiceDesc(),
+ // oracle.GrpcQueryServiceDesc(),
+ // sudotypes.GrpcQueryServiceDesc(),
+ // tokenfactory.GrpcQueryServiceDesc(),
}
stargateQueryPaths := set.New[string]()
for _, serviceDesc := range queryServiceDescriptions {
diff --git a/cmd/nibid/cmd/decode_base64.go b/cmd/nibid/cmd/decode_base64.go
index 3de3706f2..e8aa2fa73 100644
--- a/cmd/nibid/cmd/decode_base64.go
+++ b/cmd/nibid/cmd/decode_base64.go
@@ -6,11 +6,11 @@ import (
"fmt"
"strings"
+ "github.com/cosmos/gogoproto/proto"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
- sdkcodec "github.com/cosmos/cosmos-sdk/codec"
wasmvm "github.com/CosmWasm/wasmvm/types"
)
@@ -119,7 +119,7 @@ func DecodeBase64StargateMsgs(
}
decodedBz, _ := base64.StdEncoding.Strict().DecodeString(string(sgMsg.Value))
- concrete := protoMsg.(sdkcodec.ProtoMarshaler)
+ concrete := protoMsg.(proto.Message)
err = codec.Unmarshal(decodedBz, concrete)
if err != nil {
diff --git a/cmd/nibid/cmd/decode_base64_test.go b/cmd/nibid/cmd/decode_base64_test.go
index 5711d8cf6..3c1383cf9 100644
--- a/cmd/nibid/cmd/decode_base64_test.go
+++ b/cmd/nibid/cmd/decode_base64_test.go
@@ -6,7 +6,7 @@ import (
"github.com/NibiruChain/nibiru/app"
- "github.com/cometbft/cometbft/libs/log"
+ "cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
@@ -28,7 +28,7 @@ func TestBase64Decode(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
home := t.TempDir()
logger := log.NewNopLogger()
- cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
+ cfg, err := genutiltest.CreateDefaultCometConfig(home)
require.NoError(t, err)
appCodec := app.MakeEncodingConfig().Codec
diff --git a/cmd/nibid/cmd/genaccounts.go b/cmd/nibid/cmd/genaccounts.go
index 6b79b1d87..0a42afe65 100644
--- a/cmd/nibid/cmd/genaccounts.go
+++ b/cmd/nibid/cmd/genaccounts.go
@@ -90,7 +90,10 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
baseAccount := authtypes.NewBaseAccount(addr, nil, 0, 0)
if !vestingAmt.IsZero() {
- baseVestingAccount := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd)
+ baseVestingAccount, err := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd)
+ if err != nil {
+ return err
+ }
if (balances.Coins.IsZero() && !baseVestingAccount.OriginalVesting.IsZero()) ||
baseVestingAccount.OriginalVesting.IsAnyGT(balances.Coins) {
diff --git a/cmd/nibid/cmd/genaccounts_test.go b/cmd/nibid/cmd/genaccounts_test.go
index d451673bd..191489361 100644
--- a/cmd/nibid/cmd/genaccounts_test.go
+++ b/cmd/nibid/cmd/genaccounts_test.go
@@ -7,7 +7,7 @@ import (
"github.com/NibiruChain/nibiru/app"
- "github.com/cometbft/cometbft/libs/log"
+ "cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
@@ -38,7 +38,7 @@ func TestAddGenesisAccountCmd(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
home := t.TempDir()
logger := log.NewNopLogger()
- cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
+ cfg, err := genutiltest.CreateDefaultCometConfig(home)
require.NoError(t, err)
appCodec := app.MakeEncodingConfig().Codec
diff --git a/cmd/nibid/cmd/init.go b/cmd/nibid/cmd/init.go
index 534ee07c5..2c7e2c865 100644
--- a/cmd/nibid/cmd/init.go
+++ b/cmd/nibid/cmd/init.go
@@ -10,10 +10,10 @@ import (
db "github.com/cometbft/cometbft-db"
tmcfg "github.com/cometbft/cometbft/config"
+ gentypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
tmcli "github.com/cometbft/cometbft/libs/cli"
tmrand "github.com/cometbft/cometbft/libs/rand"
- tmtypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/go-bip39"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -153,20 +153,19 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
return errors.Wrap(err, "Failed to marshal default genesis state")
}
- genDoc := &tmtypes.GenesisDoc{}
+ genDoc := &gentypes.AppGenesis{}
if _, err := os.Stat(genFile); err != nil {
if !os.IsNotExist(err) {
return err
}
} else {
- genDoc, err = tmtypes.GenesisDocFromFile(genFile)
+ genDoc, err = gentypes.AppGenesisFromFile(genFile)
if err != nil {
return errors.Wrap(err, "Failed to read genesis doc from file")
}
}
genDoc.ChainID = chainID
- genDoc.Validators = nil
genDoc.AppState = appState
genDoc.InitialHeight = initHeight
diff --git a/cmd/nibid/cmd/root.go b/cmd/nibid/cmd/root.go
index 5bc620516..73cdc8602 100644
--- a/cmd/nibid/cmd/root.go
+++ b/cmd/nibid/cmd/root.go
@@ -8,12 +8,10 @@ import (
"github.com/NibiruChain/nibiru/app/server"
srvconfig "github.com/NibiruChain/nibiru/app/server/config"
- "github.com/NibiruChain/nibiru/app/appconst"
- "github.com/NibiruChain/nibiru/x/sudo/cli"
-
- dbm "github.com/cometbft/cometbft-db"
+ "cosmossdk.io/log"
+ confixcmd "cosmossdk.io/tools/confix/cmd"
tmcli "github.com/cometbft/cometbft/libs/cli"
- "github.com/cometbft/cometbft/libs/log"
+ dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/debug"
@@ -30,8 +28,11 @@ import (
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/spf13/cobra"
+ "github.com/NibiruChain/nibiru/app/appconst"
+ // "github.com/NibiruChain/nibiru/x/sudo/cli"
+
"github.com/NibiruChain/nibiru/app"
- oraclecli "github.com/NibiruChain/nibiru/x/oracle/client/cli"
+ // oraclecli "github.com/NibiruChain/nibiru/x/oracle/client/cli"
)
// NewRootCmd creates a new root command for nibid. It is called once in the
@@ -114,8 +115,8 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) {
tmcli.NewCompletionCmd(rootCmd, true),
testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}),
debug.Cmd(),
- config.Cmd(),
- pruning.PruningCmd(a.newApp),
+ confixcmd.ConfigCommand(),
+ pruning.Cmd(a.newApp, app.DefaultNodeHome),
)
server.AddCommands(
@@ -127,15 +128,15 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) {
// add keybase, auxiliary RPC, query, and tx child commands
rootCmd.AddCommand(
- rpc.StatusCommand(),
+ server.StatusCommand(),
genesisCommand(
encodingConfig,
- oraclecli.AddGenesisPricefeederDelegationCmd(app.DefaultNodeHome),
- cli.AddSudoRootAccountCmd(app.DefaultNodeHome),
+ // oraclecli.AddGenesisPricefeederDelegationCmd(app.DefaultNodeHome),
+ // cli.AddSudoRootAccountCmd(app.DefaultNodeHome),
),
queryCommand(),
txCommand(),
- keys.Commands(app.DefaultNodeHome),
+ keys.Commands(),
)
// TODO add rosettaj
@@ -171,9 +172,7 @@ func queryCommand() *cobra.Command {
}
rootQueryCmd.AddCommand(
- authcmd.GetAccountCmd(),
rpc.ValidatorCommand(),
- rpc.BlockCommand(),
authcmd.QueryTxsByEventsCmd(),
authcmd.QueryTxCmd(),
)
@@ -205,7 +204,6 @@ func txCommand() *cobra.Command {
authcmd.GetDecodeCommand(),
)
- app.ModuleBasics.AddTxCommands(cmd)
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")
return cmd
diff --git a/cmd/nibid/cmd/testnet.go b/cmd/nibid/cmd/testnet.go
index 106babf8a..940c83ae7 100644
--- a/cmd/nibid/cmd/testnet.go
+++ b/cmd/nibid/cmd/testnet.go
@@ -210,9 +210,14 @@ func InitTestnet(
genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()})
genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0))
+ valAddrCodec := clientCtx.TxConfig.SigningContext().ValidatorAddressCodec()
+ valStr, err := valAddrCodec.BytesToString(sdk.ValAddress(addr))
+ if err != nil {
+ return err
+ }
valTokens := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction)
createValMsg, err := stakingtypes.NewMsgCreateValidator(
- sdk.ValAddress(addr),
+ valStr,
valPubKeys[i],
sdk.NewCoin(denoms.NIBI, valTokens),
stakingtypes.NewDescription(nodeDirName, "", "", "", ""),
@@ -237,7 +242,7 @@ func InitTestnet(
WithKeybase(kb).
WithTxConfig(clientCtx.TxConfig)
- if err := tx.Sign(txFactory, nodeDirName, txBuilder, true); err != nil {
+ if err := tx.Sign(cmd.Context(), txFactory, nodeDirName, txBuilder, true); err != nil {
return err
}
@@ -337,19 +342,21 @@ func collectGenFiles(
nodeID, valPubKey := nodeIDs[i], valPubKeys[i]
initCfg := genutiltypes.NewInitConfig(chainID, gentxsDir, nodeID, valPubKey)
- genDoc, err := types.GenesisDocFromFile(nodeConfig.GenesisFile())
+ appGenesis, err := genutiltypes.AppGenesisFromFile(nodeConfig.GenesisFile())
if err != nil {
return err
}
+ valAddrCodec := clientCtx.TxConfig.SigningContext().ValidatorAddressCodec()
nodeAppState, err := genutil.GenAppStateFromConfig(
clientCtx.Codec,
clientCtx.TxConfig,
nodeConfig,
initCfg,
- *genDoc,
+ appGenesis,
genBalIterator,
genutiltypes.DefaultMessageValidator,
+ valAddrCodec,
)
if err != nil {
return err
diff --git a/cmd/nibid/cmd/testnet_test.go b/cmd/nibid/cmd/testnet_test.go
index fa2892689..08d112850 100644
--- a/cmd/nibid/cmd/testnet_test.go
+++ b/cmd/nibid/cmd/testnet_test.go
@@ -7,7 +7,7 @@ import (
"github.com/NibiruChain/nibiru/app"
- "github.com/cometbft/cometbft/libs/log"
+ "cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
@@ -22,7 +22,7 @@ func Test_TestnetCmd(t *testing.T) {
home := t.TempDir()
encodingConfig := app.MakeEncodingConfig()
logger := log.NewNopLogger()
- cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
+ cfg, err := genutiltest.CreateDefaultCometConfig(home)
require.NoError(t, err)
err = genutiltest.ExecInitCmd(app.ModuleBasics, home, encodingConfig.Codec)
diff --git a/cmd/nibid/main.go b/cmd/nibid/main.go
index b34315c2f..1c5dffd4c 100644
--- a/cmd/nibid/main.go
+++ b/cmd/nibid/main.go
@@ -3,7 +3,6 @@ package main
import (
"os"
- "github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/NibiruChain/nibiru/app"
@@ -14,12 +13,6 @@ func main() {
rootCmd, _ := cmd.NewRootCmd()
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
- switch e := err.(type) {
- case server.ErrorCode:
- os.Exit(e.Code)
-
- default:
- os.Exit(1)
- }
+ os.Exit(1)
}
}
diff --git a/eth/account.pb.go b/eth/account.pb.go
deleted file mode 100644
index 7cea10a19..000000000
--- a/eth/account.pb.go
+++ /dev/null
@@ -1,377 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: eth/types/v1/account.proto
-
-package eth
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/cosmos-proto"
- types "github.com/cosmos/cosmos-sdk/x/auth/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// EthAccount implements the authtypes.AccountI interface and embeds an
-// authtypes.BaseAccount type. It is compatible with the auth AccountKeeper.
-type EthAccount struct {
- // base_account is an authtypes.BaseAccount
- *types.BaseAccount `protobuf:"bytes,1,opt,name=base_account,json=baseAccount,proto3,embedded=base_account" json:"base_account,omitempty" yaml:"base_account"`
- // code_hash is the hash calculated from the code contents
- CodeHash string `protobuf:"bytes,2,opt,name=code_hash,json=codeHash,proto3" json:"code_hash,omitempty" yaml:"code_hash"`
-}
-
-func (m *EthAccount) Reset() { *m = EthAccount{} }
-func (m *EthAccount) String() string { return proto.CompactTextString(m) }
-func (*EthAccount) ProtoMessage() {}
-func (*EthAccount) Descriptor() ([]byte, []int) {
- return fileDescriptor_33844e397ad0a9a0, []int{0}
-}
-func (m *EthAccount) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EthAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EthAccount.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EthAccount) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EthAccount.Merge(m, src)
-}
-func (m *EthAccount) XXX_Size() int {
- return m.Size()
-}
-func (m *EthAccount) XXX_DiscardUnknown() {
- xxx_messageInfo_EthAccount.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EthAccount proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*EthAccount)(nil), "eth.types.v1.EthAccount")
-}
-
-func init() { proto.RegisterFile("eth/types/v1/account.proto", fileDescriptor_33844e397ad0a9a0) }
-
-var fileDescriptor_33844e397ad0a9a0 = []byte{
- // 318 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0x2d, 0xc9, 0xd0,
- 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b,
- 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x49, 0x2d, 0xc9, 0xd0, 0x03, 0xcb, 0xe9, 0x95,
- 0x19, 0x4a, 0xc9, 0x25, 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0xeb, 0x27, 0x96, 0x96, 0x64, 0xe8, 0x97,
- 0x19, 0x26, 0xa5, 0x96, 0x24, 0x1a, 0x82, 0x39, 0x10, 0xd5, 0x52, 0x92, 0x10, 0xf9, 0x78, 0x30,
- 0x4f, 0x1f, 0xc2, 0x81, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x43, 0xc4, 0x41, 0x2c, 0x88, 0xa8,
- 0xd2, 0x57, 0x46, 0x2e, 0x2e, 0xd7, 0x92, 0x0c, 0x47, 0x88, 0x9d, 0x42, 0x09, 0x5c, 0x3c, 0x49,
- 0x89, 0xc5, 0xa9, 0xf1, 0x50, 0x37, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x29, 0xe8, 0x41,
- 0x4d, 0x02, 0xdb, 0x04, 0xb5, 0x56, 0xcf, 0x29, 0xb1, 0x38, 0x15, 0xaa, 0xcf, 0x49, 0xfa, 0xc2,
- 0x3d, 0x79, 0xc6, 0x4f, 0xf7, 0xe4, 0x85, 0x2b, 0x13, 0x73, 0x73, 0xac, 0x94, 0x90, 0xcd, 0x50,
- 0x0a, 0xe2, 0x4e, 0x42, 0xa8, 0x14, 0x32, 0xe4, 0xe2, 0x4c, 0xce, 0x4f, 0x49, 0x8d, 0xcf, 0x48,
- 0x2c, 0xce, 0x90, 0x60, 0x52, 0x60, 0xd4, 0xe0, 0x74, 0x12, 0xf9, 0x74, 0x4f, 0x5e, 0x00, 0xa2,
- 0x11, 0x2e, 0xa5, 0x14, 0xc4, 0x01, 0x62, 0x7b, 0x24, 0x16, 0x67, 0x58, 0x05, 0x75, 0x2c, 0x90,
- 0x67, 0x78, 0xb1, 0x40, 0x9e, 0xe1, 0xd4, 0x16, 0x5d, 0xb7, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24,
- 0xbd, 0xe4, 0xfc, 0x5c, 0xa8, 0xf7, 0xa0, 0x94, 0x6e, 0x71, 0x4a, 0xb6, 0x7e, 0x05, 0x24, 0x60,
- 0x20, 0xc1, 0x85, 0xcd, 0xcd, 0x50, 0x57, 0x78, 0x3a, 0x59, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1,
- 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70,
- 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x22, 0x92, 0x0d, 0x7e, 0x99, 0x49, 0x99, 0x45, 0xa5, 0xce, 0x19,
- 0x89, 0x99, 0x79, 0xfa, 0x79, 0x60, 0xb6, 0x7e, 0x6a, 0x49, 0x46, 0x12, 0x1b, 0x38, 0xec, 0x8c,
- 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe9, 0x66, 0xb4, 0x6d, 0xb8, 0x01, 0x00, 0x00,
-}
-
-func (m *EthAccount) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EthAccount) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EthAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.CodeHash) > 0 {
- i -= len(m.CodeHash)
- copy(dAtA[i:], m.CodeHash)
- i = encodeVarintAccount(dAtA, i, uint64(len(m.CodeHash)))
- i--
- dAtA[i] = 0x12
- }
- if m.BaseAccount != nil {
- {
- size, err := m.BaseAccount.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintAccount(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintAccount(dAtA []byte, offset int, v uint64) int {
- offset -= sovAccount(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *EthAccount) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.BaseAccount != nil {
- l = m.BaseAccount.Size()
- n += 1 + l + sovAccount(uint64(l))
- }
- l = len(m.CodeHash)
- if l > 0 {
- n += 1 + l + sovAccount(uint64(l))
- }
- return n
-}
-
-func sovAccount(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozAccount(x uint64) (n int) {
- return sovAccount(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *EthAccount) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowAccount
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EthAccount: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EthAccount: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field BaseAccount", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowAccount
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthAccount
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthAccount
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.BaseAccount == nil {
- m.BaseAccount = &types.BaseAccount{}
- }
- if err := m.BaseAccount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CodeHash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowAccount
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthAccount
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthAccount
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.CodeHash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipAccount(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthAccount
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipAccount(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowAccount
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowAccount
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowAccount
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthAccount
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupAccount
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthAccount
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthAccount = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowAccount = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupAccount = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/eth/assert.go b/eth/assert.go
deleted file mode 100644
index 09e5bd328..000000000
--- a/eth/assert.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eth
-
-import (
- "bytes"
-
- errorsmod "cosmossdk.io/errors"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
- "github.com/ethereum/go-ethereum/common"
-)
-
-// IsEmptyHash returns true if the hash corresponds to an empty ethereum hex hash.
-func IsEmptyHash(hash string) bool {
- return bytes.Equal(common.HexToHash(hash).Bytes(), common.Hash{}.Bytes())
-}
-
-// IsZeroAddress returns true if the address corresponds to an empty ethereum hex address.
-func IsZeroAddress(address string) bool {
- return bytes.Equal(common.HexToAddress(address).Bytes(), common.Address{}.Bytes())
-}
-
-// ValidateAddress returns an error if the provided string is either not a hex formatted string address
-func ValidateAddress(address string) error {
- if !common.IsHexAddress(address) {
- return errorsmod.Wrapf(
- errortypes.ErrInvalidAddress, "address '%s' is not a valid ethereum hex address",
- address,
- )
- }
- return nil
-}
-
-// ValidateNonZeroAddress returns an error if the provided string is not a hex
-// formatted string address or is equal to zero
-func ValidateNonZeroAddress(address string) error {
- if IsZeroAddress(address) {
- return errorsmod.Wrapf(
- errortypes.ErrInvalidAddress, "address '%s' must not be zero",
- address,
- )
- }
- return ValidateAddress(address)
-}
diff --git a/eth/assert_test.go b/eth/assert_test.go
deleted file mode 100644
index 792ef7213..000000000
--- a/eth/assert_test.go
+++ /dev/null
@@ -1,145 +0,0 @@
-package eth_test
-
-import (
- "testing"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-func TestIsEmptyHash(t *testing.T) {
- testCases := []struct {
- name string
- hash string
- expEmpty bool
- }{
- {
- "empty string", "", true,
- },
- {
- "zero hash", common.Hash{}.String(), true,
- },
-
- {
- "non-empty hash", common.BytesToHash([]byte{1, 2, 3, 4}).String(), false,
- },
- }
-
- for _, tc := range testCases {
- require.Equal(t, tc.expEmpty, eth.IsEmptyHash(tc.hash), tc.name)
- }
-}
-
-func TestIsZeroAddress(t *testing.T) {
- testCases := []struct {
- name string
- address string
- expEmpty bool
- }{
- {
- "empty string", "", true,
- },
- {
- "zero address", common.Address{}.String(), true,
- },
-
- {
- "non-empty address", common.BytesToAddress([]byte{1, 2, 3, 4}).String(), false,
- },
- }
-
- for _, tc := range testCases {
- require.Equal(t, tc.expEmpty, eth.IsZeroAddress(tc.address), tc.name)
- }
-}
-
-func TestValidateAddress(t *testing.T) {
- testCases := []struct {
- name string
- address string
- expError bool
- }{
- {
- "empty string", "", true,
- },
- {
- "invalid address", "0x", true,
- },
- {
- "zero address", common.Address{}.String(), false,
- },
- {
- "valid address", evmtest.NewEthAddr().Hex(), false,
- },
- }
-
- for _, tc := range testCases {
- err := eth.ValidateAddress(tc.address)
-
- if tc.expError {
- require.Error(t, err, tc.name)
- } else {
- require.NoError(t, err, tc.name)
- }
- }
-}
-
-func TestValidateNonZeroAddress(t *testing.T) {
- testCases := []struct {
- name string
- address string
- expError bool
- }{
- {
- "empty string", "", true,
- },
- {
- "invalid address", "0x", true,
- },
- {
- "zero address", common.Address{}.String(), true,
- },
- {
- "valid address", evmtest.NewEthAddr().Hex(), false,
- },
- }
-
- for _, tc := range testCases {
- err := eth.ValidateNonZeroAddress(tc.address)
-
- if tc.expError {
- require.Error(t, err, tc.name)
- } else {
- require.NoError(t, err, tc.name)
- }
- }
-}
-
-func TestSafeInt64(t *testing.T) {
- testCases := []struct {
- name string
- value uint64
- expError bool
- }{
- {
- "no overflow", 10, false,
- },
- {
- "overflow", 18446744073709551615, true,
- },
- }
-
- for _, tc := range testCases {
- value, err := eth.SafeInt64(tc.value)
- if tc.expError {
- require.Error(t, err, tc.name)
- continue
- }
-
- require.NoError(t, err, tc.name)
- require.Equal(t, int64(tc.value), value, tc.name)
- }
-}
diff --git a/eth/chain_id.go b/eth/chain_id.go
deleted file mode 100644
index 60dfaa880..000000000
--- a/eth/chain_id.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eth
-
-import (
- "fmt"
- "math/big"
- "regexp"
- "strings"
-)
-
-var (
- regexChainID = `[a-z]{1,}`
- regexEIP155Separator = `_{1}`
- regexEIP155 = `[1-9][0-9]*`
- regexEpochSeparator = `-{1}`
- regexEpoch = `[1-9][0-9]*`
- nibiruEvmChainId = regexp.MustCompile(fmt.Sprintf(`^(%s)%s(%s)%s(%s)$`,
- regexChainID,
- regexEIP155Separator,
- regexEIP155,
- regexEpochSeparator,
- regexEpoch))
-)
-
-// IsValidChainID returns false if the given chain identifier is incorrectly
-// formatted.
-func IsValidChainID(chainID string) bool {
- if len(chainID) > 48 {
- return false
- }
-
- return nibiruEvmChainId.MatchString(chainID)
-}
-
-// ParseChainID parses a string chain identifier's epoch to an
-// Ethereum-compatible chain-id in *big.Int format. The function returns an error
-// if the chain-id has an invalid format
-func ParseChainID(chainID string) (*big.Int, error) {
- chainID = strings.TrimSpace(chainID)
- if len(chainID) > 48 {
- return nil, ErrInvalidChainID.Wrapf(
- `chain-id input "%s" cannot exceed 48 chars`, chainID)
- }
-
- matches := nibiruEvmChainId.FindStringSubmatch(chainID)
- if matches == nil || len(matches) != 4 || matches[1] == "" {
- return nil, ErrInvalidChainID.Wrapf(
- `chain-id input "%s", matches "%v"`, chainID, matches)
- }
-
- // verify that the chain-id entered is a base 10 integer
- chainIDInt, ok := new(big.Int).SetString(matches[2], 10)
- if !ok {
- return nil, ErrInvalidChainID.Wrapf(
- `epoch "%s" must be base-10 integer format`, matches[2])
- }
-
- return chainIDInt, nil
-}
diff --git a/eth/chain_id_test.go b/eth/chain_id_test.go
deleted file mode 100644
index ccddc17f2..000000000
--- a/eth/chain_id_test.go
+++ /dev/null
@@ -1,124 +0,0 @@
-package eth
-
-import (
- "math/big"
- "strings"
- "testing"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func TestParseChainID_Happy(t *testing.T) {
- testCases := []struct {
- name string
- chainID string
- expInt *big.Int
- }{
- {
- chainID: "nibiru_1-1",
- name: "valid chain-id, single digit",
- expInt: big.NewInt(1),
- },
- {
- chainID: "aragonchain_256-1",
- name: "valid chain-id, multiple digits",
- expInt: big.NewInt(256),
- },
- }
-
- for _, tc := range testCases {
- chainIDEpoch, err := ParseChainID(tc.chainID)
- require.NoError(t, err, tc.name)
- var errMsg string = ""
- if err != nil {
- errMsg = err.Error()
- }
- assert.NoError(t, err, tc.name, errMsg)
- require.Equal(t, tc.expInt, chainIDEpoch, tc.name)
- require.True(t, IsValidChainID(tc.chainID))
- }
-}
-
-func TestParseChainID_Sad(t *testing.T) {
- testCases := []struct {
- name string
- chainID string
- }{
- {
- chainID: "aragonchain-1-1",
- name: "invalid chain-id, double dash",
- },
- {
- chainID: "aragonchain_1_1",
- name: "invalid chain-id, double underscore",
- },
- {
- chainID: "-",
- name: "invalid chain-id, dash only",
- },
- {
- chainID: "-1",
- name: "invalid chain-id, undefined identifier and EIP155",
- },
- {
- chainID: "_1-1",
- name: "invalid chain-id, undefined identifier",
- },
- {
- chainID: "NIBIRU_1-1",
- name: "invalid chain-id, uppercases",
- },
- {
- chainID: "Nibiru_1-1",
- name: "invalid chain-id, mixed cases",
- },
- {
- chainID: "$&*#!_1-1",
- name: "invalid chain-id, special chars",
- },
- {
- chainID: "nibiru_001-1",
- name: "invalid eip155 chain-id, cannot start with 0",
- },
- {
- chainID: "nibiru_0x212-1",
- name: "invalid eip155 chain-id, cannot invalid base",
- },
- {
- chainID: "nibiru_1-0x212",
- name: "invalid eip155 chain-id, cannot invalid base",
- },
- {
- chainID: "nibiru_nibiru_9000-1",
- name: "invalid eip155 chain-id, non-integer",
- },
- {
- chainID: "nibiru_-",
- name: "invalid epoch, undefined",
- },
- {
- chainID: " ",
- name: "blank chain ID",
- },
- {
- chainID: "",
- name: "empty chain ID",
- },
- {
- chainID: "_-",
- name: "empty content for chain id, eip155 and epoch numbers",
- },
- {
- chainID: "nibiru_" + strings.Repeat("1", 45) + "-1",
- name: "long chain-id",
- },
- }
-
- for _, tc := range testCases {
- chainIDEpoch, err := ParseChainID(tc.chainID)
- require.Error(t, err, tc.name)
- require.Nil(t, chainIDEpoch)
- require.False(t, IsValidChainID(tc.chainID), tc.name)
- }
-}
diff --git a/eth/codec.go b/eth/codec.go
deleted file mode 100644
index 75be8cae2..000000000
--- a/eth/codec.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eth
-
-import (
- fmt "fmt"
- "math/big"
- "strings"
-
- sdkmath "cosmossdk.io/math"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdktx "github.com/cosmos/cosmos-sdk/types/tx"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
-
- "github.com/NibiruChain/nibiru/app/appconst"
-)
-
-const (
- EthBaseDenom = appconst.BondDenom
- // EIP155ChainID_Testnet: Chain ID for a testnet Nibiru following the
- // format proposed by Vitalik in EIP155.
- EIP155ChainID_Testnet = "nibirutest_420"
-
- DefaultGasPrice = 20
-
- // ProtocolVersion: Latest supported version of the Ethereum protocol.
- // Matches the message types and expected APIs.
- // As of April, 2024, the highest protocol version on Ethereum mainnet is
- // "eth/68".
- // See https://github.com/ethereum/devp2p/blob/master/caps/eth.md#change-log
- // for the historical summary of each version.
- ProtocolVersion = 65
-)
-
-// Transaction extension protobuf type URLs
-const (
- TYPE_URL_WEB3_TX = "/eth.types.v1.ExtensionOptionsWeb3Tx"
- TYPE_URL_DYNAMIC_FEE_TX = "/eth.types.v1.ExtensionOptionDynamicFeeTx"
-)
-
-// RegisterInterfaces registers the tendermint concrete client-related
-// implementations and interfaces.
-func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- // proto name: "cosmos.auth.v1beta1.AccountI"
- registry.RegisterImplementations(
- (*authtypes.AccountI)(nil),
- &EthAccount{},
- // Also impl by: [
- // &authtypes.BaseAccount{},
- // &authtypes.ModuleAccount{},
- // ]
- )
-
- // proto name: "cosmos.auth.v1beta1.GenesisAccount"
- registry.RegisterImplementations(
- (*authtypes.GenesisAccount)(nil),
- &EthAccount{},
- // Also impl by: [
- // &authtypes.BaseAccount{},
- // &authtypes.ModuleAccount{},
- // ]
- )
-
- // proto name: "cosmos.tx.v1beta1.TxExtensionOptionI"
- registry.RegisterImplementations(
- (*sdktx.TxExtensionOptionI)(nil),
- &ExtensionOptionsWeb3Tx{},
- &ExtensionOptionDynamicFeeTx{},
- )
-}
-
-func ParseEIP155ChainIDNumber(chainId string) *big.Int {
- parts := strings.Split(chainId, "_")
- int, ok := sdkmath.NewIntFromString(parts[len(parts)-1])
- if !ok {
- err := fmt.Errorf(
- "failed to parse EIP155 chain ID number from chain ID: \"%s\"",
- chainId,
- )
- panic(err)
- }
- return int.BigInt()
-}
diff --git a/eth/codec_test.go b/eth/codec_test.go
deleted file mode 100644
index 18a7cea36..000000000
--- a/eth/codec_test.go
+++ /dev/null
@@ -1,101 +0,0 @@
-package eth
-
-import (
- "strings"
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdktx "github.com/cosmos/cosmos-sdk/types/tx"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
-)
-
-type CodecTestSuite struct {
- suite.Suite
-}
-
-func TestCodecSuite(t *testing.T) {
- suite.Run(t, new(CodecTestSuite))
-}
-
-func (suite *CodecTestSuite) TestRegisterInterfaces() {
- type ProtoNameInfo struct {
- ProtoName string
- Interface interface{}
- WantImpls []string
- }
- protoInfos := []ProtoNameInfo{
- {
- ProtoName: "cosmos.auth.v1beta1.AccountI",
- Interface: new(authtypes.AccountI),
- WantImpls: []string{
- "/eth.types.v1.EthAccount",
- "/cosmos.auth.v1beta1.BaseAccount",
- "/cosmos.auth.v1beta1.ModuleAccount",
- },
- },
- {
- ProtoName: "cosmos.auth.v1beta1.GenesisAccount",
- Interface: new(authtypes.GenesisAccount),
- WantImpls: []string{
- "/eth.types.v1.EthAccount",
- "/cosmos.auth.v1beta1.BaseAccount",
- "/cosmos.auth.v1beta1.ModuleAccount",
- },
- },
- {
- ProtoName: "cosmos.tx.v1beta1.TxExtensionOptionI",
- Interface: new(sdktx.TxExtensionOptionI),
- WantImpls: []string{
- TYPE_URL_WEB3_TX,
- TYPE_URL_DYNAMIC_FEE_TX,
- },
- },
- }
-
- // -------------------------------------------
- // Case 1: Setup: Register all interfaces under test
- // -------------------------------------------
- registry := codectypes.NewInterfaceRegistry()
- for _, protoInfo := range protoInfos {
- registry.RegisterInterface(protoInfo.ProtoName, protoInfo.Interface)
- }
- RegisterInterfaces(registry)
- authtypes.RegisterInterfaces(registry)
- sdktx.RegisterInterfaces(registry)
-
- // Test: Assert that all expected protobuf interface implementations are
- // registered (base + Ethereum)
- for _, protoInfo := range protoInfos {
- gotImpls := registry.ListImplementations(protoInfo.ProtoName)
- suite.Require().ElementsMatch(protoInfo.WantImpls, gotImpls)
- }
-
- // -------------------------------------------
- // Case 2: Setup: Register only eth interfaces
- // -------------------------------------------
- registry = codectypes.NewInterfaceRegistry()
- for _, protoInfo := range protoInfos {
- registry.RegisterInterface(protoInfo.ProtoName, protoInfo.Interface)
- }
- RegisterInterfaces(registry)
-
- // Test: Assert that all expected protobuf interface implementations are
- // registered (Ethereum only)
- for _, protoInfo := range protoInfos {
- gotImpls := registry.ListImplementations(protoInfo.ProtoName)
- wantImpls := filterImplsForEth(protoInfo.WantImpls)
- suite.Require().ElementsMatch(wantImpls, gotImpls)
- }
-}
-
-func filterImplsForEth(implTypeUrls []string) []string {
- typeUrls := []string{}
- for _, typeUrl := range implTypeUrls {
- if strings.Contains(typeUrl, "eth") {
- typeUrls = append(typeUrls, typeUrl)
- }
- }
- return typeUrls
-}
diff --git a/eth/crypto/codec/amino.go b/eth/crypto/codec/amino.go
deleted file mode 100644
index feffe70e1..000000000
--- a/eth/crypto/codec/amino.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package codec
-
-import (
- "github.com/cosmos/cosmos-sdk/codec"
- "github.com/cosmos/cosmos-sdk/codec/legacy"
- cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
-)
-
-// RegisterCrypto registers all crypto dependency types with the provided Amino
-// codec.
-func RegisterCrypto(cdc *codec.LegacyAmino) {
- cdc.RegisterConcrete(ðsecp256k1.PubKey{},
- ethsecp256k1.PubKeyName, nil)
- cdc.RegisterConcrete(ðsecp256k1.PrivKey{},
- ethsecp256k1.PrivKeyName, nil)
-
- keyring.RegisterLegacyAminoCodec(cdc)
- cryptocodec.RegisterCrypto(cdc)
-
- // NOTE: update SDK's amino codec to include the ethsecp256k1 keys.
- // DO NOT REMOVE unless deprecated on the SDK.
- legacy.Cdc = cdc
-}
diff --git a/eth/crypto/codec/codec.go b/eth/crypto/codec/codec.go
deleted file mode 100644
index cfd001ad2..000000000
--- a/eth/crypto/codec/codec.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package codec
-
-import (
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
-)
-
-// RegisterInterfaces register the cryptographic key concrete types.
-func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- registry.RegisterImplementations((*cryptotypes.PubKey)(nil), ðsecp256k1.PubKey{})
- registry.RegisterImplementations((*cryptotypes.PrivKey)(nil), ðsecp256k1.PrivKey{})
-}
diff --git a/eth/crypto/ethsecp256k1/benchmark_test.go b/eth/crypto/ethsecp256k1/benchmark_test.go
deleted file mode 100644
index 815cc5832..000000000
--- a/eth/crypto/ethsecp256k1/benchmark_test.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package ethsecp256k1
-
-import (
- "fmt"
- "testing"
-)
-
-func BenchmarkGenerateKey(b *testing.B) {
- b.ReportAllocs()
- for i := 0; i < b.N; i++ {
- if _, err := GenerateKey(); err != nil {
- b.Fatal(err)
- }
- }
-}
-
-func BenchmarkPubKey_VerifySignature(b *testing.B) {
- privKey, err := GenerateKey()
- if err != nil {
- b.Fatal(err)
- }
- pubKey := privKey.PubKey()
-
- b.ResetTimer()
- b.ReportAllocs()
- for i := 0; i < b.N; i++ {
- msg := []byte(fmt.Sprintf("%10d", i))
- sig, err := privKey.Sign(msg)
- if err != nil {
- b.Fatal(err)
- }
- pubKey.VerifySignature(msg, sig)
- }
-}
diff --git a/eth/crypto/ethsecp256k1/ethsecp256k1.go b/eth/crypto/ethsecp256k1/ethsecp256k1.go
deleted file mode 100644
index cd5cdd0f5..000000000
--- a/eth/crypto/ethsecp256k1/ethsecp256k1.go
+++ /dev/null
@@ -1,249 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-
-package ethsecp256k1
-
-import (
- "bytes"
- "crypto/ecdsa"
- "crypto/subtle"
- "fmt"
-
- errorsmod "cosmossdk.io/errors"
- tmcrypto "github.com/cometbft/cometbft/crypto"
- "github.com/cosmos/cosmos-sdk/codec"
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
- "github.com/ethereum/go-ethereum/crypto"
-
- "github.com/NibiruChain/nibiru/eth/eip712"
-)
-
-const (
- // PrivKeySize defines the size of the PrivKey bytes
- PrivKeySize = 32
- // PubKeySize defines the size of the PubKey bytes
- PubKeySize = 33
- // KeyType is the string constant for the Secp256k1 algorithm
- KeyType = "eth_secp256k1"
-)
-
-// Amino encoding names
-const (
- // PrivKeyName defines the amino encoding name for the EthSecp256k1 private key
- PrivKeyName = "ethermint/PrivKeyEthSecp256k1"
- // PubKeyName defines the amino encoding name for the EthSecp256k1 public key
- PubKeyName = "ethermint/PubKeyEthSecp256k1"
-)
-
-// ----------------------------------------------------------------------------
-// secp256k1 Private Key
-
-var (
- _ cryptotypes.PrivKey = &PrivKey{}
- _ codec.AminoMarshaler = &PrivKey{}
-)
-
-// GenerateKey generates a new random private key. It returns an error upon
-// failure.
-func GenerateKey() (*PrivKey, error) {
- priv, err := crypto.GenerateKey()
- if err != nil {
- return nil, err
- }
-
- return &PrivKey{
- Key: crypto.FromECDSA(priv),
- }, nil
-}
-
-// Bytes returns the byte representation of the ECDSA Private Key.
-func (privKey PrivKey) Bytes() []byte {
- bz := make([]byte, len(privKey.Key))
- copy(bz, privKey.Key)
-
- return bz
-}
-
-// PubKey returns the ECDSA private key's public key. If the privkey is not valid
-// it returns a nil value.
-func (privKey PrivKey) PubKey() cryptotypes.PubKey {
- ecdsaPrivKey, err := privKey.ToECDSA()
- if err != nil {
- return nil
- }
-
- return &PubKey{
- Key: crypto.CompressPubkey(&ecdsaPrivKey.PublicKey),
- }
-}
-
-// Equals returns true if two ECDSA private keys are equal and false otherwise.
-func (privKey PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool {
- return privKey.Type() == other.Type() && subtle.ConstantTimeCompare(privKey.Bytes(), other.Bytes()) == 1
-}
-
-// Type returns eth_secp256k1
-func (privKey PrivKey) Type() string {
- return KeyType
-}
-
-// MarshalAmino overrides Amino binary marshaling.
-func (privKey PrivKey) MarshalAmino() ([]byte, error) {
- return privKey.Key, nil
-}
-
-// UnmarshalAmino overrides Amino binary marshaling.
-func (privKey *PrivKey) UnmarshalAmino(bz []byte) error {
- if len(bz) != PrivKeySize {
- return fmt.Errorf("invalid privkey size, expected %d got %d", PrivKeySize, len(bz))
- }
- privKey.Key = bz
-
- return nil
-}
-
-// MarshalAminoJSON overrides Amino JSON marshaling.
-func (privKey PrivKey) MarshalAminoJSON() ([]byte, error) {
- // When we marshal to Amino JSON, we don't marshal the "key" field itself,
- // just its contents (i.e. the key bytes).
- return privKey.MarshalAmino()
-}
-
-// UnmarshalAminoJSON overrides Amino JSON marshaling.
-func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error {
- return privKey.UnmarshalAmino(bz)
-}
-
-// Sign creates a recoverable ECDSA signature on the secp256k1 curve over the
-// provided hash of the message. The produced signature is 65 bytes
-// where the last byte contains the recovery ID.
-func (privKey PrivKey) Sign(digestBz []byte) ([]byte, error) {
- // TODO: remove
- if len(digestBz) != crypto.DigestLength {
- digestBz = crypto.Keccak256Hash(digestBz).Bytes()
- }
-
- key, err := privKey.ToECDSA()
- if err != nil {
- return nil, err
- }
-
- return crypto.Sign(digestBz, key)
-}
-
-// ToECDSA returns the ECDSA private key as a reference to ecdsa.PrivateKey type.
-func (privKey PrivKey) ToECDSA() (*ecdsa.PrivateKey, error) {
- return crypto.ToECDSA(privKey.Bytes())
-}
-
-// ----------------------------------------------------------------------------
-// secp256k1 Public Key
-
-var (
- _ cryptotypes.PubKey = &PubKey{}
- _ codec.AminoMarshaler = &PubKey{}
-)
-
-// Address returns the address of the ECDSA public key.
-// The function will return an empty address if the public key is invalid.
-func (pubKey PubKey) Address() tmcrypto.Address {
- pubk, err := crypto.DecompressPubkey(pubKey.Key)
- if err != nil {
- return nil
- }
-
- return tmcrypto.Address(crypto.PubkeyToAddress(*pubk).Bytes())
-}
-
-// Bytes returns the raw bytes of the ECDSA public key.
-func (pubKey PubKey) Bytes() []byte {
- bz := make([]byte, len(pubKey.Key))
- copy(bz, pubKey.Key)
-
- return bz
-}
-
-// String implements the fmt.Stringer interface.
-func (pubKey PubKey) String() string {
- return fmt.Sprintf("EthPubKeySecp256k1{%X}", pubKey.Key)
-}
-
-// Type returns eth_secp256k1
-func (pubKey PubKey) Type() string {
- return KeyType
-}
-
-// Equals returns true if the pubkey type is the same and their bytes are deeply equal.
-func (pubKey PubKey) Equals(other cryptotypes.PubKey) bool {
- return pubKey.Type() == other.Type() && bytes.Equal(pubKey.Bytes(), other.Bytes())
-}
-
-// MarshalAmino overrides Amino binary marshaling.
-func (pubKey PubKey) MarshalAmino() ([]byte, error) {
- return pubKey.Key, nil
-}
-
-// UnmarshalAmino overrides Amino binary marshaling.
-func (pubKey *PubKey) UnmarshalAmino(bz []byte) error {
- if len(bz) != PubKeySize {
- return errorsmod.Wrapf(errortypes.ErrInvalidPubKey, "invalid pubkey size, expected %d, got %d", PubKeySize, len(bz))
- }
- pubKey.Key = bz
-
- return nil
-}
-
-// MarshalAminoJSON overrides Amino JSON marshaling.
-func (pubKey PubKey) MarshalAminoJSON() ([]byte, error) {
- // When we marshal to Amino JSON, we don't marshal the "key" field itself,
- // just its contents (i.e. the key bytes).
- return pubKey.MarshalAmino()
-}
-
-// UnmarshalAminoJSON overrides Amino JSON marshaling.
-func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error {
- return pubKey.UnmarshalAmino(bz)
-}
-
-// VerifySignature verifies that the ECDSA public key created a given signature over
-// the provided message. It will calculate the Keccak256 hash of the message
-// prior to verification and approve verification if the signature can be verified
-// from either the original message or its EIP-712 representation.
-//
-// CONTRACT: The signature should be in [R || S] format.
-func (pubKey PubKey) VerifySignature(msg, sig []byte) bool {
- return pubKey.verifySignatureECDSA(msg, sig) || pubKey.verifySignatureAsEIP712(msg, sig)
-}
-
-// Verifies the signature as an EIP-712 signature by first converting the message payload
-// to EIP-712 object bytes, then performing ECDSA verification on the hash. This is to support
-// signing a Cosmos payload using EIP-712.
-func (pubKey PubKey) verifySignatureAsEIP712(msg, sig []byte) bool {
- eip712Bytes, err := eip712.GetEIP712BytesForMsg(msg)
- if err != nil {
- return false
- }
-
- if pubKey.verifySignatureECDSA(eip712Bytes, sig) {
- return true
- }
-
- // Try verifying the signature using the legacy EIP-712 encoding
- legacyEIP712Bytes, err := eip712.LegacyGetEIP712BytesForMsg(msg)
- if err != nil {
- return false
- }
-
- return pubKey.verifySignatureECDSA(legacyEIP712Bytes, sig)
-}
-
-// Perform standard ECDSA signature verification for the given raw bytes and signature.
-func (pubKey PubKey) verifySignatureECDSA(msg, sig []byte) bool {
- if len(sig) == crypto.SignatureLength {
- // remove recovery ID (V) if contained in the signature
- sig = sig[:len(sig)-1]
- }
-
- // the signature needs to be in [R || S] format when provided to VerifySignature
- return crypto.VerifySignature(pubKey.Key, crypto.Keccak256Hash(msg).Bytes(), sig)
-}
diff --git a/eth/crypto/ethsecp256k1/ethsecp256k1_test.go b/eth/crypto/ethsecp256k1/ethsecp256k1_test.go
deleted file mode 100644
index 044f1c20b..000000000
--- a/eth/crypto/ethsecp256k1/ethsecp256k1_test.go
+++ /dev/null
@@ -1,124 +0,0 @@
-package ethsecp256k1
-
-import (
- "encoding/base64"
- "testing"
-
- "github.com/stretchr/testify/require"
-
- "github.com/cosmos/cosmos-sdk/codec"
-
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/crypto/secp256k1"
-
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
-)
-
-func TestPrivKey(t *testing.T) {
- // validate type and equality
- privKey, err := GenerateKey()
- require.NoError(t, err)
- require.Implements(t, (*cryptotypes.PrivKey)(nil), privKey)
-
- // validate inequality
- privKey2, err := GenerateKey()
- require.NoError(t, err)
- require.False(t, privKey.Equals(privKey2))
-
- // validate Ethereum address equality
- addr := privKey.PubKey().Address()
- key, err := privKey.ToECDSA()
- require.NoError(t, err)
- expectedAddr := crypto.PubkeyToAddress(key.PublicKey)
- require.Equal(t, expectedAddr.Bytes(), addr.Bytes())
-
- // validate we can sign some bytes
- msg := []byte("hello world")
- sigHash := crypto.Keccak256Hash(msg)
- expectedSig, err := secp256k1.Sign(sigHash.Bytes(), privKey.Bytes())
- require.NoError(t, err)
-
- sig, err := privKey.Sign(sigHash.Bytes())
- require.NoError(t, err)
- require.Equal(t, expectedSig, sig)
-}
-
-func TestPrivKey_PubKey(t *testing.T) {
- privKey, err := GenerateKey()
- require.NoError(t, err)
-
- // validate type and equality
- pubKey := &PubKey{
- Key: privKey.PubKey().Bytes(),
- }
- require.Implements(t, (*cryptotypes.PubKey)(nil), pubKey)
-
- // validate inequality
- privKey2, err := GenerateKey()
- require.NoError(t, err)
- require.False(t, pubKey.Equals(privKey2.PubKey()))
-
- // validate signature
- msg := []byte("hello world")
- sigHash := crypto.Keccak256Hash(msg)
- sig, err := privKey.Sign(sigHash.Bytes())
- require.NoError(t, err)
-
- res := pubKey.VerifySignature(msg, sig)
- require.True(t, res)
-}
-
-func TestMarshalAmino(t *testing.T) {
- aminoCdc := codec.NewLegacyAmino()
- privKey, err := GenerateKey()
- require.NoError(t, err)
-
- pubKey := privKey.PubKey().(*PubKey)
-
- testCases := []struct {
- desc string
- msg codec.AminoMarshaler
- typ interface{}
- expBinary []byte
- expJSON string
- }{
- {
- "ethsecp256k1 private key",
- privKey,
- &PrivKey{},
- append([]byte{32}, privKey.Bytes()...), // Length-prefixed.
- "\"" + base64.StdEncoding.EncodeToString(privKey.Bytes()) + "\"",
- },
- {
- "ethsecp256k1 public key",
- pubKey,
- &PubKey{},
- append([]byte{33}, pubKey.Bytes()...), // Length-prefixed.
- "\"" + base64.StdEncoding.EncodeToString(pubKey.Bytes()) + "\"",
- },
- }
-
- for _, tc := range testCases {
- t.Run(tc.desc, func(t *testing.T) {
- // Do a round trip of encoding/decoding binary.
- bz, err := aminoCdc.Marshal(tc.msg)
- require.NoError(t, err)
- require.Equal(t, tc.expBinary, bz)
-
- err = aminoCdc.Unmarshal(bz, tc.typ)
- require.NoError(t, err)
-
- require.Equal(t, tc.msg, tc.typ)
-
- // Do a round trip of encoding/decoding JSON.
- bz, err = aminoCdc.MarshalJSON(tc.msg)
- require.NoError(t, err)
- require.Equal(t, tc.expJSON, string(bz))
-
- err = aminoCdc.UnmarshalJSON(bz, tc.typ)
- require.NoError(t, err)
-
- require.Equal(t, tc.msg, tc.typ)
- })
- }
-}
diff --git a/eth/crypto/ethsecp256k1/keys.pb.go b/eth/crypto/ethsecp256k1/keys.pb.go
deleted file mode 100644
index 93ec27286..000000000
--- a/eth/crypto/ethsecp256k1/keys.pb.go
+++ /dev/null
@@ -1,500 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: ethermint/crypto/v1/ethsecp256k1/keys.proto
-
-package ethsecp256k1
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// PubKey defines a type alias for an ecdsa.PublicKey that implements
-// Tendermint's PubKey interface. It represents the 33-byte compressed public
-// key format.
-type PubKey struct {
- // key is the public key in byte form
- Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
-}
-
-func (m *PubKey) Reset() { *m = PubKey{} }
-func (*PubKey) ProtoMessage() {}
-func (*PubKey) Descriptor() ([]byte, []int) {
- return fileDescriptor_0c10cadcf35beb64, []int{0}
-}
-func (m *PubKey) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_PubKey.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *PubKey) XXX_Merge(src proto.Message) {
- xxx_messageInfo_PubKey.Merge(m, src)
-}
-func (m *PubKey) XXX_Size() int {
- return m.Size()
-}
-func (m *PubKey) XXX_DiscardUnknown() {
- xxx_messageInfo_PubKey.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_PubKey proto.InternalMessageInfo
-
-func (m *PubKey) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-// PrivKey defines a type alias for an ecdsa.PrivateKey that implements
-// Tendermint's PrivateKey interface.
-type PrivKey struct {
- // key is the private key in byte form
- Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
-}
-
-func (m *PrivKey) Reset() { *m = PrivKey{} }
-func (m *PrivKey) String() string { return proto.CompactTextString(m) }
-func (*PrivKey) ProtoMessage() {}
-func (*PrivKey) Descriptor() ([]byte, []int) {
- return fileDescriptor_0c10cadcf35beb64, []int{1}
-}
-func (m *PrivKey) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_PrivKey.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *PrivKey) XXX_Merge(src proto.Message) {
- xxx_messageInfo_PrivKey.Merge(m, src)
-}
-func (m *PrivKey) XXX_Size() int {
- return m.Size()
-}
-func (m *PrivKey) XXX_DiscardUnknown() {
- xxx_messageInfo_PrivKey.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_PrivKey proto.InternalMessageInfo
-
-func (m *PrivKey) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*PubKey)(nil), "ethermint.crypto.v1.ethsecp256k1.PubKey")
- proto.RegisterType((*PrivKey)(nil), "ethermint.crypto.v1.ethsecp256k1.PrivKey")
-}
-
-func init() {
- proto.RegisterFile("ethermint/crypto/v1/ethsecp256k1/keys.proto", fileDescriptor_0c10cadcf35beb64)
-}
-
-var fileDescriptor_0c10cadcf35beb64 = []byte{
- // 197 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0x2d, 0xc9, 0x48,
- 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0x2f, 0x33, 0xd4,
- 0x4f, 0x2d, 0xc9, 0x28, 0x4e, 0x4d, 0x2e, 0x30, 0x32, 0x35, 0xcb, 0x36, 0xd4, 0xcf, 0x4e, 0xad,
- 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x80, 0x2b, 0xd6, 0x83, 0x28, 0xd6, 0x2b,
- 0x33, 0xd4, 0x43, 0x56, 0x2c, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xac, 0x0f, 0x62, 0x41,
- 0xf4, 0x29, 0x29, 0x70, 0xb1, 0x05, 0x94, 0x26, 0x79, 0xa7, 0x56, 0x0a, 0x09, 0x70, 0x31, 0x67,
- 0xa7, 0x56, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x04, 0x81, 0x98, 0x56, 0x2c, 0x33, 0x16, 0xc8,
- 0x33, 0x28, 0x49, 0x73, 0xb1, 0x07, 0x14, 0x65, 0x96, 0x61, 0x55, 0xe2, 0xe4, 0x71, 0xe2, 0x91,
- 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1,
- 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x7a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a,
- 0xc9, 0xf9, 0xb9, 0xfa, 0xa9, 0x65, 0xb9, 0xf9, 0xc5, 0x50, 0xb2, 0xcc, 0xd0, 0x0c, 0xe6, 0x1d,
- 0x64, 0xe7, 0x25, 0xb1, 0x81, 0xdd, 0x63, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x03, 0x69, 0xeb,
- 0xbb, 0xf6, 0x00, 0x00, 0x00,
-}
-
-func (m *PubKey) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *PubKey) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Key) > 0 {
- i -= len(m.Key)
- copy(dAtA[i:], m.Key)
- i = encodeVarintKeys(dAtA, i, uint64(len(m.Key)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *PrivKey) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *PrivKey) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *PrivKey) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Key) > 0 {
- i -= len(m.Key)
- copy(dAtA[i:], m.Key)
- i = encodeVarintKeys(dAtA, i, uint64(len(m.Key)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintKeys(dAtA []byte, offset int, v uint64) int {
- offset -= sovKeys(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *PubKey) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovKeys(uint64(l))
- }
- return n
-}
-
-func (m *PrivKey) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovKeys(uint64(l))
- }
- return n
-}
-
-func sovKeys(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozKeys(x uint64) (n int) {
- return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *PubKey) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowKeys
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: PubKey: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: PubKey: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowKeys
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthKeys
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthKeys
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipKeys(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthKeys
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *PrivKey) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowKeys
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: PrivKey: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: PrivKey: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowKeys
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthKeys
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthKeys
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipKeys(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthKeys
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipKeys(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowKeys
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowKeys
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowKeys
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthKeys
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupKeys
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthKeys
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthKeys = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowKeys = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/eth/crypto/hd/algorithm.go b/eth/crypto/hd/algorithm.go
deleted file mode 100644
index 9949b363f..000000000
--- a/eth/crypto/hd/algorithm.go
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package hd
-
-import (
- "github.com/btcsuite/btcd/btcutil/hdkeychain"
- "github.com/btcsuite/btcd/chaincfg"
- bip39 "github.com/tyler-smith/go-bip39"
-
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/crypto"
-
- "github.com/cosmos/cosmos-sdk/crypto/hd"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
-)
-
-const (
- // EthSecp256k1Type defines the ECDSA secp256k1 used on Ethereum
- EthSecp256k1Type = hd.PubKeyType(ethsecp256k1.KeyType)
-)
-
-var (
- // SupportedAlgorithms defines the list of signing algorithms used:
- // - eth_secp256k1 (Ethereum)
- // - secp256k1 (Tendermint)
- SupportedAlgorithms = keyring.SigningAlgoList{EthSecp256k1, hd.Secp256k1}
- // SupportedAlgorithmsLedger defines the list of signing algorithms used on the Ledger device:
- // - eth_secp256k1 (Ethereum)
- // - secp256k1 (Tendermint)
- SupportedAlgorithmsLedger = keyring.SigningAlgoList{EthSecp256k1, hd.Secp256k1}
-)
-
-// EthSecp256k1Option defines a function keys options for the ethereum Secp256k1 curve.
-// It supports eth_secp256k1 and secp256k1 keys for accounts.
-func EthSecp256k1Option() keyring.Option {
- return func(options *keyring.Options) {
- options.SupportedAlgos = SupportedAlgorithms
- options.SupportedAlgosLedger = SupportedAlgorithmsLedger
- }
-}
-
-var (
- _ keyring.SignatureAlgo = EthSecp256k1
-
- // EthSecp256k1 uses the Bitcoin secp256k1 ECDSA parameters.
- EthSecp256k1 = ethSecp256k1Algo{}
-)
-
-type ethSecp256k1Algo struct{}
-
-// Name returns eth_secp256k1
-func (s ethSecp256k1Algo) Name() hd.PubKeyType {
- return EthSecp256k1Type
-}
-
-// Derive derives and returns the eth_secp256k1 private key for the given mnemonic and HD path.
-func (s ethSecp256k1Algo) Derive() hd.DeriveFn {
- return func(mnemonic, bip39Passphrase, path string) ([]byte, error) {
- hdpath, err := accounts.ParseDerivationPath(path)
- if err != nil {
- return nil, err
- }
-
- seed, err := bip39.NewSeedWithErrorChecking(mnemonic, bip39Passphrase)
- if err != nil {
- return nil, err
- }
-
- // create a BTC-utils hd-derivation key chain
- masterKey, err := hdkeychain.NewMaster(seed, &chaincfg.MainNetParams)
- if err != nil {
- return nil, err
- }
-
- key := masterKey
- for _, n := range hdpath {
- key, err = key.Derive(n)
- if err != nil {
- return nil, err
- }
- }
-
- // btc-utils representation of a secp256k1 private key
- privateKey, err := key.ECPrivKey()
- if err != nil {
- return nil, err
- }
-
- // cast private key to a convertible form (single scalar field element of secp256k1)
- // and then load into ethcrypto private key format.
- // TODO: add links to godocs of the two methods or implementations of them, to compare equivalency
- privateKeyECDSA := privateKey.ToECDSA()
- derivedKey := crypto.FromECDSA(privateKeyECDSA)
-
- return derivedKey, nil
- }
-}
-
-// Generate generates a eth_secp256k1 private key from the given bytes.
-func (s ethSecp256k1Algo) Generate() hd.GenerateFn {
- return func(bz []byte) cryptotypes.PrivKey {
- bzArr := make([]byte, ethsecp256k1.PrivKeySize)
- copy(bzArr, bz)
-
- // TODO: modulo P
- return ðsecp256k1.PrivKey{
- Key: bzArr,
- }
- }
-}
diff --git a/eth/crypto/hd/algorithm_test.go b/eth/crypto/hd/algorithm_test.go
deleted file mode 100644
index 2d46d51c7..000000000
--- a/eth/crypto/hd/algorithm_test.go
+++ /dev/null
@@ -1,132 +0,0 @@
-package hd
-
-import (
- "os"
- "strings"
- "testing"
-
- "github.com/stretchr/testify/require"
-
- "github.com/ethereum/go-ethereum/common"
-
- amino "github.com/cosmos/cosmos-sdk/codec"
- "github.com/cosmos/cosmos-sdk/codec/types"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
-
- "github.com/NibiruChain/nibiru/eth"
- cryptocodec "github.com/NibiruChain/nibiru/eth/crypto/codec"
- enccodec "github.com/NibiruChain/nibiru/eth/encoding/codec"
-)
-
-var TestCodec amino.Codec
-
-func init() {
- cdc := amino.NewLegacyAmino()
- cryptocodec.RegisterCrypto(cdc)
-
- interfaceRegistry := types.NewInterfaceRegistry()
- TestCodec = amino.NewProtoCodec(interfaceRegistry)
- enccodec.RegisterInterfaces(interfaceRegistry)
-}
-
-const (
- mnemonic = "picnic rent average infant boat squirrel federal assault mercy purity very motor fossil wheel verify upset box fresh horse vivid copy predict square regret"
-
- // hdWalletFixEnv defines whether the standard (correct) bip39
- // derivation path was used, or if derivation was affected by
- // https://github.com/btcsuite/btcutil/issues/179
- hdWalletFixEnv = "GO_ETHEREUM_HDWALLET_FIX_ISSUE_179"
-)
-
-const appName = "nibid"
-
-func TestKeyring(t *testing.T) {
- dir := t.TempDir()
- mockIn := strings.NewReader("")
- kr, err := keyring.New(appName, keyring.BackendTest, dir, mockIn, TestCodec, EthSecp256k1Option())
- require.NoError(t, err)
-
- // fail in retrieving key
- info, err := kr.Key("foo")
- require.Error(t, err)
- require.Nil(t, info)
-
- mockIn.Reset("password\npassword\n")
- info, mnemonic, err := kr.NewMnemonic("foo", keyring.English, eth.BIP44HDPath, keyring.DefaultBIP39Passphrase, EthSecp256k1)
- require.NoError(t, err)
- require.NotEmpty(t, mnemonic)
- require.Equal(t, "foo", info.Name)
- require.Equal(t, "local", info.GetType().String())
- pubKey, err := info.GetPubKey()
- require.NoError(t, err)
- require.Equal(t, string(EthSecp256k1Type), pubKey.Type())
-
- hdPath := eth.BIP44HDPath
-
- bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, hdPath)
- require.NoError(t, err)
- require.NotEmpty(t, bz)
-
- wrongBz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, "/wrong/hdPath")
- require.Error(t, err)
- require.Empty(t, wrongBz)
-
- privkey := EthSecp256k1.Generate()(bz)
- addr := common.BytesToAddress(privkey.PubKey().Address().Bytes())
-
- os.Setenv(hdWalletFixEnv, "true")
- wallet, err := NewFromMnemonic(mnemonic)
- os.Setenv(hdWalletFixEnv, "")
- require.NoError(t, err)
-
- path := MustParseDerivationPath(hdPath)
-
- account, err := wallet.Derive(path, false)
- require.NoError(t, err)
- require.Equal(t, addr.String(), account.Address.String())
-}
-
-func TestDerivation(t *testing.T) {
- bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, eth.BIP44HDPath)
- require.NoError(t, err)
- require.NotEmpty(t, bz)
-
- badBz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, "44'/60'/0'/0/0")
- require.NoError(t, err)
- require.NotEmpty(t, badBz)
-
- require.NotEqual(t, bz, badBz)
-
- privkey := EthSecp256k1.Generate()(bz)
- badPrivKey := EthSecp256k1.Generate()(badBz)
-
- require.False(t, privkey.Equals(badPrivKey))
-
- wallet, err := NewFromMnemonic(mnemonic)
- require.NoError(t, err)
-
- path := MustParseDerivationPath(eth.BIP44HDPath)
- account, err := wallet.Derive(path, false)
- require.NoError(t, err)
-
- badPath := MustParseDerivationPath("44'/60'/0'/0/0")
- badAccount, err := wallet.Derive(badPath, false)
- require.NoError(t, err)
-
- // Equality of Address BIP44
- require.Equal(t, account.Address.String(), "0xA588C66983a81e800Db4dF74564F09f91c026351")
- require.Equal(t, badAccount.Address.String(), "0xF8D6FDf2B8b488ea37e54903750dcd13F67E71cb")
- // Inequality of wrong derivation path address
- require.NotEqual(t, account.Address.String(), badAccount.Address.String())
- // Equality of impls between Ethereum and Nibiru
- require.Equal(t, common.BytesToAddress(privkey.PubKey().Address().Bytes()).String(), "0xA588C66983a81e800Db4dF74564F09f91c026351")
- require.Equal(t, common.BytesToAddress(badPrivKey.PubKey().Address().Bytes()).String(), "0xF8D6FDf2B8b488ea37e54903750dcd13F67E71cb")
-
- // Equality of impls between Ethereum and Nibiru
- require.Equal(t, common.BytesToAddress(privkey.PubKey().Address()).String(), account.Address.String())
- require.Equal(t, common.BytesToAddress(badPrivKey.PubKey().Address()).String(), badAccount.Address.String())
-
- // Inequality of wrong derivation path
- require.NotEqual(t, common.BytesToAddress(privkey.PubKey().Address()).String(), badAccount.Address.String())
- require.NotEqual(t, common.BytesToAddress(badPrivKey.PubKey().Address()).String(), account.Address.Hex())
-}
diff --git a/eth/crypto/hd/benchmark_test.go b/eth/crypto/hd/benchmark_test.go
deleted file mode 100644
index 0c2246904..000000000
--- a/eth/crypto/hd/benchmark_test.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package hd
-
-import (
- "testing"
-
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-func BenchmarkEthSecp256k1Algo_Derive(b *testing.B) {
- b.ReportAllocs()
- for i := 0; i < b.N; i++ {
- deriveFn := EthSecp256k1.Derive()
- if _, err := deriveFn(mnemonic, keyring.DefaultBIP39Passphrase, eth.BIP44HDPath); err != nil {
- b.Fatal(err)
- }
- }
-}
-
-func BenchmarkEthSecp256k1Algo_Generate(b *testing.B) {
- bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, eth.BIP44HDPath)
- if err != nil {
- b.Fatal(err)
- }
-
- b.ResetTimer()
- b.ReportAllocs()
- for i := 0; i < b.N; i++ {
- (ðSecp256k1Algo{}).Generate()(bz)
- }
-}
diff --git a/eth/crypto/hd/utils_test.go b/eth/crypto/hd/utils_test.go
deleted file mode 100644
index 2082368d8..000000000
--- a/eth/crypto/hd/utils_test.go
+++ /dev/null
@@ -1,181 +0,0 @@
-// NOTE: This code is being used as test helper functions.
-package hd
-
-import (
- "crypto/ecdsa"
- "errors"
- "os"
- "sync"
-
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
-
- "github.com/btcsuite/btcd/btcutil/hdkeychain"
- "github.com/btcsuite/btcd/chaincfg"
- bip39 "github.com/tyler-smith/go-bip39"
-)
-
-const issue179FixEnvar = "GO_ETHEREUM_HDWALLET_FIX_ISSUE_179"
-
-// Wallet is the underlying wallet struct.
-type Wallet struct {
- mnemonic string
- masterKey *hdkeychain.ExtendedKey
- seed []byte
- paths map[common.Address]accounts.DerivationPath
- accounts []accounts.Account
- stateLock sync.RWMutex
- fixIssue172 bool
-}
-
-// NewFromMnemonic returns a new wallet from a BIP-39 mnemonic.
-func NewFromMnemonic(mnemonic string) (*Wallet, error) {
- if mnemonic == "" {
- return nil, errors.New("mnemonic is required")
- }
-
- if !bip39.IsMnemonicValid(mnemonic) {
- return nil, errors.New("mnemonic is invalid")
- }
-
- seed, err := NewSeedFromMnemonic(mnemonic)
- if err != nil {
- return nil, err
- }
-
- wallet, err := newWallet(seed)
- if err != nil {
- return nil, err
- }
- wallet.mnemonic = mnemonic
-
- return wallet, nil
-}
-
-// NewSeedFromMnemonic returns a BIP-39 seed based on a BIP-39 mnemonic.
-func NewSeedFromMnemonic(mnemonic string) ([]byte, error) {
- if mnemonic == "" {
- return nil, errors.New("mnemonic is required")
- }
-
- return bip39.NewSeedWithErrorChecking(mnemonic, "")
-}
-
-func newWallet(seed []byte) (*Wallet, error) {
- masterKey, err := hdkeychain.NewMaster(seed, &chaincfg.MainNetParams)
- if err != nil {
- return nil, err
- }
-
- return &Wallet{
- masterKey: masterKey,
- seed: seed,
- accounts: []accounts.Account{},
- paths: map[common.Address]accounts.DerivationPath{},
- fixIssue172: false || len(os.Getenv(issue179FixEnvar)) > 0,
- }, nil
-}
-
-// Derive implements accounts.Wallet, deriving a new account at the specific
-// derivation path. If pin is set to true, the account will be added to the list
-// of tracked accounts.
-func (w *Wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Account, error) {
- // Try to derive the actual account and update its URL if successful
- w.stateLock.RLock() // Avoid device disappearing during derivation
-
- address, err := w.deriveAddress(path)
-
- w.stateLock.RUnlock()
-
- // If an error occurred or no pinning was requested, return
- if err != nil {
- return accounts.Account{}, err
- }
-
- account := accounts.Account{
- Address: address,
- URL: accounts.URL{
- Scheme: "",
- Path: path.String(),
- },
- }
-
- if !pin {
- return account, nil
- }
-
- // Pinning needs to modify the state
- w.stateLock.Lock()
- defer w.stateLock.Unlock()
-
- if _, ok := w.paths[address]; !ok {
- w.accounts = append(w.accounts, account)
- w.paths[address] = path
- }
-
- return account, nil
-}
-
-// MustParseDerivationPath parses the derivation path in string format into
-// []uint32 but will panic if it can't parse it.
-func MustParseDerivationPath(path string) accounts.DerivationPath {
- parsed, err := accounts.ParseDerivationPath(path)
- if err != nil {
- panic(err)
- }
-
- return parsed
-}
-
-// DerivePrivateKey derives the private key of the derivation path.
-func (w *Wallet) derivePrivateKey(path accounts.DerivationPath) (*ecdsa.PrivateKey, error) {
- var err error
- key := w.masterKey
- for _, n := range path {
- if w.fixIssue172 && key.IsAffectedByIssue172() {
- key, err = key.Derive(n)
- } else {
- //lint:ignore SA1019 this is used for testing only
- key, err = key.DeriveNonStandard(n) //nolint:staticcheck
- }
- if err != nil {
- return nil, err
- }
- }
-
- privateKey, err := key.ECPrivKey()
- privateKeyECDSA := privateKey.ToECDSA()
- if err != nil {
- return nil, err
- }
-
- return privateKeyECDSA, nil
-}
-
-// derivePublicKey derives the public key of the derivation path.
-func (w *Wallet) derivePublicKey(path accounts.DerivationPath) (*ecdsa.PublicKey, error) {
- privateKeyECDSA, err := w.derivePrivateKey(path)
- if err != nil {
- return nil, err
- }
-
- publicKey := privateKeyECDSA.Public()
- publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
- if !ok {
- return nil, errors.New("failed to get public key")
- }
-
- return publicKeyECDSA, nil
-}
-
-// DeriveAddress derives the account address of the derivation path.
-func (w *Wallet) deriveAddress(path accounts.DerivationPath) (common.Address, error) {
- publicKeyECDSA, err := w.derivePublicKey(path)
- if err != nil {
- return common.Address{}, err
- }
-
- address := crypto.PubkeyToAddress(*publicKeyECDSA)
- return address, nil
-}
diff --git a/eth/crypto/keyring/options.go b/eth/crypto/keyring/options.go
deleted file mode 100644
index a53ad75a5..000000000
--- a/eth/crypto/keyring/options.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-
-package keyring
-
-import (
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- "github.com/cosmos/cosmos-sdk/crypto/types"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
- "github.com/NibiruChain/nibiru/eth/crypto/hd"
-)
-
-// AppName defines the Ledger app used for signing.
-const AppName = "Ethereum"
-
-var (
- // SupportedAlgorithms defines the list of signing algorithms used on Nibiru:
- // - eth_secp256k1 (Ethereum)
- SupportedAlgorithms = keyring.SigningAlgoList{hd.EthSecp256k1}
- // SupportedAlgorithmsLedger defines the list of signing algorithms used on
- // Nibiru for the Ledger device:
- // - secp256k1 (in order to comply with Cosmos SDK)
- // The Ledger derivation function is responsible for all signing and address generation.
- SupportedAlgorithmsLedger = keyring.SigningAlgoList{hd.EthSecp256k1}
- // CreatePubkey uses the ethsecp256k1 pubkey with Ethereum address generation and keccak hashing
- CreatePubkey = func(key []byte) types.PubKey { return ðsecp256k1.PubKey{Key: key} }
- // SkipDERConversion represents whether the signed Ledger output should skip conversion from DER to BER.
- // This is set to true for signing performed by the Ledger Ethereum app.
- SkipDERConversion = true
-)
-
-// EthSecp256k1Option defines a function keys options for the ethereum Secp256k1 curve.
-// It supports eth_secp256k1 keys for accounts.
-func Option() keyring.Option {
- return func(options *keyring.Options) {
- options.SupportedAlgos = SupportedAlgorithms
- options.SupportedAlgosLedger = SupportedAlgorithmsLedger
- options.LedgerCreateKey = CreatePubkey
- options.LedgerAppName = AppName
- options.LedgerSigSkipDERConv = SkipDERConversion
- }
-}
diff --git a/eth/crypto/secp256r1/verify.go b/eth/crypto/secp256r1/verify.go
deleted file mode 100644
index 9b4ba8685..000000000
--- a/eth/crypto/secp256r1/verify.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2014 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see .
-
-package secp256r1
-
-import (
- "crypto/ecdsa"
- "crypto/elliptic"
- "math/big"
-)
-
-// Verifies the given signature (r, s) for the given hash and public key (x, y).
-func Verify(hash []byte, r, s, x, y *big.Int) bool {
- // Create the public key format
- publicKey := newECDSAPublicKey(x, y)
-
- // Check if they are invalid public key coordinates
- if publicKey == nil {
- return false
- }
-
- // Verify the signature with the public key,
- // then return true if it's valid, false otherwise
- return ecdsa.Verify(publicKey, hash, r, s)
-}
-
-// newECDSAPublicKey creates an ECDSA P256 public key from the given coordinates
-func newECDSAPublicKey(x, y *big.Int) *ecdsa.PublicKey {
- // Check if the given coordinates are valid and in the reference point (infinity)
- if x == nil || y == nil || x.Sign() == 0 && y.Sign() == 0 || !elliptic.P256().IsOnCurve(x, y) {
- return nil
- }
-
- return &ecdsa.PublicKey{
- Curve: elliptic.P256(),
- X: x,
- Y: y,
- }
-}
diff --git a/eth/dynamic_fee.pb.go b/eth/dynamic_fee.pb.go
deleted file mode 100644
index db5a93790..000000000
--- a/eth/dynamic_fee.pb.go
+++ /dev/null
@@ -1,319 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: eth/types/v1/dynamic_fee.proto
-
-package eth
-
-import (
- cosmossdk_io_math "cosmossdk.io/math"
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// ExtensionOptionDynamicFeeTx is an extension option that specifies the maxPrioPrice for cosmos tx
-type ExtensionOptionDynamicFeeTx struct {
- // max_priority_price is the same as `max_priority_fee_per_gas` in eip-1559 spec
- MaxPriorityPrice cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=max_priority_price,json=maxPriorityPrice,proto3,customtype=cosmossdk.io/math.Int" json:"max_priority_price"`
-}
-
-func (m *ExtensionOptionDynamicFeeTx) Reset() { *m = ExtensionOptionDynamicFeeTx{} }
-func (m *ExtensionOptionDynamicFeeTx) String() string { return proto.CompactTextString(m) }
-func (*ExtensionOptionDynamicFeeTx) ProtoMessage() {}
-func (*ExtensionOptionDynamicFeeTx) Descriptor() ([]byte, []int) {
- return fileDescriptor_c23795e47c912b17, []int{0}
-}
-func (m *ExtensionOptionDynamicFeeTx) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *ExtensionOptionDynamicFeeTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_ExtensionOptionDynamicFeeTx.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *ExtensionOptionDynamicFeeTx) XXX_Merge(src proto.Message) {
- xxx_messageInfo_ExtensionOptionDynamicFeeTx.Merge(m, src)
-}
-func (m *ExtensionOptionDynamicFeeTx) XXX_Size() int {
- return m.Size()
-}
-func (m *ExtensionOptionDynamicFeeTx) XXX_DiscardUnknown() {
- xxx_messageInfo_ExtensionOptionDynamicFeeTx.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ExtensionOptionDynamicFeeTx proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*ExtensionOptionDynamicFeeTx)(nil), "eth.types.v1.ExtensionOptionDynamicFeeTx")
-}
-
-func init() { proto.RegisterFile("eth/types/v1/dynamic_fee.proto", fileDescriptor_c23795e47c912b17) }
-
-var fileDescriptor_c23795e47c912b17 = []byte{
- // 238 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x2c, 0x8e, 0xbf, 0x4a, 0xc4, 0x40,
- 0x10, 0x87, 0xb3, 0x8d, 0x60, 0xb0, 0x90, 0xa0, 0x20, 0x8a, 0x7b, 0x6a, 0x65, 0xb5, 0xcb, 0x61,
- 0x69, 0x77, 0xfe, 0x01, 0x11, 0xf4, 0x10, 0x2b, 0x9b, 0x63, 0x93, 0x1b, 0xb3, 0xa3, 0xec, 0x4e,
- 0xc8, 0xce, 0x1d, 0xc9, 0x5b, 0xf8, 0x58, 0x57, 0x5e, 0x29, 0x16, 0x87, 0x24, 0x2f, 0x22, 0xd9,
- 0xb3, 0xfb, 0xe0, 0x9b, 0x6f, 0xf8, 0xa5, 0x12, 0xd8, 0x6a, 0x6e, 0x2b, 0x08, 0x7a, 0x39, 0xd6,
- 0xf3, 0xd6, 0x1b, 0x87, 0xc5, 0xec, 0x1d, 0x40, 0x55, 0x35, 0x31, 0x65, 0x7b, 0xc0, 0x56, 0x45,
- 0xaf, 0x96, 0xe3, 0xe3, 0x83, 0x92, 0x4a, 0x8a, 0x42, 0x0f, 0xb4, 0xbd, 0xb9, 0xf8, 0x48, 0x4f,
- 0xee, 0x1a, 0x06, 0x1f, 0x90, 0xfc, 0x73, 0xc5, 0x48, 0xfe, 0x76, 0xfb, 0xe7, 0x1e, 0xe0, 0xb5,
- 0xc9, 0x1e, 0xd3, 0xcc, 0x99, 0x66, 0x56, 0xd5, 0x48, 0x35, 0x72, 0x3b, 0x40, 0x01, 0x47, 0xe2,
- 0x4c, 0x5c, 0xee, 0x4e, 0x4e, 0x57, 0x9b, 0x51, 0xf2, 0xb3, 0x19, 0x1d, 0x16, 0x14, 0x1c, 0x85,
- 0x30, 0xff, 0x54, 0x48, 0xda, 0x19, 0xb6, 0xea, 0xc1, 0xf3, 0xcb, 0xbe, 0x33, 0xcd, 0xf4, 0xbf,
- 0x9b, 0x0e, 0xd9, 0xe4, 0x7a, 0xd5, 0x49, 0xb1, 0xee, 0xa4, 0xf8, 0xed, 0xa4, 0xf8, 0xea, 0x65,
- 0xb2, 0xee, 0x65, 0xf2, 0xdd, 0xcb, 0xe4, 0xed, 0xbc, 0x44, 0xb6, 0x8b, 0x5c, 0x15, 0xe4, 0xf4,
- 0x13, 0xe6, 0x58, 0x2f, 0x6e, 0xac, 0x41, 0xaf, 0x7d, 0x64, 0x0d, 0x6c, 0xf3, 0x9d, 0xb8, 0xf7,
- 0xea, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x8e, 0xfe, 0xc0, 0xf5, 0x00, 0x00, 0x00,
-}
-
-func (m *ExtensionOptionDynamicFeeTx) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ExtensionOptionDynamicFeeTx) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *ExtensionOptionDynamicFeeTx) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size := m.MaxPriorityPrice.Size()
- i -= size
- if _, err := m.MaxPriorityPrice.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintDynamicFee(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func encodeVarintDynamicFee(dAtA []byte, offset int, v uint64) int {
- offset -= sovDynamicFee(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *ExtensionOptionDynamicFeeTx) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.MaxPriorityPrice.Size()
- n += 1 + l + sovDynamicFee(uint64(l))
- return n
-}
-
-func sovDynamicFee(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozDynamicFee(x uint64) (n int) {
- return sovDynamicFee(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *ExtensionOptionDynamicFeeTx) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowDynamicFee
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ExtensionOptionDynamicFeeTx: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ExtensionOptionDynamicFeeTx: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field MaxPriorityPrice", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowDynamicFee
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthDynamicFee
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthDynamicFee
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.MaxPriorityPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipDynamicFee(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthDynamicFee
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipDynamicFee(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowDynamicFee
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowDynamicFee
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowDynamicFee
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthDynamicFee
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupDynamicFee
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthDynamicFee
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthDynamicFee = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowDynamicFee = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupDynamicFee = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/eth/eip712/domain.go b/eth/eip712/domain.go
deleted file mode 100644
index 287ddb1f4..000000000
--- a/eth/eip712/domain.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eip712
-
-import (
- "github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/signer/core/apitypes"
-)
-
-// createEIP712Domain creates the typed data domain for the given chainID.
-func createEIP712Domain(chainID uint64) apitypes.TypedDataDomain {
- domain := apitypes.TypedDataDomain{
- Name: "Cosmos Web3",
- Version: "1.0.0",
- ChainId: math.NewHexOrDecimal256(int64(chainID)), // #nosec G701
- VerifyingContract: "cosmos",
- Salt: "0",
- }
-
- return domain
-}
diff --git a/eth/eip712/eip712.go b/eth/eip712/eip712.go
deleted file mode 100644
index 2a55524d3..000000000
--- a/eth/eip712/eip712.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eip712
-
-import (
- "github.com/ethereum/go-ethereum/signer/core/apitypes"
-)
-
-// WrapTxToTypedData wraps an Amino-encoded Cosmos Tx JSON SignDoc
-// bytestream into an EIP712-compatible TypedData request.
-func WrapTxToTypedData(
- chainID uint64,
- data []byte,
-) (apitypes.TypedData, error) {
- messagePayload, err := createEIP712MessagePayload(data)
- message := messagePayload.message
- if err != nil {
- return apitypes.TypedData{}, err
- }
-
- types, err := createEIP712Types(messagePayload)
- if err != nil {
- return apitypes.TypedData{}, err
- }
-
- domain := createEIP712Domain(chainID)
-
- typedData := apitypes.TypedData{
- Types: types,
- PrimaryType: txField,
- Domain: domain,
- Message: message,
- }
-
- return typedData, nil
-}
diff --git a/eth/eip712/eip712_fuzzer_test.go b/eth/eip712/eip712_fuzzer_test.go
deleted file mode 100644
index 319c28e3d..000000000
--- a/eth/eip712/eip712_fuzzer_test.go
+++ /dev/null
@@ -1,194 +0,0 @@
-package eip712_test
-
-import (
- "fmt"
- "strings"
-
- rand "github.com/cometbft/cometbft/libs/rand"
-
- "github.com/tidwall/gjson"
- "github.com/tidwall/sjson"
-
- "github.com/NibiruChain/nibiru/eth/eip712"
-)
-
-type EIP712FuzzTestParams struct {
- numTestObjects int
- maxNumFieldsPerObject int
- minStringLength int
- maxStringLength int
- randomFloatRange float64
- maxArrayLength int
- maxObjectDepth int
-}
-
-const (
- numPrimitiveJSONTypes = 3
- numJSONTypes = 5
- asciiRangeStart = 65
- asciiRangeEnd = 127
- fuzzTestName = "Flatten"
-)
-
-const (
- jsonBoolType = iota
- jsonStringType = iota
- jsonFloatType = iota
- jsonArrayType = iota
- jsonObjectType = iota
-)
-
-var params = EIP712FuzzTestParams{
- numTestObjects: 16,
- maxNumFieldsPerObject: 16,
- minStringLength: 16,
- maxStringLength: 48,
- randomFloatRange: 120000000,
- maxArrayLength: 8,
- maxObjectDepth: 4,
-}
-
-// TestRandomPayloadFlattening generates many random payloads with different JSON values to ensure
-// that Flattening works across all inputs.
-// Note that this is a fuzz test, although it doesn't use Go's Fuzz testing suite, since there are
-// variable input sizes, types, and fields. While it may be possible to translate a single input into
-// a JSON object, it would require difficult parsing, and ultimately approximates our randomized unit
-// tests as they are.
-func (s *EIP712TestSuite) TestRandomPayloadFlattening() {
- // Re-seed rand generator
- rand.Seed(rand.Int64())
-
- for i := 0; i < params.numTestObjects; i++ {
- s.Run(fmt.Sprintf("%v%d", fuzzTestName, i), func() {
- payload := s.generateRandomPayload(i)
-
- flattened, numMessages, err := eip712.FlattenPayloadMessages(payload)
-
- s.Require().NoError(err)
- s.Require().Equal(numMessages, i)
-
- s.verifyPayloadAgainstFlattened(payload, flattened)
- })
- }
-}
-
-// generateRandomPayload creates a random payload of the desired format, with random sub-objects.
-func (s *EIP712TestSuite) generateRandomPayload(numMessages int) gjson.Result {
- payload := s.createRandomJSONObject().Raw
- msgs := make([]gjson.Result, numMessages)
-
- for i := 0; i < numMessages; i++ {
- msgs[i] = s.createRandomJSONObject()
- }
-
- payload, err := sjson.Set(payload, msgsFieldName, msgs)
- s.Require().NoError(err)
-
- return gjson.Parse(payload)
-}
-
-// createRandomJSONObject creates a JSON object with random fields.
-func (s *EIP712TestSuite) createRandomJSONObject() gjson.Result {
- var err error
- payloadRaw := ""
-
- numFields := s.createRandomIntInRange(0, params.maxNumFieldsPerObject)
- for i := 0; i < numFields; i++ {
- key := s.createRandomString()
-
- randField := s.createRandomJSONField(i, 0)
- payloadRaw, err = sjson.Set(payloadRaw, key, randField)
- s.Require().NoError(err)
- }
-
- return gjson.Parse(payloadRaw)
-}
-
-// createRandomJSONField creates a random field with a random JSON type, with the possibility of
-// nested fields up to depth objects.
-func (s *EIP712TestSuite) createRandomJSONField(t int, depth int) interface{} {
- switch t % numJSONTypes {
- case jsonBoolType:
- return s.createRandomBoolean()
- case jsonStringType:
- return s.createRandomString()
- case jsonFloatType:
- return s.createRandomFloat()
- case jsonArrayType:
- return s.createRandomJSONNestedArray(depth)
- case jsonObjectType:
- return s.createRandomJSONNestedObject(depth)
- default:
- return nil
- }
-}
-
-// createRandomJSONNestedArray creates an array of random nested JSON fields.
-func (s *EIP712TestSuite) createRandomJSONNestedArray(depth int) []interface{} {
- arr := make([]interface{}, rand.Intn(params.maxArrayLength))
- for i := range arr {
- arr[i] = s.createRandomJSONNestedField(depth)
- }
-
- return arr
-}
-
-// createRandomJSONNestedObject creates a key-value set of objects with random nested JSON fields.
-func (s *EIP712TestSuite) createRandomJSONNestedObject(depth int) interface{} {
- numFields := rand.Intn(params.maxNumFieldsPerObject)
- obj := make(map[string]interface{})
-
- for i := 0; i < numFields; i++ {
- subField := s.createRandomJSONNestedField(depth)
-
- obj[s.createRandomString()] = subField
- }
-
- return obj
-}
-
-// createRandomJSONNestedField serves as a helper for createRandomJSONField and returns a random
-// subfield to populate an array or object type.
-func (s *EIP712TestSuite) createRandomJSONNestedField(depth int) interface{} {
- var newFieldType int
-
- if depth == params.maxObjectDepth {
- newFieldType = rand.Intn(numPrimitiveJSONTypes)
- } else {
- newFieldType = rand.Intn(numJSONTypes)
- }
-
- return s.createRandomJSONField(newFieldType, depth+1)
-}
-
-func (s *EIP712TestSuite) createRandomBoolean() bool {
- return rand.Intn(2) == 0
-}
-
-func (s *EIP712TestSuite) createRandomFloat() float64 {
- return (rand.Float64() - 0.5) * params.randomFloatRange
-}
-
-func (s *EIP712TestSuite) createRandomString() string {
- bzLen := s.createRandomIntInRange(params.minStringLength, params.maxStringLength)
- bz := make([]byte, bzLen)
-
- for i := 0; i < bzLen; i++ {
- bz[i] = byte(s.createRandomIntInRange(asciiRangeStart, asciiRangeEnd))
- }
-
- str := string(bz)
-
- // Remove control characters, since they will make JSON invalid
- str = strings.ReplaceAll(str, "{", "")
- str = strings.ReplaceAll(str, "}", "")
- str = strings.ReplaceAll(str, "]", "")
- str = strings.ReplaceAll(str, "[", "")
-
- return str
-}
-
-// createRandomIntInRange provides a random integer between [min, max)
-func (s *EIP712TestSuite) createRandomIntInRange(min int, max int) int {
- return rand.Intn(max-min) + min
-}
diff --git a/eth/eip712/eip712_legacy.go b/eth/eip712/eip712_legacy.go
deleted file mode 100644
index c1d0b1b30..000000000
--- a/eth/eip712/eip712_legacy.go
+++ /dev/null
@@ -1,461 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eip712
-
-import (
- "encoding/json"
- "fmt"
- "math/big"
- "reflect" // #nosec G702 for sensitive import
- "strings"
- "time"
-
- errorsmod "cosmossdk.io/errors"
- sdkmath "cosmossdk.io/math"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
- sdk "github.com/cosmos/cosmos-sdk/types"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
-
- "github.com/ethereum/go-ethereum/common"
- gethmath "github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/signer/core/apitypes"
-)
-
-type FeeDelegationOptions struct {
- FeePayer sdk.AccAddress
-}
-
-const (
- typeDefPrefix = "_"
-)
-
-// LegacyWrapTxToTypedData is an ultimate method that wraps Amino-encoded Cosmos
-// Tx JSON data into an EIP712-compatible TypedData request.
-func LegacyWrapTxToTypedData(
- cdc codectypes.AnyUnpacker,
- chainID uint64,
- msg sdk.Msg,
- data []byte,
- feeDelegation *FeeDelegationOptions,
-) (apitypes.TypedData, error) {
- txData := make(map[string]interface{})
-
- if err := json.Unmarshal(data, &txData); err != nil {
- return apitypes.TypedData{}, errorsmod.Wrap(errortypes.ErrJSONUnmarshal, "failed to JSON unmarshal data")
- }
-
- domain := apitypes.TypedDataDomain{
- Name: "Cosmos Web3",
- Version: "1.0.0",
- ChainId: gethmath.NewHexOrDecimal256(int64(chainID)),
- VerifyingContract: "cosmos",
- Salt: "0",
- }
-
- msgTypes, err := extractMsgTypes(cdc, "MsgValue", msg)
- if err != nil {
- return apitypes.TypedData{}, err
- }
-
- if feeDelegation != nil {
- feeInfo, ok := txData["fee"].(map[string]interface{})
- if !ok {
- return apitypes.TypedData{}, errorsmod.Wrap(errortypes.ErrInvalidType, "cannot parse fee from tx data")
- }
-
- feeInfo["feePayer"] = feeDelegation.FeePayer.String()
-
- // also patching msgTypes to include feePayer
- msgTypes["Fee"] = []apitypes.Type{
- {Name: "feePayer", Type: "string"},
- {Name: "amount", Type: "Coin[]"},
- {Name: "gas", Type: "string"},
- }
- }
-
- typedData := apitypes.TypedData{
- Types: msgTypes,
- PrimaryType: "Tx",
- Domain: domain,
- Message: txData,
- }
-
- return typedData, nil
-}
-
-func extractMsgTypes(cdc codectypes.AnyUnpacker, msgTypeName string, msg sdk.Msg) (apitypes.Types, error) {
- rootTypes := apitypes.Types{
- "EIP712Domain": {
- {
- Name: "name",
- Type: "string",
- },
- {
- Name: "version",
- Type: "string",
- },
- {
- Name: "chainId",
- Type: "uint256",
- },
- {
- Name: "verifyingContract",
- Type: "string",
- },
- {
- Name: "salt",
- Type: "string",
- },
- },
- "Tx": {
- {Name: "account_number", Type: "string"},
- {Name: "chain_id", Type: "string"},
- {Name: "fee", Type: "Fee"},
- {Name: "memo", Type: "string"},
- {Name: "msgs", Type: "Msg[]"},
- {Name: "sequence", Type: "string"},
- // Note timeout_height was removed because it was not getting filled with the legacyTx
- // {Name: "timeout_height", Type: "string"},
- },
- "Fee": {
- {Name: "amount", Type: "Coin[]"},
- {Name: "gas", Type: "string"},
- },
- "Coin": {
- {Name: "denom", Type: "string"},
- {Name: "amount", Type: "string"},
- },
- "Msg": {
- {Name: "type", Type: "string"},
- {Name: "value", Type: msgTypeName},
- },
- msgTypeName: {},
- }
-
- if err := walkFields(cdc, rootTypes, msgTypeName, msg); err != nil {
- return nil, err
- }
-
- return rootTypes, nil
-}
-
-func walkFields(cdc codectypes.AnyUnpacker, typeMap apitypes.Types, rootType string, in interface{}) (err error) {
- defer doRecover(&err)
-
- t := reflect.TypeOf(in)
- v := reflect.ValueOf(in)
-
- for {
- if t.Kind() == reflect.Ptr ||
- t.Kind() == reflect.Interface {
- t = t.Elem()
- v = v.Elem()
-
- continue
- }
-
- break
- }
-
- return legacyTraverseFields(cdc, typeMap, rootType, typeDefPrefix, t, v)
-}
-
-type CosmosAnyWrapper struct {
- Type string `json:"type"`
- Value interface{} `json:"value"`
-}
-
-// legacyTraverseFields: Recursively inspects the fields of a given
-// `reflect.Type` (t) and `reflect.Value`(v) and maps them to an
-// Ethereum-compatible type description compliant with EIP-712. For operations
-// like EIP-712 signing, complex Go structs need to be translated into a flat
-// list of types that can be understood in Ethereum's type system.
-func legacyTraverseFields(
- // cdc: A codec capable of unpackaing protobuf
- // `"github.com/cosmos/cosmos-sdk/codec/types".Any` types into Go
- // structs.
- cdc codectypes.AnyUnpacker,
- // typeMap: map storing type descriptions
- typeMap apitypes.Types,
- // rootType: name of the root type processed
- rootType string,
- // prefix: Namespace prefix to avoid name collisions in `typeMap`
- prefix string,
- // t: reflect type of the data to process
- t reflect.Type,
- // v: reflect value of the data to process
- v reflect.Value,
-) error {
- // Setup: Check that the number of fields in `typeMap` for the `rootType`
- // or a sanitized version of `prefix` matches the number of fields in
- // type `t`. If they match, the type has already been processed, so we
- // return early.
- numFieldsT := t.NumField()
- if prefix == typeDefPrefix {
- if len(typeMap[rootType]) == numFieldsT {
- return nil
- }
- } else {
- typeDef := sanitizeTypedef(prefix)
- if len(typeMap[typeDef]) == numFieldsT {
- return nil
- }
- }
-
- // Field Iteration: Iterate over each field of tpye `t`,
- // (1) extracting the type and value of the field,
- // (2) unpacking in the event the field is an `Any`,
- // (3) and skipping empty fields.
- // INFO: If a field is a struct, unpack each field recursively to handle
- // nested data structures.
- for fieldIdx := 0; fieldIdx < numFieldsT; fieldIdx++ {
- var (
- field reflect.Value
- err error
- )
-
- if v.IsValid() {
- field = v.Field(fieldIdx)
- }
-
- fieldType := t.Field(fieldIdx).Type
- fieldName := jsonNameFromTag(t.Field(fieldIdx).Tag)
-
- if fieldType == typeCosmAny {
- // Unpack field, value as Any
- if fieldType, field, err = UnpackAny(cdc, field); err != nil {
- return err
- }
- }
-
- // If field is an empty value, do not include in types, since it will not
- // be present in the object
- if field.IsZero() {
- continue
- }
-
- for {
- if fieldType.Kind() == reflect.Ptr {
- fieldType = fieldType.Elem()
-
- if field.IsValid() {
- field = field.Elem()
- }
-
- continue
- }
-
- if fieldType.Kind() == reflect.Interface {
- fieldType = reflect.TypeOf(field.Interface())
- continue
- }
-
- if field.Kind() == reflect.Ptr {
- field = field.Elem()
- continue
- }
-
- break
- }
-
- var isCollection bool
- if fieldType.Kind() == reflect.Array || fieldType.Kind() == reflect.Slice {
- if field.Len() == 0 {
- // skip empty collections from type mapping
- continue
- }
-
- fieldType = fieldType.Elem()
- field = field.Index(0)
- isCollection = true
-
- if fieldType == typeCosmAny {
- if fieldType, field, err = UnpackAny(cdc, field); err != nil {
- return err
- }
- }
- }
-
- for {
- if fieldType.Kind() == reflect.Ptr {
- fieldType = fieldType.Elem()
-
- if field.IsValid() {
- field = field.Elem()
- }
-
- continue
- }
-
- if fieldType.Kind() == reflect.Interface {
- fieldType = reflect.TypeOf(field.Interface())
- continue
- }
-
- if field.Kind() == reflect.Ptr {
- field = field.Elem()
- continue
- }
-
- break
- }
-
- fieldPrefix := fmt.Sprintf("%s.%s", prefix, fieldName)
-
- ethTyp := TypToEth(fieldType)
-
- if len(ethTyp) > 0 {
- // Support array of uint64
- if isCollection && fieldType.Kind() != reflect.Slice && fieldType.Kind() != reflect.Array {
- ethTyp += "[]"
- }
-
- if prefix == typeDefPrefix {
- typeMap[rootType] = append(typeMap[rootType], apitypes.Type{
- Name: fieldName,
- Type: ethTyp,
- })
- } else {
- typeDef := sanitizeTypedef(prefix)
- typeMap[typeDef] = append(typeMap[typeDef], apitypes.Type{
- Name: fieldName,
- Type: ethTyp,
- })
- }
-
- continue
- }
-
- if fieldType.Kind() == reflect.Struct {
- var fieldTypedef string
-
- if isCollection {
- fieldTypedef = sanitizeTypedef(fieldPrefix) + "[]"
- } else {
- fieldTypedef = sanitizeTypedef(fieldPrefix)
- }
-
- if prefix == typeDefPrefix {
- typeMap[rootType] = append(typeMap[rootType], apitypes.Type{
- Name: fieldName,
- Type: fieldTypedef,
- })
- } else {
- typeDef := sanitizeTypedef(prefix)
- typeMap[typeDef] = append(typeMap[typeDef], apitypes.Type{
- Name: fieldName,
- Type: fieldTypedef,
- })
- }
-
- if err := legacyTraverseFields(cdc, typeMap, rootType, fieldPrefix, fieldType, field); err != nil {
- return err
- }
-
- continue
- }
- }
-
- return nil
-}
-
-func jsonNameFromTag(tag reflect.StructTag) string {
- jsonTags := tag.Get("json")
- parts := strings.Split(jsonTags, ",")
- return parts[0]
-}
-
-// Unpack the given Any value with Type/Value deconstruction
-func UnpackAny(cdc codectypes.AnyUnpacker, field reflect.Value) (reflect.Type, reflect.Value, error) {
- anyData, ok := field.Interface().(*codectypes.Any)
- if !ok {
- return nil, reflect.Value{}, errorsmod.Wrapf(errortypes.ErrPackAny, "%T", field.Interface())
- }
-
- anyWrapper := &CosmosAnyWrapper{
- Type: anyData.TypeUrl,
- }
-
- if err := cdc.UnpackAny(anyData, &anyWrapper.Value); err != nil {
- return nil, reflect.Value{}, errorsmod.Wrap(err, "failed to unpack Any in msg struct")
- }
-
- fieldType := reflect.TypeOf(anyWrapper)
- field = reflect.ValueOf(anyWrapper)
-
- return fieldType, field, nil
-}
-
-var (
- typeEthHash = reflect.TypeOf(common.Hash{})
- typeEthAddr = reflect.TypeOf(common.Address{})
- typeBigInt = reflect.TypeOf(big.Int{})
- typeCosmInt = reflect.TypeOf(sdkmath.Int{})
- typeCosmDec = reflect.TypeOf(sdkmath.LegacyDec{})
- typeTime = reflect.TypeOf(time.Time{})
- typeCosmAny = reflect.TypeOf(&codectypes.Any{})
- typeEd25519 = reflect.TypeOf(ed25519.PubKey{})
-)
-
-// TypToEth supports only basic types and arrays of basic types.
-// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md
-func TypToEth(typ reflect.Type) string {
- const str = "string"
-
- switch typ.Kind() {
- case reflect.String:
- return str
- case reflect.Bool:
- return "bool"
- case reflect.Int:
- return "int64"
- case reflect.Int8:
- return "int8"
- case reflect.Int16:
- return "int16"
- case reflect.Int32:
- return "int32"
- case reflect.Int64:
- return "int64"
- case reflect.Uint:
- return "uint64"
- case reflect.Uint8:
- return "uint8"
- case reflect.Uint16:
- return "uint16"
- case reflect.Uint32:
- return "uint32"
- case reflect.Uint64:
- return "uint64"
- case reflect.Slice:
- ethName := TypToEth(typ.Elem())
- if len(ethName) > 0 {
- return ethName + "[]"
- }
- case reflect.Array:
- ethName := TypToEth(typ.Elem())
- if len(ethName) > 0 {
- return ethName + "[]"
- }
- case reflect.Ptr:
- if typ.Elem().ConvertibleTo(typeBigInt) ||
- typ.Elem().ConvertibleTo(typeTime) ||
- typ.Elem().ConvertibleTo(typeEd25519) ||
- typ.Elem().ConvertibleTo(typeCosmDec) ||
- typ.Elem().ConvertibleTo(typeCosmInt) {
- return str
- }
- case reflect.Struct:
- if typ.ConvertibleTo(typeEthHash) ||
- typ.ConvertibleTo(typeEthAddr) ||
- typ.ConvertibleTo(typeBigInt) ||
- typ.ConvertibleTo(typeEd25519) ||
- typ.ConvertibleTo(typeTime) ||
- typ.ConvertibleTo(typeCosmDec) ||
- typ.ConvertibleTo(typeCosmInt) {
- return str
- }
- }
-
- return ""
-}
diff --git a/eth/eip712/eip712_test.go b/eth/eip712/eip712_test.go
deleted file mode 100644
index ec6ecb3ad..000000000
--- a/eth/eip712/eip712_test.go
+++ /dev/null
@@ -1,723 +0,0 @@
-package eip712_test
-
-import (
- "bytes"
- "fmt"
- "math/big"
- "reflect"
- "testing"
-
- sdkmath "cosmossdk.io/math"
- sdkcodec "github.com/cosmos/cosmos-sdk/codec/types"
-
- chainparams "cosmossdk.io/simapp/params"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/signer/core/apitypes"
- "github.com/tidwall/gjson"
- "github.com/tidwall/sjson"
-
- "github.com/NibiruChain/nibiru/eth/eip712"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/evm"
-
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/cmd/ethclient"
-
- sdktx "github.com/cosmos/cosmos-sdk/types/tx"
- "github.com/cosmos/cosmos-sdk/types/tx/signing"
- authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
-
- "github.com/NibiruChain/nibiru/eth/encoding"
-
- distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
- govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
- "github.com/stretchr/testify/suite"
-)
-
-// Unit tests for single-signer EIP-712 signature verification. Multi-signature key verification tests are out-of-scope
-// here and included with the ante_tests.
-
-const (
- msgsFieldName = "msgs"
- baseDenom = "anibi"
- TESTNET_CHAIN_ID = "nibiru_9000"
-)
-
-type EIP712TestSuite struct {
- suite.Suite
-
- config chainparams.EncodingConfig
- clientCtx client.Context
- useLegacyEIP712TypedData bool
- denom string
-}
-
-type EIP712TestParams struct {
- fee sdktx.Fee
- address sdk.AccAddress
- accountNumber uint64
- sequence uint64
- memo string
-}
-
-func TestEIP712TestSuite(t *testing.T) {
- suite.Run(t, &EIP712TestSuite{})
- // Note that we don't test the Legacy EIP-712 Extension, since that case
- // is sufficiently covered by the AnteHandler tests.
- suite.Run(t, &EIP712TestSuite{
- useLegacyEIP712TypedData: true,
- })
-}
-
-func (suite *EIP712TestSuite) SetupTest() {
- suite.config = encoding.MakeConfig(app.ModuleBasics)
- suite.clientCtx = client.Context{}.WithTxConfig(suite.config.TxConfig)
- suite.denom = baseDenom
-
- sdk.GetConfig().SetBech32PrefixForAccount(ethclient.Bech32Prefix, "")
- eip712.SetEncodingConfig(suite.config)
-}
-
-// createTestAddress creates random test addresses for messages
-func (suite *EIP712TestSuite) createTestAddress() sdk.AccAddress {
- privkey, _ := ethsecp256k1.GenerateKey()
- key, err := privkey.ToECDSA()
- suite.Require().NoError(err)
-
- addr := crypto.PubkeyToAddress(key.PublicKey)
-
- return addr.Bytes()
-}
-
-// createTestKeyPair creates a random keypair for signing and verification
-func (suite *EIP712TestSuite) createTestKeyPair() (*ethsecp256k1.PrivKey, *ethsecp256k1.PubKey) {
- privKey, err := ethsecp256k1.GenerateKey()
- suite.Require().NoError(err)
-
- pubKey := ðsecp256k1.PubKey{
- Key: privKey.PubKey().Bytes(),
- }
- suite.Require().Implements((*cryptotypes.PubKey)(nil), pubKey)
-
- return privKey, pubKey
-}
-
-// makeCoins helps create an instance of sdk.Coins[] with single coin
-func (suite *EIP712TestSuite) makeCoins(denom string, amount sdkmath.Int) sdk.Coins {
- return sdk.NewCoins(
- sdk.NewCoin(
- denom,
- amount,
- ),
- )
-}
-
-func (suite *EIP712TestSuite) TestEIP712() {
- suite.SetupTest()
-
- signModes := []signing.SignMode{
- signing.SignMode_SIGN_MODE_DIRECT,
- signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON,
- }
-
- params := EIP712TestParams{
- fee: sdktx.Fee{
- Amount: suite.makeCoins(suite.denom, sdkmath.NewInt(2000)),
- GasLimit: 20000,
- },
- address: suite.createTestAddress(),
- accountNumber: 25,
- sequence: 78,
- memo: "",
- }
-
- testCases := []struct {
- title string
- chainID string
- msgs []sdk.Msg
- timeoutHeight uint64
- expectSuccess bool
- }{
- {
- title: "Succeeds - Standard MsgSend",
- msgs: []sdk.Msg{
- banktypes.NewMsgSend(
- suite.createTestAddress(),
- suite.createTestAddress(),
- suite.makeCoins(suite.denom, sdkmath.NewInt(1)),
- ),
- },
- expectSuccess: true,
- },
- {
- title: "Succeeds - Standard MsgVote",
- msgs: []sdk.Msg{
- govtypes.NewMsgVote(
- suite.createTestAddress(),
- 5,
- govtypes.OptionNo,
- ),
- },
- expectSuccess: true,
- },
- {
- title: "Succeeds - Standard MsgDelegate",
- msgs: []sdk.Msg{
- stakingtypes.NewMsgDelegate(
- suite.createTestAddress(),
- sdk.ValAddress(suite.createTestAddress()),
- suite.makeCoins(suite.denom, sdkmath.NewInt(1))[0],
- ),
- },
- expectSuccess: true,
- },
- {
- title: "Succeeds - Standard MsgWithdrawDelegationReward",
- msgs: []sdk.Msg{
- distributiontypes.NewMsgWithdrawDelegatorReward(
- suite.createTestAddress(),
- sdk.ValAddress(suite.createTestAddress()),
- ),
- },
- expectSuccess: true,
- },
- {
- title: "Succeeds - Two Single-Signer MsgDelegate",
- msgs: []sdk.Msg{
- stakingtypes.NewMsgDelegate(
- params.address,
- sdk.ValAddress(suite.createTestAddress()),
- suite.makeCoins(suite.denom, sdkmath.NewInt(1))[0],
- ),
- stakingtypes.NewMsgDelegate(
- params.address,
- sdk.ValAddress(suite.createTestAddress()),
- suite.makeCoins(suite.denom, sdkmath.NewInt(5))[0],
- ),
- },
- expectSuccess: true,
- },
- {
- title: "Succeeds - Single-Signer MsgVote V1 with Omitted Value",
- msgs: []sdk.Msg{
- govtypesv1.NewMsgVote(
- params.address,
- 5,
- govtypesv1.VoteOption_VOTE_OPTION_NO,
- "",
- ),
- },
- expectSuccess: true,
- },
- {
- title: "Succeeds - Single-Signer MsgSend + MsgVote",
- msgs: []sdk.Msg{
- govtypes.NewMsgVote(
- params.address,
- 5,
- govtypes.OptionNo,
- ),
- banktypes.NewMsgSend(
- params.address,
- suite.createTestAddress(),
- suite.makeCoins(suite.denom, sdkmath.NewInt(50)),
- ),
- },
- expectSuccess: !suite.useLegacyEIP712TypedData,
- },
- {
- title: "Succeeds - Single-Signer 2x MsgVoteV1 with Different Schemas",
- msgs: []sdk.Msg{
- govtypesv1.NewMsgVote(
- params.address,
- 5,
- govtypesv1.VoteOption_VOTE_OPTION_NO,
- "",
- ),
- govtypesv1.NewMsgVote(
- params.address,
- 10,
- govtypesv1.VoteOption_VOTE_OPTION_YES,
- "Has Metadata",
- ),
- },
- expectSuccess: !suite.useLegacyEIP712TypedData,
- },
- {
- title: "Fails - Two MsgVotes with Different Signers",
- msgs: []sdk.Msg{
- govtypes.NewMsgVote(
- suite.createTestAddress(),
- 5,
- govtypes.OptionNo,
- ),
- govtypes.NewMsgVote(
- suite.createTestAddress(),
- 25,
- govtypes.OptionAbstain,
- ),
- },
- expectSuccess: false,
- },
- {
- title: "Fails - Empty Transaction",
- msgs: []sdk.Msg{},
- expectSuccess: false,
- },
- {
- title: "Fails - Invalid ChainID",
- chainID: "invalidchainid",
- msgs: []sdk.Msg{
- govtypes.NewMsgVote(
- suite.createTestAddress(),
- 5,
- govtypes.OptionNo,
- ),
- },
- expectSuccess: false,
- },
- {
- title: "Fails - Includes TimeoutHeight",
- msgs: []sdk.Msg{
- govtypes.NewMsgVote(
- suite.createTestAddress(),
- 5,
- govtypes.OptionNo,
- ),
- },
- timeoutHeight: 1000,
- expectSuccess: false,
- },
- {
- title: "Fails - Single Message / Multi-Signer",
- msgs: []sdk.Msg{
- banktypes.NewMsgMultiSend(
- []banktypes.Input{
- banktypes.NewInput(
- suite.createTestAddress(),
- suite.makeCoins(suite.denom, sdkmath.NewInt(50)),
- ),
- banktypes.NewInput(
- suite.createTestAddress(),
- suite.makeCoins(suite.denom, sdkmath.NewInt(50)),
- ),
- },
- []banktypes.Output{
- banktypes.NewOutput(
- suite.createTestAddress(),
- suite.makeCoins(suite.denom, sdkmath.NewInt(50)),
- ),
- banktypes.NewOutput(
- suite.createTestAddress(),
- suite.makeCoins(suite.denom, sdkmath.NewInt(50)),
- ),
- },
- ),
- },
- expectSuccess: false,
- },
- }
-
- for _, tc := range testCases {
- for _, signMode := range signModes {
- suite.Run(tc.title, func() {
- privKey, pubKey := suite.createTestKeyPair()
-
- txBuilder := suite.clientCtx.TxConfig.NewTxBuilder()
-
- txBuilder.SetGasLimit(params.fee.GasLimit)
- txBuilder.SetFeeAmount(params.fee.Amount)
-
- err := txBuilder.SetMsgs(tc.msgs...)
- suite.Require().NoError(err)
-
- txBuilder.SetMemo(params.memo)
-
- // Prepare signature field with empty signatures
- txSigData := signing.SingleSignatureData{
- SignMode: signMode,
- Signature: nil,
- }
- txSig := signing.SignatureV2{
- PubKey: pubKey,
- Data: &txSigData,
- Sequence: params.sequence,
- }
-
- err = txBuilder.SetSignatures([]signing.SignatureV2{txSig}...)
- suite.Require().NoError(err)
-
- chainID := TESTNET_CHAIN_ID + "-1"
- if tc.chainID != "" {
- chainID = tc.chainID
- }
-
- if tc.timeoutHeight != 0 {
- txBuilder.SetTimeoutHeight(tc.timeoutHeight)
- }
-
- signerData := authsigning.SignerData{
- ChainID: chainID,
- AccountNumber: params.accountNumber,
- Sequence: params.sequence,
- PubKey: pubKey,
- Address: sdk.MustBech32ifyAddressBytes(ethclient.Bech32Prefix, pubKey.Bytes()),
- }
-
- bz, err := suite.clientCtx.TxConfig.SignModeHandler().GetSignBytes(
- signMode,
- signerData,
- txBuilder.GetTx(),
- )
- suite.Require().NoError(err)
-
- suite.verifyEIP712SignatureVerification(tc.expectSuccess, *privKey, *pubKey, bz)
-
- // Verify payload flattening only if the payload is in valid JSON format
- if signMode == signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON {
- suite.verifySignDocFlattening(bz)
-
- if tc.expectSuccess {
- suite.verifyBasicTypedData(bz)
- }
- }
- })
- }
- }
-}
-
-// verifyEIP712SignatureVerification verifies that the payload passes signature verification if signed as its EIP-712 representation.
-func (suite *EIP712TestSuite) verifyEIP712SignatureVerification(expectedSuccess bool, privKey ethsecp256k1.PrivKey, pubKey ethsecp256k1.PubKey, signBytes []byte) {
- eip712Bytes, err := eip712.GetEIP712BytesForMsg(signBytes)
-
- if suite.useLegacyEIP712TypedData {
- eip712Bytes, err = eip712.LegacyGetEIP712BytesForMsg(signBytes)
- }
-
- if !expectedSuccess {
- suite.Require().Error(err)
- return
- }
-
- suite.Require().NoError(err)
-
- sig, err := privKey.Sign(eip712Bytes)
- suite.Require().NoError(err)
-
- // Verify against original payload bytes. This should pass, even though it is not
- // the original message that was signed.
- res := pubKey.VerifySignature(signBytes, sig)
- suite.Require().True(res)
-
- // Verify against the signed EIP-712 bytes. This should pass, since it is the message signed.
- res = pubKey.VerifySignature(eip712Bytes, sig)
- suite.Require().True(res)
-
- // Verify against random bytes to ensure it does not pass unexpectedly (sanity check).
- randBytes := make([]byte, len(signBytes))
- copy(randBytes, signBytes)
- // Change the first element of signBytes to a different value
- randBytes[0] = (signBytes[0] + 10) % 255
- res = pubKey.VerifySignature(randBytes, sig)
- suite.Require().False(res)
-}
-
-// verifySignDocFlattening tests the flattening algorithm against the sign doc's JSON payload,
-// using verifyPayloadAgainstFlattened.
-func (suite *EIP712TestSuite) verifySignDocFlattening(signDoc []byte) {
- payload := gjson.ParseBytes(signDoc)
- suite.Require().True(payload.IsObject())
-
- flattened, _, err := eip712.FlattenPayloadMessages(payload)
- suite.Require().NoError(err)
-
- suite.verifyPayloadAgainstFlattened(payload, flattened)
-}
-
-// verifyPayloadAgainstFlattened compares a payload against its flattened counterpart to ensure that
-// the flattening algorithm behaved as expected.
-func (suite *EIP712TestSuite) verifyPayloadAgainstFlattened(payload gjson.Result, flattened gjson.Result) {
- payloadMap, ok := payload.Value().(map[string]interface{})
- suite.Require().True(ok)
- flattenedMap, ok := flattened.Value().(map[string]interface{})
- suite.Require().True(ok)
-
- suite.verifyPayloadMapAgainstFlattenedMap(payloadMap, flattenedMap)
-}
-
-// verifyPayloadMapAgainstFlattenedMap directly compares two JSON maps in Go representations to
-// test flattening.
-func (suite *EIP712TestSuite) verifyPayloadMapAgainstFlattenedMap(original map[string]interface{}, flattened map[string]interface{}) {
- interfaceMessages, ok := original[msgsFieldName]
- suite.Require().True(ok)
-
- messages, ok := interfaceMessages.([]interface{})
- suite.Require().True(ok)
-
- // Verify message contents
- for i, msg := range messages {
- flattenedMsg, ok := flattened[fmt.Sprintf("msg%d", i)]
- suite.Require().True(ok)
-
- flattenedMsgJSON, ok := flattenedMsg.(map[string]interface{})
- suite.Require().True(ok)
-
- suite.Require().Equal(flattenedMsgJSON, msg)
- }
-
- // Verify new payload does not have msgs field
- _, ok = flattened[msgsFieldName]
- suite.Require().False(ok)
-
- // Verify number of total keys
- numKeysOriginal := len(original)
- numKeysFlattened := len(flattened)
- numMessages := len(messages)
-
- // + N keys, then -1 for msgs
- suite.Require().Equal(numKeysFlattened, numKeysOriginal+numMessages-1)
-
- // Verify contents of remaining keys
- for k, obj := range original {
- if k == msgsFieldName {
- continue
- }
-
- flattenedObj, ok := flattened[k]
- suite.Require().True(ok)
-
- suite.Require().Equal(obj, flattenedObj)
- }
-}
-
-// verifyBasicTypedData performs basic verification on the TypedData generation.
-func (suite *EIP712TestSuite) verifyBasicTypedData(signDoc []byte) {
- typedData, err := eip712.GetEIP712TypedDataForMsg(signDoc)
-
- suite.Require().NoError(err)
-
- jsonPayload := gjson.ParseBytes(signDoc)
- suite.Require().True(jsonPayload.IsObject())
-
- flattened, _, err := eip712.FlattenPayloadMessages(jsonPayload)
- suite.Require().NoError(err)
- suite.Require().True(flattened.IsObject())
-
- flattenedMsgMap, ok := flattened.Value().(map[string]interface{})
- suite.Require().True(ok)
-
- suite.Require().Equal(typedData.Message, flattenedMsgMap)
-}
-
-// TestFlattenPayloadErrorHandling tests error handling in TypedData generation,
-// specifically regarding the payload.
-func (suite *EIP712TestSuite) TestFlattenPayloadErrorHandling() {
- // No msgs
- _, _, err := eip712.FlattenPayloadMessages(gjson.Parse(""))
- suite.Require().ErrorContains(err, "no messages found")
-
- // Non-array Msgs
- _, _, err = eip712.FlattenPayloadMessages(gjson.Parse(`{"msgs": 10}`))
- suite.Require().ErrorContains(err, "array of messages")
-
- // Array with non-object items
- _, _, err = eip712.FlattenPayloadMessages(gjson.Parse(`{"msgs": [10, 20]}`))
- suite.Require().ErrorContains(err, "not valid JSON")
-
- // Malformed payload
- malformed, err := sjson.Set(suite.generateRandomPayload(2).Raw, "msg0", 20)
- suite.Require().NoError(err)
- _, _, err = eip712.FlattenPayloadMessages(gjson.Parse(malformed))
- suite.Require().ErrorContains(err, "malformed payload")
-}
-
-// TestTypedDataErrorHandling tests error handling for TypedData generation
-// in the main algorithm.
-func (suite *EIP712TestSuite) TestTypedDataErrorHandling() {
- // Empty JSON
- _, err := eip712.WrapTxToTypedData(0, make([]byte, 0))
- suite.Require().ErrorContains(err, "invalid JSON")
-
- _, err = eip712.WrapTxToTypedData(0, []byte(gjson.Parse(`{"msgs": 10}`).Raw))
- suite.Require().ErrorContains(err, "array of messages")
-
- // Invalid message 'type'
- _, err = eip712.WrapTxToTypedData(0, []byte(gjson.Parse(`{"msgs": [{ "type": 10 }] }`).Raw))
- suite.Require().ErrorContains(err, "message type value")
-
- // Max duplicate type recursion depth
- messagesArr := new(bytes.Buffer)
- maxRecursionDepth := 1001
-
- messagesArr.WriteString("[")
- for i := 0; i < maxRecursionDepth; i++ {
- messagesArr.WriteString(fmt.Sprintf(`{ "type": "msgType", "value": { "field%v": 10 } }`, i))
- if i != maxRecursionDepth-1 {
- messagesArr.WriteString(",")
- }
- }
- messagesArr.WriteString("]")
-
- _, err = eip712.WrapTxToTypedData(0, []byte(fmt.Sprintf(`{ "msgs": %v }`, messagesArr)))
- suite.Require().ErrorContains(err, "maximum number of duplicates")
-}
-
-// TestTypedDataEdgeCases tests certain interesting edge cases to ensure that they work
-// (or don't work) as expected.
-func (suite *EIP712TestSuite) TestTypedDataEdgeCases() {
- // Type without '/' separator
- typedData, err := eip712.WrapTxToTypedData(0, []byte(gjson.Parse(`{"msgs": [{ "type": "MsgSend", "value": { "field": 10 } }] }`).Raw))
- suite.Require().NoError(err)
- types := typedData.Types["TypeMsgSend0"]
- suite.Require().Greater(len(types), 0)
-
- // Null value
- typedData, err = eip712.WrapTxToTypedData(0, []byte(gjson.Parse(`{"msgs": [{ "type": "MsgSend", "value": { "field": null } }] }`).Raw))
- suite.Require().NoError(err)
- types = typedData.Types["TypeValue0"]
- // Skip null type, since we don't expect any in the payload
- suite.Require().Equal(len(types), 0)
-
- // Boolean value
- typedData, err = eip712.WrapTxToTypedData(0, []byte(gjson.Parse(`{"msgs": [{ "type": "MsgSend", "value": { "field": true } }] }`).Raw))
- suite.Require().NoError(err)
- types = typedData.Types["TypeValue0"]
- suite.Require().Equal(len(types), 1)
- suite.Require().Equal(types[0], apitypes.Type{
- Name: "field",
- Type: "bool",
- })
-
- // Empty array
- typedData, err = eip712.WrapTxToTypedData(0, []byte(gjson.Parse(`{"msgs": [{ "type": "MsgSend", "value": { "field": [] } }] }`).Raw))
- suite.Require().NoError(err)
- types = typedData.Types["TypeValue0"]
- suite.Require().Equal(types[0], apitypes.Type{
- Name: "field",
- Type: "string[]",
- })
-
- // Simple arrays
- typedData, err = eip712.WrapTxToTypedData(0, []byte(gjson.Parse(`{"msgs": [{ "type": "MsgSend", "value": { "array": [1, 2, 3] } }] }`).Raw))
- suite.Require().NoError(err)
- types = typedData.Types["TypeValue0"]
- suite.Require().Equal(len(types), 1)
- suite.Require().Equal(types[0], apitypes.Type{
- Name: "array",
- Type: "int64[]",
- })
-
- // Nested arrays (EIP-712 does not support nested arrays)
- typedData, err = eip712.WrapTxToTypedData(0, []byte(gjson.Parse(`{"msgs": [{ "type": "MsgSend", "value": { "array": [[1, 2, 3], [1, 2]] } }] }`).Raw))
- suite.Require().NoError(err)
- types = typedData.Types["TypeValue0"]
- suite.Require().Equal(len(types), 0)
-}
-
-// TestTypedDataGeneration tests certain qualities about the output Types representation.
-func (s *EIP712TestSuite) TestTypedDataGeneration() {
- // Multiple messages with the same schema should share one type
- payloadRaw := `{ "msgs": [{ "type": "msgType", "value": { "field1": 10 }}, { "type": "msgType", "value": { "field1": 20 }}] }`
-
- typedData, err := eip712.WrapTxToTypedData(0, []byte(payloadRaw))
- s.Require().NoError(err)
- s.Require().True(typedData.Types["TypemsgType1"] == nil)
-
- // Multiple messages with different schemas should have different types
- payloadRaw = `{ "msgs": [{ "type": "msgType", "value": { "field1": 10 }}, { "type": "msgType", "value": { "field2": 20 }}] }`
-
- typedData, err = eip712.WrapTxToTypedData(0, []byte(payloadRaw))
- s.Require().NoError(err)
- s.Require().False(typedData.Types["TypemsgType1"] == nil)
-}
-
-func (s *EIP712TestSuite) TestTypToEth() {
- cases := []struct {
- want string
- given any
- }{
- {want: "string", given: "string"},
- {want: "int8", given: int8(0)},
- {want: "int16", given: int16(0)},
- {want: "int32", given: int32(0)},
- {want: "int64", given: int64(0)},
-
- {want: "uint64", given: uint(0)},
- {want: "uint8", given: uint8(0)},
- {want: "uint16", given: uint16(0)},
- {want: "uint32", given: uint32(0)},
- {want: "uint64", given: uint64(0)},
- {want: "bool", given: false},
-
- // slice and array cases
- {want: "uint64[]", given: []uint64{1, 2, 3}},
- {want: "string[]", given: []string{"1", "2"}},
- {want: "int8[]", given: [3]int8{3, 2, 1}},
-
- // pointer cases
- {want: "string", given: sdkmath.NewInt(1)},
- {want: "string", given: big.NewInt(1)},
- {want: "string", given: sdkmath.LegacyNewDec(1)},
- }
-
- for _, tc := range cases {
- fnInp := reflect.TypeOf(tc.given)
- result := eip712.TypToEth(fnInp)
- s.Equal(tc.want, result,
- "Type conversion did not match for %v with input %s", tc.given, fnInp)
- }
-}
-
-func (s *EIP712TestSuite) TestUnpackAny() {
- _, addr := testutil.PrivKey()
- cases := []struct {
- wantWrappedType string
- wantType string
- given sdk.Msg
- wantErr bool
- }{
- {
- wantWrappedType: "*eip712.CosmosAnyWrapper",
- wantType: "/cosmos.bank.v1beta1.MsgSend",
- given: banktypes.NewMsgSend(addr, addr, sdk.NewCoins(sdk.NewInt64Coin("unibi", 25))),
- },
- {
- wantWrappedType: "*eip712.CosmosAnyWrapper",
- wantType: "/eth.evm.v1.MsgEthereumTx",
- given: new(evm.MsgEthereumTx),
- },
- {
- given: nil,
- wantErr: true,
- },
- }
-
- for _, tc := range cases {
- anyGiven, err := sdkcodec.NewAnyWithValue(tc.given)
- if tc.wantErr {
- s.Require().Error(err)
- continue
- }
- s.NoError(err)
-
- reflectVal := reflect.ValueOf(anyGiven)
- gotReflectType, gotReflectVal, err := eip712.UnpackAny(s.config.Codec, reflectVal)
- s.Require().NoError(err,
- "got reflect.Type %s, got reflect.Value %s",
- gotReflectType, gotReflectVal)
-
- s.Equal(tc.wantWrappedType, gotReflectType.String())
- if gotWrappedAny := gotReflectVal.Interface().(*eip712.CosmosAnyWrapper); gotWrappedAny != nil {
- s.EqualValues(gotWrappedAny.Type, tc.wantType)
- }
- }
-}
diff --git a/eth/eip712/encoding.go b/eth/eip712/encoding.go
deleted file mode 100644
index 97d2a9dbb..000000000
--- a/eth/eip712/encoding.go
+++ /dev/null
@@ -1,240 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eip712
-
-import (
- "errors"
- "fmt"
-
- "cosmossdk.io/simapp/params"
- "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- txTypes "github.com/cosmos/cosmos-sdk/types/tx"
-
- apitypes "github.com/ethereum/go-ethereum/signer/core/apitypes"
-
- "github.com/NibiruChain/nibiru/eth"
-
- "github.com/cosmos/cosmos-sdk/codec"
-)
-
-var (
- protoCodec codec.ProtoCodecMarshaler
- aminoCodec *codec.LegacyAmino
-)
-
-// SetEncodingConfig set the encoding config to the singleton codecs (Amino and Protobuf).
-// The process of unmarshaling SignDoc bytes into a SignDoc object requires having a codec
-// populated with all relevant message types. As a result, we must call this method on app
-// initialization with the app's encoding config.
-func SetEncodingConfig(cfg params.EncodingConfig) {
- aminoCodec = cfg.Amino
- protoCodec = codec.NewProtoCodec(cfg.InterfaceRegistry)
-}
-
-// GetEIP712BytesForMsg returns the EIP-712 object bytes for the given SignDoc bytes by decoding the bytes into
-// an EIP-712 object, then converting via WrapTxToTypedData. See https://eips.ethereum.org/EIPS/eip-712 for more.
-func GetEIP712BytesForMsg(signDocBytes []byte) ([]byte, error) {
- typedData, err := GetEIP712TypedDataForMsg(signDocBytes)
- if err != nil {
- return nil, err
- }
-
- _, rawData, err := apitypes.TypedDataAndHash(typedData)
- if err != nil {
- return nil, fmt.Errorf("could not get EIP-712 object bytes: %w", err)
- }
-
- return []byte(rawData), nil
-}
-
-// GetEIP712TypedDataForMsg returns the EIP-712 TypedData representation for either
-// Amino or Protobuf encoded signature doc bytes.
-func GetEIP712TypedDataForMsg(signDocBytes []byte) (apitypes.TypedData, error) {
- // Attempt to decode as both Amino and Protobuf since the message format is unknown.
- // If either decode works, we can move forward with the corresponding typed data.
- typedDataAmino, errAmino := decodeAminoSignDoc(signDocBytes)
- if errAmino == nil && isValidEIP712Payload(typedDataAmino) {
- return typedDataAmino, nil
- }
- typedDataProtobuf, errProtobuf := decodeProtobufSignDoc(signDocBytes)
- if errProtobuf == nil && isValidEIP712Payload(typedDataProtobuf) {
- return typedDataProtobuf, nil
- }
-
- return apitypes.TypedData{}, fmt.Errorf("could not decode sign doc as either Amino or Protobuf.\n amino: %v\n protobuf: %v", errAmino, errProtobuf)
-}
-
-// isValidEIP712Payload ensures that the given TypedData does not contain empty fields from
-// an improper initialization.
-func isValidEIP712Payload(typedData apitypes.TypedData) bool {
- return len(typedData.Message) != 0 && len(typedData.Types) != 0 && typedData.PrimaryType != "" && typedData.Domain != apitypes.TypedDataDomain{}
-}
-
-// decodeAminoSignDoc attempts to decode the provided sign doc (bytes) as an Amino payload
-// and returns a signable EIP-712 TypedData object.
-func decodeAminoSignDoc(signDocBytes []byte) (apitypes.TypedData, error) {
- // Ensure codecs have been initialized
- if err := validateCodecInit(); err != nil {
- return apitypes.TypedData{}, err
- }
-
- var aminoDoc legacytx.StdSignDoc
- if err := aminoCodec.UnmarshalJSON(signDocBytes, &aminoDoc); err != nil {
- return apitypes.TypedData{}, err
- }
-
- var fees legacytx.StdFee
- if err := aminoCodec.UnmarshalJSON(aminoDoc.Fee, &fees); err != nil {
- return apitypes.TypedData{}, err
- }
-
- // Validate payload messages
- msgs := make([]sdk.Msg, len(aminoDoc.Msgs))
- for i, jsonMsg := range aminoDoc.Msgs {
- var m sdk.Msg
- if err := aminoCodec.UnmarshalJSON(jsonMsg, &m); err != nil {
- return apitypes.TypedData{}, fmt.Errorf("failed to unmarshal sign doc message: %w", err)
- }
- msgs[i] = m
- }
-
- if err := validatePayloadMessages(msgs); err != nil {
- return apitypes.TypedData{}, err
- }
-
- chainID, err := eth.ParseChainID(aminoDoc.ChainID)
- if err != nil {
- return apitypes.TypedData{}, errors.New("invalid chain ID passed as argument")
- }
-
- typedData, err := WrapTxToTypedData(
- chainID.Uint64(),
- signDocBytes,
- )
- if err != nil {
- return apitypes.TypedData{}, fmt.Errorf("could not convert to EIP712 representation: %w", err)
- }
-
- return typedData, nil
-}
-
-// decodeProtobufSignDoc attempts to decode the provided sign doc (bytes) as a Protobuf payload
-// and returns a signable EIP-712 TypedData object.
-func decodeProtobufSignDoc(signDocBytes []byte) (apitypes.TypedData, error) {
- // Ensure codecs have been initialized
- if err := validateCodecInit(); err != nil {
- return apitypes.TypedData{}, err
- }
-
- signDoc := &txTypes.SignDoc{}
- if err := signDoc.Unmarshal(signDocBytes); err != nil {
- return apitypes.TypedData{}, err
- }
-
- authInfo := &txTypes.AuthInfo{}
- if err := authInfo.Unmarshal(signDoc.AuthInfoBytes); err != nil {
- return apitypes.TypedData{}, err
- }
-
- body := &txTypes.TxBody{}
- if err := body.Unmarshal(signDoc.BodyBytes); err != nil {
- return apitypes.TypedData{}, err
- }
-
- // Until support for these fields is added, throw an error at their presence
- if body.TimeoutHeight != 0 || len(body.ExtensionOptions) != 0 || len(body.NonCriticalExtensionOptions) != 0 {
- return apitypes.TypedData{}, errors.New("body contains unsupported fields: TimeoutHeight, ExtensionOptions, or NonCriticalExtensionOptions")
- }
-
- if len(authInfo.SignerInfos) != 1 {
- return apitypes.TypedData{}, fmt.Errorf("invalid number of signer infos provided, expected 1 got %v", len(authInfo.SignerInfos))
- }
-
- // Validate payload messages
- msgs := make([]sdk.Msg, len(body.Messages))
- for i, protoMsg := range body.Messages {
- var m sdk.Msg
- if err := protoCodec.UnpackAny(protoMsg, &m); err != nil {
- return apitypes.TypedData{}, fmt.Errorf("could not unpack message object with error %w", err)
- }
- msgs[i] = m
- }
-
- if err := validatePayloadMessages(msgs); err != nil {
- return apitypes.TypedData{}, err
- }
-
- signerInfo := authInfo.SignerInfos[0]
-
- chainID, err := eth.ParseChainID(signDoc.ChainId)
- if err != nil {
- return apitypes.TypedData{}, fmt.Errorf("invalid chain ID passed as argument: %w", err)
- }
-
- stdFee := &legacytx.StdFee{
- Amount: authInfo.Fee.Amount,
- Gas: authInfo.Fee.GasLimit,
- }
-
- tip := authInfo.Tip
-
- // WrapTxToTypedData expects the payload as an Amino Sign Doc
- signBytes := legacytx.StdSignBytes(
- signDoc.ChainId,
- signDoc.AccountNumber,
- signerInfo.Sequence,
- body.TimeoutHeight,
- *stdFee,
- msgs,
- body.Memo,
- tip,
- )
-
- typedData, err := WrapTxToTypedData(
- chainID.Uint64(),
- signBytes,
- )
- if err != nil {
- return apitypes.TypedData{}, err
- }
-
- return typedData, nil
-}
-
-// validateCodecInit ensures that both Amino and Protobuf encoding codecs have been set on app init,
-// so the module does not panic if either codec is not found.
-func validateCodecInit() error {
- if aminoCodec == nil || protoCodec == nil {
- return errors.New("missing codec: codecs have not been properly initialized using SetEncodingConfig")
- }
-
- return nil
-}
-
-// validatePayloadMessages ensures that the transaction messages can be represented in an EIP-712
-// encoding by checking that messages exist and share a single signer.
-func validatePayloadMessages(msgs []sdk.Msg) error {
- if len(msgs) == 0 {
- return errors.New("unable to build EIP-712 payload: transaction does contain any messages")
- }
-
- var msgSigner sdk.AccAddress
-
- for i, m := range msgs {
- if len(m.GetSigners()) != 1 {
- return errors.New("unable to build EIP-712 payload: expect exactly 1 signer")
- }
-
- if i == 0 {
- msgSigner = m.GetSigners()[0]
- continue
- }
-
- if !msgSigner.Equals(m.GetSigners()[0]) {
- return errors.New("unable to build EIP-712 payload: multiple signers detected")
- }
- }
-
- return nil
-}
diff --git a/eth/eip712/encoding_legacy.go b/eth/eip712/encoding_legacy.go
deleted file mode 100644
index 08653560a..000000000
--- a/eth/eip712/encoding_legacy.go
+++ /dev/null
@@ -1,267 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eip712
-
-import (
- "encoding/json"
- "errors"
- "fmt"
-
- "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- txTypes "github.com/cosmos/cosmos-sdk/types/tx"
-
- apitypes "github.com/ethereum/go-ethereum/signer/core/apitypes"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-type aminoMessage struct {
- Type string `json:"type"`
- Value interface{} `json:"value"`
-}
-
-// LegacyGetEIP712BytesForMsg returns the EIP-712 object bytes for the given SignDoc bytes by decoding the bytes into
-// an EIP-712 object, then converting via LegacyWrapTxToTypedData. See https://eips.ethereum.org/EIPS/eip-712 for more.
-func LegacyGetEIP712BytesForMsg(signDocBytes []byte) ([]byte, error) {
- typedData, err := LegacyGetEIP712TypedDataForMsg(signDocBytes)
- if err != nil {
- return nil, err
- }
-
- _, rawData, err := apitypes.TypedDataAndHash(typedData)
- if err != nil {
- return nil, fmt.Errorf("could not get EIP-712 object bytes: %w", err)
- }
-
- return []byte(rawData), nil
-}
-
-// LegacyGetEIP712TypedDataForMsg returns the EIP-712 TypedData representation for either
-// Amino or Protobuf encoded signature doc bytes.
-func LegacyGetEIP712TypedDataForMsg(signDocBytes []byte) (apitypes.TypedData, error) {
- // Attempt to decode as both Amino and Protobuf since the message format is unknown.
- // If either decode works, we can move forward with the corresponding typed data.
- typedDataAmino, errAmino := legacyDecodeAminoSignDoc(signDocBytes)
- if errAmino == nil && isValidEIP712Payload(typedDataAmino) {
- return typedDataAmino, nil
- }
- typedDataProtobuf, errProtobuf := legacyDecodeProtobufSignDoc(signDocBytes)
- if errProtobuf == nil && isValidEIP712Payload(typedDataProtobuf) {
- return typedDataProtobuf, nil
- }
-
- return apitypes.TypedData{}, fmt.Errorf("could not decode sign doc as either Amino or Protobuf.\n amino: %v\n protobuf: %v", errAmino, errProtobuf)
-}
-
-// legacyDecodeAminoSignDoc attempts to decode the provided sign doc (bytes) as an Amino payload
-// and returns a signable EIP-712 TypedData object.
-func legacyDecodeAminoSignDoc(signDocBytes []byte) (apitypes.TypedData, error) {
- // Ensure codecs have been initialized
- if err := validateCodecInit(); err != nil {
- return apitypes.TypedData{}, err
- }
-
- var aminoDoc legacytx.StdSignDoc
- if err := aminoCodec.UnmarshalJSON(signDocBytes, &aminoDoc); err != nil {
- return apitypes.TypedData{}, err
- }
-
- var fees legacytx.StdFee
- if err := aminoCodec.UnmarshalJSON(aminoDoc.Fee, &fees); err != nil {
- return apitypes.TypedData{}, err
- }
-
- // Validate payload messages
- msgs := make([]sdk.Msg, len(aminoDoc.Msgs))
- for i, jsonMsg := range aminoDoc.Msgs {
- var m sdk.Msg
- if err := aminoCodec.UnmarshalJSON(jsonMsg, &m); err != nil {
- return apitypes.TypedData{}, fmt.Errorf("failed to unmarshal sign doc message: %w", err)
- }
- msgs[i] = m
- }
-
- if err := legacyValidatePayloadMessages(msgs); err != nil {
- return apitypes.TypedData{}, err
- }
-
- // Use first message for fee payer and type inference
- msg := msgs[0]
-
- // By convention, the fee payer is the first address in the list of signers.
- feePayer := msg.GetSigners()[0]
- feeDelegation := &FeeDelegationOptions{
- FeePayer: feePayer,
- }
-
- chainID, err := eth.ParseChainID(aminoDoc.ChainID)
- if err != nil {
- return apitypes.TypedData{}, errors.New("invalid chain ID passed as argument")
- }
-
- typedData, err := LegacyWrapTxToTypedData(
- protoCodec,
- chainID.Uint64(),
- msg,
- signDocBytes,
- feeDelegation,
- )
- if err != nil {
- return apitypes.TypedData{}, fmt.Errorf("could not convert to EIP712 representation: %w", err)
- }
-
- return typedData, nil
-}
-
-// legacyDecodeProtobufSignDoc attempts to decode the provided sign doc (bytes) as a Protobuf payload
-// and returns a signable EIP-712 TypedData object.
-func legacyDecodeProtobufSignDoc(signDocBytes []byte) (apitypes.TypedData, error) {
- // Ensure codecs have been initialized
- if err := validateCodecInit(); err != nil {
- return apitypes.TypedData{}, err
- }
-
- signDoc := &txTypes.SignDoc{}
- if err := signDoc.Unmarshal(signDocBytes); err != nil {
- return apitypes.TypedData{}, err
- }
-
- authInfo := &txTypes.AuthInfo{}
- if err := authInfo.Unmarshal(signDoc.AuthInfoBytes); err != nil {
- return apitypes.TypedData{}, err
- }
-
- body := &txTypes.TxBody{}
- if err := body.Unmarshal(signDoc.BodyBytes); err != nil {
- return apitypes.TypedData{}, err
- }
-
- // Until support for these fields is added, throw an error at their presence
- if body.TimeoutHeight != 0 || len(body.ExtensionOptions) != 0 || len(body.NonCriticalExtensionOptions) != 0 {
- return apitypes.TypedData{}, errors.New("body contains unsupported fields: TimeoutHeight, ExtensionOptions, or NonCriticalExtensionOptions")
- }
-
- if len(authInfo.SignerInfos) != 1 {
- return apitypes.TypedData{}, fmt.Errorf("invalid number of signer infos provided, expected 1 got %v", len(authInfo.SignerInfos))
- }
-
- // Validate payload messages
- msgs := make([]sdk.Msg, len(body.Messages))
- for i, protoMsg := range body.Messages {
- var m sdk.Msg
- if err := protoCodec.UnpackAny(protoMsg, &m); err != nil {
- return apitypes.TypedData{}, fmt.Errorf("could not unpack message object with error %w", err)
- }
- msgs[i] = m
- }
-
- if err := legacyValidatePayloadMessages(msgs); err != nil {
- return apitypes.TypedData{}, err
- }
-
- // Use first message for fee payer and type inference
- msg := msgs[0]
-
- signerInfo := authInfo.SignerInfos[0]
-
- chainID, err := eth.ParseChainID(signDoc.ChainId)
- if err != nil {
- return apitypes.TypedData{}, fmt.Errorf("invalid chain ID passed as argument: %w", err)
- }
-
- stdFee := &legacytx.StdFee{
- Amount: authInfo.Fee.Amount,
- Gas: authInfo.Fee.GasLimit,
- }
-
- feePayer := msg.GetSigners()[0]
- feeDelegation := &FeeDelegationOptions{
- FeePayer: feePayer,
- }
-
- tip := authInfo.Tip
-
- // WrapTxToTypedData expects the payload as an Amino Sign Doc
- signBytes := legacytx.StdSignBytes(
- signDoc.ChainId,
- signDoc.AccountNumber,
- signerInfo.Sequence,
- body.TimeoutHeight,
- *stdFee,
- msgs,
- body.Memo,
- tip,
- )
-
- typedData, err := LegacyWrapTxToTypedData(
- protoCodec,
- chainID.Uint64(),
- msg,
- signBytes,
- feeDelegation,
- )
- if err != nil {
- return apitypes.TypedData{}, err
- }
-
- return typedData, nil
-}
-
-// validatePayloadMessages ensures that the transaction messages can be represented in an EIP-712
-// encoding by checking that messages exist, are of the same type, and share a single signer.
-func legacyValidatePayloadMessages(msgs []sdk.Msg) error {
- if len(msgs) == 0 {
- return errors.New("unable to build EIP-712 payload: transaction does contain any messages")
- }
-
- var msgType string
- var msgSigner sdk.AccAddress
-
- for i, m := range msgs {
- t, err := getMsgType(m)
- if err != nil {
- return err
- }
-
- if len(m.GetSigners()) != 1 {
- return errors.New("unable to build EIP-712 payload: expect exactly 1 signer")
- }
-
- if i == 0 {
- msgType = t
- msgSigner = m.GetSigners()[0]
- continue
- }
-
- if t != msgType {
- return errors.New("unable to build EIP-712 payload: different types of messages detected")
- }
-
- if !msgSigner.Equals(m.GetSigners()[0]) {
- return errors.New("unable to build EIP-712 payload: multiple signers detected")
- }
- }
-
- return nil
-}
-
-// getMsgType returns the message type prefix for the given Cosmos SDK Msg
-func getMsgType(msg sdk.Msg) (string, error) {
- jsonBytes, err := aminoCodec.MarshalJSON(msg)
- if err != nil {
- return "", err
- }
-
- var jsonMsg aminoMessage
- if err := json.Unmarshal(jsonBytes, &jsonMsg); err != nil {
- return "", err
- }
-
- // Verify Type was successfully filled in
- if jsonMsg.Type == "" {
- return "", errors.New("could not decode message: type is missing")
- }
-
- return jsonMsg.Type, nil
-}
diff --git a/eth/eip712/message.go b/eth/eip712/message.go
deleted file mode 100644
index 6a8577c22..000000000
--- a/eth/eip712/message.go
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eip712
-
-import (
- "fmt"
-
- errorsmod "cosmossdk.io/errors"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
-
- "github.com/tidwall/gjson"
- "github.com/tidwall/sjson"
-)
-
-type eip712MessagePayload struct {
- payload gjson.Result
- numPayloadMsgs int
- message map[string]interface{}
-}
-
-const (
- payloadMsgsField = "msgs"
-)
-
-// createEIP712MessagePayload generates the EIP-712 message payload
-// corresponding to the input data.
-func createEIP712MessagePayload(data []byte) (eip712MessagePayload, error) {
- basicPayload, err := unmarshalBytesToJSONObject(data)
- if err != nil {
- return eip712MessagePayload{}, err
- }
-
- payload, numPayloadMsgs, err := FlattenPayloadMessages(basicPayload)
- if err != nil {
- return eip712MessagePayload{}, errorsmod.Wrap(err, "failed to flatten payload JSON messages")
- }
-
- message, ok := payload.Value().(map[string]interface{})
- if !ok {
- return eip712MessagePayload{}, errorsmod.Wrap(errortypes.ErrInvalidType, "failed to parse JSON as map")
- }
-
- messagePayload := eip712MessagePayload{
- payload: payload,
- numPayloadMsgs: numPayloadMsgs,
- message: message,
- }
-
- return messagePayload, nil
-}
-
-// unmarshalBytesToJSONObject converts a bytestream into
-// a JSON object, then makes sure the JSON is an object.
-func unmarshalBytesToJSONObject(data []byte) (gjson.Result, error) {
- if !gjson.ValidBytes(data) {
- return gjson.Result{}, errorsmod.Wrap(errortypes.ErrJSONUnmarshal, "invalid JSON received")
- }
-
- payload := gjson.ParseBytes(data)
-
- if !payload.IsObject() {
- return gjson.Result{}, errorsmod.Wrap(errortypes.ErrJSONUnmarshal, "failed to JSON unmarshal data as object")
- }
-
- return payload, nil
-}
-
-// FlattenPayloadMessages flattens the input payload's messages, representing
-// them as key-value pairs of "msg{i}": {Msg}, rather than as an array of Msgs.
-// We do this to support messages with different schemas.
-func FlattenPayloadMessages(payload gjson.Result) (gjson.Result, int, error) {
- flattened := payload
- var err error
-
- msgs, err := getPayloadMessages(payload)
- if err != nil {
- return gjson.Result{}, 0, err
- }
-
- for i, msg := range msgs {
- flattened, err = payloadWithNewMessage(flattened, msg, i)
- if err != nil {
- return gjson.Result{}, 0, err
- }
- }
-
- flattened, err = payloadWithoutMsgsField(flattened)
- if err != nil {
- return gjson.Result{}, 0, err
- }
-
- return flattened, len(msgs), nil
-}
-
-// getPayloadMessages processes and returns the payload messages as a JSON array.
-func getPayloadMessages(payload gjson.Result) ([]gjson.Result, error) {
- rawMsgs := payload.Get(payloadMsgsField)
-
- if !rawMsgs.Exists() {
- return nil, errorsmod.Wrap(errortypes.ErrInvalidRequest, "no messages found in payload, unable to parse")
- }
-
- if !rawMsgs.IsArray() {
- return nil, errorsmod.Wrap(errortypes.ErrInvalidRequest, "expected type array of messages, cannot parse")
- }
-
- return rawMsgs.Array(), nil
-}
-
-// payloadWithNewMessage returns the updated payload object with the message
-// set at the field corresponding to index.
-func payloadWithNewMessage(payload gjson.Result, msg gjson.Result, index int) (gjson.Result, error) {
- field := msgFieldForIndex(index)
-
- if payload.Get(field).Exists() {
- return gjson.Result{}, errorsmod.Wrapf(
- errortypes.ErrInvalidRequest,
- "malformed payload received, did not expect to find key at field %v", field,
- )
- }
-
- if !msg.IsObject() {
- return gjson.Result{}, errorsmod.Wrapf(errortypes.ErrInvalidRequest, "msg at index %d is not valid JSON: %v", index, msg)
- }
-
- newRaw, err := sjson.SetRaw(payload.Raw, field, msg.Raw)
- if err != nil {
- return gjson.Result{}, err
- }
-
- return gjson.Parse(newRaw), nil
-}
-
-// msgFieldForIndex returns the payload field for a given message post-flattening.
-// e.g. msgs[2] becomes 'msg2'
-func msgFieldForIndex(i int) string {
- return fmt.Sprintf("msg%d", i)
-}
-
-// payloadWithoutMsgsField returns the updated payload without the "msgs" array
-// field, which flattening makes obsolete.
-func payloadWithoutMsgsField(payload gjson.Result) (gjson.Result, error) {
- newRaw, err := sjson.Delete(payload.Raw, payloadMsgsField)
- if err != nil {
- return gjson.Result{}, err
- }
-
- return gjson.Parse(newRaw), nil
-}
diff --git a/eth/eip712/preprocess.go b/eth/eip712/preprocess.go
deleted file mode 100644
index d03a44fbc..000000000
--- a/eth/eip712/preprocess.go
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eip712
-
-import (
- "fmt"
-
- "github.com/cosmos/cosmos-sdk/client"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- cosmoskr "github.com/cosmos/cosmos-sdk/crypto/keyring"
- "github.com/cosmos/cosmos-sdk/types/tx/signing"
- authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-// PreprocessLedgerTx reformats Ledger-signed Cosmos transactions to match the fork expected by Ethermint
-// by including the signature in a Web3Tx extension and sending a blank signature in the body.
-func PreprocessLedgerTx(chainID string, keyType cosmoskr.KeyType, txBuilder client.TxBuilder) error {
- // Only process Ledger transactions
- if keyType != cosmoskr.TypeLedger {
- return nil
- }
-
- // Init extension builder to set Web3 extension
- extensionBuilder, ok := txBuilder.(authtx.ExtensionOptionsTxBuilder)
- if !ok {
- return fmt.Errorf("cannot cast TxBuilder to ExtensionOptionsTxBuilder")
- }
-
- // Get signatures from TxBuilder
- sigs, err := txBuilder.GetTx().GetSignaturesV2()
- if err != nil {
- return fmt.Errorf("could not get signatures: %w", err)
- }
-
- // Verify single-signer
- if len(sigs) != 1 {
- return fmt.Errorf("invalid number of signatures, expected 1 and got %v", len(sigs))
- }
-
- signature := sigs[0]
- sigData, ok := signature.Data.(*signing.SingleSignatureData)
- if !ok {
- return fmt.Errorf("unexpected signature type, expected SingleSignatureData")
- }
- sigBytes := sigData.Signature
-
- // Parse Chain ID as big.Int
- chainIDInt, err := eth.ParseChainID(chainID)
- if err != nil {
- return fmt.Errorf("could not parse chain id: %w", err)
- }
-
- // Add ExtensionOptionsWeb3Tx extension with signature
- var option *codectypes.Any
- option, err = codectypes.NewAnyWithValue(ð.ExtensionOptionsWeb3Tx{
- FeePayer: txBuilder.GetTx().FeePayer().String(),
- TypedDataChainID: chainIDInt.Uint64(),
- FeePayerSig: sigBytes,
- })
- if err != nil {
- return fmt.Errorf("could not set extension as any: %w", err)
- }
-
- extensionBuilder.SetExtensionOptions(option)
-
- // Set blank signature with Amino Sign Type
- // (Regardless of input signMode, Nibiru requires Amino signature type for
- // Ledger support on EVM)
- blankSig := signing.SingleSignatureData{
- SignMode: signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON,
- Signature: nil,
- }
- sig := signing.SignatureV2{
- PubKey: signature.PubKey,
- Data: &blankSig,
- Sequence: signature.Sequence,
- }
-
- err = txBuilder.SetSignatures(sig)
- if err != nil {
- return fmt.Errorf("unable to set signatures on payload: %w", err)
- }
-
- return nil
-}
diff --git a/eth/eip712/preprocess_test.go b/eth/eip712/preprocess_test.go
deleted file mode 100644
index 50b2cba5b..000000000
--- a/eth/eip712/preprocess_test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package eip712_test
-
-import (
- "testing"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
-
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/eth/eip712"
- "github.com/NibiruChain/nibiru/eth/encoding"
-)
-
-// Testing Constants
-var (
- chainID = "cataclysm" + "-1"
- ctx = client.Context{}.WithTxConfig(
- encoding.MakeConfig(app.ModuleBasics).TxConfig,
- )
-)
-
-func TestBlankTxBuilder(t *testing.T) {
- txBuilder := ctx.TxConfig.NewTxBuilder()
-
- err := eip712.PreprocessLedgerTx(
- chainID,
- keyring.TypeLedger,
- txBuilder,
- )
-
- require.Error(t, err)
-}
-
-func TestNonLedgerTxBuilder(t *testing.T) {
- txBuilder := ctx.TxConfig.NewTxBuilder()
-
- err := eip712.PreprocessLedgerTx(
- chainID,
- keyring.TypeLocal,
- txBuilder,
- )
-
- require.NoError(t, err)
-}
-
-func TestInvalidChainId(t *testing.T) {
- txBuilder := ctx.TxConfig.NewTxBuilder()
-
- err := eip712.PreprocessLedgerTx(
- "invalid-chain-id",
- keyring.TypeLedger,
- txBuilder,
- )
-
- require.Error(t, err)
-}
diff --git a/eth/eip712/types.go b/eth/eip712/types.go
deleted file mode 100644
index 82c4dee9f..000000000
--- a/eth/eip712/types.go
+++ /dev/null
@@ -1,390 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eip712
-
-import (
- "bytes"
- "fmt"
- "sort"
- "strings"
-
- "golang.org/x/text/cases"
- "golang.org/x/text/language"
-
- errorsmod "cosmossdk.io/errors"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
-
- "github.com/ethereum/go-ethereum/signer/core/apitypes"
- "github.com/tidwall/gjson"
-)
-
-const (
- rootPrefix = "_"
- typePrefix = "Type"
-
- txField = "Tx"
- ethBool = "bool"
- ethInt64 = "int64"
- ethString = "string"
-
- msgTypeField = "type"
-
- maxDuplicateTypeDefs = 1000
-)
-
-// getEIP712Types creates and returns the EIP-712 types
-// for the given message payload.
-func createEIP712Types(messagePayload eip712MessagePayload) (apitypes.Types, error) {
- eip712Types := apitypes.Types{
- "EIP712Domain": {
- {
- Name: "name",
- Type: "string",
- },
- {
- Name: "version",
- Type: "string",
- },
- {
- Name: "chainId",
- Type: "uint256",
- },
- {
- Name: "verifyingContract",
- Type: "string",
- },
- {
- Name: "salt",
- Type: "string",
- },
- },
- "Tx": {
- {Name: "account_number", Type: "string"},
- {Name: "chain_id", Type: "string"},
- {Name: "fee", Type: "Fee"},
- {Name: "memo", Type: "string"},
- {Name: "sequence", Type: "string"},
- // Note timeout_height was removed because it was not getting filled with the legacyTx
- },
- "Fee": {
- {Name: "amount", Type: "Coin[]"},
- {Name: "gas", Type: "string"},
- },
- "Coin": {
- {Name: "denom", Type: "string"},
- {Name: "amount", Type: "string"},
- },
- }
-
- for i := 0; i < messagePayload.numPayloadMsgs; i++ {
- field := msgFieldForIndex(i)
- msg := messagePayload.payload.Get(field)
-
- if err := addMsgTypesToRoot(eip712Types, field, msg); err != nil {
- return nil, err
- }
- }
-
- return eip712Types, nil
-}
-
-// addMsgTypesToRoot adds all types for the given message
-// to eip712Types, recursively handling object sub-fields.
-func addMsgTypesToRoot(eip712Types apitypes.Types, msgField string, msg gjson.Result) (err error) {
- defer doRecover(&err)
-
- if !msg.IsObject() {
- return errorsmod.Wrapf(errortypes.ErrInvalidRequest, "message is not valid JSON, cannot parse types")
- }
-
- msgRootType, err := msgRootType(msg)
- if err != nil {
- return err
- }
-
- msgTypeDef, err := recursivelyAddTypesToRoot(eip712Types, msgRootType, rootPrefix, msg)
- if err != nil {
- return err
- }
-
- addMsgTypeDefToTxSchema(eip712Types, msgField, msgTypeDef)
-
- return nil
-}
-
-// msgRootType parses the message and returns the formatted
-// type signature corresponding to the message type.
-func msgRootType(msg gjson.Result) (string, error) {
- msgType := msg.Get(msgTypeField).Str
- if msgType == "" {
- // .Str is empty for arrays and objects
- return "", errorsmod.Wrap(errortypes.ErrInvalidType, "malformed message type value, expected type string")
- }
-
- // Convert e.g. cosmos-sdk/MsgSend to TypeMsgSend
- typeTokenized := strings.Split(msgType, "/")
- msgSignature := typeTokenized[len(typeTokenized)-1]
- rootType := fmt.Sprintf("%v%v", typePrefix, msgSignature)
-
- return rootType, nil
-}
-
-// addMsgTypeDefToTxSchema adds the message's field-type pairing
-// to the Tx schema.
-func addMsgTypeDefToTxSchema(eip712Types apitypes.Types, msgField, msgTypeDef string) {
- eip712Types[txField] = append(eip712Types[txField], apitypes.Type{
- Name: msgField,
- Type: msgTypeDef,
- })
-}
-
-// recursivelyAddTypesToRoot walks all types in the given map
-// and recursively adds sub-maps as new types when necessary.
-// It adds all type definitions to typeMap, then returns a key
-// to the json object's type definition within the map.
-func recursivelyAddTypesToRoot(
- typeMap apitypes.Types,
- rootType string,
- prefix string,
- payload gjson.Result,
-) (string, error) {
- typesToAdd := []apitypes.Type{}
-
- // Must sort the JSON keys for deterministic type generation.
- sortedFieldNames, err := sortedJSONKeys(payload)
- if err != nil {
- return "", errorsmod.Wrap(err, "unable to sort object keys")
- }
-
- typeDef := typeDefForPrefix(prefix, rootType)
-
- for _, fieldName := range sortedFieldNames {
- field := payload.Get(fieldName)
- if !field.Exists() {
- continue
- }
-
- // Handle array type by unwrapping the first element.
- // Note that arrays with multiple types are not supported
- // using EIP-712, so we can ignore that case.
- isCollection := false
- if field.IsArray() {
- fieldAsArray := field.Array()
-
- if len(fieldAsArray) == 0 {
- // Arbitrarily add string[] type to handle empty arrays,
- // since we cannot access the underlying object.
- emptyArrayType := "string[]"
- typesToAdd = appendedTypesList(typesToAdd, fieldName, emptyArrayType)
-
- continue
- }
-
- field = fieldAsArray[0]
- isCollection = true
- }
-
- ethType := getEthTypeForJSON(field)
-
- // Handle JSON primitive types by adding the corresponding
- // EIP-712 type to the types schema.
- if ethType != "" {
- if isCollection {
- ethType += "[]"
- }
- typesToAdd = appendedTypesList(typesToAdd, fieldName, ethType)
-
- continue
- }
-
- // Handle object types recursively. Note that nested array types are not supported
- // in EIP-712, so we can exclude that case.
- if field.IsObject() {
- fieldPrefix := prefixForSubField(prefix, fieldName)
-
- fieldTypeDef, err := recursivelyAddTypesToRoot(typeMap, rootType, fieldPrefix, field)
- if err != nil {
- return "", err
- }
-
- fieldTypeDef = sanitizeTypedef(fieldTypeDef)
- if isCollection {
- fieldTypeDef += "[]"
- }
-
- typesToAdd = appendedTypesList(typesToAdd, fieldName, fieldTypeDef)
-
- continue
- }
- }
-
- return addTypesToRoot(typeMap, typeDef, typesToAdd)
-}
-
-// sortedJSONKeys returns the sorted JSON keys for the input object,
-// to be used for deterministic iteration.
-func sortedJSONKeys(json gjson.Result) ([]string, error) {
- if !json.IsObject() {
- return nil, errorsmod.Wrap(errortypes.ErrInvalidType, "expected JSON map to parse")
- }
-
- jsonMap := json.Map()
-
- keys := make([]string, len(jsonMap))
- i := 0
- // #nosec G705 for map iteration
- for k := range jsonMap {
- keys[i] = k
- i++
- }
-
- sort.Slice(keys, func(i, j int) bool {
- return strings.Compare(keys[i], keys[j]) > 0
- })
-
- return keys, nil
-}
-
-// typeDefForPrefix computes the type definition for the given
-// prefix. This value will represent the types key within
-// the EIP-712 types map.
-func typeDefForPrefix(prefix, rootType string) string {
- if prefix == rootPrefix {
- return rootType
- }
- return sanitizeTypedef(prefix)
-}
-
-// appendedTypesList returns an array of Types with a new element
-// consisting of name and typeDef.
-func appendedTypesList(types []apitypes.Type, name, typeDef string) []apitypes.Type {
- return append(types, apitypes.Type{
- Name: name,
- Type: typeDef,
- })
-}
-
-// prefixForSubField computes the prefix for a subfield by
-// indicating that it's derived from the object associated with prefix.
-func prefixForSubField(prefix, fieldName string) string {
- return fmt.Sprintf("%s.%s", prefix, fieldName)
-}
-
-// addTypesToRoot attempts to add the types to the root at key
-// typeDef and returns the key at which the types are present,
-// or an error if they cannot be added. If the typeDef key is a
-// duplicate, we return the key corresponding to an identical copy
-// if present, without modifying the structure. Otherwise, we insert
-// the types at the next available typeDef-{n} field. We do this to
-// support identically named payloads with different schemas.
-func addTypesToRoot(typeMap apitypes.Types, typeDef string, types []apitypes.Type) (string, error) {
- var indexedTypeDef string
-
- indexAsDuplicate := 0
-
- for {
- indexedTypeDef = typeDefWithIndex(typeDef, indexAsDuplicate)
- existingTypes, foundElement := typeMap[indexedTypeDef]
-
- // Found identical duplicate, so we can simply return
- // the existing type definition.
- if foundElement && typesAreEqual(types, existingTypes) {
- return indexedTypeDef, nil
- }
-
- // Found no element, so we can create a new one at this index.
- if !foundElement {
- break
- }
-
- indexAsDuplicate++
-
- if indexAsDuplicate == maxDuplicateTypeDefs {
- return "", errorsmod.Wrap(errortypes.ErrInvalidRequest, "exceeded maximum number of duplicates for a single type definition")
- }
- }
-
- typeMap[indexedTypeDef] = types
-
- return indexedTypeDef, nil
-}
-
-// typeDefWithIndex creates a duplicate-indexed type definition
-// to differentiate between different schemas with the same name.
-func typeDefWithIndex(typeDef string, index int) string {
- return fmt.Sprintf("%v%d", typeDef, index)
-}
-
-// typesAreEqual compares two apitypes.Type arrays
-// and returns a boolean indicating whether they have
-// the same values.
-// It assumes both arrays are in the same sorted order.
-func typesAreEqual(types1 []apitypes.Type, types2 []apitypes.Type) bool {
- if len(types1) != len(types2) {
- return false
- }
-
- for i := 0; i < len(types1); i++ {
- if types1[i].Name != types2[i].Name || types1[i].Type != types2[i].Type {
- return false
- }
- }
-
- return true
-}
-
-// _.foo_bar.baz -> TypeFooBarBaz
-//
-// Since Geth does not tolerate complex EIP-712 type names, we need to sanitize
-// the inputs.
-func sanitizeTypedef(str string) string {
- buf := new(bytes.Buffer)
- caser := cases.Title(language.English, cases.NoLower)
- parts := strings.Split(str, ".")
-
- for _, part := range parts {
- if part == rootPrefix {
- buf.WriteString(typePrefix)
- continue
- }
-
- subparts := strings.Split(part, "_")
- for _, subpart := range subparts {
- buf.WriteString(caser.String(subpart))
- }
- }
-
- return buf.String()
-}
-
-// getEthTypeForJSON converts a JSON type to an Ethereum type.
-// It returns an empty string for Objects, Arrays, or Null.
-// See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md for more.
-func getEthTypeForJSON(json gjson.Result) string {
- switch json.Type {
- case gjson.True, gjson.False:
- return ethBool
- case gjson.Number:
- return ethInt64
- case gjson.String:
- return ethString
- case gjson.JSON:
- // Array or Object type
- return ""
- default:
- return ""
- }
-}
-
-// doRecover attempts to recover in the event of a panic to
-// prevent DOS and gracefully handle an error instead.
-func doRecover(err *error) {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- e = errorsmod.Wrap(e, "panicked with error")
- *err = e
- return
- }
-
- *err = fmt.Errorf("%v", r)
- }
-}
diff --git a/eth/encoding/codec/codec.go b/eth/encoding/codec/codec.go
deleted file mode 100644
index 19916af90..000000000
--- a/eth/encoding/codec/codec.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package codec
-
-import (
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- "github.com/cosmos/cosmos-sdk/std"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/eth"
- cryptocodec "github.com/NibiruChain/nibiru/eth/crypto/codec"
-)
-
-// RegisterLegacyAminoCodec registers Interfaces from types, crypto, and SDK std.
-func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- sdk.RegisterLegacyAminoCodec(cdc)
- cryptocodec.RegisterCrypto(cdc)
- codec.RegisterEvidences(cdc)
-}
-
-// RegisterInterfaces registers Interfaces from types, crypto, and SDK std.
-func RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) {
- std.RegisterInterfaces(interfaceRegistry)
- cryptocodec.RegisterInterfaces(interfaceRegistry)
- eth.RegisterInterfaces(interfaceRegistry)
-}
diff --git a/eth/encoding/config.go b/eth/encoding/config.go
deleted file mode 100644
index ac8962c31..000000000
--- a/eth/encoding/config.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package encoding
-
-import (
- "cosmossdk.io/simapp/params"
- amino "github.com/cosmos/cosmos-sdk/codec"
- "github.com/cosmos/cosmos-sdk/codec/types"
- "github.com/cosmos/cosmos-sdk/types/module"
- "github.com/cosmos/cosmos-sdk/x/auth/tx"
-
- enccodec "github.com/NibiruChain/nibiru/eth/encoding/codec"
-)
-
-// MakeConfig creates an EncodingConfig for testing
-func MakeConfig(mb module.BasicManager) params.EncodingConfig {
- cdc := amino.NewLegacyAmino()
- interfaceRegistry := types.NewInterfaceRegistry()
- codec := amino.NewProtoCodec(interfaceRegistry)
-
- encodingConfig := params.EncodingConfig{
- InterfaceRegistry: interfaceRegistry,
- Codec: codec,
- TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes),
- Amino: cdc,
- }
-
- enccodec.RegisterLegacyAminoCodec(encodingConfig.Amino)
- enccodec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
- mb.RegisterLegacyAminoCodec(encodingConfig.Amino)
- mb.RegisterInterfaces(encodingConfig.InterfaceRegistry)
- return encodingConfig
-}
diff --git a/eth/encoding/config_test.go b/eth/encoding/config_test.go
deleted file mode 100644
index 40f58901c..000000000
--- a/eth/encoding/config_test.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package encoding_test
-
-import (
- "math/big"
- "testing"
-
- "github.com/stretchr/testify/require"
-
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/eth/encoding"
- "github.com/NibiruChain/nibiru/x/evm"
- "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-func TestTxEncoding(t *testing.T) {
- addr, key := evmtest.PrivKeyEth()
- signer := evmtest.NewSigner(key)
-
- ethTxParams := evm.EvmTxArgs{
- ChainID: big.NewInt(1),
- Nonce: 1,
- Amount: big.NewInt(10),
- GasLimit: 100000,
- GasFeeCap: big.NewInt(1),
- GasTipCap: big.NewInt(1),
- Input: []byte{},
- }
- msg := evm.NewTx(ðTxParams)
- msg.From = addr.Hex()
-
- ethSigner := gethcore.LatestSignerForChainID(big.NewInt(1))
- err := msg.Sign(ethSigner, signer)
- require.NoError(t, err)
-
- cfg := encoding.MakeConfig(app.ModuleBasics)
-
- _, err = cfg.TxConfig.TxEncoder()(msg)
- require.Error(t, err, "encoding failed")
-}
diff --git a/eth/errors.go b/eth/errors.go
deleted file mode 100644
index 8f2ea84f4..000000000
--- a/eth/errors.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package eth
-
-import (
- sdkerrors "cosmossdk.io/errors"
-)
-
-var moduleErrorCodeIdx uint32 = 1
-
-func registerError(msg string) *sdkerrors.Error {
- moduleErrorCodeIdx += 1
- return sdkerrors.Register("eth", moduleErrorCodeIdx, msg)
-}
-
-// Module "sentinel" errors
-var (
- ErrInvalidChainID = registerError("invalid Ethereum chain ID")
-)
diff --git a/eth/eth_account.go b/eth/eth_account.go
deleted file mode 100644
index 781f09f06..000000000
--- a/eth/eth_account.go
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eth
-
-import (
- "bytes"
-
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
-)
-
-var (
- _ authtypes.AccountI = (*EthAccount)(nil)
- _ EthAccountI = (*EthAccount)(nil)
- _ authtypes.GenesisAccount = (*EthAccount)(nil)
- _ codectypes.UnpackInterfacesMessage = (*EthAccount)(nil)
-)
-
-// EthAccType: Enum for Ethereum account types.
-type EthAccType = int8
-
-const (
- // EthAccType_EOA: For externally owned accounts (EOAs)
- EthAccType_EOA EthAccType = iota + 1
- // EthAccType_Contract: For smart contracts accounts.
- EthAccType_Contract
-)
-
-// EthAccountI represents the interface of an EVM compatible account
-type EthAccountI interface { //revive:disable-line:exported
- authtypes.AccountI
- // EthAddress returns the ethereum Address representation of the AccAddress
- EthAddress() common.Address
- // CodeHash is the keccak256 hash of the contract code (if any)
- GetCodeHash() common.Hash
- // SetCodeHash sets the code hash to the account fields
- SetCodeHash(code common.Hash) error
- // Type returns the type of Ethereum Account (EOA or Contract)
- Type() EthAccType
-}
-
-func (acc EthAccount) GetBaseAccount() *authtypes.BaseAccount {
- return acc.BaseAccount
-}
-
-// EthAddress returns the account address ethereum format.
-func (acc EthAccount) EthAddress() common.Address {
- return common.BytesToAddress(acc.GetAddress().Bytes())
-}
-
-func (acc EthAccount) GetCodeHash() common.Hash {
- return common.HexToHash(acc.CodeHash)
-}
-
-func (acc *EthAccount) SetCodeHash(codeHash common.Hash) error {
- acc.CodeHash = codeHash.Hex()
- return nil
-}
-
-// Type returns the type of Ethereum Account (EOA or Contract)
-func (acc EthAccount) Type() EthAccType {
- if bytes.Equal(
- emptyCodeHash, common.HexToHash(acc.CodeHash).Bytes(),
- ) {
- return EthAccType_EOA
- }
- return EthAccType_Contract
-}
-
-var emptyCodeHash = crypto.Keccak256(nil)
-
-// ProtoBaseAccount: Implementation of `BaseAccount` for the `AccountI` interface
-// used in the AccountKeeper from the Auth Module. [ProtoBaseAccount] is a
-// drop-in replacement for the `auth.ProtoBaseAccount` from
-// "cosmos-sdk/auth/types" extended to fit the the `EthAccountI` interface for
-// Ethereum accounts.
-func ProtoBaseAccount() authtypes.AccountI {
- return &EthAccount{
- BaseAccount: &authtypes.BaseAccount{},
- CodeHash: common.BytesToHash(emptyCodeHash).String(),
- }
-}
diff --git a/eth/hdpath.go b/eth/hdpath.go
deleted file mode 100644
index c563e6fd0..000000000
--- a/eth/hdpath.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eth
-
-import (
- ethaccounts "github.com/ethereum/go-ethereum/accounts"
-)
-
-var (
- // Bip44CoinType satisfies EIP84. See https://github.com/ethereum/EIPs/issues/84 for more info.
- Bip44CoinType uint32 = 60
-
- // BIP44HDPath is the default BIP44 HD path used on Ethereum.
- BIP44HDPath = ethaccounts.DefaultBaseDerivationPath.String()
-)
-
-type (
- HDPathIterator func() ethaccounts.DerivationPath
-)
-
-// HDPathIterator receives a base path as a string and a boolean for the desired iterator type and
-// returns a function that iterates over the base HD path, returning the string.
-func NewHDPathIterator(basePath string, ledgerIter bool) (HDPathIterator, error) {
- hdPath, err := ethaccounts.ParseDerivationPath(basePath)
- if err != nil {
- return nil, err
- }
-
- if ledgerIter {
- return ethaccounts.LedgerLiveIterator(hdPath), nil
- }
-
- return ethaccounts.DefaultIterator(hdPath), nil
-}
diff --git a/eth/indexer.go b/eth/indexer.go
deleted file mode 100644
index bf2dda109..000000000
--- a/eth/indexer.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package eth
-
-import (
- abci "github.com/cometbft/cometbft/abci/types"
- tmtypes "github.com/cometbft/cometbft/types"
- "github.com/ethereum/go-ethereum/common"
-)
-
-// EVMTxIndexer defines the interface of custom eth tx indexer.
-type EVMTxIndexer interface {
- // LastIndexedBlock returns -1 if indexer db is empty
- LastIndexedBlock() (int64, error)
- IndexBlock(*tmtypes.Block, []*abci.ResponseDeliverTx) error
-
- // GetByTxHash returns nil if tx not found.
- GetByTxHash(common.Hash) (*TxResult, error)
- // GetByBlockAndIndex returns nil if tx not found.
- GetByBlockAndIndex(int64, int32) (*TxResult, error)
-}
diff --git a/eth/indexer.pb.go b/eth/indexer.pb.go
deleted file mode 100644
index 93a3ddb8c..000000000
--- a/eth/indexer.pb.go
+++ /dev/null
@@ -1,486 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: eth/types/v1/indexer.proto
-
-package eth
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// TxResult is the value stored in eth tx indexer
-type TxResult struct {
- // height of the blockchain
- Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
- // tx_index of the cosmos transaction
- TxIndex uint32 `protobuf:"varint,2,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"`
- // msg_index in a batch transaction
- MsgIndex uint32 `protobuf:"varint,3,opt,name=msg_index,json=msgIndex,proto3" json:"msg_index,omitempty"`
- // eth_tx_index is the index in the list of valid eth tx in the block,
- // aka. the transaction list returned by eth_getBlock api.
- EthTxIndex int32 `protobuf:"varint,4,opt,name=eth_tx_index,json=ethTxIndex,proto3" json:"eth_tx_index,omitempty"`
- // failed is true if the eth transaction did not go succeed
- Failed bool `protobuf:"varint,5,opt,name=failed,proto3" json:"failed,omitempty"`
- // gas_used by the transaction. If it exceeds the block gas limit,
- // it's set to gas limit, which is what's actually deducted by ante handler.
- GasUsed uint64 `protobuf:"varint,6,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"`
- // cumulative_gas_used specifies the cumulated amount of gas used for all
- // processed messages within the current batch transaction.
- CumulativeGasUsed uint64 `protobuf:"varint,7,opt,name=cumulative_gas_used,json=cumulativeGasUsed,proto3" json:"cumulative_gas_used,omitempty"`
-}
-
-func (m *TxResult) Reset() { *m = TxResult{} }
-func (m *TxResult) String() string { return proto.CompactTextString(m) }
-func (*TxResult) ProtoMessage() {}
-func (*TxResult) Descriptor() ([]byte, []int) {
- return fileDescriptor_6eb4a496a6639a52, []int{0}
-}
-func (m *TxResult) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *TxResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_TxResult.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *TxResult) XXX_Merge(src proto.Message) {
- xxx_messageInfo_TxResult.Merge(m, src)
-}
-func (m *TxResult) XXX_Size() int {
- return m.Size()
-}
-func (m *TxResult) XXX_DiscardUnknown() {
- xxx_messageInfo_TxResult.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_TxResult proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*TxResult)(nil), "eth.types.v1.TxResult")
-}
-
-func init() { proto.RegisterFile("eth/types/v1/indexer.proto", fileDescriptor_6eb4a496a6639a52) }
-
-var fileDescriptor_6eb4a496a6639a52 = []byte{
- // 300 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x90, 0xb1, 0x4e, 0xeb, 0x30,
- 0x18, 0x85, 0xe3, 0xdb, 0x36, 0xcd, 0xb5, 0x60, 0x20, 0xa0, 0x2a, 0x14, 0x29, 0x18, 0xa6, 0x4c,
- 0xb1, 0x2a, 0x36, 0xd8, 0x60, 0x40, 0x2c, 0x0c, 0x56, 0x59, 0x58, 0xa2, 0xb4, 0xf9, 0xb1, 0x2d,
- 0x35, 0x4d, 0x55, 0xff, 0xae, 0xc2, 0x1b, 0x30, 0xf2, 0x08, 0x3c, 0x0e, 0x63, 0x47, 0x46, 0xd4,
- 0x8a, 0xf7, 0x40, 0x71, 0xa3, 0xb2, 0x9d, 0xa3, 0xef, 0x3b, 0xb6, 0x65, 0x3a, 0x04, 0x54, 0x1c,
- 0x5f, 0x17, 0x60, 0xf8, 0x6a, 0xc4, 0xf5, 0xbc, 0x80, 0x1a, 0x96, 0xe9, 0x62, 0x59, 0x61, 0x15,
- 0x1e, 0x00, 0xaa, 0xd4, 0xb1, 0x74, 0x35, 0x1a, 0x9e, 0xc8, 0x4a, 0x56, 0x0e, 0xf0, 0x26, 0xed,
- 0x9c, 0xcb, 0x1f, 0x42, 0x83, 0x71, 0x2d, 0xc0, 0xd8, 0x19, 0x86, 0x03, 0xea, 0x2b, 0xd0, 0x52,
- 0x61, 0x44, 0x18, 0x49, 0x3a, 0xa2, 0x6d, 0xe1, 0x29, 0x0d, 0xb0, 0xce, 0xdc, 0xe1, 0xd1, 0x3f,
- 0x46, 0x92, 0x43, 0xd1, 0xc7, 0xfa, 0xa1, 0xa9, 0xe1, 0x19, 0xfd, 0x5f, 0x1a, 0xd9, 0xb2, 0x8e,
- 0x63, 0x41, 0x69, 0xe4, 0x0e, 0x32, 0xda, 0x3c, 0x21, 0xdb, 0x6f, 0xbb, 0x8c, 0x24, 0x3d, 0x41,
- 0x01, 0xd5, 0xb8, 0x9d, 0x0f, 0xa8, 0xff, 0x92, 0xeb, 0x19, 0x14, 0x51, 0x8f, 0x91, 0x24, 0x10,
- 0x6d, 0x6b, 0x6e, 0x94, 0xb9, 0xc9, 0xac, 0x81, 0x22, 0xf2, 0x19, 0x49, 0xba, 0xa2, 0x2f, 0x73,
- 0xf3, 0x64, 0xa0, 0x08, 0x53, 0x7a, 0x3c, 0xb5, 0xa5, 0x9d, 0xe5, 0xa8, 0x57, 0x90, 0xed, 0xad,
- 0xbe, 0xb3, 0x8e, 0xfe, 0xd0, 0xfd, 0xce, 0xbf, 0xee, 0xbe, 0x7d, 0x9c, 0x7b, 0xb7, 0x37, 0x9f,
- 0x9b, 0x98, 0xac, 0x37, 0x31, 0xf9, 0xde, 0xc4, 0xe4, 0x7d, 0x1b, 0x7b, 0xeb, 0x6d, 0xec, 0x7d,
- 0x6d, 0x63, 0xef, 0xf9, 0x42, 0x6a, 0x54, 0x76, 0x92, 0x4e, 0xab, 0x92, 0x3f, 0xea, 0x89, 0x5e,
- 0xda, 0x3b, 0x95, 0xeb, 0x39, 0x9f, 0xbb, 0xcc, 0x01, 0xd5, 0xc4, 0x77, 0x7f, 0x75, 0xf5, 0x1b,
- 0x00, 0x00, 0xff, 0xff, 0xd4, 0xa8, 0xcc, 0x00, 0x6d, 0x01, 0x00, 0x00,
-}
-
-func (m *TxResult) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *TxResult) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *TxResult) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.CumulativeGasUsed != 0 {
- i = encodeVarintIndexer(dAtA, i, uint64(m.CumulativeGasUsed))
- i--
- dAtA[i] = 0x38
- }
- if m.GasUsed != 0 {
- i = encodeVarintIndexer(dAtA, i, uint64(m.GasUsed))
- i--
- dAtA[i] = 0x30
- }
- if m.Failed {
- i--
- if m.Failed {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x28
- }
- if m.EthTxIndex != 0 {
- i = encodeVarintIndexer(dAtA, i, uint64(m.EthTxIndex))
- i--
- dAtA[i] = 0x20
- }
- if m.MsgIndex != 0 {
- i = encodeVarintIndexer(dAtA, i, uint64(m.MsgIndex))
- i--
- dAtA[i] = 0x18
- }
- if m.TxIndex != 0 {
- i = encodeVarintIndexer(dAtA, i, uint64(m.TxIndex))
- i--
- dAtA[i] = 0x10
- }
- if m.Height != 0 {
- i = encodeVarintIndexer(dAtA, i, uint64(m.Height))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintIndexer(dAtA []byte, offset int, v uint64) int {
- offset -= sovIndexer(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *TxResult) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.Height != 0 {
- n += 1 + sovIndexer(uint64(m.Height))
- }
- if m.TxIndex != 0 {
- n += 1 + sovIndexer(uint64(m.TxIndex))
- }
- if m.MsgIndex != 0 {
- n += 1 + sovIndexer(uint64(m.MsgIndex))
- }
- if m.EthTxIndex != 0 {
- n += 1 + sovIndexer(uint64(m.EthTxIndex))
- }
- if m.Failed {
- n += 2
- }
- if m.GasUsed != 0 {
- n += 1 + sovIndexer(uint64(m.GasUsed))
- }
- if m.CumulativeGasUsed != 0 {
- n += 1 + sovIndexer(uint64(m.CumulativeGasUsed))
- }
- return n
-}
-
-func sovIndexer(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozIndexer(x uint64) (n int) {
- return sovIndexer(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *TxResult) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: TxResult: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: TxResult: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType)
- }
- m.Height = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Height |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field TxIndex", wireType)
- }
- m.TxIndex = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.TxIndex |= uint32(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MsgIndex", wireType)
- }
- m.MsgIndex = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MsgIndex |= uint32(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EthTxIndex", wireType)
- }
- m.EthTxIndex = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.EthTxIndex |= int32(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Failed", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Failed = bool(v != 0)
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasUsed", wireType)
- }
- m.GasUsed = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.GasUsed |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 7:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CumulativeGasUsed", wireType)
- }
- m.CumulativeGasUsed = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.CumulativeGasUsed |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipIndexer(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthIndexer
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipIndexer(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowIndexer
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthIndexer
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupIndexer
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthIndexer
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthIndexer = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowIndexer = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupIndexer = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/eth/indexer/kv_indexer.go b/eth/indexer/kv_indexer.go
deleted file mode 100644
index cb3054aef..000000000
--- a/eth/indexer/kv_indexer.go
+++ /dev/null
@@ -1,231 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package indexer
-
-import (
- "fmt"
-
- errorsmod "cosmossdk.io/errors"
- dbm "github.com/cometbft/cometbft-db"
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cometbft/cometbft/libs/log"
- tmtypes "github.com/cometbft/cometbft/types"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
- authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
- "github.com/ethereum/go-ethereum/common"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-const (
- KeyPrefixTxHash = 1
- KeyPrefixTxIndex = 2
-
- // TxIndexKeyLength is the length of tx-index key
- TxIndexKeyLength = 1 + 8 + 8
-)
-
-var _ eth.EVMTxIndexer = &KVIndexer{}
-
-// KVIndexer implements a eth tx indexer on a KV db.
-type KVIndexer struct {
- db dbm.DB
- logger log.Logger
- clientCtx client.Context
-}
-
-// NewKVIndexer creates the KVIndexer
-func NewKVIndexer(db dbm.DB, logger log.Logger, clientCtx client.Context) *KVIndexer {
- return &KVIndexer{db, logger, clientCtx}
-}
-
-// IndexBlock index all the eth txs in a block through the following steps:
-// - Iterates over all of the Txs in Block
-// - Parses eth Tx infos from cosmos-sdk events for every TxResult
-// - Iterates over all the messages of the Tx
-// - Builds and stores a indexer.TxResult based on parsed events for every message
-func (kv *KVIndexer) IndexBlock(block *tmtypes.Block, txResults []*abci.ResponseDeliverTx) error {
- height := block.Header.Height
-
- batch := kv.db.NewBatch()
- defer batch.Close()
-
- // record index of valid eth tx during the iteration
- var ethTxIndex int32
- for txIndex, tx := range block.Txs {
- result := txResults[txIndex]
- if !rpc.TxSuccessOrExpectedFailure(result) {
- continue
- }
-
- tx, err := kv.clientCtx.TxConfig.TxDecoder()(tx)
- if err != nil {
- kv.logger.Error("Fail to decode tx", "err", err, "block", height, "txIndex", txIndex)
- continue
- }
-
- if !isEthTx(tx) {
- continue
- }
-
- txs, err := rpc.ParseTxResult(result, tx)
- if err != nil {
- kv.logger.Error("Fail to parse event", "err", err, "block", height, "txIndex", txIndex)
- continue
- }
-
- var cumulativeGasUsed uint64
- for msgIndex, msg := range tx.GetMsgs() {
- ethMsg := msg.(*evm.MsgEthereumTx)
- txHash := common.HexToHash(ethMsg.Hash)
-
- txResult := eth.TxResult{
- Height: height,
- TxIndex: uint32(txIndex),
- MsgIndex: uint32(msgIndex),
- EthTxIndex: ethTxIndex,
- }
- if result.Code != abci.CodeTypeOK {
- // exceeds block gas limit scenario, set gas used to gas limit because that's what's charged by ante handler.
- // some old versions don't emit any events, so workaround here directly.
- txResult.GasUsed = ethMsg.GetGas()
- txResult.Failed = true
- } else {
- parsedTx := txs.GetTxByMsgIndex(msgIndex)
- if parsedTx == nil {
- kv.logger.Error("msg index not found in events", "msgIndex", msgIndex)
- continue
- }
- if parsedTx.EthTxIndex >= 0 && parsedTx.EthTxIndex != ethTxIndex {
- kv.logger.Error("eth tx index don't match", "expect", ethTxIndex, "found", parsedTx.EthTxIndex)
- }
- txResult.GasUsed = parsedTx.GasUsed
- txResult.Failed = parsedTx.Failed
- }
-
- cumulativeGasUsed += txResult.GasUsed
- txResult.CumulativeGasUsed = cumulativeGasUsed
- ethTxIndex++
-
- if err := saveTxResult(kv.clientCtx.Codec, batch, txHash, &txResult); err != nil {
- return errorsmod.Wrapf(err, "IndexBlock %d", height)
- }
- }
- }
- if err := batch.Write(); err != nil {
- return errorsmod.Wrapf(err, "IndexBlock %d, write batch", block.Height)
- }
- return nil
-}
-
-// LastIndexedBlock returns the latest indexed block number, returns -1 if db is empty
-func (kv *KVIndexer) LastIndexedBlock() (int64, error) {
- return LoadLastBlock(kv.db)
-}
-
-// FirstIndexedBlock returns the first indexed block number, returns -1 if db is empty
-func (kv *KVIndexer) FirstIndexedBlock() (int64, error) {
- return LoadFirstBlock(kv.db)
-}
-
-// GetByTxHash finds eth tx by eth tx hash
-func (kv *KVIndexer) GetByTxHash(hash common.Hash) (*eth.TxResult, error) {
- bz, err := kv.db.Get(TxHashKey(hash))
- if err != nil {
- return nil, errorsmod.Wrapf(err, "GetByTxHash %s", hash.Hex())
- }
- if len(bz) == 0 {
- return nil, fmt.Errorf("tx not found, hash: %s", hash.Hex())
- }
- var txKey eth.TxResult
- if err := kv.clientCtx.Codec.Unmarshal(bz, &txKey); err != nil {
- return nil, errorsmod.Wrapf(err, "GetByTxHash %s", hash.Hex())
- }
- return &txKey, nil
-}
-
-// GetByBlockAndIndex finds eth tx by block number and eth tx index
-func (kv *KVIndexer) GetByBlockAndIndex(blockNumber int64, txIndex int32) (*eth.TxResult, error) {
- bz, err := kv.db.Get(TxIndexKey(blockNumber, txIndex))
- if err != nil {
- return nil, errorsmod.Wrapf(err, "GetByBlockAndIndex %d %d", blockNumber, txIndex)
- }
- if len(bz) == 0 {
- return nil, fmt.Errorf("tx not found, block: %d, eth-index: %d", blockNumber, txIndex)
- }
- return kv.GetByTxHash(common.BytesToHash(bz))
-}
-
-// TxHashKey returns the key for db entry: `tx hash -> tx result struct`
-func TxHashKey(hash common.Hash) []byte {
- return append([]byte{KeyPrefixTxHash}, hash.Bytes()...)
-}
-
-// TxIndexKey returns the key for db entry: `(block number, tx index) -> tx hash`
-func TxIndexKey(blockNumber int64, txIndex int32) []byte {
- bz1 := sdk.Uint64ToBigEndian(uint64(blockNumber))
- bz2 := sdk.Uint64ToBigEndian(uint64(txIndex))
- return append(append([]byte{KeyPrefixTxIndex}, bz1...), bz2...)
-}
-
-// LoadLastBlock returns the latest indexed block number, returns -1 if db is empty
-func LoadLastBlock(db dbm.DB) (int64, error) {
- it, err := db.ReverseIterator([]byte{KeyPrefixTxIndex}, []byte{KeyPrefixTxIndex + 1})
- if err != nil {
- return 0, errorsmod.Wrap(err, "LoadLastBlock")
- }
- defer it.Close()
- if !it.Valid() {
- return -1, nil
- }
- return parseBlockNumberFromKey(it.Key())
-}
-
-// LoadFirstBlock loads the first indexed block, returns -1 if db is empty
-func LoadFirstBlock(db dbm.DB) (int64, error) {
- it, err := db.Iterator([]byte{KeyPrefixTxIndex}, []byte{KeyPrefixTxIndex + 1})
- if err != nil {
- return 0, errorsmod.Wrap(err, "LoadFirstBlock")
- }
- defer it.Close()
- if !it.Valid() {
- return -1, nil
- }
- return parseBlockNumberFromKey(it.Key())
-}
-
-// isEthTx check if the tx is an eth tx
-func isEthTx(tx sdk.Tx) bool {
- extTx, ok := tx.(authante.HasExtensionOptionsTx)
- if !ok {
- return false
- }
- opts := extTx.GetExtensionOptions()
- if len(opts) != 1 || opts[0].GetTypeUrl() != "/eth.evm.v1.ExtensionOptionsEthereumTx" {
- return false
- }
- return true
-}
-
-// saveTxResult index the txResult into the kv db batch
-func saveTxResult(codec codec.Codec, batch dbm.Batch, txHash common.Hash, txResult *eth.TxResult) error {
- bz := codec.MustMarshal(txResult)
- if err := batch.Set(TxHashKey(txHash), bz); err != nil {
- return errorsmod.Wrap(err, "set tx-hash key")
- }
- if err := batch.Set(TxIndexKey(txResult.Height, txResult.EthTxIndex), txHash.Bytes()); err != nil {
- return errorsmod.Wrap(err, "set tx-index key")
- }
- return nil
-}
-
-func parseBlockNumberFromKey(key []byte) (int64, error) {
- if len(key) != TxIndexKeyLength {
- return 0, fmt.Errorf("wrong tx index key length, expect: %d, got: %d", TxIndexKeyLength, len(key))
- }
-
- return int64(sdk.BigEndianToUint64(key[1:9])), nil
-}
diff --git a/eth/indexer/kv_indexer_test.go b/eth/indexer/kv_indexer_test.go
deleted file mode 100644
index bb446aa71..000000000
--- a/eth/indexer/kv_indexer_test.go
+++ /dev/null
@@ -1,200 +0,0 @@
-package indexer_test
-
-import (
- "math/big"
- "testing"
-
- "cosmossdk.io/simapp/params"
- dbm "github.com/cometbft/cometbft-db"
- abci "github.com/cometbft/cometbft/abci/types"
- tmlog "github.com/cometbft/cometbft/libs/log"
- tmtypes "github.com/cometbft/cometbft/types"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
- evmenc "github.com/NibiruChain/nibiru/eth/encoding"
- "github.com/NibiruChain/nibiru/eth/indexer"
- "github.com/NibiruChain/nibiru/x/evm"
- evmtest "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-func TestKVIndexer(t *testing.T) {
- priv, err := ethsecp256k1.GenerateKey()
- require.NoError(t, err)
- from := common.BytesToAddress(priv.PubKey().Address().Bytes())
- signer := evmtest.NewSigner(priv)
- ethSigner := gethcore.LatestSignerForChainID(nil)
-
- to := common.BigToAddress(big.NewInt(1))
- ethTxParams := evm.EvmTxArgs{
- Nonce: 0,
- To: &to,
- Amount: big.NewInt(1000),
- GasLimit: 21000,
- }
- tx := evm.NewTx(ðTxParams)
- tx.From = from.Hex()
- require.NoError(t, tx.Sign(ethSigner, signer))
- txHash := tx.AsTransaction().Hash()
-
- // encCfg := MakeEncodingConfig()
- encCfg := app.MakeEncodingConfig()
- eth.RegisterInterfaces(encCfg.InterfaceRegistry)
- evm.RegisterInterfaces(encCfg.InterfaceRegistry)
- clientCtx := client.Context{}.
- WithTxConfig(encCfg.TxConfig).
- WithCodec(encCfg.Codec)
-
- // build cosmos-sdk wrapper tx
- tmTx, err := tx.BuildTx(clientCtx.TxConfig.NewTxBuilder(), eth.EthBaseDenom)
- require.NoError(t, err)
- txBz, err := clientCtx.TxConfig.TxEncoder()(tmTx)
- require.NoError(t, err)
-
- // build an invalid wrapper tx
- builder := clientCtx.TxConfig.NewTxBuilder()
- require.NoError(t, builder.SetMsgs(tx))
- tmTx2 := builder.GetTx()
- txBz2, err := clientCtx.TxConfig.TxEncoder()(tmTx2)
- require.NoError(t, err)
-
- testCases := []struct {
- name string
- block *tmtypes.Block
- blockResult []*abci.ResponseDeliverTx
- expSuccess bool
- }{
- {
- "success, format 1",
- &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "0"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: ""},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- },
- },
- },
- true,
- },
- {
- "success, format 2",
- &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "0"},
- }},
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: "14A84ED06282645EFBF080E0B7ED80D8D8D6A36337668A12B5F229F81CDD3F57"},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- },
- },
- },
- true,
- },
- {
- "success, exceed block gas limit",
- &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 11,
- Log: "out of gas in location: block gas meter; gasWanted: 21000",
- Events: []abci.Event{},
- },
- },
- true,
- },
- {
- "fail, failed eth tx",
- &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 15,
- Log: "nonce mismatch",
- Events: []abci.Event{},
- },
- },
- false,
- },
- {
- "fail, invalid events",
- &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{},
- },
- },
- false,
- },
- {
- "fail, not eth tx",
- &tmtypes.Block{Header: tmtypes.Header{Height: 1}, Data: tmtypes.Data{Txs: []tmtypes.Tx{txBz2}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{},
- },
- },
- false,
- },
- }
-
- for _, tc := range testCases {
- t.Run(tc.name, func(t *testing.T) {
- db := dbm.NewMemDB()
- idxer := indexer.NewKVIndexer(db, tmlog.NewNopLogger(), clientCtx)
-
- err = idxer.IndexBlock(tc.block, tc.blockResult)
- require.NoError(t, err)
- if !tc.expSuccess {
- first, err := idxer.FirstIndexedBlock()
- require.NoError(t, err)
- require.Equal(t, int64(-1), first)
-
- last, err := idxer.LastIndexedBlock()
- require.NoError(t, err)
- require.Equal(t, int64(-1), last)
- } else {
- first, err := idxer.FirstIndexedBlock()
- require.NoError(t, err)
- require.Equal(t, tc.block.Header.Height, first)
-
- last, err := idxer.LastIndexedBlock()
- require.NoError(t, err)
- require.Equal(t, tc.block.Header.Height, last)
-
- res1, err := idxer.GetByTxHash(txHash)
- require.NoError(t, err)
- require.NotNil(t, res1)
- res2, err := idxer.GetByBlockAndIndex(1, 0)
- require.NoError(t, err)
- require.Equal(t, res1, res2)
- }
- })
- }
-}
-
-// MakeEncodingConfig creates the EncodingConfig
-func MakeEncodingConfig() params.EncodingConfig {
- return evmenc.MakeConfig(app.ModuleBasics)
-}
diff --git a/eth/rpc/addrlocker.go b/eth/rpc/addrlocker.go
deleted file mode 100644
index 3722a447e..000000000
--- a/eth/rpc/addrlocker.go
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpc
-
-import (
- "sync"
-
- "github.com/ethereum/go-ethereum/common"
-)
-
-// AddrLocker is a mutex (mutual exclusion lock) structure used to avoid querying
-// outdated account data. It prevents data races by allowing only one goroutine
-// to access critical sections at a time.
-type AddrLocker struct {
- // mu protects access to the locks map
- mu sync.Mutex
- locks map[common.Address]*sync.Mutex
-}
-
-// lock returns the mutex lock of the given Ethereum address. If no mutex exists
-// for the address, it creates a new one. This function ensures that each address
-// has exactly one mutex associated with it, and it is thread-safe.
-//
-// The returned mutex is not locked; callers are responsible for locking and
-// unlocking it as necessary.
-func (l *AddrLocker) lock(address common.Address) *sync.Mutex {
- l.mu.Lock()
- defer l.mu.Unlock()
- if l.locks == nil {
- l.locks = make(map[common.Address]*sync.Mutex)
- }
- if _, ok := l.locks[address]; !ok {
- l.locks[address] = new(sync.Mutex)
- }
- return l.locks[address]
-}
-
-// LockAddr acquires the mutex for a specific address, blocking if it is already
-// held by another goroutine. The mutex lock prevents an identical nonce from
-// being read again during the time that the first transaction is being signed.
-func (l *AddrLocker) LockAddr(address common.Address) {
- l.lock(address).Lock()
-}
-
-// UnlockAddr unlocks the mutex for a specific address, allowing other goroutines
-// to acquire it.
-func (l *AddrLocker) UnlockAddr(address common.Address) {
- l.lock(address).Unlock()
-}
diff --git a/eth/rpc/addrlocker_test.go b/eth/rpc/addrlocker_test.go
deleted file mode 100644
index f215a507b..000000000
--- a/eth/rpc/addrlocker_test.go
+++ /dev/null
@@ -1,126 +0,0 @@
-package rpc_test
-
-import (
- "sync"
- "testing"
- "time"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/stretchr/testify/suite"
-
- rpc "github.com/NibiruChain/nibiru/eth/rpc"
-)
-
-type SuiteAddrLocker struct {
- suite.Suite
-}
-
-func TestSuiteAddrLocker(t *testing.T) {
- suite.Run(t, new(SuiteAddrLocker))
-}
-
-// TestLockAddr: This test checks that the lock mechanism prevents multiple
-// goroutines from entering critical sections of code simultaneously for the same
-// address.
-func (s *SuiteAddrLocker) TestLockAddr() {
- // Setup: Lock the address
- locker := &rpc.AddrLocker{}
- addr := common.HexToAddress("0x123")
- locker.LockAddr(addr)
-
- // Concurrent Lock Attempt: Attempt to lock again in a separate goroutine. If
- // the initial lock is effective, this attempt should block and not complete
- // immediately.
- done := make(chan bool)
- go func() {
- locker.LockAddr(addr) // This should block if the first lock is effective
- done <- true
- }()
-
- // Assertion: A select statement is used to check if the channel receives a
- // value, which would indicate the lock did not block as expected.
- select {
- case <-done:
- s.Fail("LockAddr did not block the second call as expected")
- default:
- // expected behavior, continue test
- }
-
- // Cleanup: Unlock and allow the goroutine to proceed
- locker.UnlockAddr(addr)
- <-done // Ensure goroutine completes
-}
-
-func (s *SuiteAddrLocker) TestUnlockAddr() {
- // Setup: Lock the address
- locker := &rpc.AddrLocker{}
- addr := common.HexToAddress("0x123")
- locker.LockAddr(addr)
-
- locker.UnlockAddr(addr)
-
- // Try re-locking to test if unlock was successful
- locked := make(chan bool)
- go func() {
- locker.LockAddr(addr) // This should not block if unlock worked
- locked <- true
- locker.UnlockAddr(addr)
- }()
-
- select {
- case <-locked:
- // expected behavior, continue
- case <-time.After(time.Second):
- s.Fail("UnlockAddr did not effectively unlock the mutex")
- }
-}
-
-func (s *SuiteAddrLocker) TestMultipleAddresses() {
- locker := &rpc.AddrLocker{}
- addr1 := common.HexToAddress("0x123")
- addr2 := common.HexToAddress("0x456")
-
- locker.LockAddr(addr1)
- locked := make(chan bool)
-
- go func() {
- locker.LockAddr(addr2) // This should not block if locks are address-specific
- locked <- true
- locker.UnlockAddr(addr2)
- }()
-
- select {
- case <-locked:
- // expected behavior, continue
- case <-time.After(time.Second):
- s.Fail("Locks are not address-specific as expected")
- }
-
- locker.UnlockAddr(addr1)
-}
-
-// TestConcurrentAccess: Tests the system's behavior under high concurrency,
-// specifically ensuring that the lock can handle multiple locking and unlocking
-// operations on the same address without leading to race conditions or
-// deadlocks.
-func (s *SuiteAddrLocker) TestConcurrentAccess() {
- locker := &rpc.AddrLocker{}
- addr := common.HexToAddress("0x789")
- var wg sync.WaitGroup
-
- // Spawn 100 goroutines, each locking and unlocking the same address.
- // Each routine will hod the lock briefly to simulate work done during the
- // lock (like an Ethereum query).
- for i := 0; i < 100; i++ {
- wg.Add(1)
- go func() {
- locker.LockAddr(addr)
- time.Sleep(time.Millisecond * 5) // Simulate work
- locker.UnlockAddr(addr)
- wg.Done()
- }()
- }
-
- // Cleanup: Wait for all goroutines to complete
- wg.Wait()
-}
diff --git a/eth/rpc/backend/account_info.go b/eth/rpc/backend/account_info.go
deleted file mode 100644
index a3340983d..000000000
--- a/eth/rpc/backend/account_info.go
+++ /dev/null
@@ -1,223 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "fmt"
- "math"
- "math/big"
-
- errorsmod "cosmossdk.io/errors"
-
- sdkmath "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/pkg/errors"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// GetCode returns the contract code at the given address and block number.
-func (b *Backend) GetCode(
- address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
-) (hexutil.Bytes, error) {
- blockNum, err := b.BlockNumberFromTendermint(blockNrOrHash)
- if err != nil {
- return nil, err
- }
-
- req := &evm.QueryCodeRequest{
- Address: address.String(),
- }
-
- res, err := b.queryClient.Code(rpc.NewContextWithHeight(blockNum.Int64()), req)
- if err != nil {
- return nil, err
- }
-
- return res.Code, nil
-}
-
-// GetProof returns an account object with proof and any storage proofs
-func (b *Backend) GetProof(
- address common.Address,
- storageKeys []string,
- blockNrOrHash rpc.BlockNumberOrHash,
-) (*rpc.AccountResult, error) {
- blockNum, err := b.BlockNumberFromTendermint(blockNrOrHash)
- if err != nil {
- return nil, err
- }
-
- height := blockNum.Int64()
-
- _, err = b.TendermintBlockByNumber(blockNum)
- if err != nil {
- // the error message imitates geth behavior
- return nil, errors.New("header not found")
- }
- ctx := rpc.NewContextWithHeight(height)
-
- // if the height is equal to zero, meaning the query condition of the block is either "pending" or "latest"
- if height == 0 {
- bn, err := b.BlockNumber()
- if err != nil {
- return nil, err
- }
-
- if bn > math.MaxInt64 {
- return nil, fmt.Errorf("not able to query block number greater than MaxInt64")
- }
-
- height = int64(bn) //#nosec G701 -- checked for int overflow already
- }
-
- clientCtx := b.clientCtx.WithHeight(height)
-
- // query storage proofs
- storageProofs := make([]rpc.StorageResult, len(storageKeys))
-
- for i, key := range storageKeys {
- hexKey := common.HexToHash(key)
- valueBz, proof, err := b.queryClient.GetProof(clientCtx, evm.StoreKey, evm.StateKey(address, hexKey.Bytes()))
- if err != nil {
- return nil, err
- }
-
- storageProofs[i] = rpc.StorageResult{
- Key: key,
- Value: (*hexutil.Big)(new(big.Int).SetBytes(valueBz)),
- Proof: GetHexProofs(proof),
- }
- }
-
- // query EVM account
- req := &evm.QueryEthAccountRequest{
- Address: address.String(),
- }
-
- res, err := b.queryClient.EthAccount(ctx, req)
- if err != nil {
- return nil, err
- }
-
- // query account proofs
- accountKey := authtypes.AddressStoreKey(sdk.AccAddress(address.Bytes()))
- _, proof, err := b.queryClient.GetProof(clientCtx, authtypes.StoreKey, accountKey)
- if err != nil {
- return nil, err
- }
-
- balance, ok := sdkmath.NewIntFromString(res.Balance)
- if !ok {
- return nil, errors.New("invalid balance")
- }
-
- return &rpc.AccountResult{
- Address: address,
- AccountProof: GetHexProofs(proof),
- Balance: (*hexutil.Big)(balance.BigInt()),
- CodeHash: common.HexToHash(res.CodeHash),
- Nonce: hexutil.Uint64(res.Nonce),
- // NOTE: The StorageHash is blank. Consider whether this is useful in the
- // future. Currently, all storage is handles by persistent and transient
- // `sdk.KVStore` objects.
- StorageHash: common.Hash{},
- StorageProof: storageProofs,
- }, nil
-}
-
-// GetStorageAt returns the contract storage at the given address, block number, and key.
-func (b *Backend) GetStorageAt(address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) {
- blockNum, err := b.BlockNumberFromTendermint(blockNrOrHash)
- if err != nil {
- return nil, err
- }
-
- req := &evm.QueryStorageRequest{
- Address: address.String(),
- Key: key,
- }
-
- res, err := b.queryClient.Storage(rpc.NewContextWithHeight(blockNum.Int64()), req)
- if err != nil {
- return nil, err
- }
-
- value := common.HexToHash(res.Value)
- return value.Bytes(), nil
-}
-
-// GetBalance returns the provided account's balance up to the provided block number.
-func (b *Backend) GetBalance(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) {
- blockNum, err := b.BlockNumberFromTendermint(blockNrOrHash)
- if err != nil {
- return nil, err
- }
-
- req := &evm.QueryBalanceRequest{
- Address: address.String(),
- }
-
- _, err = b.TendermintBlockByNumber(blockNum)
- if err != nil {
- return nil, err
- }
-
- res, err := b.queryClient.Balance(rpc.NewContextWithHeight(blockNum.Int64()), req)
- if err != nil {
- return nil, err
- }
-
- val, ok := sdkmath.NewIntFromString(res.Balance)
- if !ok {
- return nil, errors.New("invalid balance")
- }
-
- // balance can only be negative in case of pruned node
- if val.IsNegative() {
- return nil, errors.New("couldn't fetch balance. Node state is pruned")
- }
-
- return (*hexutil.Big)(val.BigInt()), nil
-}
-
-// GetTransactionCount returns the number of transactions at the given address up to the given block number.
-func (b *Backend) GetTransactionCount(address common.Address, blockNum rpc.BlockNumber) (*hexutil.Uint64, error) {
- n := hexutil.Uint64(0)
- bn, err := b.BlockNumber()
- if err != nil {
- return &n, err
- }
- height := blockNum.Int64()
-
- currentHeight := int64(bn) //#nosec G701 -- checked for int overflow already
- if height > currentHeight {
- return &n, errorsmod.Wrapf(
- sdkerrors.ErrInvalidHeight,
- "cannot query with height in the future (current: %d, queried: %d); please provide a valid height",
- currentHeight, height,
- )
- }
- // Get nonce (sequence) from account
- from := sdk.AccAddress(address.Bytes())
- accRet := b.clientCtx.AccountRetriever
-
- err = accRet.EnsureExists(b.clientCtx, from)
- if err != nil {
- // account doesn't exist yet, return 0
- return &n, nil
- }
-
- includePending := blockNum == rpc.EthPendingBlockNumber
- nonce, err := b.getAccountNonce(address, includePending, blockNum.Int64(), b.logger)
- if err != nil {
- return nil, err
- }
-
- n = hexutil.Uint64(nonce)
- return &n, nil
-}
diff --git a/eth/rpc/backend/account_info_test.go b/eth/rpc/backend/account_info_test.go
deleted file mode 100644
index 64531bdec..000000000
--- a/eth/rpc/backend/account_info_test.go
+++ /dev/null
@@ -1,412 +0,0 @@
-package backend
-
-import (
- "fmt"
- "math/big"
-
- tmrpcclient "github.com/cometbft/cometbft/rpc/client"
- sdk "github.com/cosmos/cosmos-sdk/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "google.golang.org/grpc/metadata"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
- evmtest "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-func (s *BackendSuite) TestGetCode() {
- blockNr := rpc.NewBlockNumber(big.NewInt(1))
- contractCode := []byte(
- "0xef616c92f3cfc9e92dc270d6acff9cea213cecc7020a76ee4395af09bdceb4837a1ebdb5735e11e7d3adb6104e0c3ac55180b4ddf5e54d022cc5e8837f6a4f971b",
- )
-
- testCases := []struct {
- name string
- addr common.Address
- blockNrOrHash rpc.BlockNumberOrHash
- registerMock func(common.Address)
- expPass bool
- expCode hexutil.Bytes
- }{
- {
- "fail - BlockHash and BlockNumber are both nil ",
- evmtest.NewEthAddr(),
- rpc.BlockNumberOrHash{},
- func(addr common.Address) {},
- false,
- nil,
- },
- {
- "fail - query client errors on getting Code",
- evmtest.NewEthAddr(),
- rpc.BlockNumberOrHash{BlockNumber: &blockNr},
- func(addr common.Address) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterCodeError(queryClient, addr)
- },
- false,
- nil,
- },
- {
- "pass",
- evmtest.NewEthAddr(),
- rpc.BlockNumberOrHash{BlockNumber: &blockNr},
- func(addr common.Address) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterCode(queryClient, addr, contractCode)
- },
- true,
- contractCode,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset
- tc.registerMock(tc.addr)
-
- code, err := s.backend.GetCode(tc.addr, tc.blockNrOrHash)
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expCode, code)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetProof() {
- blockNrInvalid := rpc.NewBlockNumber(big.NewInt(1))
- blockNr := rpc.NewBlockNumber(big.NewInt(4))
- address1 := evmtest.NewEthAddr()
-
- testCases := []struct {
- name string
- addr common.Address
- storageKeys []string
- blockNrOrHash rpc.BlockNumberOrHash
- registerMock func(rpc.BlockNumber, common.Address)
- expPass bool
- expAccRes *rpc.AccountResult
- }{
- {
- "fail - BlockNumeber = 1 (invalidBlockNumber)",
- address1,
- []string{},
- rpc.BlockNumberOrHash{BlockNumber: &blockNrInvalid},
- func(bn rpc.BlockNumber, addr common.Address) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, bn.Int64(), nil)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterAccount(queryClient, addr, blockNrInvalid.Int64())
- },
- false,
- &rpc.AccountResult{},
- },
- {
- "fail - Block doesn't exist",
- address1,
- []string{},
- rpc.BlockNumberOrHash{BlockNumber: &blockNrInvalid},
- func(bn rpc.BlockNumber, addr common.Address) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockError(client, bn.Int64())
- },
- false,
- &rpc.AccountResult{},
- },
- {
- "pass",
- address1,
- []string{"0x0"},
- rpc.BlockNumberOrHash{BlockNumber: &blockNr},
- func(bn rpc.BlockNumber, addr common.Address) {
- s.backend.ctx = rpc.NewContextWithHeight(bn.Int64())
-
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, bn.Int64(), nil)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterAccount(queryClient, addr, bn.Int64())
-
- // Use the IAVL height if a valid tendermint height is passed in.
- iavlHeight := bn.Int64()
- RegisterABCIQueryWithOptions(
- client,
- bn.Int64(),
- "store/evm/key",
- evm.StateKey(address1, common.HexToHash("0x0").Bytes()),
- tmrpcclient.ABCIQueryOptions{Height: iavlHeight, Prove: true},
- )
- RegisterABCIQueryWithOptions(
- client,
- bn.Int64(),
- "store/acc/key",
- authtypes.AddressStoreKey(sdk.AccAddress(address1.Bytes())),
- tmrpcclient.ABCIQueryOptions{Height: iavlHeight, Prove: true},
- )
- },
- true,
- &rpc.AccountResult{
- Address: address1,
- AccountProof: []string{""},
- Balance: (*hexutil.Big)(big.NewInt(0)),
- CodeHash: common.HexToHash(""),
- Nonce: 0x0,
- StorageHash: common.Hash{},
- StorageProof: []rpc.StorageResult{
- {
- Key: "0x0",
- Value: (*hexutil.Big)(big.NewInt(2)),
- Proof: []string{""},
- },
- },
- },
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest()
- tc.registerMock(*tc.blockNrOrHash.BlockNumber, tc.addr)
-
- accRes, err := s.backend.GetProof(tc.addr, tc.storageKeys, tc.blockNrOrHash)
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expAccRes, accRes)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetStorageAt() {
- blockNr := rpc.NewBlockNumber(big.NewInt(1))
-
- testCases := []struct {
- name string
- addr common.Address
- key string
- blockNrOrHash rpc.BlockNumberOrHash
- registerMock func(common.Address, string, string)
- expPass bool
- expStorage hexutil.Bytes
- }{
- {
- "fail - BlockHash and BlockNumber are both nil",
- evmtest.NewEthAddr(),
- "0x0",
- rpc.BlockNumberOrHash{},
- func(addr common.Address, key string, storage string) {},
- false,
- nil,
- },
- {
- "fail - query client errors on getting Storage",
- evmtest.NewEthAddr(),
- "0x0",
- rpc.BlockNumberOrHash{BlockNumber: &blockNr},
- func(addr common.Address, key string, storage string) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterStorageAtError(queryClient, addr, key)
- },
- false,
- nil,
- },
- {
- "pass",
- evmtest.NewEthAddr(),
- "0x0",
- rpc.BlockNumberOrHash{BlockNumber: &blockNr},
- func(addr common.Address, key string, storage string) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterStorageAt(queryClient, addr, key, storage)
- },
- true,
- hexutil.Bytes{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest()
- tc.registerMock(tc.addr, tc.key, tc.expStorage.String())
-
- storage, err := s.backend.GetStorageAt(tc.addr, tc.key, tc.blockNrOrHash)
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expStorage, storage)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetEvmGasBalance() {
- blockNr := rpc.NewBlockNumber(big.NewInt(1))
-
- testCases := []struct {
- name string
- addr common.Address
- blockNrOrHash rpc.BlockNumberOrHash
- registerMock func(rpc.BlockNumber, common.Address)
- expPass bool
- expBalance *hexutil.Big
- }{
- {
- "fail - BlockHash and BlockNumber are both nil",
- evmtest.NewEthAddr(),
- rpc.BlockNumberOrHash{},
- func(bn rpc.BlockNumber, addr common.Address) {
- },
- false,
- nil,
- },
- {
- "fail - tendermint client failed to get block",
- evmtest.NewEthAddr(),
- rpc.BlockNumberOrHash{BlockNumber: &blockNr},
- func(bn rpc.BlockNumber, addr common.Address) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockError(client, bn.Int64())
- },
- false,
- nil,
- },
- {
- "fail - query client failed to get balance",
- evmtest.NewEthAddr(),
- rpc.BlockNumberOrHash{BlockNumber: &blockNr},
- func(bn rpc.BlockNumber, addr common.Address) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, bn.Int64(), nil)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBalanceError(queryClient, addr, bn.Int64())
- },
- false,
- nil,
- },
- {
- "fail - invalid balance",
- evmtest.NewEthAddr(),
- rpc.BlockNumberOrHash{BlockNumber: &blockNr},
- func(bn rpc.BlockNumber, addr common.Address) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, bn.Int64(), nil)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBalanceInvalid(queryClient, addr, bn.Int64())
- },
- false,
- nil,
- },
- {
- "fail - pruned node state",
- evmtest.NewEthAddr(),
- rpc.BlockNumberOrHash{BlockNumber: &blockNr},
- func(bn rpc.BlockNumber, addr common.Address) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, bn.Int64(), nil)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBalanceNegative(queryClient, addr, bn.Int64())
- },
- false,
- nil,
- },
- {
- "pass",
- evmtest.NewEthAddr(),
- rpc.BlockNumberOrHash{BlockNumber: &blockNr},
- func(bn rpc.BlockNumber, addr common.Address) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, bn.Int64(), nil)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBalance(queryClient, addr, bn.Int64())
- },
- true,
- (*hexutil.Big)(big.NewInt(1)),
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest()
-
- // avoid nil pointer reference
- if tc.blockNrOrHash.BlockNumber != nil {
- tc.registerMock(*tc.blockNrOrHash.BlockNumber, tc.addr)
- }
-
- balance, err := s.backend.GetBalance(tc.addr, tc.blockNrOrHash)
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expBalance, balance)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetTransactionCount() {
- testCases := []struct {
- name string
- accExists bool
- blockNum rpc.BlockNumber
- registerMock func(common.Address, rpc.BlockNumber)
- expPass bool
- expTxCount hexutil.Uint64
- }{
- {
- "pass - account doesn't exist",
- false,
- rpc.NewBlockNumber(big.NewInt(1)),
- func(addr common.Address, bn rpc.BlockNumber) {
- var header metadata.MD
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, 1)
- },
- true,
- hexutil.Uint64(0),
- },
- {
- "fail - block height is in the future",
- false,
- rpc.NewBlockNumber(big.NewInt(10000)),
- func(addr common.Address, bn rpc.BlockNumber) {
- var header metadata.MD
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, 1)
- },
- false,
- hexutil.Uint64(0),
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest()
-
- addr := evmtest.NewEthAddr()
- if tc.accExists {
- addr = common.BytesToAddress(s.acc.Bytes())
- }
-
- tc.registerMock(addr, tc.blockNum)
-
- txCount, err := s.backend.GetTransactionCount(addr, tc.blockNum)
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expTxCount, *txCount)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
diff --git a/eth/rpc/backend/backend.go b/eth/rpc/backend/backend.go
deleted file mode 100644
index c6344efe6..000000000
--- a/eth/rpc/backend/backend.go
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "context"
- "math/big"
- "time"
-
- "github.com/cometbft/cometbft/libs/log"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- "github.com/cosmos/cosmos-sdk/server"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- params "github.com/ethereum/go-ethereum/params"
- gethrpc "github.com/ethereum/go-ethereum/rpc"
- "github.com/ethereum/go-ethereum/signer/core/apitypes"
-
- "github.com/NibiruChain/nibiru/app/server/config"
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// BackendI implements the Cosmos and EVM backend.
-type BackendI interface { //nolint: revive
- CosmosBackend
- EVMBackend
-}
-
-// CosmosBackend: Currently unused. Backend functionality for the shared
-// "cosmos" RPC namespace. Implements [BackendI] in combination with [EVMBackend].
-// TODO: feat(eth): Implement the cosmos JSON-RPC defined by Wallet Connect V2:
-// https://docs.walletconnect.com/2.0/json-rpc/cosmos.
-type CosmosBackend interface {
- // TODO: GetAccounts()
- // TODO: SignDirect()
- // TODO: SignAmino()
-}
-
-// EVMBackend implements the functionality shared within ethereum namespaces
-// as defined by EIP-1474: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md
-// Implemented by Backend.
-type EVMBackend interface {
- // Node specific queries
- Accounts() ([]common.Address, error)
- Syncing() (interface{}, error)
- SetEtherbase(etherbase common.Address) bool
- SetGasPrice(gasPrice hexutil.Big) bool
- ImportRawKey(privkey, password string) (common.Address, error)
- ListAccounts() ([]common.Address, error)
- NewMnemonic(uid string, language keyring.Language, hdPath, bip39Passphrase string, algo keyring.SignatureAlgo) (*keyring.Record, error)
- UnprotectedAllowed() bool
- RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection
- RPCEVMTimeout() time.Duration // global timeout for eth_call over rpc: DoS protection
- RPCTxFeeCap() float64 // RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for send-transaction variants. The unit is ether.
- RPCMinGasPrice() int64
-
- // Sign Tx
- Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
- SendTransaction(args evm.JsonTxArgs) (common.Hash, error)
- SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error)
-
- // Blocks Info
- BlockNumber() (hexutil.Uint64, error)
- GetBlockByNumber(blockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
- GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
- GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint
- GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) *hexutil.Uint
- TendermintBlockByNumber(blockNum rpc.BlockNumber) (*tmrpctypes.ResultBlock, error)
- TendermintBlockResultByNumber(height *int64) (*tmrpctypes.ResultBlockResults, error)
- TendermintBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error)
- BlockNumberFromTendermint(blockNrOrHash rpc.BlockNumberOrHash) (rpc.BlockNumber, error)
- BlockNumberFromTendermintByHash(blockHash common.Hash) (*big.Int, error)
- EthMsgsFromTendermintBlock(block *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults) []*evm.MsgEthereumTx
- BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (gethcore.Bloom, error)
- HeaderByNumber(blockNum rpc.BlockNumber) (*gethcore.Header, error)
- HeaderByHash(blockHash common.Hash) (*gethcore.Header, error)
- RPCBlockFromTendermintBlock(resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults, fullTx bool) (map[string]interface{}, error)
- EthBlockByNumber(blockNum rpc.BlockNumber) (*gethcore.Block, error)
- EthBlockFromTendermintBlock(resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults) (*gethcore.Block, error)
-
- // Account Info
- GetCode(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)
- GetBalance(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)
- GetStorageAt(address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)
- GetProof(address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*rpc.AccountResult, error)
- GetTransactionCount(address common.Address, blockNum rpc.BlockNumber) (*hexutil.Uint64, error)
-
- // Chain Info
- ChainID() (*hexutil.Big, error)
- ChainConfig() *params.ChainConfig
- // TODO: feat: Dynamic fees
- // GlobalMinGasPrice() (math.LegacyDec, error)
- BaseFee(blockRes *tmrpctypes.ResultBlockResults) (*big.Int, error)
- CurrentHeader() (*gethcore.Header, error)
- PendingTransactions() ([]*sdk.Tx, error)
- GetCoinbase() (sdk.AccAddress, error)
- FeeHistory(blockCount gethrpc.DecimalOrHex, lastBlock gethrpc.BlockNumber, rewardPercentiles []float64) (*rpc.FeeHistoryResult, error)
- SuggestGasTipCap(baseFee *big.Int) (*big.Int, error)
-
- // Tx Info
- GetTransactionByHash(txHash common.Hash) (*rpc.EthTxJsonRPC, error)
- GetTxByEthHash(txHash common.Hash) (*eth.TxResult, error)
- GetTxByTxIndex(height int64, txIndex uint) (*eth.TxResult, error)
- GetTransactionByBlockAndIndex(block *tmrpctypes.ResultBlock, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error)
- GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error)
- GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error)
- GetTransactionByBlockNumberAndIndex(blockNum rpc.BlockNumber, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error)
-
- // Send Transaction
- Resend(args evm.JsonTxArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error)
- SendRawTransaction(data hexutil.Bytes) (common.Hash, error)
- SetTxDefaults(args evm.JsonTxArgs) (evm.JsonTxArgs, error)
- EstimateGas(args evm.JsonTxArgs, blockNrOptional *rpc.BlockNumber) (hexutil.Uint64, error)
- DoCall(args evm.JsonTxArgs, blockNr rpc.BlockNumber) (*evm.MsgEthereumTxResponse, error)
- GasPrice() (*hexutil.Big, error)
-
- // Filter API
- GetLogs(hash common.Hash) ([][]*gethcore.Log, error)
- GetLogsByHeight(height *int64) ([][]*gethcore.Log, error)
- BloomStatus() (uint64, uint64)
-
- // Tracing
- TraceTransaction(hash common.Hash, config *evm.TraceConfig) (interface{}, error)
- TraceBlock(
- height rpc.BlockNumber,
- config *evm.TraceConfig,
- block *tmrpctypes.ResultBlock,
- ) ([]*evm.TxTraceResult, error)
-}
-
-var _ BackendI = (*Backend)(nil)
-
-// Backend implements the BackendI interface
-type Backend struct {
- ctx context.Context
- clientCtx client.Context
- queryClient *rpc.QueryClient // gRPC query client
- logger log.Logger
- chainID *big.Int
- cfg config.Config
- allowUnprotectedTxs bool
- indexer eth.EVMTxIndexer
-}
-
-// NewBackend creates a new Backend instance for cosmos and ethereum namespaces
-func NewBackend(
- ctx *server.Context,
- logger log.Logger,
- clientCtx client.Context,
- allowUnprotectedTxs bool,
- indexer eth.EVMTxIndexer,
-) *Backend {
- chainID, err := eth.ParseChainID(clientCtx.ChainID)
- if err != nil {
- panic(err)
- }
-
- appConf, err := config.GetConfig(ctx.Viper)
- if err != nil {
- panic(err)
- }
-
- return &Backend{
- ctx: context.Background(),
- clientCtx: clientCtx,
- queryClient: rpc.NewQueryClient(clientCtx),
- logger: logger.With("module", "backend"),
- chainID: chainID,
- cfg: appConf,
- allowUnprotectedTxs: allowUnprotectedTxs,
- indexer: indexer,
- }
-}
diff --git a/eth/rpc/backend/backend_suite_test.go b/eth/rpc/backend/backend_suite_test.go
deleted file mode 100644
index e77d53c45..000000000
--- a/eth/rpc/backend/backend_suite_test.go
+++ /dev/null
@@ -1,201 +0,0 @@
-package backend
-
-import (
- "bufio"
- "math/big"
- "os"
- "path/filepath"
- "testing"
-
- dbm "github.com/cometbft/cometbft-db"
-
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- "github.com/cosmos/cosmos-sdk/server"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/crypto/hd"
- "github.com/NibiruChain/nibiru/eth/encoding"
- "github.com/NibiruChain/nibiru/eth/indexer"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
- evmtest "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-type BackendSuite struct {
- suite.Suite
-
- backend *Backend
- from common.Address
- acc sdk.AccAddress
- signer keyring.Signer
-}
-
-func TestBackendSuite(t *testing.T) {
- suite.Run(t, new(BackendSuite))
-}
-
-const ChainID = eth.EIP155ChainID_Testnet + "-1"
-
-// SetupTest is executed before every BackendTestSuite test
-func (s *BackendSuite) SetupTest() {
- ctx := server.NewDefaultContext()
- ctx.Viper.Set("telemetry.global-labels", []interface{}{})
-
- baseDir := s.T().TempDir()
- nodeDirName := "node"
- clientDir := filepath.Join(baseDir, nodeDirName, "nibirucli")
- keyRing, err := s.generateTestKeyring(clientDir)
- if err != nil {
- panic(err)
- }
-
- // Create Account with set sequence
- s.acc = sdk.AccAddress(evmtest.NewEthAddr().Bytes())
- accounts := map[string]client.TestAccount{}
- accounts[s.acc.String()] = client.TestAccount{
- Address: s.acc,
- Num: uint64(1),
- Seq: uint64(1),
- }
-
- from, priv := evmtest.PrivKeyEth()
- s.from = from
- s.signer = evmtest.NewSigner(priv)
- s.Require().NoError(err)
-
- encCfg := encoding.MakeConfig(app.ModuleBasics)
- evm.RegisterInterfaces(encCfg.InterfaceRegistry)
- eth.RegisterInterfaces(encCfg.InterfaceRegistry)
- clientCtx := client.Context{}.WithChainID(ChainID).
- WithHeight(1).
- WithTxConfig(encCfg.TxConfig).
- WithKeyringDir(clientDir).
- WithKeyring(keyRing).
- WithAccountRetriever(client.TestAccountRetriever{Accounts: accounts})
-
- allowUnprotectedTxs := false
- idxer := indexer.NewKVIndexer(dbm.NewMemDB(), ctx.Logger, clientCtx)
-
- s.backend = NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, idxer)
- s.backend.cfg.JSONRPC.GasCap = 0
- s.backend.cfg.JSONRPC.EVMTimeout = 0
- s.backend.queryClient.QueryClient = mocks.NewEVMQueryClient(s.T())
- s.backend.clientCtx.Client = mocks.NewClient(s.T())
- s.backend.ctx = rpc.NewContextWithHeight(1)
-
- s.backend.clientCtx.Codec = encCfg.Codec
-}
-
-// buildEthereumTx returns an example legacy Ethereum transaction
-func (s *BackendSuite) buildEthereumTx() (*evm.MsgEthereumTx, []byte) {
- ethTxParams := evm.EvmTxArgs{
- ChainID: s.backend.chainID,
- Nonce: uint64(0),
- To: &common.Address{},
- Amount: big.NewInt(0),
- GasLimit: 100000,
- GasPrice: big.NewInt(1),
- }
- msgEthereumTx := evm.NewTx(ðTxParams)
-
- // A valid msg should have empty `From`
- msgEthereumTx.From = s.from.Hex()
-
- txBuilder := s.backend.clientCtx.TxConfig.NewTxBuilder()
- err := txBuilder.SetMsgs(msgEthereumTx)
- s.Require().NoError(err)
-
- bz, err := s.backend.clientCtx.TxConfig.TxEncoder()(txBuilder.GetTx())
- s.Require().NoError(err)
- return msgEthereumTx, bz
-}
-
-// buildFormattedBlock returns a formatted block for testing
-func (s *BackendSuite) buildFormattedBlock(
- blockRes *tmrpctypes.ResultBlockResults,
- resBlock *tmrpctypes.ResultBlock,
- fullTx bool,
- tx *evm.MsgEthereumTx,
- validator sdk.AccAddress,
- baseFee *big.Int,
-) map[string]interface{} {
- header := resBlock.Block.Header
- gasLimit := int64(^uint32(0)) // for `MaxGas = -1` (DefaultConsensusParams)
- gasUsed := new(big.Int).SetUint64(uint64(blockRes.TxsResults[0].GasUsed))
-
- root := common.Hash{}.Bytes()
- receipt := gethcore.NewReceipt(root, false, gasUsed.Uint64())
- bloom := gethcore.CreateBloom(gethcore.Receipts{receipt})
-
- ethRPCTxs := []interface{}{}
- if tx != nil {
- if fullTx {
- rpcTx, err := rpc.NewRPCTxFromEthTx(
- tx.AsTransaction(),
- common.BytesToHash(header.Hash()),
- uint64(header.Height),
- uint64(0),
- baseFee,
- s.backend.chainID,
- )
- s.Require().NoError(err)
- ethRPCTxs = []interface{}{rpcTx}
- } else {
- ethRPCTxs = []interface{}{common.HexToHash(tx.Hash)}
- }
- }
-
- return rpc.FormatBlock(
- header,
- resBlock.Block.Size(),
- gasLimit,
- gasUsed,
- ethRPCTxs,
- bloom,
- common.BytesToAddress(validator.Bytes()),
- baseFee,
- )
-}
-
-func (s *BackendSuite) generateTestKeyring(clientDir string) (keyring.Keyring, error) {
- buf := bufio.NewReader(os.Stdin)
- encCfg := encoding.MakeConfig(app.ModuleBasics)
- return keyring.New(
- sdk.KeyringServiceName(), // appName
- keyring.BackendTest, // backend
- clientDir, // rootDir
- buf, // userInput
- encCfg.Codec, // codec
- []keyring.Option{hd.EthSecp256k1Option()}...,
- )
-}
-
-func (s *BackendSuite) signAndEncodeEthTx(msgEthereumTx *evm.MsgEthereumTx) []byte {
- from, priv := evmtest.PrivKeyEth()
- signer := evmtest.NewSigner(priv)
-
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParamsWithoutHeader(queryClient, 1)
-
- ethSigner := gethcore.LatestSigner(s.backend.ChainConfig())
- msgEthereumTx.From = from.String()
- err := msgEthereumTx.Sign(ethSigner, signer)
- s.Require().NoError(err)
-
- tx, err := msgEthereumTx.BuildTx(s.backend.clientCtx.TxConfig.NewTxBuilder(), eth.EthBaseDenom)
- s.Require().NoError(err)
-
- txEncoder := s.backend.clientCtx.TxConfig.TxEncoder()
- txBz, err := txEncoder(tx)
- s.Require().NoError(err)
-
- return txBz
-}
diff --git a/eth/rpc/backend/blocks.go b/eth/rpc/backend/blocks.go
deleted file mode 100644
index 1e5f1fc3e..000000000
--- a/eth/rpc/backend/blocks.go
+++ /dev/null
@@ -1,515 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "fmt"
- "math"
- "math/big"
- "strconv"
-
- tmrpcclient "github.com/cometbft/cometbft/rpc/client"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/trie"
- "github.com/pkg/errors"
- "google.golang.org/grpc"
- "google.golang.org/grpc/metadata"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// BlockNumber returns the current block number in abci app state. Because abci
-// app state could lag behind from tendermint latest block, it's more stable for
-// the client to use the latest block number in abci app state than tendermint
-// rpc.
-func (b *Backend) BlockNumber() (hexutil.Uint64, error) {
- // do any grpc query, ignore the response and use the returned block height
- var header metadata.MD
- _, err := b.queryClient.Params(b.ctx, &evm.QueryParamsRequest{}, grpc.Header(&header))
- if err != nil {
- return hexutil.Uint64(0), err
- }
-
- blockHeightHeader := header.Get(grpctypes.GRPCBlockHeightHeader)
- if headerLen := len(blockHeightHeader); headerLen != 1 {
- return 0, fmt.Errorf("unexpected '%s' gRPC header length; got %d, expected: %d", grpctypes.GRPCBlockHeightHeader, headerLen, 1)
- }
-
- height, err := strconv.ParseUint(blockHeightHeader[0], 10, 64)
- if err != nil {
- return 0, fmt.Errorf("failed to parse block height: %w", err)
- }
-
- if height > math.MaxInt64 {
- return 0, fmt.Errorf("block height %d is greater than max uint64", height)
- }
-
- return hexutil.Uint64(height), nil
-}
-
-// GetBlockByNumber returns the JSON-RPC compatible Ethereum block identified by
-// block number. Depending on fullTx it either returns the full transaction
-// objects or if false only the hashes of the transactions.
-func (b *Backend) GetBlockByNumber(blockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) {
- resBlock, err := b.TendermintBlockByNumber(blockNum)
- if err != nil {
- return nil, nil
- }
-
- // return if requested block height is greater than the current one
- if resBlock == nil || resBlock.Block == nil {
- return nil, nil
- }
-
- blockRes, err := b.TendermintBlockResultByNumber(&resBlock.Block.Height)
- if err != nil {
- b.logger.Debug("failed to fetch block result from Tendermint", "height", blockNum, "error", err.Error())
- return nil, nil
- }
-
- res, err := b.RPCBlockFromTendermintBlock(resBlock, blockRes, fullTx)
- if err != nil {
- b.logger.Debug("GetEthBlockFromTendermint failed", "height", blockNum, "error", err.Error())
- return nil, err
- }
-
- return res, nil
-}
-
-// GetBlockByHash returns the JSON-RPC compatible Ethereum block identified by
-// hash.
-func (b *Backend) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error) {
- resBlock, err := b.TendermintBlockByHash(hash)
- if err != nil {
- return nil, err
- }
-
- if resBlock == nil {
- // block not found
- return nil, nil
- }
-
- blockRes, err := b.TendermintBlockResultByNumber(&resBlock.Block.Height)
- if err != nil {
- b.logger.Debug("failed to fetch block result from Tendermint", "block-hash", hash.String(), "error", err.Error())
- return nil, nil
- }
-
- res, err := b.RPCBlockFromTendermintBlock(resBlock, blockRes, fullTx)
- if err != nil {
- b.logger.Debug("GetEthBlockFromTendermint failed", "hash", hash, "error", err.Error())
- return nil, err
- }
-
- return res, nil
-}
-
-// GetBlockTransactionCountByHash returns the number of Ethereum transactions in
-// the block identified by hash.
-func (b *Backend) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint {
- sc, ok := b.clientCtx.Client.(tmrpcclient.SignClient)
- if !ok {
- b.logger.Error("invalid rpc client")
- }
-
- block, err := sc.BlockByHash(b.ctx, hash.Bytes())
- if err != nil {
- b.logger.Debug("block not found", "hash", hash.Hex(), "error", err.Error())
- return nil
- }
-
- if block.Block == nil {
- b.logger.Debug("block not found", "hash", hash.Hex())
- return nil
- }
-
- return b.GetBlockTransactionCount(block)
-}
-
-// GetBlockTransactionCountByNumber returns the number of Ethereum transactions
-// in the block identified by number.
-func (b *Backend) GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) *hexutil.Uint {
- block, err := b.TendermintBlockByNumber(blockNum)
- if err != nil {
- b.logger.Debug("block not found", "height", blockNum.Int64(), "error", err.Error())
- return nil
- }
-
- if block.Block == nil {
- b.logger.Debug("block not found", "height", blockNum.Int64())
- return nil
- }
-
- return b.GetBlockTransactionCount(block)
-}
-
-// GetBlockTransactionCount returns the number of Ethereum transactions in a
-// given block.
-func (b *Backend) GetBlockTransactionCount(block *tmrpctypes.ResultBlock) *hexutil.Uint {
- blockRes, err := b.TendermintBlockResultByNumber(&block.Block.Height)
- if err != nil {
- return nil
- }
-
- ethMsgs := b.EthMsgsFromTendermintBlock(block, blockRes)
- n := hexutil.Uint(len(ethMsgs))
- return &n
-}
-
-// TendermintBlockByNumber returns a Tendermint-formatted block for a given
-// block number
-func (b *Backend) TendermintBlockByNumber(blockNum rpc.BlockNumber) (*tmrpctypes.ResultBlock, error) {
- height := blockNum.Int64()
- if height <= 0 {
- // fetch the latest block number from the app state, more accurate than the tendermint block store state.
- n, err := b.BlockNumber()
- if err != nil {
- return nil, err
- }
- height = int64(n) //#nosec G701 -- checked for int overflow already
- }
- resBlock, err := b.clientCtx.Client.Block(b.ctx, &height)
- if err != nil {
- b.logger.Debug("tendermint client failed to get block", "height", height, "error", err.Error())
- return nil, err
- }
-
- if resBlock.Block == nil {
- b.logger.Debug("TendermintBlockByNumber block not found", "height", height)
- return nil, nil
- }
-
- return resBlock, nil
-}
-
-// TendermintBlockResultByNumber returns a Tendermint-formatted block result
-// by block number
-func (b *Backend) TendermintBlockResultByNumber(height *int64) (*tmrpctypes.ResultBlockResults, error) {
- sc, ok := b.clientCtx.Client.(tmrpcclient.SignClient)
- if !ok {
- return nil, errors.New("invalid rpc client")
- }
- return sc.BlockResults(b.ctx, height)
-}
-
-// TendermintBlockByHash returns a Tendermint-formatted block by block number
-func (b *Backend) TendermintBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error) {
- sc, ok := b.clientCtx.Client.(tmrpcclient.SignClient)
- if !ok {
- return nil, errors.New("invalid rpc client")
- }
- resBlock, err := sc.BlockByHash(b.ctx, blockHash.Bytes())
- if err != nil {
- b.logger.Debug("tendermint client failed to get block", "blockHash", blockHash.Hex(), "error", err.Error())
- return nil, err
- }
-
- if resBlock == nil || resBlock.Block == nil {
- b.logger.Debug("TendermintBlockByHash block not found", "blockHash", blockHash.Hex())
- return nil, nil
- }
-
- return resBlock, nil
-}
-
-// BlockNumberFromTendermint returns the BlockNumber from BlockNumberOrHash
-func (b *Backend) BlockNumberFromTendermint(blockNrOrHash rpc.BlockNumberOrHash) (rpc.BlockNumber, error) {
- switch {
- case blockNrOrHash.BlockHash == nil && blockNrOrHash.BlockNumber == nil:
- return rpc.EthEarliestBlockNumber, fmt.Errorf("types BlockHash and BlockNumber cannot be both nil")
- case blockNrOrHash.BlockHash != nil:
- blockNumber, err := b.BlockNumberFromTendermintByHash(*blockNrOrHash.BlockHash)
- if err != nil {
- return rpc.EthEarliestBlockNumber, err
- }
- return rpc.NewBlockNumber(blockNumber), nil
- case blockNrOrHash.BlockNumber != nil:
- return *blockNrOrHash.BlockNumber, nil
- default:
- return rpc.EthEarliestBlockNumber, nil
- }
-}
-
-// BlockNumberFromTendermintByHash returns the block height of given block hash
-func (b *Backend) BlockNumberFromTendermintByHash(blockHash common.Hash) (*big.Int, error) {
- resBlock, err := b.TendermintBlockByHash(blockHash)
- if err != nil {
- return nil, err
- }
- if resBlock == nil {
- return nil, errors.Errorf("block not found for hash %s", blockHash.Hex())
- }
- return big.NewInt(resBlock.Block.Height), nil
-}
-
-// EthMsgsFromTendermintBlock returns all real MsgEthereumTxs from a
-// Tendermint block. It also ensures consistency over the correct txs indexes
-// across RPC endpoints
-func (b *Backend) EthMsgsFromTendermintBlock(
- resBlock *tmrpctypes.ResultBlock,
- blockRes *tmrpctypes.ResultBlockResults,
-) []*evm.MsgEthereumTx {
- var result []*evm.MsgEthereumTx
- block := resBlock.Block
-
- txResults := blockRes.TxsResults
-
- for i, tx := range block.Txs {
- // Check if tx exists on EVM by cross checking with blockResults:
- // - Include unsuccessful tx that exceeds block gas limit
- // - Include unsuccessful tx that failed when committing changes to stateDB
- // - Exclude unsuccessful tx with any other error but ExceedBlockGasLimit
- if !rpc.TxSuccessOrExpectedFailure(txResults[i]) {
- b.logger.Debug("invalid tx result code", "cosmos-hash", hexutil.Encode(tx.Hash()))
- continue
- }
-
- tx, err := b.clientCtx.TxConfig.TxDecoder()(tx)
- if err != nil {
- b.logger.Debug("failed to decode transaction in block", "height", block.Height, "error", err.Error())
- continue
- }
-
- for _, msg := range tx.GetMsgs() {
- ethMsg, ok := msg.(*evm.MsgEthereumTx)
- if !ok {
- continue
- }
-
- ethMsg.Hash = ethMsg.AsTransaction().Hash().Hex()
- result = append(result, ethMsg)
- }
- }
-
- return result
-}
-
-// HeaderByNumber returns the block header identified by height.
-func (b *Backend) HeaderByNumber(blockNum rpc.BlockNumber) (*gethcore.Header, error) {
- resBlock, err := b.TendermintBlockByNumber(blockNum)
- if err != nil {
- return nil, err
- }
-
- if resBlock == nil {
- return nil, errors.Errorf("block not found for height %d", blockNum)
- }
-
- blockRes, err := b.TendermintBlockResultByNumber(&resBlock.Block.Height)
- if err != nil {
- return nil, fmt.Errorf("block result not found for height %d. %w", resBlock.Block.Height, err)
- }
-
- bloom, err := b.BlockBloom(blockRes)
- if err != nil {
- b.logger.Debug("HeaderByNumber BlockBloom failed", "height", resBlock.Block.Height)
- }
-
- baseFee, err := b.BaseFee(blockRes)
- if err != nil {
- // handle the error for pruned node.
- b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", resBlock.Block.Height, "error", err)
- }
-
- ethHeader := rpc.EthHeaderFromTendermint(resBlock.Block.Header, bloom, baseFee)
- return ethHeader, nil
-}
-
-// HeaderByHash returns the block header identified by hash.
-func (b *Backend) HeaderByHash(blockHash common.Hash) (*gethcore.Header, error) {
- resBlock, err := b.TendermintBlockByHash(blockHash)
- if err != nil {
- return nil, err
- }
- if resBlock == nil {
- return nil, errors.Errorf("block not found for hash %s", blockHash.Hex())
- }
-
- blockRes, err := b.TendermintBlockResultByNumber(&resBlock.Block.Height)
- if err != nil {
- return nil, errors.Errorf("block result not found for height %d", resBlock.Block.Height)
- }
-
- bloom, err := b.BlockBloom(blockRes)
- if err != nil {
- b.logger.Debug("HeaderByHash BlockBloom failed", "height", resBlock.Block.Height)
- }
-
- baseFee, err := b.BaseFee(blockRes)
- if err != nil {
- // handle the error for pruned node.
- b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", resBlock.Block.Height, "error", err)
- }
-
- ethHeader := rpc.EthHeaderFromTendermint(resBlock.Block.Header, bloom, baseFee)
- return ethHeader, nil
-}
-
-// BlockBloom query block bloom filter from block results
-func (b *Backend) BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (gethcore.Bloom, error) {
- for _, event := range blockRes.EndBlockEvents {
- if event.Type != evm.EventTypeBlockBloom {
- continue
- }
-
- for _, attr := range event.Attributes {
- if attr.Key == evm.AttributeKeyEthereumBloom {
- return gethcore.BytesToBloom([]byte(attr.Value)), nil
- }
- }
- }
- return gethcore.Bloom{}, errors.New("block bloom event is not found")
-}
-
-// RPCBlockFromTendermintBlock returns a JSON-RPC compatible Ethereum block from a
-// given Tendermint block and its block result.
-func (b *Backend) RPCBlockFromTendermintBlock(
- resBlock *tmrpctypes.ResultBlock,
- blockRes *tmrpctypes.ResultBlockResults,
- fullTx bool,
-) (map[string]interface{}, error) {
- ethRPCTxs := []interface{}{}
- block := resBlock.Block
-
- baseFee, err := b.BaseFee(blockRes)
- if err != nil {
- // handle the error for pruned node.
- b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", block.Height, "error", err)
- }
-
- msgs := b.EthMsgsFromTendermintBlock(resBlock, blockRes)
- for txIndex, ethMsg := range msgs {
- if !fullTx {
- hash := common.HexToHash(ethMsg.Hash)
- ethRPCTxs = append(ethRPCTxs, hash)
- continue
- }
-
- tx := ethMsg.AsTransaction()
- height := uint64(block.Height) //#nosec G701 -- checked for int overflow already
- index := uint64(txIndex) //#nosec G701 -- checked for int overflow already
- rpcTx, err := rpc.NewRPCTxFromEthTx(
- tx,
- common.BytesToHash(block.Hash()),
- height,
- index,
- baseFee,
- b.chainID,
- )
- if err != nil {
- b.logger.Debug("NewTransactionFromData for receipt failed", "hash", tx.Hash().Hex(), "error", err.Error())
- continue
- }
- ethRPCTxs = append(ethRPCTxs, rpcTx)
- }
-
- bloom, err := b.BlockBloom(blockRes)
- if err != nil {
- b.logger.Debug("failed to query BlockBloom", "height", block.Height, "error", err.Error())
- }
-
- req := &evm.QueryValidatorAccountRequest{
- ConsAddress: sdk.ConsAddress(block.Header.ProposerAddress).String(),
- }
-
- var validatorAccAddr sdk.AccAddress
-
- ctx := rpc.NewContextWithHeight(block.Height)
- res, err := b.queryClient.ValidatorAccount(ctx, req)
- if err != nil {
- b.logger.Debug(
- "failed to query validator operator address",
- "height", block.Height,
- "cons-address", req.ConsAddress,
- "error", err.Error(),
- )
- // use zero address as the validator operator address
- validatorAccAddr = sdk.AccAddress(common.Address{}.Bytes())
- } else {
- validatorAccAddr, err = sdk.AccAddressFromBech32(res.AccountAddress)
- if err != nil {
- return nil, err
- }
- }
-
- validatorAddr := common.BytesToAddress(validatorAccAddr)
-
- gasLimit, err := rpc.BlockMaxGasFromConsensusParams(ctx, b.clientCtx, block.Height)
- if err != nil {
- b.logger.Error("failed to query consensus params", "error", err.Error())
- }
-
- gasUsed := uint64(0)
-
- for _, txsResult := range blockRes.TxsResults {
- // workaround for cosmos-sdk bug. https://github.com/cosmos/cosmos-sdk/issues/10832
- if ShouldIgnoreGasUsed(txsResult) {
- // block gas limit has exceeded, other txs must have failed with same reason.
- break
- }
- gasUsed += uint64(txsResult.GetGasUsed()) // #nosec G701 -- checked for int overflow already
- }
-
- formattedBlock := rpc.FormatBlock(
- block.Header, block.Size(),
- gasLimit, new(big.Int).SetUint64(gasUsed),
- ethRPCTxs, bloom, validatorAddr, baseFee,
- )
- return formattedBlock, nil
-}
-
-// EthBlockByNumber returns the Ethereum Block identified by number.
-func (b *Backend) EthBlockByNumber(blockNum rpc.BlockNumber) (*gethcore.Block, error) {
- resBlock, err := b.TendermintBlockByNumber(blockNum)
- if err != nil {
- return nil, err
- }
- if resBlock == nil {
- // block not found
- return nil, fmt.Errorf("block not found for height %d", blockNum)
- }
-
- blockRes, err := b.TendermintBlockResultByNumber(&resBlock.Block.Height)
- if err != nil {
- return nil, fmt.Errorf("block result not found for height %d", resBlock.Block.Height)
- }
-
- return b.EthBlockFromTendermintBlock(resBlock, blockRes)
-}
-
-// EthBlockFromTendermintBlock returns an Ethereum Block type from Tendermint block
-// EthBlockFromTendermintBlock
-func (b *Backend) EthBlockFromTendermintBlock(
- resBlock *tmrpctypes.ResultBlock,
- blockRes *tmrpctypes.ResultBlockResults,
-) (*gethcore.Block, error) {
- block := resBlock.Block
- height := block.Height
- bloom, err := b.BlockBloom(blockRes)
- if err != nil {
- b.logger.Debug("HeaderByNumber BlockBloom failed", "height", height)
- }
-
- baseFee, err := b.BaseFee(blockRes)
- if err != nil {
- // handle error for pruned node and log
- b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", height, "error", err)
- }
-
- ethHeader := rpc.EthHeaderFromTendermint(block.Header, bloom, baseFee)
- msgs := b.EthMsgsFromTendermintBlock(resBlock, blockRes)
-
- txs := make([]*gethcore.Transaction, len(msgs))
- for i, ethMsg := range msgs {
- txs[i] = ethMsg.AsTransaction()
- }
-
- // TODO: add tx receipts
- ethBlock := gethcore.NewBlock(ethHeader, txs, nil, nil, trie.NewStackTrie(nil))
- return ethBlock, nil
-}
diff --git a/eth/rpc/backend/blocks_test.go b/eth/rpc/backend/blocks_test.go
deleted file mode 100644
index e415bf334..000000000
--- a/eth/rpc/backend/blocks_test.go
+++ /dev/null
@@ -1,1629 +0,0 @@
-package backend
-
-import (
- "fmt"
- "math/big"
-
- "cosmossdk.io/math"
-
- "github.com/cometbft/cometbft/abci/types"
- cmtrpc "github.com/cometbft/cometbft/rpc/core/types"
- cmt "github.com/cometbft/cometbft/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/trie"
- "google.golang.org/grpc/metadata"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
- evmtest "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-func (s *BackendSuite) TestBlockNumber() {
- testCases := []struct {
- name string
- registerMock func()
- wantBlockNum hexutil.Uint64
- wantPass bool
- }{
- {
- name: "fail - invalid block header height",
- registerMock: func() {
- var header metadata.MD
- height := int64(1)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParamsInvalidHeight(queryClient, &header, height)
- },
- wantBlockNum: 0x0,
- wantPass: false,
- },
- {
- name: "fail - invalid block header",
- registerMock: func() {
- var header metadata.MD
- height := int64(1)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParamsInvalidHeader(queryClient, &header, height)
- },
- wantBlockNum: 0x0,
- wantPass: false,
- },
- {
- name: "pass - app state header height 1",
- registerMock: func() {
- var header metadata.MD
- height := int64(1)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, height)
- },
- wantBlockNum: 0x1,
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- blockNumber, err := s.backend.BlockNumber()
-
- if tc.wantPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.wantBlockNum, blockNumber)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetBlockByNumber() {
- var (
- blockRes *cmtrpc.ResultBlockResults
- resBlock *cmtrpc.ResultBlock
- )
- msgEthereumTx, bz := s.buildEthereumTx()
-
- testCases := []struct {
- name string
- blockNumber rpc.BlockNumber
- fullTx bool
- baseFee *big.Int
- validator sdk.AccAddress
- ethTx *evm.MsgEthereumTx
- ethTxBz []byte
- registerMock func(rpc.BlockNumber, math.Int, sdk.AccAddress, []byte)
- wantNoop bool
- wantPass bool
- }{
- {
- name: "pass - tendermint block not found",
- blockNumber: rpc.BlockNumber(1),
- fullTx: true,
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- ethTx: nil,
- ethTxBz: nil,
- registerMock: func(blockNum rpc.BlockNumber, _ math.Int, _ sdk.AccAddress, _ []byte) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockError(client, height)
- },
- wantNoop: true,
- wantPass: true,
- },
- {
- name: "pass - block not found (e.g. request block height that is greater than current one)",
- blockNumber: rpc.BlockNumber(1),
- fullTx: true,
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- ethTx: nil,
- ethTxBz: nil,
- registerMock: func(blockNum rpc.BlockNumber, baseFee math.Int, validator sdk.AccAddress, txBz []byte) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- resBlock, _ = RegisterBlockNotFound(client, height)
- },
- wantNoop: true,
- wantPass: true,
- },
- {
- name: "pass - block results error",
- blockNumber: rpc.BlockNumber(1),
- fullTx: true,
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- ethTx: nil,
- ethTxBz: nil,
- registerMock: func(blockNum rpc.BlockNumber, baseFee math.Int, validator sdk.AccAddress, txBz []byte) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- resBlock, _ = RegisterBlock(client, height, txBz)
- RegisterBlockResultsError(client, blockNum.Int64())
- },
- wantNoop: true,
- wantPass: true,
- },
- {
- name: "pass - without tx",
- blockNumber: rpc.BlockNumber(1),
- fullTx: true,
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- ethTx: nil,
- ethTxBz: nil,
- registerMock: func(blockNum rpc.BlockNumber, baseFee math.Int, validator sdk.AccAddress, txBz []byte) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- resBlock, _ = RegisterBlock(client, height, txBz)
- blockRes, _ = RegisterBlockResults(client, blockNum.Int64())
- RegisterConsensusParams(client, height)
-
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccount(queryClient, validator)
- },
- wantNoop: false,
- wantPass: true,
- },
- {
- name: "pass - with tx",
- blockNumber: rpc.BlockNumber(1),
- fullTx: true,
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- ethTx: msgEthereumTx,
- ethTxBz: bz,
- registerMock: func(blockNum rpc.BlockNumber, baseFee math.Int, validator sdk.AccAddress, txBz []byte) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- resBlock, _ = RegisterBlock(client, height, txBz)
- blockRes, _ = RegisterBlockResults(client, blockNum.Int64())
- RegisterConsensusParams(client, height)
-
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccount(queryClient, validator)
- },
- wantNoop: false,
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock(tc.blockNumber, math.NewIntFromBigInt(tc.baseFee), tc.validator, tc.ethTxBz)
-
- block, err := s.backend.GetBlockByNumber(tc.blockNumber, tc.fullTx)
-
- if tc.wantPass {
- if tc.wantNoop {
- s.Require().Nil(block)
- } else {
- expBlock := s.buildFormattedBlock(
- blockRes,
- resBlock,
- tc.fullTx,
- tc.ethTx,
- tc.validator,
- tc.baseFee,
- )
- s.Require().Equal(expBlock, block)
- }
- s.Require().NoError(err)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetBlockByHash() {
- var (
- blockRes *cmtrpc.ResultBlockResults
- resBlock *cmtrpc.ResultBlock
- )
- msgEthereumTx, bz := s.buildEthereumTx()
-
- block := cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil)
-
- testCases := []struct {
- name string
- hash common.Hash
- fullTx bool
- baseFee *big.Int
- validator sdk.AccAddress
- tx *evm.MsgEthereumTx
- txBz []byte
- registerMock func(
- common.Hash, math.Int, sdk.AccAddress, []byte)
- wantNoop bool
- wantPass bool
- }{
- {
- name: "fail - tendermint failed to get block",
- hash: common.BytesToHash(block.Hash()),
- fullTx: true,
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- tx: nil,
- txBz: nil,
- registerMock: func(hash common.Hash, baseFee math.Int, validator sdk.AccAddress, txBz []byte) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockByHashError(client, hash, txBz)
- },
- wantNoop: false,
- wantPass: false,
- },
- {
- name: "noop - tendermint blockres not found",
- hash: common.BytesToHash(block.Hash()),
- fullTx: true,
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- tx: nil,
- txBz: nil,
- registerMock: func(hash common.Hash, baseFee math.Int, validator sdk.AccAddress, txBz []byte) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockByHashNotFound(client, hash, txBz)
- },
- wantNoop: true,
- wantPass: true,
- },
- {
- name: "noop - tendermint failed to fetch block result",
- hash: common.BytesToHash(block.Hash()),
- fullTx: true,
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- tx: nil,
- txBz: nil,
- registerMock: func(hash common.Hash, baseFee math.Int, validator sdk.AccAddress, txBz []byte) {
- height := int64(1)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- resBlock, _ = RegisterBlockByHash(client, hash, txBz)
-
- RegisterBlockResultsError(client, height)
- },
- wantNoop: true,
- wantPass: true,
- },
- {
- name: "pass - without tx",
- hash: common.BytesToHash(block.Hash()),
- fullTx: true,
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- tx: nil,
- txBz: nil,
- registerMock: func(hash common.Hash, baseFee math.Int, validator sdk.AccAddress, txBz []byte) {
- height := int64(1)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- resBlock, _ = RegisterBlockByHash(client, hash, txBz)
-
- blockRes, _ = RegisterBlockResults(client, height)
- RegisterConsensusParams(client, height)
-
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccount(queryClient, validator)
- },
- wantNoop: false,
- wantPass: true,
- },
- {
- name: "pass - with tx",
- hash: common.BytesToHash(block.Hash()),
- fullTx: true,
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- tx: msgEthereumTx,
- txBz: bz,
- registerMock: func(hash common.Hash, baseFee math.Int, validator sdk.AccAddress, txBz []byte) {
- height := int64(1)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- resBlock, _ = RegisterBlockByHash(client, hash, txBz)
-
- blockRes, _ = RegisterBlockResults(client, height)
- RegisterConsensusParams(client, height)
-
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccount(queryClient, validator)
- },
- wantNoop: false,
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock(tc.hash, math.NewIntFromBigInt(tc.baseFee), tc.validator, tc.txBz)
-
- block, err := s.backend.GetBlockByHash(tc.hash, tc.fullTx)
-
- if tc.wantPass {
- if tc.wantNoop {
- s.Require().Nil(block)
- } else {
- expBlock := s.buildFormattedBlock(
- blockRes,
- resBlock,
- tc.fullTx,
- tc.tx,
- tc.validator,
- tc.baseFee,
- )
- s.Require().Equal(expBlock, block)
- }
- s.Require().NoError(err)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetBlockTransactionCountByHash() {
- _, bz := s.buildEthereumTx()
- block := cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil)
- emptyBlock := cmt.MakeBlock(1, []cmt.Tx{}, nil, nil)
-
- testCases := []struct {
- name string
- hash common.Hash
- registerMock func(common.Hash)
- wantCount hexutil.Uint
- wantPass bool
- }{
- {
- name: "fail - block not found",
- hash: common.BytesToHash(emptyBlock.Hash()),
- registerMock: func(hash common.Hash) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockByHashError(client, hash, nil)
- },
- wantCount: hexutil.Uint(0),
- wantPass: false,
- },
- {
- name: "fail - tendermint client failed to get block result",
- hash: common.BytesToHash(emptyBlock.Hash()),
- registerMock: func(hash common.Hash) {
- height := int64(1)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockByHash(client, hash, nil)
- s.Require().NoError(err)
- RegisterBlockResultsError(client, height)
- },
- wantCount: hexutil.Uint(0),
- wantPass: false,
- },
- {
- name: "pass - block without tx",
- hash: common.BytesToHash(emptyBlock.Hash()),
- registerMock: func(hash common.Hash) {
- height := int64(1)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockByHash(client, hash, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, height)
- s.Require().NoError(err)
- },
- wantCount: hexutil.Uint(0),
- wantPass: true,
- },
- {
- name: "pass - block with tx",
- hash: common.BytesToHash(block.Hash()),
- registerMock: func(hash common.Hash) {
- height := int64(1)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockByHash(client, hash, bz)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, height)
- s.Require().NoError(err)
- },
- wantCount: hexutil.Uint(1),
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
-
- tc.registerMock(tc.hash)
- count := s.backend.GetBlockTransactionCountByHash(tc.hash)
- if tc.wantPass {
- s.Require().Equal(tc.wantCount, *count)
- } else {
- s.Require().Nil(count)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetBlockTransactionCountByNumber() {
- _, bz := s.buildEthereumTx()
- block := cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil)
- emptyBlock := cmt.MakeBlock(1, []cmt.Tx{}, nil, nil)
-
- testCases := []struct {
- name string
- blockNum rpc.BlockNumber
- registerMock func(rpc.BlockNumber)
- wantCount hexutil.Uint
- wantPass bool
- }{
- {
- name: "fail - block not found",
- blockNum: rpc.BlockNumber(emptyBlock.Height),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockError(client, height)
- },
- wantCount: hexutil.Uint(0),
- wantPass: false,
- },
- {
- name: "fail - tendermint client failed to get block result",
- blockNum: rpc.BlockNumber(emptyBlock.Height),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, height, nil)
- s.Require().NoError(err)
- RegisterBlockResultsError(client, height)
- },
- wantCount: hexutil.Uint(0),
- wantPass: false,
- },
- {
- name: "pass - block without tx",
- blockNum: rpc.BlockNumber(emptyBlock.Height),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, height, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, height)
- s.Require().NoError(err)
- },
- wantCount: hexutil.Uint(0),
- wantPass: true,
- },
- {
- name: "pass - block with tx",
- blockNum: rpc.BlockNumber(block.Height),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, height, bz)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, height)
- s.Require().NoError(err)
- },
- wantCount: hexutil.Uint(1),
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
-
- tc.registerMock(tc.blockNum)
- count := s.backend.GetBlockTransactionCountByNumber(tc.blockNum)
- if tc.wantPass {
- s.Require().Equal(tc.wantCount, *count)
- } else {
- s.Require().Nil(count)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestTendermintBlockByNumber() {
- var expResultBlock *cmtrpc.ResultBlock
-
- testCases := []struct {
- name string
- blockNumber rpc.BlockNumber
- registerMock func(rpc.BlockNumber)
- wantBlockFound bool
- wantPass bool
- }{
- {
- name: "fail - client error",
- blockNumber: rpc.BlockNumber(1),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockError(client, height)
- },
- wantBlockFound: false,
- wantPass: false,
- },
- {
- name: "noop - block not found",
- blockNumber: rpc.BlockNumber(1),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockNotFound(client, height)
- s.Require().NoError(err)
- },
- wantBlockFound: false,
- wantPass: true,
- },
- {
- name: "fail - blockNum < 0 with app state height error",
- blockNumber: rpc.BlockNumber(-1),
- registerMock: func(_ rpc.BlockNumber) {
- var header metadata.MD
- appHeight := int64(1)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParamsError(queryClient, &header, appHeight)
- },
- wantBlockFound: false,
- wantPass: false,
- },
- {
- name: "pass - blockNum < 0 with app state height >= 1",
- blockNumber: rpc.BlockNumber(-1),
- registerMock: func(blockNum rpc.BlockNumber) {
- var header metadata.MD
- appHeight := int64(1)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, appHeight)
-
- tmHeight := appHeight
- client := s.backend.clientCtx.Client.(*mocks.Client)
- expResultBlock, _ = RegisterBlock(client, tmHeight, nil)
- },
- wantBlockFound: true,
- wantPass: true,
- },
- {
- name: "pass - blockNum = 0 (defaults to blockNum = 1 due to a difference between tendermint heights and geth heights)",
- blockNumber: rpc.BlockNumber(0),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- expResultBlock, _ = RegisterBlock(client, height, nil)
- },
- wantBlockFound: true,
- wantPass: true,
- },
- {
- name: "pass - blockNum = 1",
- blockNumber: rpc.BlockNumber(1),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- expResultBlock, _ = RegisterBlock(client, height, nil)
- },
- wantBlockFound: true,
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
-
- tc.registerMock(tc.blockNumber)
- resultBlock, err := s.backend.TendermintBlockByNumber(tc.blockNumber)
-
- if tc.wantPass {
- s.Require().NoError(err)
-
- if !tc.wantBlockFound {
- s.Require().Nil(resultBlock)
- } else {
- s.Require().Equal(expResultBlock, resultBlock)
- s.Require().Equal(expResultBlock.Block.Header.Height, resultBlock.Block.Header.Height)
- }
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestTendermintBlockResultByNumber() {
- var expBlockRes *cmtrpc.ResultBlockResults
-
- testCases := []struct {
- name string
- blockNumber int64
- registerMock func(int64)
- wantPass bool
- }{
- {
- name: "fail",
- blockNumber: 1,
- registerMock: func(blockNum int64) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockResultsError(client, blockNum)
- },
- wantPass: false,
- },
- {
- name: "pass",
- blockNumber: 1,
- registerMock: func(blockNum int64) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockResults(client, blockNum)
- s.Require().NoError(err)
- expBlockRes = &cmtrpc.ResultBlockResults{
- Height: blockNum,
- TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- }
- },
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock(tc.blockNumber)
-
- blockRes, err := s.backend.TendermintBlockResultByNumber(&tc.blockNumber) //#nosec G601 -- fine for tests
-
- if tc.wantPass {
- s.Require().NoError(err)
- s.Require().Equal(expBlockRes, blockRes)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestBlockNumberFromTendermint() {
- var resBlock *cmtrpc.ResultBlock
-
- _, bz := s.buildEthereumTx()
- block := cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil)
- blockNum := rpc.NewBlockNumber(big.NewInt(block.Height))
- blockHash := common.BytesToHash(block.Hash())
-
- testCases := []struct {
- name string
- blockNum *rpc.BlockNumber
- hash *common.Hash
- registerMock func(*common.Hash)
- wantPass bool
- }{
- {
- "error - without blockHash or blockNum",
- nil,
- nil,
- func(hash *common.Hash) {},
- false,
- },
- {
- "error - with blockHash, tendermint client failed to get block",
- nil,
- &blockHash,
- func(hash *common.Hash) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockByHashError(client, *hash, bz)
- },
- false,
- },
- {
- "pass - with blockHash",
- nil,
- &blockHash,
- func(hash *common.Hash) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- resBlock, _ = RegisterBlockByHash(client, *hash, bz)
- },
- true,
- },
- {
- "pass - without blockHash & with blockNumber",
- &blockNum,
- nil,
- func(hash *common.Hash) {},
- true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
-
- blockNrOrHash := rpc.BlockNumberOrHash{
- BlockNumber: tc.blockNum,
- BlockHash: tc.hash,
- }
-
- tc.registerMock(tc.hash)
- blockNum, err := s.backend.BlockNumberFromTendermint(blockNrOrHash)
-
- if tc.wantPass {
- s.Require().NoError(err)
- if tc.hash == nil {
- s.Require().Equal(*tc.blockNum, blockNum)
- } else {
- expHeight := rpc.NewBlockNumber(big.NewInt(resBlock.Block.Height))
- s.Require().Equal(expHeight, blockNum)
- }
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestBlockNumberFromTendermintByHash() {
- var resBlock *cmtrpc.ResultBlock
-
- _, bz := s.buildEthereumTx()
- block := cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil)
- emptyBlock := cmt.MakeBlock(1, []cmt.Tx{}, nil, nil)
-
- testCases := []struct {
- name string
- hash common.Hash
- registerMock func(common.Hash)
- wantPass bool
- }{
- {
- "fail - tendermint client failed to get block",
- common.BytesToHash(block.Hash()),
- func(hash common.Hash) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockByHashError(client, hash, bz)
- },
- false,
- },
- {
- "pass - block without tx",
- common.BytesToHash(emptyBlock.Hash()),
- func(hash common.Hash) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- resBlock, _ = RegisterBlockByHash(client, hash, bz)
- },
- true,
- },
- {
- "pass - block with tx",
- common.BytesToHash(block.Hash()),
- func(hash common.Hash) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- resBlock, _ = RegisterBlockByHash(client, hash, bz)
- },
- true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
-
- tc.registerMock(tc.hash)
- blockNum, err := s.backend.BlockNumberFromTendermintByHash(tc.hash)
- if tc.wantPass {
- expHeight := big.NewInt(resBlock.Block.Height)
- s.Require().NoError(err)
- s.Require().Equal(expHeight, blockNum)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestBlockBloom() {
- testCases := []struct {
- name string
- blockRes *cmtrpc.ResultBlockResults
- wantBlockBloom gethcore.Bloom
- wantPass bool
- }{
- {
- "fail - empty block result",
- &cmtrpc.ResultBlockResults{},
- gethcore.Bloom{},
- false,
- },
- {
- "fail - non block bloom event type",
- &cmtrpc.ResultBlockResults{
- EndBlockEvents: []types.Event{{Type: evm.EventTypeEthereumTx}},
- },
- gethcore.Bloom{},
- false,
- },
- {
- "fail - nonblock bloom attribute key",
- &cmtrpc.ResultBlockResults{
- EndBlockEvents: []types.Event{
- {
- Type: evm.EventTypeBlockBloom,
- Attributes: []types.EventAttribute{
- {Key: evm.AttributeKeyEthereumTxHash},
- },
- },
- },
- },
- gethcore.Bloom{},
- false,
- },
- {
- "pass - block bloom attribute key",
- &cmtrpc.ResultBlockResults{
- EndBlockEvents: []types.Event{
- {
- Type: evm.EventTypeBlockBloom,
- Attributes: []types.EventAttribute{
- {Key: evm.AttributeKeyEthereumBloom},
- },
- },
- },
- },
- gethcore.Bloom{},
- true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- blockBloom, err := s.backend.BlockBloom(tc.blockRes)
-
- if tc.wantPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.wantBlockBloom, blockBloom)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetEthBlockFromTendermint() {
- msgEthereumTx, bz := s.buildEthereumTx()
- emptyBlock := cmt.MakeBlock(1, []cmt.Tx{}, nil, nil)
-
- testCases := []struct {
- name string
- baseFee *big.Int
- validator sdk.AccAddress
- height int64
- resBlock *cmtrpc.ResultBlock
- blockRes *cmtrpc.ResultBlockResults
- fullTx bool
- registerMock func(math.Int, sdk.AccAddress, int64)
- wantTxs bool
- wantPass bool
- }{
- {
- name: "pass - block without tx",
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(common.Address{}.Bytes()),
- height: int64(1),
- resBlock: &cmtrpc.ResultBlock{Block: emptyBlock},
- blockRes: &cmtrpc.ResultBlockResults{
- Height: 1,
- TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- },
- fullTx: false,
- registerMock: func(baseFee math.Int, validator sdk.AccAddress, height int64) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccount(queryClient, validator)
-
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterConsensusParams(client, height)
- },
- wantTxs: false,
- wantPass: true,
- },
- {
- name: "pass - block with tx - with BaseFee error",
- baseFee: nil,
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- height: int64(1),
- resBlock: &cmtrpc.ResultBlock{
- Block: cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil),
- },
- blockRes: &cmtrpc.ResultBlockResults{
- Height: 1,
- TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- },
- fullTx: true,
- registerMock: func(baseFee math.Int, validator sdk.AccAddress, height int64) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFeeError(queryClient)
- RegisterValidatorAccount(queryClient, validator)
-
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterConsensusParams(client, height)
- },
- wantTxs: true,
- wantPass: true,
- },
- {
- name: "pass - block with tx - with ValidatorAccount error",
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(common.Address{}.Bytes()),
- height: int64(1),
- resBlock: &cmtrpc.ResultBlock{
- Block: cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil),
- },
- blockRes: &cmtrpc.ResultBlockResults{
- Height: 1,
- TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- },
- fullTx: true,
- registerMock: func(baseFee math.Int, validator sdk.AccAddress, height int64) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccountError(queryClient)
-
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterConsensusParams(client, height)
- },
- wantTxs: true,
- wantPass: true,
- },
- {
- name: "pass - block with tx - with ConsensusParams error - BlockMaxGas defaults to max uint32",
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- height: int64(1),
- resBlock: &cmtrpc.ResultBlock{
- Block: cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil),
- },
- blockRes: &cmtrpc.ResultBlockResults{
- Height: 1,
- TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- },
- fullTx: true,
- registerMock: func(baseFee math.Int, validator sdk.AccAddress, height int64) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccount(queryClient, validator)
-
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterConsensusParamsError(client, height)
- },
- wantTxs: true,
- wantPass: true,
- },
- {
- name: "pass - block with tx - with ShouldIgnoreGasUsed - empty txs",
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- height: int64(1),
- resBlock: &cmtrpc.ResultBlock{
- Block: cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil),
- },
- blockRes: &cmtrpc.ResultBlockResults{
- Height: 1,
- TxsResults: []*types.ResponseDeliverTx{
- {
- Code: 11,
- GasUsed: 0,
- Log: "no block gas left to run tx: out of gas",
- },
- },
- },
- fullTx: true,
- registerMock: func(baseFee math.Int, validator sdk.AccAddress, height int64) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccount(queryClient, validator)
-
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterConsensusParams(client, height)
- },
- wantTxs: false,
- wantPass: true,
- },
- {
- name: "pass - block with tx - non fullTx",
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- height: int64(1),
- resBlock: &cmtrpc.ResultBlock{
- Block: cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil),
- },
- blockRes: &cmtrpc.ResultBlockResults{
- Height: 1,
- TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- },
- fullTx: false,
- registerMock: func(baseFee math.Int, validator sdk.AccAddress, height int64) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccount(queryClient, validator)
-
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterConsensusParams(client, height)
- },
- wantTxs: true,
- wantPass: true,
- },
- {
- name: "pass - block with tx",
- baseFee: math.NewInt(1).BigInt(),
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- height: int64(1),
- resBlock: &cmtrpc.ResultBlock{
- Block: cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil),
- },
- blockRes: &cmtrpc.ResultBlockResults{
- Height: 1,
- TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- },
- fullTx: true,
- registerMock: func(baseFee math.Int, validator sdk.AccAddress, height int64) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccount(queryClient, validator)
-
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterConsensusParams(client, height)
- },
- wantTxs: true,
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock(math.NewIntFromBigInt(tc.baseFee), tc.validator, tc.height)
-
- block, err := s.backend.RPCBlockFromTendermintBlock(tc.resBlock, tc.blockRes, tc.fullTx)
-
- var expBlock map[string]interface{}
- header := tc.resBlock.Block.Header
- gasLimit := int64(^uint32(0)) // for `MaxGas = -1` (DefaultConsensusParams)
- gasUsed := new(big.Int).SetUint64(uint64(tc.blockRes.TxsResults[0].GasUsed))
-
- root := common.Hash{}.Bytes()
- receipt := gethcore.NewReceipt(root, false, gasUsed.Uint64())
- bloom := gethcore.CreateBloom(gethcore.Receipts{receipt})
-
- ethRPCTxs := []interface{}{}
-
- if tc.wantTxs {
- if tc.fullTx {
- rpcTx, err := rpc.NewRPCTxFromEthTx(
- msgEthereumTx.AsTransaction(),
- common.BytesToHash(header.Hash()),
- uint64(header.Height),
- uint64(0),
- tc.baseFee,
- s.backend.chainID,
- )
- s.Require().NoError(err)
- ethRPCTxs = []interface{}{rpcTx}
- } else {
- ethRPCTxs = []interface{}{common.HexToHash(msgEthereumTx.Hash)}
- }
- }
-
- expBlock = rpc.FormatBlock(
- header,
- tc.resBlock.Block.Size(),
- gasLimit,
- gasUsed,
- ethRPCTxs,
- bloom,
- common.BytesToAddress(tc.validator.Bytes()),
- tc.baseFee,
- )
-
- if tc.wantPass {
- s.Require().Equal(expBlock, block)
- s.Require().NoError(err)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestEthMsgsFromTendermintBlock() {
- msgEthereumTx, bz := s.buildEthereumTx()
-
- testCases := []struct {
- name string
- resBlock *cmtrpc.ResultBlock
- blockRes *cmtrpc.ResultBlockResults
- wantMsgs []*evm.MsgEthereumTx
- }{
- {
- "tx in not included in block - unsuccessful tx without ExceedBlockGasLimit error",
- &cmtrpc.ResultBlock{
- Block: cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil),
- },
- &cmtrpc.ResultBlockResults{
- TxsResults: []*types.ResponseDeliverTx{
- {
- Code: 1,
- },
- },
- },
- []*evm.MsgEthereumTx(nil),
- },
- {
- "tx included in block - unsuccessful tx with ExceedBlockGasLimit error",
- &cmtrpc.ResultBlock{
- Block: cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil),
- },
- &cmtrpc.ResultBlockResults{
- TxsResults: []*types.ResponseDeliverTx{
- {
- Code: 1,
- Log: rpc.ErrExceedBlockGasLimit,
- },
- },
- },
- []*evm.MsgEthereumTx{msgEthereumTx},
- },
- {
- "pass",
- &cmtrpc.ResultBlock{
- Block: cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil),
- },
- &cmtrpc.ResultBlockResults{
- TxsResults: []*types.ResponseDeliverTx{
- {
- Code: 0,
- Log: rpc.ErrExceedBlockGasLimit,
- },
- },
- },
- []*evm.MsgEthereumTx{msgEthereumTx},
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
-
- msgs := s.backend.EthMsgsFromTendermintBlock(tc.resBlock, tc.blockRes)
- s.Require().Equal(tc.wantMsgs, msgs)
- })
- }
-}
-
-func (s *BackendSuite) TestHeaderByNumber() {
- var expResultBlock *cmtrpc.ResultBlock
-
- _, bz := s.buildEthereumTx()
-
- testCases := []struct {
- name string
- blockNumber rpc.BlockNumber
- baseFee *big.Int
- registerMock func(rpc.BlockNumber, math.Int)
- wantPass bool
- }{
- {
- name: "fail - tendermint client failed to get block",
- blockNumber: rpc.BlockNumber(1),
- baseFee: math.NewInt(1).BigInt(),
- registerMock: func(blockNum rpc.BlockNumber, baseFee math.Int) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockError(client, height)
- },
- wantPass: false,
- },
- {
- name: "fail - block not found for height",
- blockNumber: rpc.BlockNumber(1),
- baseFee: math.NewInt(1).BigInt(),
- registerMock: func(blockNum rpc.BlockNumber, baseFee math.Int) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockNotFound(client, height)
- s.Require().NoError(err)
- },
- wantPass: false,
- },
- {
- name: "fail - block not found for height",
- blockNumber: rpc.BlockNumber(1),
- baseFee: math.NewInt(1).BigInt(),
- registerMock: func(blockNum rpc.BlockNumber, baseFee math.Int) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, height, nil)
- s.Require().NoError(err)
- RegisterBlockResultsError(client, height)
- },
- wantPass: false,
- },
- {
- name: "pass - without Base Fee, failed to fetch from prunned block",
- blockNumber: rpc.BlockNumber(1),
- baseFee: nil,
- registerMock: func(blockNum rpc.BlockNumber, baseFee math.Int) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- expResultBlock, _ = RegisterBlock(client, height, nil)
- _, err := RegisterBlockResults(client, height)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFeeError(queryClient)
- },
- wantPass: true,
- },
- {
- name: "pass - blockNum = 1, without tx",
- blockNumber: rpc.BlockNumber(1),
- baseFee: math.NewInt(1).BigInt(),
- registerMock: func(blockNum rpc.BlockNumber, baseFee math.Int) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- expResultBlock, _ = RegisterBlock(client, height, nil)
- _, err := RegisterBlockResults(client, height)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- },
- wantPass: true,
- },
- {
- name: "pass - blockNum = 1, with tx",
- blockNumber: rpc.BlockNumber(1),
- baseFee: math.NewInt(1).BigInt(),
- registerMock: func(blockNum rpc.BlockNumber, baseFee math.Int) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- expResultBlock, _ = RegisterBlock(client, height, bz)
- _, err := RegisterBlockResults(client, height)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- },
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
-
- tc.registerMock(tc.blockNumber, math.NewIntFromBigInt(tc.baseFee))
- header, err := s.backend.HeaderByNumber(tc.blockNumber)
-
- if tc.wantPass {
- expHeader := rpc.EthHeaderFromTendermint(expResultBlock.Block.Header, gethcore.Bloom{}, tc.baseFee)
- s.Require().NoError(err)
- s.Require().Equal(expHeader, header)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestHeaderByHash() {
- var expResultBlock *cmtrpc.ResultBlock
-
- _, bz := s.buildEthereumTx()
- block := cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil)
- emptyBlock := cmt.MakeBlock(1, []cmt.Tx{}, nil, nil)
-
- testCases := []struct {
- name string
- hash common.Hash
- baseFee *big.Int
- registerMock func(common.Hash, math.Int)
- wantPass bool
- }{
- {
- name: "fail - tendermint client failed to get block",
- hash: common.BytesToHash(block.Hash()),
- baseFee: math.NewInt(1).BigInt(),
- registerMock: func(hash common.Hash, baseFee math.Int) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockByHashError(client, hash, bz)
- },
- wantPass: false,
- },
- {
- name: "fail - block not found for height",
- hash: common.BytesToHash(block.Hash()),
- baseFee: math.NewInt(1).BigInt(),
- registerMock: func(hash common.Hash, baseFee math.Int) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockByHashNotFound(client, hash, bz)
- },
- wantPass: false,
- },
- {
- name: "fail - block not found for height",
- hash: common.BytesToHash(block.Hash()),
- baseFee: math.NewInt(1).BigInt(),
- registerMock: func(hash common.Hash, baseFee math.Int) {
- height := int64(1)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockByHash(client, hash, bz)
- s.Require().NoError(err)
- RegisterBlockResultsError(client, height)
- },
- wantPass: false,
- },
- {
- name: "pass - without Base Fee, failed to fetch from prunned block",
- hash: common.BytesToHash(block.Hash()),
- baseFee: nil,
- registerMock: func(hash common.Hash, baseFee math.Int) {
- height := int64(1)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- expResultBlock, _ = RegisterBlockByHash(client, hash, bz)
- _, err := RegisterBlockResults(client, height)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFeeError(queryClient)
- },
- wantPass: true,
- },
- {
- name: "pass - blockNum = 1, without tx",
- hash: common.BytesToHash(emptyBlock.Hash()),
- baseFee: math.NewInt(1).BigInt(),
- registerMock: func(hash common.Hash, baseFee math.Int) {
- height := int64(1)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- expResultBlock, _ = RegisterBlockByHash(client, hash, nil)
- _, err := RegisterBlockResults(client, height)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- },
- wantPass: true,
- },
- {
- name: "pass - with tx",
- hash: common.BytesToHash(block.Hash()),
- baseFee: math.NewInt(1).BigInt(),
- registerMock: func(hash common.Hash, baseFee math.Int) {
- height := int64(1)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- expResultBlock, _ = RegisterBlockByHash(client, hash, bz)
- _, err := RegisterBlockResults(client, height)
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- },
- wantPass: true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
-
- tc.registerMock(tc.hash, math.NewIntFromBigInt(tc.baseFee))
- header, err := s.backend.HeaderByHash(tc.hash)
-
- if tc.wantPass {
- expHeader := rpc.EthHeaderFromTendermint(expResultBlock.Block.Header, gethcore.Bloom{}, tc.baseFee)
- s.Require().NoError(err)
- s.Require().Equal(expHeader, header)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestEthBlockByNumber() {
- msgEthereumTx, bz := s.buildEthereumTx()
- emptyBlock := cmt.MakeBlock(1, []cmt.Tx{}, nil, nil)
-
- testCases := []struct {
- name string
- blockNumber rpc.BlockNumber
- registerMock func(rpc.BlockNumber)
- expEthBlock *gethcore.Block
- wantPass bool
- }{
- {
- name: "fail - tendermint client failed to get block",
- blockNumber: rpc.BlockNumber(1),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockError(client, height)
- },
- expEthBlock: nil,
- wantPass: false,
- },
- {
- name: "fail - block result not found for height",
- blockNumber: rpc.BlockNumber(1),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, height, nil)
- s.Require().NoError(err)
- RegisterBlockResultsError(client, blockNum.Int64())
- },
- expEthBlock: nil,
- wantPass: false,
- },
- {
- name: "pass - block without tx",
- blockNumber: rpc.BlockNumber(1),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, height, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, blockNum.Int64())
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- baseFee := math.NewInt(1)
- RegisterBaseFee(queryClient, baseFee)
- },
- expEthBlock: gethcore.NewBlock(
- rpc.EthHeaderFromTendermint(
- emptyBlock.Header,
- gethcore.Bloom{},
- math.NewInt(1).BigInt(),
- ),
- []*gethcore.Transaction{},
- nil,
- nil,
- nil,
- ),
- wantPass: true,
- },
- {
- name: "pass - block with tx",
- blockNumber: rpc.BlockNumber(1),
- registerMock: func(blockNum rpc.BlockNumber) {
- height := blockNum.Int64()
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, height, bz)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, blockNum.Int64())
- s.Require().NoError(err)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- baseFee := math.NewInt(1)
- RegisterBaseFee(queryClient, baseFee)
- },
- expEthBlock: gethcore.NewBlock(
- rpc.EthHeaderFromTendermint(
- emptyBlock.Header,
- gethcore.Bloom{},
- math.NewInt(1).BigInt(),
- ),
- []*gethcore.Transaction{msgEthereumTx.AsTransaction()},
- nil,
- nil,
- trie.NewStackTrie(nil),
- ),
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock(tc.blockNumber)
-
- ethBlock, err := s.backend.EthBlockByNumber(tc.blockNumber)
-
- if tc.wantPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expEthBlock.Header(), ethBlock.Header())
- s.Require().Equal(tc.expEthBlock.Uncles(), ethBlock.Uncles())
- s.Require().Equal(tc.expEthBlock.ReceiptHash(), ethBlock.ReceiptHash())
- for i, tx := range tc.expEthBlock.Transactions() {
- s.Require().Equal(tx.Data(), ethBlock.Transactions()[i].Data())
- }
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestEthBlockFromTendermintBlock() {
- msgEthereumTx, bz := s.buildEthereumTx()
- emptyBlock := cmt.MakeBlock(1, []cmt.Tx{}, nil, nil)
-
- testCases := []struct {
- name string
- baseFee *big.Int
- resBlock *cmtrpc.ResultBlock
- blockRes *cmtrpc.ResultBlockResults
- registerMock func(math.Int, int64)
- expEthBlock *gethcore.Block
- wantPass bool
- }{
- {
- name: "pass - block without tx",
- baseFee: math.NewInt(1).BigInt(),
- resBlock: &cmtrpc.ResultBlock{
- Block: emptyBlock,
- },
- blockRes: &cmtrpc.ResultBlockResults{
- Height: 1,
- TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- },
- registerMock: func(baseFee math.Int, blockNum int64) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- },
- expEthBlock: gethcore.NewBlock(
- rpc.EthHeaderFromTendermint(
- emptyBlock.Header,
- gethcore.Bloom{},
- math.NewInt(1).BigInt(),
- ),
- []*gethcore.Transaction{},
- nil,
- nil,
- nil,
- ),
- wantPass: true,
- },
- {
- name: "pass - block with tx",
- baseFee: math.NewInt(1).BigInt(),
- resBlock: &cmtrpc.ResultBlock{
- Block: cmt.MakeBlock(1, []cmt.Tx{bz}, nil, nil),
- },
- blockRes: &cmtrpc.ResultBlockResults{
- Height: 1,
- TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- EndBlockEvents: []types.Event{
- {
- Type: evm.EventTypeBlockBloom,
- Attributes: []types.EventAttribute{
- {Key: evm.AttributeKeyEthereumBloom},
- },
- },
- },
- },
- registerMock: func(baseFee math.Int, blockNum int64) {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- },
- expEthBlock: gethcore.NewBlock(
- rpc.EthHeaderFromTendermint(
- emptyBlock.Header,
- gethcore.Bloom{},
- math.NewInt(1).BigInt(),
- ),
- []*gethcore.Transaction{msgEthereumTx.AsTransaction()},
- nil,
- nil,
- trie.NewStackTrie(nil),
- ),
- wantPass: true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock(math.NewIntFromBigInt(tc.baseFee), tc.blockRes.Height)
-
- ethBlock, err := s.backend.EthBlockFromTendermintBlock(tc.resBlock, tc.blockRes)
-
- if tc.wantPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expEthBlock.Header(), ethBlock.Header())
- s.Require().Equal(tc.expEthBlock.Uncles(), ethBlock.Uncles())
- s.Require().Equal(tc.expEthBlock.ReceiptHash(), ethBlock.ReceiptHash())
- for i, tx := range tc.expEthBlock.Transactions() {
- s.Require().Equal(tx.Data(), ethBlock.Transactions()[i].Data())
- }
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
diff --git a/eth/rpc/backend/call_tx.go b/eth/rpc/backend/call_tx.go
deleted file mode 100644
index b207f7b66..000000000
--- a/eth/rpc/backend/call_tx.go
+++ /dev/null
@@ -1,417 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "bytes"
- "context"
- "encoding/json"
- "fmt"
- "math/big"
-
- errorsmod "cosmossdk.io/errors"
- "github.com/cosmos/cosmos-sdk/client/flags"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/pkg/errors"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// Resend accepts an existing transaction and a new gas price and limit. It will remove
-// the given transaction from the pool and reinsert it with the new gas price and limit.
-func (b *Backend) Resend(args evm.JsonTxArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) {
- if args.Nonce == nil {
- return common.Hash{}, fmt.Errorf("missing transaction nonce in transaction spec")
- }
-
- args, err := b.SetTxDefaults(args)
- if err != nil {
- return common.Hash{}, err
- }
-
- // The signer used should always be the 'latest' known one because we expect
- // signers to be backwards-compatible with old transactions.
- eip155ChainID, err := eth.ParseChainID(b.clientCtx.ChainID)
- if err != nil {
- return common.Hash{}, err
- }
-
- cfg := b.ChainConfig()
- if cfg == nil {
- cfg = evm.DefaultChainConfig().EthereumConfig(eip155ChainID)
- }
-
- signer := gethcore.LatestSigner(cfg)
-
- matchTx := args.ToTransaction().AsTransaction()
-
- // Before replacing the old transaction, ensure the _new_ transaction fee is reasonable.
- price := matchTx.GasPrice()
- if gasPrice != nil {
- price = gasPrice.ToInt()
- }
- gas := matchTx.Gas()
- if gasLimit != nil {
- gas = uint64(*gasLimit)
- }
- if err := rpc.CheckTxFee(price, gas, b.RPCTxFeeCap()); err != nil {
- return common.Hash{}, err
- }
-
- pending, err := b.PendingTransactions()
- if err != nil {
- return common.Hash{}, err
- }
-
- for _, tx := range pending {
- p, err := evm.UnwrapEthereumMsg(tx, common.Hash{})
- if err != nil {
- // not valid ethereum tx
- continue
- }
-
- pTx := p.AsTransaction()
-
- wantSigHash := signer.Hash(matchTx)
- pFrom, err := gethcore.Sender(signer, pTx)
- if err != nil {
- continue
- }
-
- if pFrom == *args.From && signer.Hash(pTx) == wantSigHash {
- // Match. Re-sign and send the transaction.
- if gasPrice != nil && (*big.Int)(gasPrice).Sign() != 0 {
- args.GasPrice = gasPrice
- }
- if gasLimit != nil && *gasLimit != 0 {
- args.Gas = gasLimit
- }
-
- return b.SendTransaction(args) // TODO: this calls SetTxDefaults again, refactor to avoid calling it twice
- }
- }
-
- return common.Hash{}, fmt.Errorf("transaction %#x not found", matchTx.Hash())
-}
-
-// SendRawTransaction send a raw Ethereum transaction.
-func (b *Backend) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) {
- // RLP decode raw transaction bytes
- tx := &gethcore.Transaction{}
- if err := tx.UnmarshalBinary(data); err != nil {
- b.logger.Error("transaction decoding failed", "error", err.Error())
- return common.Hash{}, err
- }
-
- // check the local node config in case unprotected txs are disabled
- if !b.UnprotectedAllowed() && !tx.Protected() {
- // Ensure only eip155 signed transactions are submitted if EIP155Required is set.
- return common.Hash{}, errors.New("only replay-protected (EIP-155) transactions allowed over RPC")
- }
-
- ethereumTx := &evm.MsgEthereumTx{}
- if err := ethereumTx.FromEthereumTx(tx); err != nil {
- b.logger.Error("transaction converting failed", "error", err.Error())
- return common.Hash{}, err
- }
-
- if err := ethereumTx.ValidateBasic(); err != nil {
- b.logger.Debug("tx failed basic validation", "error", err.Error())
- return common.Hash{}, err
- }
-
- // Query params to use the EVM denomination
- res, err := b.queryClient.QueryClient.Params(b.ctx, &evm.QueryParamsRequest{})
- if err != nil {
- b.logger.Error("failed to query evm params", "error", err.Error())
- return common.Hash{}, err
- }
-
- cosmosTx, err := ethereumTx.BuildTx(b.clientCtx.TxConfig.NewTxBuilder(), res.Params.EvmDenom)
- if err != nil {
- b.logger.Error("failed to build cosmos tx", "error", err.Error())
- return common.Hash{}, err
- }
-
- // Encode transaction by default Tx encoder
- txBytes, err := b.clientCtx.TxConfig.TxEncoder()(cosmosTx)
- if err != nil {
- b.logger.Error("failed to encode eth tx using default encoder", "error", err.Error())
- return common.Hash{}, err
- }
-
- txHash := ethereumTx.AsTransaction().Hash()
-
- syncCtx := b.clientCtx.WithBroadcastMode(flags.BroadcastSync)
- rsp, err := syncCtx.BroadcastTx(txBytes)
- if rsp != nil && rsp.Code != 0 {
- err = errorsmod.ABCIError(rsp.Codespace, rsp.Code, rsp.RawLog)
- }
- if err != nil {
- b.logger.Error("failed to broadcast tx", "error", err.Error())
- return txHash, err
- }
-
- return txHash, nil
-}
-
-// SetTxDefaults populates tx message with default values in case they are not
-// provided on the args
-func (b *Backend) SetTxDefaults(args evm.JsonTxArgs) (evm.JsonTxArgs, error) {
- if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) {
- return args, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
- }
-
- head, _ := b.CurrentHeader() // #nosec G703 -- no need to check error cause we're already checking that head == nil
- if head == nil {
- return args, errors.New("latest header is nil")
- }
-
- // If user specifies both maxPriorityfee and maxFee, then we do not
- // need to consult the chain for defaults. It's definitely a London tx.
- if args.MaxPriorityFeePerGas == nil || args.MaxFeePerGas == nil {
- // In this clause, user left some fields unspecified.
- if head.BaseFee != nil && args.GasPrice == nil {
- if args.MaxPriorityFeePerGas == nil {
- tip, err := b.SuggestGasTipCap(head.BaseFee)
- if err != nil {
- return args, err
- }
- args.MaxPriorityFeePerGas = (*hexutil.Big)(tip)
- }
-
- if args.MaxFeePerGas == nil {
- gasFeeCap := new(big.Int).Add(
- (*big.Int)(args.MaxPriorityFeePerGas),
- new(big.Int).Mul(head.BaseFee, big.NewInt(2)),
- )
- args.MaxFeePerGas = (*hexutil.Big)(gasFeeCap)
- }
-
- if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
- return args, fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas)
- }
- } else {
- if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil {
- return args, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
- }
-
- if args.GasPrice == nil {
- price, err := b.SuggestGasTipCap(head.BaseFee)
- if err != nil {
- return args, err
- }
- if head.BaseFee != nil {
- // The legacy tx gas price suggestion should not add 2x base fee
- // because all fees are consumed, so it would result in a spiral
- // upwards.
- price.Add(price, head.BaseFee)
- }
- args.GasPrice = (*hexutil.Big)(price)
- }
- }
- } else {
- // Both maxPriorityfee and maxFee set by caller. Sanity-check their internal relation
- if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
- return args, fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas)
- }
- }
-
- if args.Value == nil {
- args.Value = new(hexutil.Big)
- }
- if args.Nonce == nil {
- // get the nonce from the account retriever
- // ignore error in case tge account doesn't exist yet
- nonce, _ := b.getAccountNonce(*args.From, true, 0, b.logger) // #nosec G703s
- args.Nonce = (*hexutil.Uint64)(&nonce)
- }
-
- if args.Data != nil && args.Input != nil && !bytes.Equal(*args.Data, *args.Input) {
- return args, errors.New("both 'data' and 'input' are set and not equal. Please use 'input' to pass transaction call data")
- }
-
- if args.To == nil {
- // Contract creation
- var input []byte
- if args.Data != nil {
- input = *args.Data
- } else if args.Input != nil {
- input = *args.Input
- }
-
- if len(input) == 0 {
- return args, errors.New("contract creation without any data provided")
- }
- }
-
- if args.Gas == nil {
- // For backwards-compatibility reason, we try both input and data
- // but input is preferred.
- input := args.Input
- if input == nil {
- input = args.Data
- }
-
- callArgs := evm.JsonTxArgs{
- From: args.From,
- To: args.To,
- Gas: args.Gas,
- GasPrice: args.GasPrice,
- MaxFeePerGas: args.MaxFeePerGas,
- MaxPriorityFeePerGas: args.MaxPriorityFeePerGas,
- Value: args.Value,
- Data: input,
- AccessList: args.AccessList,
- ChainID: args.ChainID,
- Nonce: args.Nonce,
- }
-
- blockNr := rpc.NewBlockNumber(big.NewInt(0))
- estimated, err := b.EstimateGas(callArgs, &blockNr)
- if err != nil {
- return args, err
- }
- args.Gas = &estimated
- b.logger.Debug("estimate gas usage automatically", "gas", args.Gas)
- }
-
- if args.ChainID == nil {
- args.ChainID = (*hexutil.Big)(b.chainID)
- }
-
- return args, nil
-}
-
-// EstimateGas returns an estimate of gas usage for the given smart contract call.
-func (b *Backend) EstimateGas(args evm.JsonTxArgs, blockNrOptional *rpc.BlockNumber) (hexutil.Uint64, error) {
- blockNr := rpc.EthPendingBlockNumber
- if blockNrOptional != nil {
- blockNr = *blockNrOptional
- }
-
- bz, err := json.Marshal(&args)
- if err != nil {
- return 0, err
- }
-
- header, err := b.TendermintBlockByNumber(blockNr)
- if err != nil {
- // the error message imitates geth behavior
- return 0, errors.New("header not found")
- }
-
- req := evm.EthCallRequest{
- Args: bz,
- GasCap: b.RPCGasCap(),
- ProposerAddress: sdk.ConsAddress(header.Block.ProposerAddress),
- ChainId: b.chainID.Int64(),
- }
-
- // From ContextWithHeight: if the provided height is 0,
- // it will return an empty context and the gRPC query will use
- // the latest block height for querying.
- res, err := b.queryClient.EstimateGas(rpc.NewContextWithHeight(blockNr.Int64()), &req)
- if err != nil {
- return 0, err
- }
- return hexutil.Uint64(res.Gas), nil
-}
-
-// DoCall performs a simulated call operation through the evmtypes. It returns the
-// estimated gas used on the operation or an error if fails.
-func (b *Backend) DoCall(
- args evm.JsonTxArgs, blockNr rpc.BlockNumber,
-) (*evm.MsgEthereumTxResponse, error) {
- bz, err := json.Marshal(&args)
- if err != nil {
- return nil, err
- }
- header, err := b.TendermintBlockByNumber(blockNr)
- if err != nil {
- // the error message imitates geth behavior
- return nil, errors.New("header not found")
- }
-
- req := evm.EthCallRequest{
- Args: bz,
- GasCap: b.RPCGasCap(),
- ProposerAddress: sdk.ConsAddress(header.Block.ProposerAddress),
- ChainId: b.chainID.Int64(),
- }
-
- // From ContextWithHeight: if the provided height is 0,
- // it will return an empty context and the gRPC query will use
- // the latest block height for querying.
- ctx := rpc.NewContextWithHeight(blockNr.Int64())
- timeout := b.RPCEVMTimeout()
-
- // Setup context so it may be canceled the call has completed
- // or, in case of unmetered gas, setup a context with a timeout.
- var cancel context.CancelFunc
- if timeout > 0 {
- ctx, cancel = context.WithTimeout(ctx, timeout)
- } else {
- ctx, cancel = context.WithCancel(ctx)
- }
-
- // Make sure the context is canceled when the call has completed
- // this makes sure resources are cleaned up.
- defer cancel()
-
- res, err := b.queryClient.EthCall(ctx, &req)
- if err != nil {
- return nil, err
- }
-
- if res.Failed() {
- if res.VmError != vm.ErrExecutionReverted.Error() {
- return nil, status.Error(codes.Internal, res.VmError)
- }
- return nil, evm.NewExecErrorWithReason(res.Ret)
- }
-
- return res, nil
-}
-
-// GasPrice returns the current gas price based on Ethermint's gas price oracle.
-func (b *Backend) GasPrice() (*hexutil.Big, error) {
- var (
- result *big.Int
- err error
- )
-
- head, err := b.CurrentHeader()
- if err != nil {
- return nil, err
- }
-
- if head.BaseFee != nil {
- result, err = b.SuggestGasTipCap(head.BaseFee)
- if err != nil {
- return nil, err
- }
- result = result.Add(result, head.BaseFee)
- } else {
- result = big.NewInt(b.RPCMinGasPrice())
- }
-
- // return at least GlobalMinGasPrice
- minGasPrice, err := b.GlobalMinGasPrice()
- if err != nil {
- return nil, err
- }
- minGasPriceInt := minGasPrice.TruncateInt().BigInt()
- if result.Cmp(minGasPriceInt) < 0 {
- result = minGasPriceInt
- }
-
- return (*hexutil.Big)(result), nil
-}
diff --git a/eth/rpc/backend/call_tx_test.go b/eth/rpc/backend/call_tx_test.go
deleted file mode 100644
index dd55c1500..000000000
--- a/eth/rpc/backend/call_tx_test.go
+++ /dev/null
@@ -1,502 +0,0 @@
-package backend
-
-import (
- "encoding/json"
- "fmt"
- "math/big"
-
- "cosmossdk.io/math"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/rlp"
- "google.golang.org/grpc/metadata"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
- evmtest "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-func (s *BackendSuite) TestResend() {
- txNonce := (hexutil.Uint64)(1)
- baseFee := math.NewInt(1)
- gasPrice := new(hexutil.Big)
- toAddr := evmtest.NewEthAddr()
- chainID := (*hexutil.Big)(s.backend.chainID)
- callArgs := evm.JsonTxArgs{
- From: nil,
- To: &toAddr,
- Gas: nil,
- GasPrice: nil,
- MaxFeePerGas: gasPrice,
- MaxPriorityFeePerGas: gasPrice,
- Value: gasPrice,
- Nonce: &txNonce,
- Input: nil,
- Data: nil,
- AccessList: nil,
- ChainID: chainID,
- }
-
- testCases := []struct {
- name string
- registerMock func()
- args evm.JsonTxArgs
- gasPrice *hexutil.Big
- gasLimit *hexutil.Uint64
- expHash common.Hash
- expPass bool
- }{
- {
- "fail - Missing transaction nonce",
- func() {},
- evm.JsonTxArgs{
- Nonce: nil,
- },
- nil,
- nil,
- common.Hash{},
- false,
- },
- {
- "pass - Can't set Tx defaults BaseFee disabled",
- func() {
- var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, 1)
- _, err := RegisterBlock(client, 1, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFeeDisabled(queryClient)
- },
- evm.JsonTxArgs{
- Nonce: &txNonce,
- ChainID: callArgs.ChainID,
- },
- nil,
- nil,
- common.Hash{},
- true,
- },
- {
- "pass - Can't set Tx defaults",
- func() {
- var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, 1)
- _, err := RegisterBlock(client, 1, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, baseFee)
- },
- evm.JsonTxArgs{
- Nonce: &txNonce,
- },
- nil,
- nil,
- common.Hash{},
- true,
- },
- {
- "pass - MaxFeePerGas is nil",
- func() {
- var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, 1)
- _, err := RegisterBlock(client, 1, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFeeDisabled(queryClient)
- },
- evm.JsonTxArgs{
- Nonce: &txNonce,
- MaxPriorityFeePerGas: nil,
- GasPrice: nil,
- MaxFeePerGas: nil,
- },
- nil,
- nil,
- common.Hash{},
- true,
- },
- {
- "fail - GasPrice and (MaxFeePerGas or MaxPriorityPerGas specified)",
- func() {},
- evm.JsonTxArgs{
- Nonce: &txNonce,
- MaxPriorityFeePerGas: nil,
- GasPrice: gasPrice,
- MaxFeePerGas: gasPrice,
- },
- nil,
- nil,
- common.Hash{},
- false,
- },
- {
- "fail - Block error",
- func() {
- var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, 1)
- RegisterBlockError(client, 1)
- },
- evm.JsonTxArgs{
- Nonce: &txNonce,
- },
- nil,
- nil,
- common.Hash{},
- false,
- },
- {
- "pass - MaxFeePerGas is nil",
- func() {
- var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, 1)
- _, err := RegisterBlock(client, 1, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, baseFee)
- },
- evm.JsonTxArgs{
- Nonce: &txNonce,
- GasPrice: nil,
- MaxPriorityFeePerGas: gasPrice,
- MaxFeePerGas: gasPrice,
- ChainID: callArgs.ChainID,
- },
- nil,
- nil,
- common.Hash{},
- true,
- },
- {
- "pass - Chain Id is nil",
- func() {
- var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, 1)
- _, err := RegisterBlock(client, 1, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, baseFee)
- },
- evm.JsonTxArgs{
- Nonce: &txNonce,
- MaxPriorityFeePerGas: gasPrice,
- ChainID: nil,
- },
- nil,
- nil,
- common.Hash{},
- true,
- },
- {
- "fail - Pending transactions error",
- func() {
- var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- _, err := RegisterBlock(client, 1, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, baseFee)
- RegisterEstimateGas(queryClient, callArgs)
- RegisterParams(queryClient, &header, 1)
- RegisterParamsWithoutHeader(queryClient, 1)
- RegisterUnconfirmedTxsError(client, nil)
- },
- evm.JsonTxArgs{
- Nonce: &txNonce,
- To: &toAddr,
- MaxFeePerGas: gasPrice,
- MaxPriorityFeePerGas: gasPrice,
- Value: gasPrice,
- Gas: nil,
- ChainID: callArgs.ChainID,
- },
- gasPrice,
- nil,
- common.Hash{},
- false,
- },
- {
- "fail - Not Ethereum txs",
- func() {
- var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- _, err := RegisterBlock(client, 1, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, baseFee)
- RegisterEstimateGas(queryClient, callArgs)
- RegisterParams(queryClient, &header, 1)
- RegisterParamsWithoutHeader(queryClient, 1)
- RegisterUnconfirmedTxsEmpty(client, nil)
- },
- evm.JsonTxArgs{
- Nonce: &txNonce,
- To: &toAddr,
- MaxFeePerGas: gasPrice,
- MaxPriorityFeePerGas: gasPrice,
- Value: gasPrice,
- Gas: nil,
- ChainID: callArgs.ChainID,
- },
- gasPrice,
- nil,
- common.Hash{},
- false,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- hash, err := s.backend.Resend(tc.args, tc.gasPrice, tc.gasLimit)
-
- if tc.expPass {
- s.Require().Equal(tc.expHash, hash)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestSendRawTransaction() {
- ethTx, bz := s.buildEthereumTx()
-
- // Sign the ethTx
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParamsWithoutHeader(queryClient, 1)
- ethSigner := gethcore.LatestSigner(s.backend.ChainConfig())
- err := ethTx.Sign(ethSigner, s.signer)
- s.Require().NoError(err)
-
- rlpEncodedBz, _ := rlp.EncodeToBytes(ethTx.AsTransaction())
- cosmosTx, _ := ethTx.BuildTx(s.backend.clientCtx.TxConfig.NewTxBuilder(), evm.DefaultEVMDenom)
- txBytes, _ := s.backend.clientCtx.TxConfig.TxEncoder()(cosmosTx)
-
- testCases := []struct {
- name string
- registerMock func()
- rawTx []byte
- expHash common.Hash
- expPass bool
- }{
- {
- "fail - empty bytes",
- func() {},
- []byte{},
- common.Hash{},
- false,
- },
- {
- "fail - no RLP encoded bytes",
- func() {},
- bz,
- common.Hash{},
- false,
- },
- {
- "fail - unprotected transactions",
- func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- s.backend.allowUnprotectedTxs = false
- RegisterParamsWithoutHeaderError(queryClient, 1)
- },
- rlpEncodedBz,
- common.Hash{},
- false,
- },
- {
- "fail - failed to get evm params",
- func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- s.backend.allowUnprotectedTxs = true
- RegisterParamsWithoutHeaderError(queryClient, 1)
- },
- rlpEncodedBz,
- common.Hash{},
- false,
- },
- {
- "fail - failed to broadcast transaction",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- s.backend.allowUnprotectedTxs = true
- RegisterParamsWithoutHeader(queryClient, 1)
- RegisterBroadcastTxError(client, txBytes)
- },
- rlpEncodedBz,
- common.HexToHash(ethTx.Hash),
- false,
- },
- {
- "pass - Gets the correct transaction hash of the eth transaction",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- s.backend.allowUnprotectedTxs = true
- RegisterParamsWithoutHeader(queryClient, 1)
- RegisterBroadcastTx(client, txBytes)
- },
- rlpEncodedBz,
- common.HexToHash(ethTx.Hash),
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- hash, err := s.backend.SendRawTransaction(tc.rawTx)
-
- if tc.expPass {
- s.Require().Equal(tc.expHash, hash)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestDoCall() {
- _, bz := s.buildEthereumTx()
- gasPrice := (*hexutil.Big)(big.NewInt(1))
- toAddr := evmtest.NewEthAddr()
- chainID := (*hexutil.Big)(s.backend.chainID)
- callArgs := evm.JsonTxArgs{
- From: nil,
- To: &toAddr,
- Gas: nil,
- GasPrice: nil,
- MaxFeePerGas: gasPrice,
- MaxPriorityFeePerGas: gasPrice,
- Value: gasPrice,
- Input: nil,
- Data: nil,
- AccessList: nil,
- ChainID: chainID,
- }
- argsBz, err := json.Marshal(callArgs)
- s.Require().NoError(err)
-
- testCases := []struct {
- name string
- registerMock func()
- blockNum rpc.BlockNumber
- callArgs evm.JsonTxArgs
- expEthTx *evm.MsgEthereumTxResponse
- expPass bool
- }{
- {
- "fail - Invalid request",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- _, err := RegisterBlock(client, 1, bz)
- s.Require().NoError(err)
- RegisterEthCallError(queryClient, &evm.EthCallRequest{Args: argsBz, ChainId: s.backend.chainID.Int64()})
- },
- rpc.BlockNumber(1),
- callArgs,
- &evm.MsgEthereumTxResponse{},
- false,
- },
- {
- "pass - Returned transaction response",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- _, err := RegisterBlock(client, 1, bz)
- s.Require().NoError(err)
- RegisterEthCall(queryClient, &evm.EthCallRequest{Args: argsBz, ChainId: s.backend.chainID.Int64()})
- },
- rpc.BlockNumber(1),
- callArgs,
- &evm.MsgEthereumTxResponse{},
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- msgEthTx, err := s.backend.DoCall(tc.callArgs, tc.blockNum)
-
- if tc.expPass {
- s.Require().Equal(tc.expEthTx, msgEthTx)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGasPrice() {
- defaultGasPrice := (*hexutil.Big)(big.NewInt(1))
-
- testCases := []struct {
- name string
- registerMock func()
- expGas *hexutil.Big
- expPass bool
- }{
- {
- "pass - get the default gas price",
- func() {
- var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParams(queryClient, &header, 1)
- _, err := RegisterBlock(client, 1, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, math.NewInt(1))
- },
- defaultGasPrice,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- gasPrice, err := s.backend.GasPrice()
- if tc.expPass {
- s.Require().Equal(tc.expGas, gasPrice)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
diff --git a/eth/rpc/backend/chain_info.go b/eth/rpc/backend/chain_info.go
deleted file mode 100644
index 3936d5416..000000000
--- a/eth/rpc/backend/chain_info.go
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "fmt"
- "math/big"
-
- sdkmath "cosmossdk.io/math"
- tmrpcclient "github.com/cometbft/cometbft/rpc/client"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/params"
- gethrpc "github.com/ethereum/go-ethereum/rpc"
- "github.com/pkg/errors"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// ChainID is the EIP-155 replay-protection chain id for the current ethereum chain config.
-func (b *Backend) ChainID() (*hexutil.Big, error) {
- eip155ChainID, err := eth.ParseChainID(b.clientCtx.ChainID)
- if err != nil {
- panic(err)
- }
- // if current block is at or past the EIP-155 replay-protection fork block, return chainID from config
- bn, err := b.BlockNumber()
- if err != nil {
- b.logger.Debug("failed to fetch latest block number", "error", err.Error())
- return (*hexutil.Big)(eip155ChainID), nil
- }
-
- if config := b.ChainConfig(); config.IsEIP155(new(big.Int).SetUint64(uint64(bn))) {
- return (*hexutil.Big)(config.ChainID), nil
- }
-
- return nil, fmt.Errorf("chain not synced beyond EIP-155 replay-protection fork block")
-}
-
-// ChainConfig returns the latest ethereum chain configuration
-func (b *Backend) ChainConfig() *params.ChainConfig {
- params, err := b.queryClient.Params(b.ctx, &evm.QueryParamsRequest{})
- if err != nil {
- return nil
- }
-
- return params.Params.ChainConfig.EthereumConfig(b.chainID)
-}
-
-// BaseFee returns the base fee tracked by the Fee Market module.
-// If the base fee is not enabled globally, the query returns nil.
-// If the London hard fork is not activated at the current height, the query will
-// return nil.
-func (b *Backend) BaseFee(
- blockRes *tmrpctypes.ResultBlockResults,
-) (baseFee *big.Int, err error) {
- // return BaseFee if London hard fork is activated and feemarket is enabled
- res, err := b.queryClient.BaseFee(rpc.NewContextWithHeight(blockRes.Height), &evm.QueryBaseFeeRequest{})
- if err != nil || res.BaseFee == nil {
- baseFee = nil
- // TODO: feat: dynamic fee handling on events
- return baseFee, nil
- }
- return res.BaseFee.BigInt(), nil
-}
-
-// CurrentHeader returns the latest block header
-// This will return error as per node configuration
-// if the ABCI responses are discarded ('discard_abci_responses' config param)
-func (b *Backend) CurrentHeader() (*gethcore.Header, error) {
- return b.HeaderByNumber(rpc.EthLatestBlockNumber)
-}
-
-// PendingTransactions returns the transactions that are in the transaction pool
-// and have a from address that is one of the accounts this node manages.
-func (b *Backend) PendingTransactions() ([]*sdk.Tx, error) {
- mc, ok := b.clientCtx.Client.(tmrpcclient.MempoolClient)
- if !ok {
- return nil, errors.New("invalid rpc client")
- }
-
- res, err := mc.UnconfirmedTxs(b.ctx, nil)
- if err != nil {
- return nil, err
- }
-
- result := make([]*sdk.Tx, 0, len(res.Txs))
- for _, txBz := range res.Txs {
- tx, err := b.clientCtx.TxConfig.TxDecoder()(txBz)
- if err != nil {
- return nil, err
- }
- result = append(result, &tx)
- }
-
- return result, nil
-}
-
-// GetCoinbase is the address that staking rewards will be send to (alias for Etherbase).
-func (b *Backend) GetCoinbase() (sdk.AccAddress, error) {
- node, err := b.clientCtx.GetNode()
- if err != nil {
- return nil, err
- }
-
- status, err := node.Status(b.ctx)
- if err != nil {
- return nil, err
- }
-
- req := &evm.QueryValidatorAccountRequest{
- ConsAddress: sdk.ConsAddress(status.ValidatorInfo.Address).String(),
- }
-
- res, err := b.queryClient.ValidatorAccount(b.ctx, req)
- if err != nil {
- return nil, err
- }
-
- address, _ := sdk.AccAddressFromBech32(res.AccountAddress) // #nosec G703
- return address, nil
-}
-
-// FeeHistory returns data relevant for fee estimation based on the specified range of blocks.
-func (b *Backend) FeeHistory(
- userBlockCount gethrpc.DecimalOrHex, // number blocks to fetch, maximum is 100
- lastBlock gethrpc.BlockNumber, // the block to start search , to oldest
- rewardPercentiles []float64, // percentiles to fetch reward
-) (*rpc.FeeHistoryResult, error) {
- blockEnd := int64(lastBlock) //#nosec G701 -- checked for int overflow already
-
- if blockEnd < 0 {
- blockNumber, err := b.BlockNumber()
- if err != nil {
- return nil, err
- }
- blockEnd = int64(blockNumber) //#nosec G701 -- checked for int overflow already
- }
-
- blocks := int64(userBlockCount) // #nosec G701 -- checked for int overflow already
- maxBlockCount := int64(b.cfg.JSONRPC.FeeHistoryCap) // #nosec G701 -- checked for int overflow already
- if blocks > maxBlockCount {
- return nil, fmt.Errorf("FeeHistory user block count %d higher than %d", blocks, maxBlockCount)
- }
-
- if blockEnd+1 < blocks {
- blocks = blockEnd + 1
- }
- // Ensure not trying to retrieve before genesis.
- blockStart := blockEnd + 1 - blocks
- oldestBlock := (*hexutil.Big)(big.NewInt(blockStart))
-
- // prepare space
- reward := make([][]*hexutil.Big, blocks)
- rewardCount := len(rewardPercentiles)
- for i := 0; i < int(blocks); i++ {
- reward[i] = make([]*hexutil.Big, rewardCount)
- }
-
- thisBaseFee := make([]*hexutil.Big, blocks+1)
- thisGasUsedRatio := make([]float64, blocks)
-
- // rewards should only be calculated if reward percentiles were included
- calculateRewards := rewardCount != 0
-
- // fetch block
- for blockID := blockStart; blockID <= blockEnd; blockID++ {
- index := int32(blockID - blockStart) // #nosec G701
- // tendermint block
- tendermintblock, err := b.TendermintBlockByNumber(rpc.BlockNumber(blockID))
- if tendermintblock == nil {
- return nil, err
- }
-
- // eth block
- ethBlock, err := b.GetBlockByNumber(rpc.BlockNumber(blockID), true)
- if ethBlock == nil {
- return nil, err
- }
-
- // tendermint block result
- tendermintBlockResult, err := b.TendermintBlockResultByNumber(&tendermintblock.Block.Height)
- if tendermintBlockResult == nil {
- b.logger.Debug("block result not found", "height", tendermintblock.Block.Height, "error", err.Error())
- return nil, err
- }
-
- oneFeeHistory := rpc.OneFeeHistory{}
- err = b.processBlock(tendermintblock, ðBlock, rewardPercentiles, tendermintBlockResult, &oneFeeHistory)
- if err != nil {
- return nil, err
- }
-
- // copy
- thisBaseFee[index] = (*hexutil.Big)(oneFeeHistory.BaseFee)
- thisBaseFee[index+1] = (*hexutil.Big)(oneFeeHistory.NextBaseFee)
- thisGasUsedRatio[index] = oneFeeHistory.GasUsedRatio
- if calculateRewards {
- for j := 0; j < rewardCount; j++ {
- reward[index][j] = (*hexutil.Big)(oneFeeHistory.Reward[j])
- if reward[index][j] == nil {
- reward[index][j] = (*hexutil.Big)(big.NewInt(0))
- }
- }
- }
- }
-
- feeHistory := rpc.FeeHistoryResult{
- OldestBlock: oldestBlock,
- BaseFee: thisBaseFee,
- GasUsedRatio: thisGasUsedRatio,
- }
-
- if calculateRewards {
- feeHistory.Reward = reward
- }
-
- return &feeHistory, nil
-}
-
-// SuggestGasTipCap: Not yet supported. Returns 0 as the suggested tip cap. After
-// implementing tx prioritization, this function can come to life.
-func (b *Backend) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) {
- maxDelta := big.NewInt(0)
- return maxDelta, nil
-}
-
-func DefaultMinGasPrice() sdkmath.LegacyDec { return sdkmath.LegacyZeroDec() }
-
-// GlobalMinGasPrice returns the minimum gas price for all nodes. This is
-// distinct from the individual configuration set by the validator set.
-func (b *Backend) GlobalMinGasPrice() (sdkmath.LegacyDec, error) {
- // TODO: feat(eth): dynamic fees
- return DefaultMinGasPrice(), nil
-}
diff --git a/eth/rpc/backend/chain_info_test.go b/eth/rpc/backend/chain_info_test.go
deleted file mode 100644
index c1267cd0d..000000000
--- a/eth/rpc/backend/chain_info_test.go
+++ /dev/null
@@ -1,350 +0,0 @@
-package backend
-
-import (
- "fmt"
- "math/big"
-
- sdkmath "cosmossdk.io/math"
- "github.com/ethereum/go-ethereum/common/hexutil"
- ethrpc "github.com/ethereum/go-ethereum/rpc"
-
- "google.golang.org/grpc/metadata"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/cometbft/cometbft/abci/types"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
- evmtest "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-func (s *BackendSuite) TestBaseFee() {
- baseFee := sdkmath.NewInt(1)
-
- testCases := []struct {
- name string
- blockRes *tmrpctypes.ResultBlockResults
- registerMock func()
- expBaseFee *big.Int
- expPass bool
- }{
- // TODO: test(eth): Test base fee query after it's enabled.
- // {
- // "fail - grpc BaseFee error",
- // &tmrpctypes.ResultBlockResults{Height: 1},
- // func() {
- // queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- // RegisterBaseFeeError(queryClient)
- // },
- // nil,
- // false,
- // },
- {
- name: "pass - grpc BaseFee error - with non feemarket block event",
- blockRes: &tmrpctypes.ResultBlockResults{
- Height: 1,
- BeginBlockEvents: []types.Event{
- {
- Type: evm.EventTypeBlockBloom,
- },
- },
- },
- registerMock: func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFeeDisabled(queryClient)
- },
- expBaseFee: nil,
- expPass: true,
- },
- {
- name: "pass - base fee or london fork not enabled",
- blockRes: &tmrpctypes.ResultBlockResults{Height: 1},
- registerMock: func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFeeDisabled(queryClient)
- },
- expBaseFee: nil,
- expPass: true,
- },
- {
- "pass",
- &tmrpctypes.ResultBlockResults{Height: 1},
- func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterBaseFee(queryClient, baseFee)
- },
- baseFee.BigInt(),
- true,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- baseFee, err := s.backend.BaseFee(tc.blockRes)
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expBaseFee, baseFee)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestChainId() {
- expChainIDNumber := eth.ParseEIP155ChainIDNumber(eth.EIP155ChainID_Testnet)
- expChainID := (*hexutil.Big)(expChainIDNumber)
- testCases := []struct {
- name string
- registerMock func()
- expChainID *hexutil.Big
- expPass bool
- }{
- {
- "pass - block is at or past the EIP-155 replay-protection fork block, return chainID from config ",
- func() {
- var header metadata.MD
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParamsInvalidHeight(queryClient, &header, int64(1))
- },
- expChainID,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- chainID, err := s.backend.ChainID()
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expChainID, chainID)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetCoinbase() {
- validatorAcc := sdk.AccAddress(evmtest.NewEthAddr().Bytes())
- testCases := []struct {
- name string
- registerMock func()
- accAddr sdk.AccAddress
- expPass bool
- }{
- {
- "fail - Can't retrieve status from node",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterStatusError(client)
- },
- validatorAcc,
- false,
- },
- {
- "fail - Can't query validator account",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterStatus(client)
- RegisterValidatorAccountError(queryClient)
- },
- validatorAcc,
- false,
- },
- {
- "pass - Gets coinbase account",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterStatus(client)
- RegisterValidatorAccount(queryClient, validatorAcc)
- },
- validatorAcc,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- accAddr, err := s.backend.GetCoinbase()
-
- if tc.expPass {
- s.Require().Equal(tc.accAddr, accAddr)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestSuggestGasTipCap() {
- testCases := []struct {
- name string
- registerMock func()
- baseFee *big.Int
- expGasTipCap *big.Int
- expPass bool
- }{
- {
- "pass - London hardfork not enabled or feemarket not enabled ",
- func() {},
- nil,
- big.NewInt(0),
- true,
- },
- {
- "pass - Gets the suggest gas tip cap ",
- func() {},
- nil,
- big.NewInt(0),
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- maxDelta, err := s.backend.SuggestGasTipCap(tc.baseFee)
-
- if tc.expPass {
- s.Require().Equal(tc.expGasTipCap, maxDelta)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestFeeHistory() {
- testCases := []struct {
- name string
- registerMock func(validator sdk.AccAddress)
- userBlockCount ethrpc.DecimalOrHex
- latestBlock ethrpc.BlockNumber
- expFeeHistory *rpc.FeeHistoryResult
- validator sdk.AccAddress
- expPass bool
- }{
- {
- "fail - can't get params ",
- func(validator sdk.AccAddress) {
- var header metadata.MD
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- s.backend.cfg.JSONRPC.FeeHistoryCap = 0
- RegisterParamsError(queryClient, &header, ethrpc.BlockNumber(1).Int64())
- },
- 1,
- -1,
- nil,
- nil,
- false,
- },
- {
- "fail - user block count higher than max block count ",
- func(validator sdk.AccAddress) {
- var header metadata.MD
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- s.backend.cfg.JSONRPC.FeeHistoryCap = 0
- RegisterParams(queryClient, &header, ethrpc.BlockNumber(1).Int64())
- },
- 1,
- -1,
- nil,
- nil,
- false,
- },
- {
- "fail - Tendermint block fetching error ",
- func(validator sdk.AccAddress) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- s.backend.cfg.JSONRPC.FeeHistoryCap = 2
- RegisterBlockError(client, ethrpc.BlockNumber(1).Int64())
- },
- 1,
- 1,
- nil,
- nil,
- false,
- },
- {
- "fail - Eth block fetching error",
- func(validator sdk.AccAddress) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- s.backend.cfg.JSONRPC.FeeHistoryCap = 2
- _, err := RegisterBlock(client, ethrpc.BlockNumber(1).Int64(), nil)
- s.Require().NoError(err)
- RegisterBlockResultsError(client, 1)
- },
- 1,
- 1,
- nil,
- nil,
- true,
- },
- {
- name: "pass - Valid FeeHistoryResults object",
- registerMock: func(validator sdk.AccAddress) {
- baseFee := sdkmath.NewInt(1)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- s.backend.cfg.JSONRPC.FeeHistoryCap = 2
- blockHeight := int64(1)
- _, err := RegisterBlock(client, blockHeight, nil)
- s.Require().NoError(err)
-
- _, err = RegisterBlockResults(client, blockHeight)
- s.Require().NoError(err)
-
- RegisterBaseFee(queryClient, baseFee)
- RegisterValidatorAccount(queryClient, validator)
- RegisterConsensusParams(client, blockHeight)
-
- header := new(metadata.MD)
- RegisterParams(queryClient, header, blockHeight)
- RegisterParamsWithoutHeader(queryClient, blockHeight)
- },
- userBlockCount: 1,
- latestBlock: 1,
- expFeeHistory: &rpc.FeeHistoryResult{
- OldestBlock: (*hexutil.Big)(big.NewInt(1)),
- BaseFee: []*hexutil.Big{(*hexutil.Big)(big.NewInt(1)), (*hexutil.Big)(big.NewInt(1))},
- GasUsedRatio: []float64{0},
- Reward: [][]*hexutil.Big{{(*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0))}},
- },
- validator: sdk.AccAddress(evmtest.NewEthAddr().Bytes()),
- expPass: true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock(tc.validator)
-
- feeHistory, err := s.backend.FeeHistory(tc.userBlockCount, tc.latestBlock, []float64{25, 50, 75, 100})
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(feeHistory, tc.expFeeHistory)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
diff --git a/eth/rpc/backend/client_test.go b/eth/rpc/backend/client_test.go
deleted file mode 100644
index 21f22ce4d..000000000
--- a/eth/rpc/backend/client_test.go
+++ /dev/null
@@ -1,286 +0,0 @@
-package backend
-
-import (
- "context"
- "testing"
-
- "github.com/cosmos/cosmos-sdk/client"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
-
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cometbft/cometbft/libs/bytes"
- tmrpcclient "github.com/cometbft/cometbft/rpc/client"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- "github.com/cometbft/cometbft/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- "github.com/ethereum/go-ethereum/common"
- mock "github.com/stretchr/testify/mock"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// Client defines a mocked object that implements the Tendermint JSON-RPC Client
-// interface. It allows for performing Client queries without having to run a
-// Tendermint RPC Client server.
-//
-// To use a mock method it has to be registered in a given test.
-var _ tmrpcclient.Client = &mocks.Client{}
-
-// Tx Search
-func RegisterTxSearch(client *mocks.Client, query string, txBz []byte) {
- resulTxs := []*tmrpctypes.ResultTx{{Tx: txBz}}
- client.On("TxSearch", rpc.NewContextWithHeight(1), query, false, (*int)(nil), (*int)(nil), "").
- Return(&tmrpctypes.ResultTxSearch{Txs: resulTxs, TotalCount: 1}, nil)
-}
-
-func RegisterTxSearchEmpty(client *mocks.Client, query string) {
- client.On("TxSearch", rpc.NewContextWithHeight(1), query, false, (*int)(nil), (*int)(nil), "").
- Return(&tmrpctypes.ResultTxSearch{}, nil)
-}
-
-func RegisterTxSearchError(client *mocks.Client, query string) {
- client.On("TxSearch", rpc.NewContextWithHeight(1), query, false, (*int)(nil), (*int)(nil), "").
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-// Broadcast Tx
-func RegisterBroadcastTx(client *mocks.Client, tx types.Tx) {
- client.On("BroadcastTxSync", context.Background(), tx).
- Return(&tmrpctypes.ResultBroadcastTx{}, nil)
-}
-
-func RegisterBroadcastTxError(client *mocks.Client, tx types.Tx) {
- client.On("BroadcastTxSync", context.Background(), tx).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-// Unconfirmed Transactions
-func RegisterUnconfirmedTxs(client *mocks.Client, limit *int, txs []types.Tx) {
- client.On("UnconfirmedTxs", rpc.NewContextWithHeight(1), limit).
- Return(&tmrpctypes.ResultUnconfirmedTxs{Txs: txs}, nil)
-}
-
-func RegisterUnconfirmedTxsEmpty(client *mocks.Client, limit *int) {
- client.On("UnconfirmedTxs", rpc.NewContextWithHeight(1), limit).
- Return(&tmrpctypes.ResultUnconfirmedTxs{
- Txs: make([]types.Tx, 2),
- }, nil)
-}
-
-func RegisterUnconfirmedTxsError(client *mocks.Client, limit *int) {
- client.On("UnconfirmedTxs", rpc.NewContextWithHeight(1), limit).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-// Status
-func RegisterStatus(client *mocks.Client) {
- client.On("Status", rpc.NewContextWithHeight(1)).
- Return(&tmrpctypes.ResultStatus{}, nil)
-}
-
-func RegisterStatusError(client *mocks.Client) {
- client.On("Status", rpc.NewContextWithHeight(1)).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-// Block
-func RegisterBlockMultipleTxs(
- client *mocks.Client,
- height int64,
- txs []types.Tx,
-) (*tmrpctypes.ResultBlock, error) {
- block := types.MakeBlock(height, txs, nil, nil)
- block.ChainID = ChainID
- resBlock := &tmrpctypes.ResultBlock{Block: block}
- client.On("Block", rpc.NewContextWithHeight(height), mock.AnythingOfType("*int64")).Return(resBlock, nil)
- return resBlock, nil
-}
-
-func RegisterBlock(
- client *mocks.Client,
- height int64,
- tx []byte,
-) (*tmrpctypes.ResultBlock, error) {
- // without tx
- if tx == nil {
- emptyBlock := types.MakeBlock(height, []types.Tx{}, nil, nil)
- emptyBlock.ChainID = ChainID
- resBlock := &tmrpctypes.ResultBlock{Block: emptyBlock}
- client.On("Block", rpc.NewContextWithHeight(height), mock.AnythingOfType("*int64")).Return(resBlock, nil)
- return resBlock, nil
- }
-
- // with tx
- block := types.MakeBlock(height, []types.Tx{tx}, nil, nil)
- block.ChainID = ChainID
- resBlock := &tmrpctypes.ResultBlock{Block: block}
- client.On("Block", rpc.NewContextWithHeight(height), mock.AnythingOfType("*int64")).Return(resBlock, nil)
- return resBlock, nil
-}
-
-// Block returns error
-func RegisterBlockError(client *mocks.Client, height int64) {
- client.On("Block", rpc.NewContextWithHeight(height), mock.AnythingOfType("*int64")).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-// Block not found
-func RegisterBlockNotFound(
- client *mocks.Client,
- height int64,
-) (*tmrpctypes.ResultBlock, error) {
- client.On("Block", rpc.NewContextWithHeight(height), mock.AnythingOfType("*int64")).
- Return(&tmrpctypes.ResultBlock{Block: nil}, nil)
-
- return &tmrpctypes.ResultBlock{Block: nil}, nil
-}
-
-func TestRegisterBlock(t *testing.T) {
- client := mocks.NewClient(t)
- height := rpc.BlockNumber(1).Int64()
- _, err := RegisterBlock(client, height, nil)
- require.NoError(t, err)
-
- res, err := client.Block(rpc.NewContextWithHeight(height), &height)
-
- emptyBlock := types.MakeBlock(height, []types.Tx{}, nil, nil)
- emptyBlock.ChainID = ChainID
- resBlock := &tmrpctypes.ResultBlock{Block: emptyBlock}
- require.Equal(t, resBlock, res)
- require.NoError(t, err)
-}
-
-// ConsensusParams
-func RegisterConsensusParams(client *mocks.Client, height int64) {
- consensusParams := types.DefaultConsensusParams()
- client.On("ConsensusParams", rpc.NewContextWithHeight(height), mock.AnythingOfType("*int64")).
- Return(&tmrpctypes.ResultConsensusParams{ConsensusParams: *consensusParams}, nil)
-}
-
-func RegisterConsensusParamsError(client *mocks.Client, height int64) {
- client.On("ConsensusParams", rpc.NewContextWithHeight(height), mock.AnythingOfType("*int64")).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-func TestRegisterConsensusParams(t *testing.T) {
- client := mocks.NewClient(t)
- height := int64(1)
- RegisterConsensusParams(client, height)
-
- res, err := client.ConsensusParams(rpc.NewContextWithHeight(height), &height)
- consensusParams := types.DefaultConsensusParams()
- require.Equal(t, &tmrpctypes.ResultConsensusParams{ConsensusParams: *consensusParams}, res)
- require.NoError(t, err)
-}
-
-// BlockResults
-
-func RegisterBlockResultsWithEventLog(client *mocks.Client, height int64) (*tmrpctypes.ResultBlockResults, error) {
- res := &tmrpctypes.ResultBlockResults{
- Height: height,
- TxsResults: []*abci.ResponseDeliverTx{
- {Code: 0, GasUsed: 0, Events: []abci.Event{{
- Type: evm.EventTypeTxLog,
- Attributes: []abci.EventAttribute{{
- Key: evm.AttributeKeyTxLog,
- Value: "{\"test\": \"hello\"}", // TODO refactor the value to unmarshall to a evmtypes.Log struct successfully
- Index: true,
- }},
- }}},
- },
- }
- client.On("BlockResults", rpc.NewContextWithHeight(height), mock.AnythingOfType("*int64")).
- Return(res, nil)
- return res, nil
-}
-
-func RegisterBlockResults(
- client *mocks.Client,
- height int64,
-) (*tmrpctypes.ResultBlockResults, error) {
- res := &tmrpctypes.ResultBlockResults{
- Height: height,
- TxsResults: []*abci.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- }
-
- client.On("BlockResults", rpc.NewContextWithHeight(height), mock.AnythingOfType("*int64")).
- Return(res, nil)
- return res, nil
-}
-
-func RegisterBlockResultsError(client *mocks.Client, height int64) {
- client.On("BlockResults", rpc.NewContextWithHeight(height), mock.AnythingOfType("*int64")).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-func TestRegisterBlockResults(t *testing.T) {
- client := mocks.NewClient(t)
- height := int64(1)
- _, err := RegisterBlockResults(client, height)
- require.NoError(t, err)
-
- res, err := client.BlockResults(rpc.NewContextWithHeight(height), &height)
- expRes := &tmrpctypes.ResultBlockResults{
- Height: height,
- TxsResults: []*abci.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
- }
- require.Equal(t, expRes, res)
- require.NoError(t, err)
-}
-
-// BlockByHash
-func RegisterBlockByHash(
- client *mocks.Client,
- _ common.Hash,
- tx []byte,
-) (*tmrpctypes.ResultBlock, error) {
- block := types.MakeBlock(1, []types.Tx{tx}, nil, nil)
- resBlock := &tmrpctypes.ResultBlock{Block: block}
-
- client.On("BlockByHash", rpc.NewContextWithHeight(1), []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}).
- Return(resBlock, nil)
- return resBlock, nil
-}
-
-func RegisterBlockByHashError(client *mocks.Client, _ common.Hash, _ []byte) {
- client.On("BlockByHash", rpc.NewContextWithHeight(1), []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-func RegisterBlockByHashNotFound(client *mocks.Client, _ common.Hash, _ []byte) {
- client.On("BlockByHash", rpc.NewContextWithHeight(1), []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}).
- Return(nil, nil)
-}
-
-func RegisterABCIQueryWithOptions(client *mocks.Client, height int64, path string, data bytes.HexBytes, opts tmrpcclient.ABCIQueryOptions) {
- client.On("ABCIQueryWithOptions", context.Background(), path, data, opts).
- Return(&tmrpctypes.ResultABCIQuery{
- Response: abci.ResponseQuery{
- Value: []byte{2}, // TODO replace with data.Bytes(),
- Height: height,
- },
- }, nil)
-}
-
-func RegisterABCIQueryWithOptionsError(clients *mocks.Client, path string, data bytes.HexBytes, opts tmrpcclient.ABCIQueryOptions) {
- clients.On("ABCIQueryWithOptions", context.Background(), path, data, opts).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-func RegisterABCIQueryAccount(clients *mocks.Client, data bytes.HexBytes, opts tmrpcclient.ABCIQueryOptions, acc client.Account) {
- baseAccount := authtypes.NewBaseAccount(acc.GetAddress(), acc.GetPubKey(), acc.GetAccountNumber(), acc.GetSequence())
- accAny, _ := codectypes.NewAnyWithValue(baseAccount)
- accResponse := authtypes.QueryAccountResponse{Account: accAny}
- respBz, _ := accResponse.Marshal()
- clients.On("ABCIQueryWithOptions", context.Background(), "/cosmos.auth.v1beta1.Query/Account", data, opts).
- Return(&tmrpctypes.ResultABCIQuery{
- Response: abci.ResponseQuery{
- Value: respBz,
- Height: 1,
- },
- }, nil)
-}
diff --git a/eth/rpc/backend/evm_query_client_test.go b/eth/rpc/backend/evm_query_client_test.go
deleted file mode 100644
index 112cc8a07..000000000
--- a/eth/rpc/backend/evm_query_client_test.go
+++ /dev/null
@@ -1,324 +0,0 @@
-package backend
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "strconv"
- "testing"
-
- "cosmossdk.io/math"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
- grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
- "github.com/ethereum/go-ethereum/common"
- mock "github.com/stretchr/testify/mock"
- "github.com/stretchr/testify/require"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
- evmtest "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-// QueryClient defines a mocked object that implements the ethermint GRPC
-// QueryClient interface. It allows for performing QueryClient queries without having
-// to run a ethermint GRPC server.
-//
-// To use a mock method it has to be registered in a given test.
-var _ evm.QueryClient = &mocks.EVMQueryClient{}
-
-var TEST_CHAIN_ID_NUMBER = eth.ParseEIP155ChainIDNumber(eth.EIP155ChainID_Testnet).Int64()
-
-// TraceTransaction
-func RegisterTraceTransactionWithPredecessors(
- queryClient *mocks.EVMQueryClient, msgEthTx *evm.MsgEthereumTx, predecessors []*evm.MsgEthereumTx,
-) {
- data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d}
- queryClient.On("TraceTx", rpc.NewContextWithHeight(1),
- &evm.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: predecessors, ChainId: TEST_CHAIN_ID_NUMBER, BlockMaxGas: -1}).
- Return(&evm.QueryTraceTxResponse{Data: data}, nil)
-}
-
-func RegisterTraceTransaction(
- queryClient *mocks.EVMQueryClient, msgEthTx *evm.MsgEthereumTx,
-) {
- data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d}
- queryClient.On("TraceTx", rpc.NewContextWithHeight(1), &evm.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: TEST_CHAIN_ID_NUMBER, BlockMaxGas: -1}).
- Return(&evm.QueryTraceTxResponse{Data: data}, nil)
-}
-
-func RegisterTraceTransactionError(
- queryClient *mocks.EVMQueryClient, msgEthTx *evm.MsgEthereumTx,
-) {
- queryClient.On("TraceTx", rpc.NewContextWithHeight(1), &evm.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: TEST_CHAIN_ID_NUMBER}).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-// TraceBlock
-func RegisterTraceBlock(
- queryClient *mocks.EVMQueryClient, txs []*evm.MsgEthereumTx,
-) {
- data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d}
- queryClient.On("TraceBlock", rpc.NewContextWithHeight(1),
- &evm.QueryTraceBlockRequest{Txs: txs, BlockNumber: 1, TraceConfig: &evm.TraceConfig{}, ChainId: TEST_CHAIN_ID_NUMBER, BlockMaxGas: -1}).
- Return(&evm.QueryTraceBlockResponse{Data: data}, nil)
-}
-
-func RegisterTraceBlockError(queryClient *mocks.EVMQueryClient) {
- queryClient.On("TraceBlock", rpc.NewContextWithHeight(1), &evm.QueryTraceBlockRequest{}).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-// Params
-func RegisterParams(
- queryClient *mocks.EVMQueryClient, header *metadata.MD, height int64,
-) {
- queryClient.On("Params", rpc.NewContextWithHeight(height), &evm.QueryParamsRequest{}, grpc.Header(header)).
- Return(&evm.QueryParamsResponse{}, nil).
- Run(func(args mock.Arguments) {
- // If Params call is successful, also update the header height
- arg := args.Get(2).(grpc.HeaderCallOption)
- h := metadata.MD{}
- h.Set(grpctypes.GRPCBlockHeightHeader, fmt.Sprint(height))
- *arg.HeaderAddr = h
- })
-}
-
-func RegisterParamsWithoutHeader(
- queryClient *mocks.EVMQueryClient, height int64,
-) {
- queryClient.On("Params", rpc.NewContextWithHeight(height), &evm.QueryParamsRequest{}).
- Return(&evm.QueryParamsResponse{Params: evm.DefaultParams()}, nil)
-}
-
-func RegisterParamsInvalidHeader(
- queryClient *mocks.EVMQueryClient, header *metadata.MD, height int64,
-) {
- queryClient.On("Params", rpc.NewContextWithHeight(height), &evm.QueryParamsRequest{}, grpc.Header(header)).
- Return(&evm.QueryParamsResponse{}, nil).
- Run(func(args mock.Arguments) {
- // If Params call is successful, also update the header height
- arg := args.Get(2).(grpc.HeaderCallOption)
- h := metadata.MD{}
- *arg.HeaderAddr = h
- })
-}
-
-func RegisterParamsInvalidHeight(queryClient *mocks.EVMQueryClient, header *metadata.MD, height int64) {
- queryClient.On("Params", rpc.NewContextWithHeight(height), &evm.QueryParamsRequest{}, grpc.Header(header)).
- Return(&evm.QueryParamsResponse{}, nil).
- Run(func(args mock.Arguments) {
- // If Params call is successful, also update the header height
- arg := args.Get(2).(grpc.HeaderCallOption)
- h := metadata.MD{}
- h.Set(grpctypes.GRPCBlockHeightHeader, "invalid")
- *arg.HeaderAddr = h
- })
-}
-
-func RegisterParamsWithoutHeaderError(queryClient *mocks.EVMQueryClient, height int64) {
- queryClient.On("Params", rpc.NewContextWithHeight(height), &evm.QueryParamsRequest{}).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-// Params returns error
-func RegisterParamsError(
- queryClient *mocks.EVMQueryClient, header *metadata.MD, height int64,
-) {
- queryClient.On("Params", rpc.NewContextWithHeight(height), &evm.QueryParamsRequest{}, grpc.Header(header)).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-func TestRegisterParams(t *testing.T) {
- var header metadata.MD
- queryClient := mocks.NewEVMQueryClient(t)
-
- height := int64(1)
- RegisterParams(queryClient, &header, height)
-
- _, err := queryClient.Params(rpc.NewContextWithHeight(height), &evm.QueryParamsRequest{}, grpc.Header(&header))
- require.NoError(t, err)
- blockHeightHeader := header.Get(grpctypes.GRPCBlockHeightHeader)
- headerHeight, err := strconv.ParseInt(blockHeightHeader[0], 10, 64)
- require.NoError(t, err)
- require.Equal(t, height, headerHeight)
-}
-
-func TestRegisterParamsError(t *testing.T) {
- queryClient := mocks.NewEVMQueryClient(t)
- RegisterBaseFeeError(queryClient)
- _, err := queryClient.BaseFee(rpc.NewContextWithHeight(1), &evm.QueryBaseFeeRequest{})
- require.Error(t, err)
-}
-
-// ETH Call
-func RegisterEthCall(
- queryClient *mocks.EVMQueryClient, request *evm.EthCallRequest,
-) {
- ctx, _ := context.WithCancel(rpc.NewContextWithHeight(1)) //nolint
- queryClient.On("EthCall", ctx, request).
- Return(&evm.MsgEthereumTxResponse{}, nil)
-}
-
-func RegisterEthCallError(
- queryClient *mocks.EVMQueryClient, request *evm.EthCallRequest,
-) {
- ctx, _ := context.WithCancel(rpc.NewContextWithHeight(1)) //nolint
- queryClient.On("EthCall", ctx, request).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-// Estimate Gas
-func RegisterEstimateGas(
- queryClient *mocks.EVMQueryClient, args evm.JsonTxArgs,
-) {
- bz, _ := json.Marshal(args)
- queryClient.On("EstimateGas", rpc.NewContextWithHeight(1), &evm.EthCallRequest{Args: bz, ChainId: args.ChainID.ToInt().Int64()}).
- Return(&evm.EstimateGasResponse{}, nil)
-}
-
-// BaseFee
-func RegisterBaseFee(
- queryClient *mocks.EVMQueryClient, baseFee math.Int,
-) {
- queryClient.On("BaseFee", rpc.NewContextWithHeight(1), &evm.QueryBaseFeeRequest{}).
- Return(&evm.QueryBaseFeeResponse{BaseFee: &baseFee}, nil)
-}
-
-// Base fee returns error
-func RegisterBaseFeeError(queryClient *mocks.EVMQueryClient) {
- queryClient.On("BaseFee", rpc.NewContextWithHeight(1), &evm.QueryBaseFeeRequest{}).
- Return(&evm.QueryBaseFeeResponse{}, evm.ErrInvalidBaseFee)
-}
-
-// Base fee not enabled
-func RegisterBaseFeeDisabled(queryClient *mocks.EVMQueryClient) {
- queryClient.On("BaseFee", rpc.NewContextWithHeight(1), &evm.QueryBaseFeeRequest{}).
- Return(&evm.QueryBaseFeeResponse{}, nil)
-}
-
-func TestRegisterBaseFee(t *testing.T) {
- baseFee := math.NewInt(1)
- queryClient := mocks.NewEVMQueryClient(t)
- RegisterBaseFee(queryClient, baseFee)
- res, err := queryClient.BaseFee(rpc.NewContextWithHeight(1), &evm.QueryBaseFeeRequest{})
- require.Equal(t, &evm.QueryBaseFeeResponse{BaseFee: &baseFee}, res)
- require.NoError(t, err)
-}
-
-func TestRegisterBaseFeeError(t *testing.T) {
- queryClient := mocks.NewEVMQueryClient(t)
- RegisterBaseFeeError(queryClient)
- res, err := queryClient.BaseFee(rpc.NewContextWithHeight(1), &evm.QueryBaseFeeRequest{})
- require.Equal(t, &evm.QueryBaseFeeResponse{}, res)
- require.Error(t, err)
-}
-
-func TestRegisterBaseFeeDisabled(t *testing.T) {
- queryClient := mocks.NewEVMQueryClient(t)
- RegisterBaseFeeDisabled(queryClient)
- res, err := queryClient.BaseFee(rpc.NewContextWithHeight(1), &evm.QueryBaseFeeRequest{})
- require.Equal(t, &evm.QueryBaseFeeResponse{}, res)
- require.NoError(t, err)
-}
-
-// ValidatorAccount
-func RegisterValidatorAccount(
- queryClient *mocks.EVMQueryClient, validator sdk.AccAddress,
-) {
- queryClient.On("ValidatorAccount", rpc.NewContextWithHeight(1), &evm.QueryValidatorAccountRequest{}).
- Return(&evm.QueryValidatorAccountResponse{AccountAddress: validator.String()}, nil)
-}
-
-func RegisterValidatorAccountError(queryClient *mocks.EVMQueryClient) {
- queryClient.On("ValidatorAccount", rpc.NewContextWithHeight(1), &evm.QueryValidatorAccountRequest{}).
- Return(nil, status.Error(codes.InvalidArgument, "empty request"))
-}
-
-func TestRegisterValidatorAccount(t *testing.T) {
- queryClient := mocks.NewEVMQueryClient(t)
-
- validator := sdk.AccAddress(evmtest.NewEthAddr().Bytes())
- RegisterValidatorAccount(queryClient, validator)
- res, err := queryClient.ValidatorAccount(rpc.NewContextWithHeight(1), &evm.QueryValidatorAccountRequest{})
- require.Equal(t, &evm.QueryValidatorAccountResponse{AccountAddress: validator.String()}, res)
- require.NoError(t, err)
-}
-
-// Code
-func RegisterCode(
- queryClient *mocks.EVMQueryClient, addr common.Address, code []byte,
-) {
- queryClient.On("Code", rpc.NewContextWithHeight(1), &evm.QueryCodeRequest{Address: addr.String()}).
- Return(&evm.QueryCodeResponse{Code: code}, nil)
-}
-
-func RegisterCodeError(queryClient *mocks.EVMQueryClient, addr common.Address) {
- queryClient.On("Code", rpc.NewContextWithHeight(1), &evm.QueryCodeRequest{Address: addr.String()}).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-// Storage
-func RegisterStorageAt(
- queryClient *mocks.EVMQueryClient, addr common.Address,
- key string, storage string,
-) {
- queryClient.On("Storage", rpc.NewContextWithHeight(1), &evm.QueryStorageRequest{Address: addr.String(), Key: key}).
- Return(&evm.QueryStorageResponse{Value: storage}, nil)
-}
-
-func RegisterStorageAtError(
- queryClient *mocks.EVMQueryClient, addr common.Address, key string,
-) {
- queryClient.On("Storage", rpc.NewContextWithHeight(1), &evm.QueryStorageRequest{Address: addr.String(), Key: key}).
- Return(nil, errortypes.ErrInvalidRequest)
-}
-
-func RegisterAccount(
- queryClient *mocks.EVMQueryClient, addr common.Address, height int64,
-) {
- queryClient.On("EthAccount", rpc.NewContextWithHeight(height), &evm.QueryEthAccountRequest{Address: addr.String()}).
- Return(&evm.QueryEthAccountResponse{
- Balance: "0",
- CodeHash: "",
- Nonce: 0,
- },
- nil,
- )
-}
-
-// Balance
-func RegisterBalance(
- queryClient *mocks.EVMQueryClient, addr common.Address, height int64,
-) {
- queryClient.On("Balance", rpc.NewContextWithHeight(height), &evm.QueryBalanceRequest{Address: addr.String()}).
- Return(&evm.QueryBalanceResponse{Balance: "1"}, nil)
-}
-
-func RegisterBalanceInvalid(
- queryClient *mocks.EVMQueryClient, addr common.Address, height int64,
-) {
- queryClient.On("Balance", rpc.NewContextWithHeight(height), &evm.QueryBalanceRequest{Address: addr.String()}).
- Return(&evm.QueryBalanceResponse{Balance: "invalid"}, nil)
-}
-
-func RegisterBalanceNegative(
- queryClient *mocks.EVMQueryClient, addr common.Address, height int64,
-) {
- queryClient.On("Balance", rpc.NewContextWithHeight(height), &evm.QueryBalanceRequest{Address: addr.String()}).
- Return(&evm.QueryBalanceResponse{Balance: "-1"}, nil)
-}
-
-func RegisterBalanceError(
- queryClient *mocks.EVMQueryClient, addr common.Address, height int64,
-) {
- queryClient.On("Balance", rpc.NewContextWithHeight(height), &evm.QueryBalanceRequest{Address: addr.String()}).
- Return(nil, errortypes.ErrInvalidRequest)
-}
diff --git a/eth/rpc/backend/filters.go b/eth/rpc/backend/filters.go
deleted file mode 100644
index 244cda0e5..000000000
--- a/eth/rpc/backend/filters.go
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/pkg/errors"
-)
-
-// GetLogs returns all the logs from all the ethereum transactions in a block.
-func (b *Backend) GetLogs(hash common.Hash) ([][]*gethcore.Log, error) {
- resBlock, err := b.TendermintBlockByHash(hash)
- if err != nil {
- return nil, err
- }
- if resBlock == nil {
- return nil, errors.Errorf("block not found for hash %s", hash)
- }
- return b.GetLogsByHeight(&resBlock.Block.Header.Height)
-}
-
-// GetLogsByHeight returns all the logs from all the ethereum transactions in a block.
-func (b *Backend) GetLogsByHeight(height *int64) ([][]*gethcore.Log, error) {
- // NOTE: we query the state in case the tx result logs are not persisted after an upgrade.
- blockRes, err := b.TendermintBlockResultByNumber(height)
- if err != nil {
- return nil, err
- }
-
- return GetLogsFromBlockResults(blockRes)
-}
-
-// BloomStatus returns the BloomBitsBlocks and the number of processed sections maintained
-// by the chain indexer.
-func (b *Backend) BloomStatus() (uint64, uint64) {
- return 4096, 0
-}
diff --git a/eth/rpc/backend/filters_test.go b/eth/rpc/backend/filters_test.go
deleted file mode 100644
index 831a2c1bf..000000000
--- a/eth/rpc/backend/filters_test.go
+++ /dev/null
@@ -1,123 +0,0 @@
-package backend
-
-import (
- "encoding/json"
-
- tmtypes "github.com/cometbft/cometbft/types"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-func (s *BackendSuite) TestGetLogs() {
- _, bz := s.buildEthereumTx()
- block := tmtypes.MakeBlock(1, []tmtypes.Tx{bz}, nil, nil)
- logs := make([]*evm.Log, 0, 1)
- var log evm.Log
- err := json.Unmarshal([]byte("{\"test\": \"hello\"}"), &log) // TODO refactor this to unmarshall to a log struct successfully
- s.Require().NoError(err)
-
- logs = append(logs, &log)
-
- testCases := []struct {
- name string
- registerMock func(hash common.Hash)
- blockHash common.Hash
- expLogs [][]*gethcore.Log
- expPass bool
- }{
- {
- "fail - no block with that hash",
- func(hash common.Hash) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockByHashNotFound(client, hash, bz)
- },
- common.Hash{},
- nil,
- false,
- },
- {
- "fail - error fetching block by hash",
- func(hash common.Hash) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockByHashError(client, hash, bz)
- },
- common.Hash{},
- nil,
- false,
- },
- {
- "fail - error getting block results",
- func(hash common.Hash) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockByHash(client, hash, bz)
- s.Require().NoError(err)
- RegisterBlockResultsError(client, 1)
- },
- common.Hash{},
- nil,
- false,
- },
- {
- "success - getting logs with block hash",
- func(hash common.Hash) {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockByHash(client, hash, bz)
- s.Require().NoError(err)
- _, err = RegisterBlockResultsWithEventLog(client, rpc.BlockNumber(1).Int64())
- s.Require().NoError(err)
- },
- common.BytesToHash(block.Hash()),
- [][]*gethcore.Log{evm.LogsToEthereum(logs)},
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest()
-
- tc.registerMock(tc.blockHash)
- logs, err := s.backend.GetLogs(tc.blockHash)
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expLogs, logs)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestBloomStatus() {
- testCases := []struct {
- name string
- registerMock func()
- expResult uint64
- expPass bool
- }{
- {
- "pass - returns the BloomBitsBlocks and the number of processed sections maintained",
- func() {},
- 4096,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest()
-
- tc.registerMock()
- bloom, _ := s.backend.BloomStatus()
-
- if tc.expPass {
- s.Require().Equal(tc.expResult, bloom)
- }
- })
- }
-}
diff --git a/eth/rpc/backend/mocks/client.go b/eth/rpc/backend/mocks/client.go
deleted file mode 100644
index 2fabaa113..000000000
--- a/eth/rpc/backend/mocks/client.go
+++ /dev/null
@@ -1,887 +0,0 @@
-// Code generated by mockery v2.14.0. DO NOT EDIT.
-
-package mocks
-
-import (
- bytes "github.com/cometbft/cometbft/libs/bytes"
- client "github.com/cometbft/cometbft/rpc/client"
-
- context "context"
-
- coretypes "github.com/cometbft/cometbft/rpc/core/types"
-
- log "github.com/cometbft/cometbft/libs/log"
-
- mock "github.com/stretchr/testify/mock"
-
- types "github.com/cometbft/cometbft/types"
-)
-
-// Client is an autogenerated mock type for the Client type
-type Client struct {
- mock.Mock
-}
-
-// ABCIInfo provides a mock function with given fields: _a0
-func (_m *Client) ABCIInfo(_a0 context.Context) (*coretypes.ResultABCIInfo, error) {
- ret := _m.Called(_a0)
-
- var r0 *coretypes.ResultABCIInfo
- if rf, ok := ret.Get(0).(func(context.Context) *coretypes.ResultABCIInfo); ok {
- r0 = rf(_a0)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultABCIInfo)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context) error); ok {
- r1 = rf(_a0)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// ABCIQuery provides a mock function with given fields: ctx, path, data
-func (_m *Client) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error) {
- ret := _m.Called(ctx, path, data)
-
- var r0 *coretypes.ResultABCIQuery
- if rf, ok := ret.Get(0).(func(context.Context, string, bytes.HexBytes) *coretypes.ResultABCIQuery); ok {
- r0 = rf(ctx, path, data)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultABCIQuery)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, string, bytes.HexBytes) error); ok {
- r1 = rf(ctx, path, data)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// ABCIQueryWithOptions provides a mock function with given fields: ctx, path, data, opts
-func (_m *Client) ABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes, opts client.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) {
- ret := _m.Called(ctx, path, data, opts)
-
- var r0 *coretypes.ResultABCIQuery
- if rf, ok := ret.Get(0).(func(context.Context, string, bytes.HexBytes, client.ABCIQueryOptions) *coretypes.ResultABCIQuery); ok {
- r0 = rf(ctx, path, data, opts)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultABCIQuery)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, string, bytes.HexBytes, client.ABCIQueryOptions) error); ok {
- r1 = rf(ctx, path, data, opts)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Block provides a mock function with given fields: ctx, height
-func (_m *Client) Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error) {
- ret := _m.Called(ctx, height)
-
- var r0 *coretypes.ResultBlock
- if rf, ok := ret.Get(0).(func(context.Context, *int64) *coretypes.ResultBlock); ok {
- r0 = rf(ctx, height)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultBlock)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *int64) error); ok {
- r1 = rf(ctx, height)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// BlockByHash provides a mock function with given fields: ctx, hash
-func (_m *Client) BlockByHash(ctx context.Context, hash []byte) (*coretypes.ResultBlock, error) {
- ret := _m.Called(ctx, hash)
-
- var r0 *coretypes.ResultBlock
- if rf, ok := ret.Get(0).(func(context.Context, []byte) *coretypes.ResultBlock); ok {
- r0 = rf(ctx, hash)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultBlock)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, []byte) error); ok {
- r1 = rf(ctx, hash)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// BlockResults provides a mock function with given fields: ctx, height
-func (_m *Client) BlockResults(ctx context.Context, height *int64) (*coretypes.ResultBlockResults, error) {
- ret := _m.Called(ctx, height)
-
- var r0 *coretypes.ResultBlockResults
- if rf, ok := ret.Get(0).(func(context.Context, *int64) *coretypes.ResultBlockResults); ok {
- r0 = rf(ctx, height)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultBlockResults)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *int64) error); ok {
- r1 = rf(ctx, height)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// BlockSearch provides a mock function with given fields: ctx, query, page, perPage, orderBy
-func (_m *Client) BlockSearch(ctx context.Context, query string, page *int, perPage *int, orderBy string) (*coretypes.ResultBlockSearch, error) {
- ret := _m.Called(ctx, query, page, perPage, orderBy)
-
- var r0 *coretypes.ResultBlockSearch
- if rf, ok := ret.Get(0).(func(context.Context, string, *int, *int, string) *coretypes.ResultBlockSearch); ok {
- r0 = rf(ctx, query, page, perPage, orderBy)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultBlockSearch)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, string, *int, *int, string) error); ok {
- r1 = rf(ctx, query, page, perPage, orderBy)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// BlockchainInfo provides a mock function with given fields: ctx, minHeight, maxHeight
-func (_m *Client) BlockchainInfo(ctx context.Context, minHeight int64, maxHeight int64) (*coretypes.ResultBlockchainInfo, error) {
- ret := _m.Called(ctx, minHeight, maxHeight)
-
- var r0 *coretypes.ResultBlockchainInfo
- if rf, ok := ret.Get(0).(func(context.Context, int64, int64) *coretypes.ResultBlockchainInfo); ok {
- r0 = rf(ctx, minHeight, maxHeight)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultBlockchainInfo)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, int64, int64) error); ok {
- r1 = rf(ctx, minHeight, maxHeight)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// BroadcastEvidence provides a mock function with given fields: _a0, _a1
-func (_m *Client) BroadcastEvidence(_a0 context.Context, _a1 types.Evidence) (*coretypes.ResultBroadcastEvidence, error) {
- ret := _m.Called(_a0, _a1)
-
- var r0 *coretypes.ResultBroadcastEvidence
- if rf, ok := ret.Get(0).(func(context.Context, types.Evidence) *coretypes.ResultBroadcastEvidence); ok {
- r0 = rf(_a0, _a1)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultBroadcastEvidence)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, types.Evidence) error); ok {
- r1 = rf(_a0, _a1)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// BroadcastTxAsync provides a mock function with given fields: _a0, _a1
-func (_m *Client) BroadcastTxAsync(_a0 context.Context, _a1 types.Tx) (*coretypes.ResultBroadcastTx, error) {
- ret := _m.Called(_a0, _a1)
-
- var r0 *coretypes.ResultBroadcastTx
- if rf, ok := ret.Get(0).(func(context.Context, types.Tx) *coretypes.ResultBroadcastTx); ok {
- r0 = rf(_a0, _a1)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultBroadcastTx)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, types.Tx) error); ok {
- r1 = rf(_a0, _a1)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// BroadcastTxCommit provides a mock function with given fields: _a0, _a1
-func (_m *Client) BroadcastTxCommit(_a0 context.Context, _a1 types.Tx) (*coretypes.ResultBroadcastTxCommit, error) {
- ret := _m.Called(_a0, _a1)
-
- var r0 *coretypes.ResultBroadcastTxCommit
- if rf, ok := ret.Get(0).(func(context.Context, types.Tx) *coretypes.ResultBroadcastTxCommit); ok {
- r0 = rf(_a0, _a1)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultBroadcastTxCommit)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, types.Tx) error); ok {
- r1 = rf(_a0, _a1)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// BroadcastTxSync provides a mock function with given fields: _a0, _a1
-func (_m *Client) BroadcastTxSync(_a0 context.Context, _a1 types.Tx) (*coretypes.ResultBroadcastTx, error) {
- ret := _m.Called(_a0, _a1)
-
- var r0 *coretypes.ResultBroadcastTx
- if rf, ok := ret.Get(0).(func(context.Context, types.Tx) *coretypes.ResultBroadcastTx); ok {
- r0 = rf(_a0, _a1)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultBroadcastTx)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, types.Tx) error); ok {
- r1 = rf(_a0, _a1)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// CheckTx provides a mock function with given fields: _a0, _a1
-func (_m *Client) CheckTx(_a0 context.Context, _a1 types.Tx) (*coretypes.ResultCheckTx, error) {
- ret := _m.Called(_a0, _a1)
-
- var r0 *coretypes.ResultCheckTx
- if rf, ok := ret.Get(0).(func(context.Context, types.Tx) *coretypes.ResultCheckTx); ok {
- r0 = rf(_a0, _a1)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultCheckTx)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, types.Tx) error); ok {
- r1 = rf(_a0, _a1)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Commit provides a mock function with given fields: ctx, height
-func (_m *Client) Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error) {
- ret := _m.Called(ctx, height)
-
- var r0 *coretypes.ResultCommit
- if rf, ok := ret.Get(0).(func(context.Context, *int64) *coretypes.ResultCommit); ok {
- r0 = rf(ctx, height)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultCommit)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *int64) error); ok {
- r1 = rf(ctx, height)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// ConsensusParams provides a mock function with given fields: ctx, height
-func (_m *Client) ConsensusParams(ctx context.Context, height *int64) (*coretypes.ResultConsensusParams, error) {
- ret := _m.Called(ctx, height)
-
- var r0 *coretypes.ResultConsensusParams
- if rf, ok := ret.Get(0).(func(context.Context, *int64) *coretypes.ResultConsensusParams); ok {
- r0 = rf(ctx, height)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultConsensusParams)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *int64) error); ok {
- r1 = rf(ctx, height)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// ConsensusState provides a mock function with given fields: _a0
-func (_m *Client) ConsensusState(_a0 context.Context) (*coretypes.ResultConsensusState, error) {
- ret := _m.Called(_a0)
-
- var r0 *coretypes.ResultConsensusState
- if rf, ok := ret.Get(0).(func(context.Context) *coretypes.ResultConsensusState); ok {
- r0 = rf(_a0)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultConsensusState)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context) error); ok {
- r1 = rf(_a0)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// DumpConsensusState provides a mock function with given fields: _a0
-func (_m *Client) DumpConsensusState(_a0 context.Context) (*coretypes.ResultDumpConsensusState, error) {
- ret := _m.Called(_a0)
-
- var r0 *coretypes.ResultDumpConsensusState
- if rf, ok := ret.Get(0).(func(context.Context) *coretypes.ResultDumpConsensusState); ok {
- r0 = rf(_a0)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultDumpConsensusState)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context) error); ok {
- r1 = rf(_a0)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Genesis provides a mock function with given fields: _a0
-func (_m *Client) Genesis(_a0 context.Context) (*coretypes.ResultGenesis, error) {
- ret := _m.Called(_a0)
-
- var r0 *coretypes.ResultGenesis
- if rf, ok := ret.Get(0).(func(context.Context) *coretypes.ResultGenesis); ok {
- r0 = rf(_a0)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultGenesis)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context) error); ok {
- r1 = rf(_a0)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// GenesisChunked provides a mock function with given fields: _a0, _a1
-func (_m *Client) GenesisChunked(_a0 context.Context, _a1 uint) (*coretypes.ResultGenesisChunk, error) {
- ret := _m.Called(_a0, _a1)
-
- var r0 *coretypes.ResultGenesisChunk
- if rf, ok := ret.Get(0).(func(context.Context, uint) *coretypes.ResultGenesisChunk); ok {
- r0 = rf(_a0, _a1)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultGenesisChunk)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, uint) error); ok {
- r1 = rf(_a0, _a1)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Header provides a mock function with given fields: ctx, height
-func (_m *Client) Header(ctx context.Context, height *int64) (*coretypes.ResultHeader, error) {
- ret := _m.Called(ctx, height)
-
- var r0 *coretypes.ResultHeader
- if rf, ok := ret.Get(0).(func(context.Context, *int64) *coretypes.ResultHeader); ok {
- r0 = rf(ctx, height)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultHeader)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *int64) error); ok {
- r1 = rf(ctx, height)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// HeaderByHash provides a mock function with given fields: ctx, hash
-func (_m *Client) HeaderByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultHeader, error) {
- ret := _m.Called(ctx, hash)
-
- var r0 *coretypes.ResultHeader
- if rf, ok := ret.Get(0).(func(context.Context, bytes.HexBytes) *coretypes.ResultHeader); ok {
- r0 = rf(ctx, hash)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultHeader)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, bytes.HexBytes) error); ok {
- r1 = rf(ctx, hash)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Health provides a mock function with given fields: _a0
-func (_m *Client) Health(_a0 context.Context) (*coretypes.ResultHealth, error) {
- ret := _m.Called(_a0)
-
- var r0 *coretypes.ResultHealth
- if rf, ok := ret.Get(0).(func(context.Context) *coretypes.ResultHealth); ok {
- r0 = rf(_a0)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultHealth)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context) error); ok {
- r1 = rf(_a0)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// IsRunning provides a mock function with given fields:
-func (_m *Client) IsRunning() bool {
- ret := _m.Called()
-
- var r0 bool
- if rf, ok := ret.Get(0).(func() bool); ok {
- r0 = rf()
- } else {
- r0 = ret.Get(0).(bool)
- }
-
- return r0
-}
-
-// NetInfo provides a mock function with given fields: _a0
-func (_m *Client) NetInfo(_a0 context.Context) (*coretypes.ResultNetInfo, error) {
- ret := _m.Called(_a0)
-
- var r0 *coretypes.ResultNetInfo
- if rf, ok := ret.Get(0).(func(context.Context) *coretypes.ResultNetInfo); ok {
- r0 = rf(_a0)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultNetInfo)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context) error); ok {
- r1 = rf(_a0)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// NumUnconfirmedTxs provides a mock function with given fields: _a0
-func (_m *Client) NumUnconfirmedTxs(_a0 context.Context) (*coretypes.ResultUnconfirmedTxs, error) {
- ret := _m.Called(_a0)
-
- var r0 *coretypes.ResultUnconfirmedTxs
- if rf, ok := ret.Get(0).(func(context.Context) *coretypes.ResultUnconfirmedTxs); ok {
- r0 = rf(_a0)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultUnconfirmedTxs)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context) error); ok {
- r1 = rf(_a0)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// OnReset provides a mock function with given fields:
-func (_m *Client) OnReset() error {
- ret := _m.Called()
-
- var r0 error
- if rf, ok := ret.Get(0).(func() error); ok {
- r0 = rf()
- } else {
- r0 = ret.Error(0)
- }
-
- return r0
-}
-
-// OnStart provides a mock function with given fields:
-func (_m *Client) OnStart() error {
- ret := _m.Called()
-
- var r0 error
- if rf, ok := ret.Get(0).(func() error); ok {
- r0 = rf()
- } else {
- r0 = ret.Error(0)
- }
-
- return r0
-}
-
-// OnStop provides a mock function with given fields:
-func (_m *Client) OnStop() {
- _m.Called()
-}
-
-// Quit provides a mock function with given fields:
-func (_m *Client) Quit() <-chan struct{} {
- ret := _m.Called()
-
- var r0 <-chan struct{}
- if rf, ok := ret.Get(0).(func() <-chan struct{}); ok {
- r0 = rf()
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(<-chan struct{})
- }
- }
-
- return r0
-}
-
-// Reset provides a mock function with given fields:
-func (_m *Client) Reset() error {
- ret := _m.Called()
-
- var r0 error
- if rf, ok := ret.Get(0).(func() error); ok {
- r0 = rf()
- } else {
- r0 = ret.Error(0)
- }
-
- return r0
-}
-
-// SetLogger provides a mock function with given fields: _a0
-func (_m *Client) SetLogger(_a0 log.Logger) {
- _m.Called(_a0)
-}
-
-// Start provides a mock function with given fields:
-func (_m *Client) Start() error {
- ret := _m.Called()
-
- var r0 error
- if rf, ok := ret.Get(0).(func() error); ok {
- r0 = rf()
- } else {
- r0 = ret.Error(0)
- }
-
- return r0
-}
-
-// Status provides a mock function with given fields: _a0
-func (_m *Client) Status(_a0 context.Context) (*coretypes.ResultStatus, error) {
- ret := _m.Called(_a0)
-
- var r0 *coretypes.ResultStatus
- if rf, ok := ret.Get(0).(func(context.Context) *coretypes.ResultStatus); ok {
- r0 = rf(_a0)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultStatus)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context) error); ok {
- r1 = rf(_a0)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Stop provides a mock function with given fields:
-func (_m *Client) Stop() error {
- ret := _m.Called()
-
- var r0 error
- if rf, ok := ret.Get(0).(func() error); ok {
- r0 = rf()
- } else {
- r0 = ret.Error(0)
- }
-
- return r0
-}
-
-// String provides a mock function with given fields:
-func (_m *Client) String() string {
- ret := _m.Called()
-
- var r0 string
- if rf, ok := ret.Get(0).(func() string); ok {
- r0 = rf()
- } else {
- r0 = ret.Get(0).(string)
- }
-
- return r0
-}
-
-// Subscribe provides a mock function with given fields: ctx, subscriber, query, outCapacity
-func (_m *Client) Subscribe(ctx context.Context, subscriber string, query string, outCapacity ...int) (<-chan coretypes.ResultEvent, error) {
- _va := make([]interface{}, len(outCapacity))
- for _i := range outCapacity {
- _va[_i] = outCapacity[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, subscriber, query)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 <-chan coretypes.ResultEvent
- if rf, ok := ret.Get(0).(func(context.Context, string, string, ...int) <-chan coretypes.ResultEvent); ok {
- r0 = rf(ctx, subscriber, query, outCapacity...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(<-chan coretypes.ResultEvent)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, string, string, ...int) error); ok {
- r1 = rf(ctx, subscriber, query, outCapacity...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Tx provides a mock function with given fields: ctx, hash, prove
-func (_m *Client) Tx(ctx context.Context, hash []byte, prove bool) (*coretypes.ResultTx, error) {
- ret := _m.Called(ctx, hash, prove)
-
- var r0 *coretypes.ResultTx
- if rf, ok := ret.Get(0).(func(context.Context, []byte, bool) *coretypes.ResultTx); ok {
- r0 = rf(ctx, hash, prove)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultTx)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, []byte, bool) error); ok {
- r1 = rf(ctx, hash, prove)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// TxSearch provides a mock function with given fields: ctx, query, prove, page, perPage, orderBy
-func (_m *Client) TxSearch(ctx context.Context, query string, prove bool, page *int, perPage *int, orderBy string) (*coretypes.ResultTxSearch, error) {
- ret := _m.Called(ctx, query, prove, page, perPage, orderBy)
-
- var r0 *coretypes.ResultTxSearch
- if rf, ok := ret.Get(0).(func(context.Context, string, bool, *int, *int, string) *coretypes.ResultTxSearch); ok {
- r0 = rf(ctx, query, prove, page, perPage, orderBy)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultTxSearch)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, string, bool, *int, *int, string) error); ok {
- r1 = rf(ctx, query, prove, page, perPage, orderBy)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// UnconfirmedTxs provides a mock function with given fields: ctx, limit
-func (_m *Client) UnconfirmedTxs(ctx context.Context, limit *int) (*coretypes.ResultUnconfirmedTxs, error) {
- ret := _m.Called(ctx, limit)
-
- var r0 *coretypes.ResultUnconfirmedTxs
- if rf, ok := ret.Get(0).(func(context.Context, *int) *coretypes.ResultUnconfirmedTxs); ok {
- r0 = rf(ctx, limit)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultUnconfirmedTxs)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *int) error); ok {
- r1 = rf(ctx, limit)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Unsubscribe provides a mock function with given fields: ctx, subscriber, query
-func (_m *Client) Unsubscribe(ctx context.Context, subscriber string, query string) error {
- ret := _m.Called(ctx, subscriber, query)
-
- var r0 error
- if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
- r0 = rf(ctx, subscriber, query)
- } else {
- r0 = ret.Error(0)
- }
-
- return r0
-}
-
-// UnsubscribeAll provides a mock function with given fields: ctx, subscriber
-func (_m *Client) UnsubscribeAll(ctx context.Context, subscriber string) error {
- ret := _m.Called(ctx, subscriber)
-
- var r0 error
- if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
- r0 = rf(ctx, subscriber)
- } else {
- r0 = ret.Error(0)
- }
-
- return r0
-}
-
-// Validators provides a mock function with given fields: ctx, height, page, perPage
-func (_m *Client) Validators(ctx context.Context, height *int64, page *int, perPage *int) (*coretypes.ResultValidators, error) {
- ret := _m.Called(ctx, height, page, perPage)
-
- var r0 *coretypes.ResultValidators
- if rf, ok := ret.Get(0).(func(context.Context, *int64, *int, *int) *coretypes.ResultValidators); ok {
- r0 = rf(ctx, height, page, perPage)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*coretypes.ResultValidators)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *int64, *int, *int) error); ok {
- r1 = rf(ctx, height, page, perPage)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-type mockConstructorTestingTNewClient interface {
- mock.TestingT
- Cleanup(func())
-}
-
-// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-func NewClient(t mockConstructorTestingTNewClient) *Client {
- mock := &Client{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
diff --git a/eth/rpc/backend/mocks/evm_query_client.go b/eth/rpc/backend/mocks/evm_query_client.go
deleted file mode 100644
index e018a93a2..000000000
--- a/eth/rpc/backend/mocks/evm_query_client.go
+++ /dev/null
@@ -1,393 +0,0 @@
-// Code generated by mockery v2.14.0. DO NOT EDIT.
-
-package mocks
-
-import (
- context "context"
-
- grpc "google.golang.org/grpc"
-
- mock "github.com/stretchr/testify/mock"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// EVMQueryClient is an autogenerated mock type for the EVMQueryClient type
-type EVMQueryClient struct {
- mock.Mock
-}
-
-// EthAccount provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) EthAccount(ctx context.Context, in *evm.QueryEthAccountRequest, opts ...grpc.CallOption) (*evm.QueryEthAccountResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.QueryEthAccountResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.QueryEthAccountRequest, ...grpc.CallOption) *evm.QueryEthAccountResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.QueryEthAccountResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.QueryEthAccountRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Balance provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) Balance(ctx context.Context, in *evm.QueryBalanceRequest, opts ...grpc.CallOption) (*evm.QueryBalanceResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.QueryBalanceResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.QueryBalanceRequest, ...grpc.CallOption) *evm.QueryBalanceResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.QueryBalanceResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.QueryBalanceRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// BaseFee provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) BaseFee(ctx context.Context, in *evm.QueryBaseFeeRequest, opts ...grpc.CallOption) (*evm.QueryBaseFeeResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.QueryBaseFeeResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.QueryBaseFeeRequest, ...grpc.CallOption) *evm.QueryBaseFeeResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.QueryBaseFeeResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.QueryBaseFeeRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Code provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) Code(ctx context.Context, in *evm.QueryCodeRequest, opts ...grpc.CallOption) (*evm.QueryCodeResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.QueryCodeResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.QueryCodeRequest, ...grpc.CallOption) *evm.QueryCodeResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.QueryCodeResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.QueryCodeRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// NibiruAccount provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) NibiruAccount(ctx context.Context, in *evm.QueryNibiruAccountRequest, opts ...grpc.CallOption) (*evm.QueryNibiruAccountResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.QueryNibiruAccountResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.QueryNibiruAccountRequest, ...grpc.CallOption) *evm.QueryNibiruAccountResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.QueryNibiruAccountResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.QueryNibiruAccountRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// EstimateGas provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) EstimateGas(ctx context.Context, in *evm.EthCallRequest, opts ...grpc.CallOption) (*evm.EstimateGasResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.EstimateGasResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.EthCallRequest, ...grpc.CallOption) *evm.EstimateGasResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.EstimateGasResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.EthCallRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// EthCall provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) EthCall(ctx context.Context, in *evm.EthCallRequest, opts ...grpc.CallOption) (*evm.MsgEthereumTxResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.MsgEthereumTxResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.EthCallRequest, ...grpc.CallOption) *evm.MsgEthereumTxResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.MsgEthereumTxResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.EthCallRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Params provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) Params(ctx context.Context, in *evm.QueryParamsRequest, opts ...grpc.CallOption) (*evm.QueryParamsResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.QueryParamsResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.QueryParamsRequest, ...grpc.CallOption) *evm.QueryParamsResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.QueryParamsResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.QueryParamsRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// Storage provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) Storage(ctx context.Context, in *evm.QueryStorageRequest, opts ...grpc.CallOption) (*evm.QueryStorageResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.QueryStorageResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.QueryStorageRequest, ...grpc.CallOption) *evm.QueryStorageResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.QueryStorageResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.QueryStorageRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// TraceBlock provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) TraceBlock(ctx context.Context, in *evm.QueryTraceBlockRequest, opts ...grpc.CallOption) (*evm.QueryTraceBlockResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.QueryTraceBlockResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.QueryTraceBlockRequest, ...grpc.CallOption) *evm.QueryTraceBlockResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.QueryTraceBlockResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.QueryTraceBlockRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// TraceTx provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) TraceTx(ctx context.Context, in *evm.QueryTraceTxRequest, opts ...grpc.CallOption) (*evm.QueryTraceTxResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.QueryTraceTxResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.QueryTraceTxRequest, ...grpc.CallOption) *evm.QueryTraceTxResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.QueryTraceTxResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.QueryTraceTxRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// ValidatorAccount provides a mock function with given fields: ctx, in, opts
-func (_m *EVMQueryClient) ValidatorAccount(ctx context.Context, in *evm.QueryValidatorAccountRequest, opts ...grpc.CallOption) (*evm.QueryValidatorAccountResponse, error) {
- _va := make([]interface{}, len(opts))
- for _i := range opts {
- _va[_i] = opts[_i]
- }
- var _ca []interface{}
- _ca = append(_ca, ctx, in)
- _ca = append(_ca, _va...)
- ret := _m.Called(_ca...)
-
- var r0 *evm.QueryValidatorAccountResponse
- if rf, ok := ret.Get(0).(func(context.Context, *evm.QueryValidatorAccountRequest, ...grpc.CallOption) *evm.QueryValidatorAccountResponse); ok {
- r0 = rf(ctx, in, opts...)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*evm.QueryValidatorAccountResponse)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, *evm.QueryValidatorAccountRequest, ...grpc.CallOption) error); ok {
- r1 = rf(ctx, in, opts...)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-type mockConstructorTestingTNewEVMQueryClient interface {
- mock.TestingT
- Cleanup(func())
-}
-
-// NewEVMQueryClient creates a new instance of EVMQueryClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-func NewEVMQueryClient(t mockConstructorTestingTNewEVMQueryClient) *EVMQueryClient {
- mock := &EVMQueryClient{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
diff --git a/eth/rpc/backend/node_info.go b/eth/rpc/backend/node_info.go
deleted file mode 100644
index e99cee5d9..000000000
--- a/eth/rpc/backend/node_info.go
+++ /dev/null
@@ -1,341 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "fmt"
- "math/big"
- "time"
-
- errorsmod "cosmossdk.io/errors"
- sdkmath "cosmossdk.io/math"
- tmtypes "github.com/cometbft/cometbft/types"
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/client/tx"
- sdkcrypto "github.com/cosmos/cosmos-sdk/crypto"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- sdkconfig "github.com/cosmos/cosmos-sdk/server/config"
- sdk "github.com/cosmos/cosmos-sdk/types"
- authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
- distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/crypto"
-
- "github.com/NibiruChain/nibiru/app/server/config"
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// Accounts returns the list of accounts available to this node.
-func (b *Backend) Accounts() ([]common.Address, error) {
- addresses := make([]common.Address, 0) // return [] instead of nil if empty
-
- infos, err := b.clientCtx.Keyring.List()
- if err != nil {
- return addresses, err
- }
-
- for _, info := range infos {
- pubKey, err := info.GetPubKey()
- if err != nil {
- return nil, err
- }
- addressBytes := pubKey.Address().Bytes()
- addresses = append(addresses, common.BytesToAddress(addressBytes))
- }
-
- return addresses, nil
-}
-
-// Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not
-// yet received the latest block headers from its pears. In case it is synchronizing:
-// - startingBlock: block number this node started to synchronize from
-// - currentBlock: block number this node is currently importing
-// - highestBlock: block number of the highest block header this node has received from peers
-// - pulledStates: number of state entries processed until now
-// - knownStates: number of known state entries that still need to be pulled
-func (b *Backend) Syncing() (interface{}, error) {
- status, err := b.clientCtx.Client.Status(b.ctx)
- if err != nil {
- return false, err
- }
-
- if !status.SyncInfo.CatchingUp {
- return false, nil
- }
-
- return map[string]interface{}{
- "startingBlock": hexutil.Uint64(status.SyncInfo.EarliestBlockHeight),
- "currentBlock": hexutil.Uint64(status.SyncInfo.LatestBlockHeight),
- // "highestBlock": nil, // NA
- // "pulledStates": nil, // NA
- // "knownStates": nil, // NA
- }, nil
-}
-
-// SetEtherbase sets the etherbase of the miner
-func (b *Backend) SetEtherbase(etherbase common.Address) bool {
- delAddr, err := b.GetCoinbase()
- if err != nil {
- b.logger.Debug("failed to get coinbase address", "error", err.Error())
- return false
- }
-
- withdrawAddr := sdk.AccAddress(etherbase.Bytes())
- msg := distributiontypes.NewMsgSetWithdrawAddress(delAddr, withdrawAddr)
-
- if err := msg.ValidateBasic(); err != nil {
- b.logger.Debug("tx failed basic validation", "error", err.Error())
- return false
- }
-
- // Assemble transaction from fields
- builder, ok := b.clientCtx.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder)
- if !ok {
- b.logger.Debug("clientCtx.TxConfig.NewTxBuilder returns unsupported builder", "error", err.Error())
- return false
- }
-
- err = builder.SetMsgs(msg)
- if err != nil {
- b.logger.Error("builder.SetMsgs failed", "error", err.Error())
- return false
- }
-
- // Fetch minimun gas price to calculate fees using the configuration.
- minGasPrices := b.cfg.GetMinGasPrices()
- if len(minGasPrices) == 0 || minGasPrices.Empty() {
- b.logger.Debug("the minimun fee is not set")
- return false
- }
- minGasPriceValue := minGasPrices[0].Amount
- denom := minGasPrices[0].Denom
-
- delCommonAddr := common.BytesToAddress(delAddr.Bytes())
- nonce, err := b.GetTransactionCount(delCommonAddr, rpc.EthPendingBlockNumber)
- if err != nil {
- b.logger.Debug("failed to get nonce", "error", err.Error())
- return false
- }
-
- txFactory := tx.Factory{}
- txFactory = txFactory.
- WithChainID(b.clientCtx.ChainID).
- WithKeybase(b.clientCtx.Keyring).
- WithTxConfig(b.clientCtx.TxConfig).
- WithSequence(uint64(*nonce)).
- WithGasAdjustment(1.25)
-
- _, gas, err := tx.CalculateGas(b.clientCtx, txFactory, msg)
- if err != nil {
- b.logger.Debug("failed to calculate gas", "error", err.Error())
- return false
- }
-
- txFactory = txFactory.WithGas(gas)
-
- value := new(big.Int).SetUint64(gas * minGasPriceValue.Ceil().TruncateInt().Uint64())
- fees := sdk.Coins{sdk.NewCoin(denom, sdkmath.NewIntFromBigInt(value))}
- builder.SetFeeAmount(fees)
- builder.SetGasLimit(gas)
-
- keyInfo, err := b.clientCtx.Keyring.KeyByAddress(delAddr)
- if err != nil {
- b.logger.Debug("failed to get the wallet address using the keyring", "error", err.Error())
- return false
- }
-
- if err := tx.Sign(txFactory, keyInfo.Name, builder, false); err != nil {
- b.logger.Debug("failed to sign tx", "error", err.Error())
- return false
- }
-
- // Encode transaction by default Tx encoder
- txEncoder := b.clientCtx.TxConfig.TxEncoder()
- txBytes, err := txEncoder(builder.GetTx())
- if err != nil {
- b.logger.Debug("failed to encode eth tx using default encoder", "error", err.Error())
- return false
- }
-
- tmHash := common.BytesToHash(tmtypes.Tx(txBytes).Hash())
-
- // Broadcast transaction in sync mode (default)
- // NOTE: If error is encountered on the node, the broadcast will not return an error
- syncCtx := b.clientCtx.WithBroadcastMode(flags.BroadcastSync)
- rsp, err := syncCtx.BroadcastTx(txBytes)
- if rsp != nil && rsp.Code != 0 {
- err = errorsmod.ABCIError(rsp.Codespace, rsp.Code, rsp.RawLog)
- }
- if err != nil {
- b.logger.Debug("failed to broadcast tx", "error", err.Error())
- return false
- }
-
- b.logger.Debug("broadcasted tx to set miner withdraw address (etherbase)", "hash", tmHash.String())
- return true
-}
-
-// ImportRawKey armors and encrypts a given raw hex encoded ECDSA key and stores it into the key directory.
-// The name of the key will have the format "personal_", where is the total number of
-// keys stored on the keyring.
-//
-// NOTE: The key will be both armored and encrypted using the same passphrase.
-func (b *Backend) ImportRawKey(privkey, password string) (common.Address, error) {
- priv, err := crypto.HexToECDSA(privkey)
- if err != nil {
- return common.Address{}, err
- }
-
- privKey := ðsecp256k1.PrivKey{Key: crypto.FromECDSA(priv)}
-
- addr := sdk.AccAddress(privKey.PubKey().Address().Bytes())
- ethereumAddr := common.BytesToAddress(addr)
-
- // return if the key has already been imported
- if _, err := b.clientCtx.Keyring.KeyByAddress(addr); err == nil {
- return ethereumAddr, nil
- }
-
- // ignore error as we only care about the length of the list
- list, _ := b.clientCtx.Keyring.List() // #nosec G703
- privKeyName := fmt.Sprintf("personal_%d", len(list))
-
- armor := sdkcrypto.EncryptArmorPrivKey(privKey, password, ethsecp256k1.KeyType)
-
- if err := b.clientCtx.Keyring.ImportPrivKey(privKeyName, armor, password); err != nil {
- return common.Address{}, err
- }
-
- b.logger.Info("key successfully imported", "name", privKeyName, "address", ethereumAddr.String())
-
- return ethereumAddr, nil
-}
-
-// ListAccounts will return a list of addresses for accounts this node manages.
-func (b *Backend) ListAccounts() ([]common.Address, error) {
- addrs := []common.Address{}
-
- list, err := b.clientCtx.Keyring.List()
- if err != nil {
- return nil, err
- }
-
- for _, info := range list {
- pubKey, err := info.GetPubKey()
- if err != nil {
- return nil, err
- }
- addrs = append(addrs, common.BytesToAddress(pubKey.Address()))
- }
-
- return addrs, nil
-}
-
-// NewAccount will create a new account and returns the address for the new account.
-func (b *Backend) NewMnemonic(uid string,
- _ keyring.Language,
- hdPath,
- bip39Passphrase string,
- algo keyring.SignatureAlgo,
-) (*keyring.Record, error) {
- info, _, err := b.clientCtx.Keyring.NewMnemonic(uid, keyring.English, hdPath, bip39Passphrase, algo)
- if err != nil {
- return nil, err
- }
- return info, err
-}
-
-// SetGasPrice sets the minimum accepted gas price for the miner.
-// NOTE: this function accepts only integers to have the same interface than go-eth
-// to use float values, the gas prices must be configured using the configuration file
-func (b *Backend) SetGasPrice(gasPrice hexutil.Big) bool {
- appConf, err := config.GetConfig(b.clientCtx.Viper)
- if err != nil {
- b.logger.Debug("could not get the server config", "error", err.Error())
- return false
- }
-
- var unit string
- minGasPrices := appConf.GetMinGasPrices()
-
- // fetch the base denom from the sdk Config in case it's not currently defined on the node config
- if len(minGasPrices) == 0 || minGasPrices.Empty() {
- var err error
- unit, err = sdk.GetBaseDenom()
- if err != nil {
- b.logger.Debug("could not get the denom of smallest unit registered", "error", err.Error())
- return false
- }
- } else {
- unit = minGasPrices[0].Denom
- }
-
- c := sdk.NewDecCoin(unit, sdkmath.NewIntFromBigInt(gasPrice.ToInt()))
-
- appConf.SetMinGasPrices(sdk.DecCoins{c})
- sdkconfig.WriteConfigFile(b.clientCtx.Viper.ConfigFileUsed(), appConf)
- b.logger.Info("Your configuration file was modified. Please RESTART your node.", "gas-price", c.String())
- return true
-}
-
-// UnprotectedAllowed returns the node configuration value for allowing
-// unprotected transactions (i.e not replay-protected)
-func (b Backend) UnprotectedAllowed() bool {
- return b.allowUnprotectedTxs
-}
-
-// RPCGasCap is the global gas cap for eth-call variants.
-func (b *Backend) RPCGasCap() uint64 {
- return b.cfg.JSONRPC.GasCap
-}
-
-// RPCEVMTimeout is the global evm timeout for eth-call variants.
-func (b *Backend) RPCEVMTimeout() time.Duration {
- return b.cfg.JSONRPC.EVMTimeout
-}
-
-// RPCGasCap is the global gas cap for eth-call variants.
-func (b *Backend) RPCTxFeeCap() float64 {
- return b.cfg.JSONRPC.TxFeeCap
-}
-
-// RPCFilterCap is the limit for total number of filters that can be created
-func (b *Backend) RPCFilterCap() int32 {
- return b.cfg.JSONRPC.FilterCap
-}
-
-// RPCFeeHistoryCap is the limit for total number of blocks that can be fetched
-func (b *Backend) RPCFeeHistoryCap() int32 {
- return b.cfg.JSONRPC.FeeHistoryCap
-}
-
-// RPCLogsCap defines the max number of results can be returned from single `eth_getLogs` query.
-func (b *Backend) RPCLogsCap() int32 {
- return b.cfg.JSONRPC.LogsCap
-}
-
-// RPCBlockRangeCap defines the max block range allowed for `eth_getLogs` query.
-func (b *Backend) RPCBlockRangeCap() int32 {
- return b.cfg.JSONRPC.BlockRangeCap
-}
-
-// RPCMinGasPrice returns the minimum gas price for a transaction obtained from
-// the node config. If set value is 0, it will default to 20.
-
-func (b *Backend) RPCMinGasPrice() int64 {
- evmParams, err := b.queryClient.Params(b.ctx, &evm.QueryParamsRequest{})
- if err != nil {
- return eth.DefaultGasPrice
- }
-
- minGasPrice := b.cfg.GetMinGasPrices()
- amt := minGasPrice.AmountOf(evmParams.Params.EvmDenom).TruncateInt64()
- if amt == 0 {
- return eth.DefaultGasPrice
- }
-
- return amt
-}
diff --git a/eth/rpc/backend/node_info_test.go b/eth/rpc/backend/node_info_test.go
deleted file mode 100644
index 87fe46b63..000000000
--- a/eth/rpc/backend/node_info_test.go
+++ /dev/null
@@ -1,335 +0,0 @@
-package backend
-
-import (
- "fmt"
- "math/big"
-
- "cosmossdk.io/math"
- tmrpcclient "github.com/cometbft/cometbft/rpc/client"
- sdk "github.com/cosmos/cosmos-sdk/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/spf13/viper"
- "google.golang.org/grpc/metadata"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
-)
-
-func (s *BackendSuite) TestRPCMinGasPrice() {
- testCases := []struct {
- name string
- registerMock func()
- expMinGasPrice int64
- expPass bool
- }{
- {
- "pass - default gas price",
- func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParamsWithoutHeaderError(queryClient, 1)
- },
- eth.DefaultGasPrice,
- true,
- },
- {
- "pass - min gas price is 0",
- func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParamsWithoutHeader(queryClient, 1)
- },
- eth.DefaultGasPrice,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- minPrice := s.backend.RPCMinGasPrice()
- if tc.expPass {
- s.Require().Equal(tc.expMinGasPrice, minPrice)
- } else {
- s.Require().NotEqual(tc.expMinGasPrice, minPrice)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestSetGasPrice() {
- defaultGasPrice := (*hexutil.Big)(big.NewInt(1))
- testCases := []struct {
- name string
- registerMock func()
- gasPrice hexutil.Big
- expOutput bool
- }{
- {
- "pass - cannot get server config",
- func() {
- s.backend.clientCtx.Viper = viper.New()
- },
- *defaultGasPrice,
- false,
- },
- {
- "pass - cannot find coin denom",
- func() {
- s.backend.clientCtx.Viper = viper.New()
- s.backend.clientCtx.Viper.Set("telemetry.global-labels", []interface{}{})
- },
- *defaultGasPrice,
- false,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
- output := s.backend.SetGasPrice(tc.gasPrice)
- s.Require().Equal(tc.expOutput, output)
- })
- }
-}
-
-// TODO: Combine these 2 into one test since the code is identical
-func (s *BackendSuite) TestListAccounts() {
- testCases := []struct {
- name string
- registerMock func()
- expAddr []common.Address
- expPass bool
- }{
- {
- "pass - returns empty address",
- func() {},
- []common.Address{},
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- output, err := s.backend.ListAccounts()
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expAddr, output)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestAccounts() {
- testCases := []struct {
- name string
- registerMock func()
- expAddr []common.Address
- expPass bool
- }{
- {
- "pass - returns empty address",
- func() {},
- []common.Address{},
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- output, err := s.backend.Accounts()
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expAddr, output)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestSyncing() {
- testCases := []struct {
- name string
- registerMock func()
- expResponse interface{}
- expPass bool
- }{
- {
- "fail - Can't get status",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterStatusError(client)
- },
- false,
- false,
- },
- {
- "pass - Node not catching up",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterStatus(client)
- },
- false,
- true,
- },
- {
- "pass - Node is catching up",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterStatus(client)
- status, _ := client.Status(s.backend.ctx)
- status.SyncInfo.CatchingUp = true
- },
- map[string]interface{}{
- "startingBlock": hexutil.Uint64(0),
- "currentBlock": hexutil.Uint64(0),
- },
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- output, err := s.backend.Syncing()
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expResponse, output)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestSetEtherbase() {
- testCases := []struct {
- name string
- registerMock func()
- etherbase common.Address
- expResult bool
- }{
- {
- "pass - Failed to get coinbase address",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterStatusError(client)
- },
- common.Address{},
- false,
- },
- {
- "pass - the minimum fee is not set",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterStatus(client)
- RegisterValidatorAccount(queryClient, s.acc)
- },
- common.Address{},
- false,
- },
- {
- "fail - error querying for account",
- func() {
- var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterStatus(client)
- RegisterValidatorAccount(queryClient, s.acc)
- RegisterParams(queryClient, &header, 1)
- c := sdk.NewDecCoin(eth.EthBaseDenom, math.NewIntFromBigInt(big.NewInt(1)))
- s.backend.cfg.SetMinGasPrices(sdk.DecCoins{c})
- delAddr, _ := s.backend.GetCoinbase()
- // account, _ := suite.backend.clientCtx.AccountRetriever.GetAccount(suite.backend.clientCtx, delAddr)
- delCommonAddr := common.BytesToAddress(delAddr.Bytes())
- request := &authtypes.QueryAccountRequest{Address: sdk.AccAddress(delCommonAddr.Bytes()).String()}
- requestMarshal, _ := request.Marshal()
- RegisterABCIQueryWithOptionsError(
- client,
- "/cosmos.auth.v1beta1.Query/Account",
- requestMarshal,
- tmrpcclient.ABCIQueryOptions{Height: int64(1), Prove: false},
- )
- },
- common.Address{},
- false,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- output := s.backend.SetEtherbase(tc.etherbase)
-
- s.Require().Equal(tc.expResult, output)
- })
- }
-}
-
-func (s *BackendSuite) TestImportRawKey() {
- priv, _ := ethsecp256k1.GenerateKey()
- privHex := common.Bytes2Hex(priv.Bytes())
- pubAddr := common.BytesToAddress(priv.PubKey().Address().Bytes())
-
- testCases := []struct {
- name string
- registerMock func()
- privKey string
- password string
- expAddr common.Address
- expPass bool
- }{
- {
- "fail - not a valid private key",
- func() {},
- "",
- "",
- common.Address{},
- false,
- },
- {
- "pass - returning correct address",
- func() {},
- privHex,
- "",
- pubAddr,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- output, err := s.backend.ImportRawKey(tc.privKey, tc.password)
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expAddr, output)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
diff --git a/eth/rpc/backend/sign_tx.go b/eth/rpc/backend/sign_tx.go
deleted file mode 100644
index 806df48d4..000000000
--- a/eth/rpc/backend/sign_tx.go
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "errors"
- "fmt"
- "math/big"
-
- errorsmod "cosmossdk.io/errors"
- "github.com/cosmos/cosmos-sdk/client/flags"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/signer/core/apitypes"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// SendTransaction sends transaction based on received args using Node's key to sign it
-func (b *Backend) SendTransaction(args evm.JsonTxArgs) (common.Hash, error) {
- // Look up the wallet containing the requested signer
- _, err := b.clientCtx.Keyring.KeyByAddress(sdk.AccAddress(args.GetFrom().Bytes()))
- if err != nil {
- b.logger.Error("failed to find key in keyring", "address", args.GetFrom(), "error", err.Error())
- return common.Hash{}, fmt.Errorf("failed to find key in the node's keyring; %s; %s", keystore.ErrNoMatch, err.Error())
- }
-
- if args.ChainID != nil && (b.chainID).Cmp((*big.Int)(args.ChainID)) != 0 {
- return common.Hash{}, fmt.Errorf("chainId does not match node's (have=%v, want=%v)", args.ChainID, (*hexutil.Big)(b.chainID))
- }
-
- args, err = b.SetTxDefaults(args)
- if err != nil {
- return common.Hash{}, err
- }
-
- bn, err := b.BlockNumber()
- if err != nil {
- b.logger.Debug("failed to fetch latest block number", "error", err.Error())
- return common.Hash{}, err
- }
-
- signer := gethcore.MakeSigner(b.ChainConfig(), new(big.Int).SetUint64(uint64(bn)))
-
- // LegacyTx derives chainID from the signature. To make sure the msg.ValidateBasic makes
- // the corresponding chainID validation, we need to sign the transaction before calling it
-
- // Sign transaction
- msg := args.ToTransaction()
- if err := msg.Sign(signer, b.clientCtx.Keyring); err != nil {
- b.logger.Debug("failed to sign tx", "error", err.Error())
- return common.Hash{}, err
- }
-
- if err := msg.ValidateBasic(); err != nil {
- b.logger.Debug("tx failed basic validation", "error", err.Error())
- return common.Hash{}, err
- }
-
- // Query params to use the EVM denomination
- res, err := b.queryClient.QueryClient.Params(b.ctx, &evm.QueryParamsRequest{})
- if err != nil {
- b.logger.Error("failed to query evm params", "error", err.Error())
- return common.Hash{}, err
- }
-
- // Assemble transaction from fields
- tx, err := msg.BuildTx(b.clientCtx.TxConfig.NewTxBuilder(), res.Params.EvmDenom)
- if err != nil {
- b.logger.Error("build cosmos tx failed", "error", err.Error())
- return common.Hash{}, err
- }
-
- // Encode transaction by default Tx encoder
- txEncoder := b.clientCtx.TxConfig.TxEncoder()
- txBytes, err := txEncoder(tx)
- if err != nil {
- b.logger.Error("failed to encode eth tx using default encoder", "error", err.Error())
- return common.Hash{}, err
- }
-
- ethTx := msg.AsTransaction()
-
- // check the local node config in case unprotected txs are disabled
- if !b.UnprotectedAllowed() && !ethTx.Protected() {
- // Ensure only eip155 signed transactions are submitted if EIP155Required is set.
- return common.Hash{}, errors.New("only replay-protected (EIP-155) transactions allowed over RPC")
- }
-
- txHash := ethTx.Hash()
-
- // Broadcast transaction in sync mode (default)
- // NOTE: If error is encountered on the node, the broadcast will not return an error
- syncCtx := b.clientCtx.WithBroadcastMode(flags.BroadcastSync)
- rsp, err := syncCtx.BroadcastTx(txBytes)
- if rsp != nil && rsp.Code != 0 {
- err = errorsmod.ABCIError(rsp.Codespace, rsp.Code, rsp.RawLog)
- }
- if err != nil {
- b.logger.Error("failed to broadcast tx", "error", err.Error())
- return txHash, err
- }
-
- // Return transaction hash
- return txHash, nil
-}
-
-// Sign signs the provided data using the private key of address via Geth's signature standard.
-func (b *Backend) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) {
- from := sdk.AccAddress(address.Bytes())
-
- _, err := b.clientCtx.Keyring.KeyByAddress(from)
- if err != nil {
- b.logger.Error("failed to find key in keyring", "address", address.String())
- return nil, fmt.Errorf("%s; %s", keystore.ErrNoMatch, err.Error())
- }
-
- // Sign the requested hash with the wallet
- signature, _, err := b.clientCtx.Keyring.SignByAddress(from, data)
- if err != nil {
- b.logger.Error("keyring.SignByAddress failed", "address", address.Hex())
- return nil, err
- }
-
- signature[crypto.RecoveryIDOffset] += 27 // Transform V from 0/1 to 27/28 according to the yellow paper
- return signature, nil
-}
-
-// SignTypedData signs EIP-712 conformant typed data
-func (b *Backend) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) {
- from := sdk.AccAddress(address.Bytes())
-
- _, err := b.clientCtx.Keyring.KeyByAddress(from)
- if err != nil {
- b.logger.Error("failed to find key in keyring", "address", address.String())
- return nil, fmt.Errorf("%s; %s", keystore.ErrNoMatch, err.Error())
- }
-
- sigHash, _, err := apitypes.TypedDataAndHash(typedData)
- if err != nil {
- return nil, err
- }
-
- // Sign the requested hash with the wallet
- signature, _, err := b.clientCtx.Keyring.SignByAddress(from, sigHash)
- if err != nil {
- b.logger.Error("keyring.SignByAddress failed", "address", address.Hex())
- return nil, err
- }
-
- signature[crypto.RecoveryIDOffset] += 27 // Transform V from 0/1 to 27/28 according to the yellow paper
- return signature, nil
-}
diff --git a/eth/rpc/backend/sign_tx_test.go b/eth/rpc/backend/sign_tx_test.go
deleted file mode 100644
index 7141bf5bb..000000000
--- a/eth/rpc/backend/sign_tx_test.go
+++ /dev/null
@@ -1,270 +0,0 @@
-package backend
-
-import (
- "fmt"
-
- "cosmossdk.io/math"
-
- "github.com/cosmos/cosmos-sdk/crypto"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- goethcrypto "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/signer/core/apitypes"
- "google.golang.org/grpc/metadata"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
- evmtest "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-func (s *BackendSuite) TestSendTransaction() {
- gasPrice := new(hexutil.Big)
- gas := hexutil.Uint64(1)
- zeroGas := hexutil.Uint64(0)
- toAddr := evmtest.NewEthAddr()
- priv, _ := ethsecp256k1.GenerateKey()
- from := common.BytesToAddress(priv.PubKey().Address().Bytes())
- nonce := hexutil.Uint64(1)
- baseFee := math.NewInt(1)
- callArgsDefault := evm.JsonTxArgs{
- From: &from,
- To: &toAddr,
- GasPrice: gasPrice,
- Gas: &gas,
- Nonce: &nonce,
- }
-
- hash := common.Hash{}
-
- testCases := []struct {
- name string
- registerMock func()
- args evm.JsonTxArgs
- expHash common.Hash
- expPass bool
- }{
- {
- "fail - Can't find account in Keyring",
- func() {},
- evm.JsonTxArgs{},
- hash,
- false,
- },
- {
- "fail - Block error can't set Tx defaults",
- func() {
- var header metadata.MD
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- armor := crypto.EncryptArmorPrivKey(priv, "", "eth_secp256k1")
- err := s.backend.clientCtx.Keyring.ImportPrivKey("test_key", armor, "")
- s.Require().NoError(err)
- RegisterParams(queryClient, &header, 1)
- RegisterBlockError(client, 1)
- },
- callArgsDefault,
- hash,
- false,
- },
- {
- "fail - Cannot validate transaction gas set to 0",
- func() {
- var header metadata.MD
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- armor := crypto.EncryptArmorPrivKey(priv, "", "eth_secp256k1")
- err := s.backend.clientCtx.Keyring.ImportPrivKey("test_key", armor, "")
- s.Require().NoError(err)
- RegisterParams(queryClient, &header, 1)
- _, err = RegisterBlock(client, 1, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, baseFee)
- RegisterParamsWithoutHeader(queryClient, 1)
- },
- evm.JsonTxArgs{
- From: &from,
- To: &toAddr,
- GasPrice: gasPrice,
- Gas: &zeroGas,
- Nonce: &nonce,
- },
- hash,
- false,
- },
- {
- "fail - Cannot broadcast transaction",
- func() {
- client, txBytes := broadcastTx(s, priv, baseFee, callArgsDefault)
- RegisterBroadcastTxError(client, txBytes)
- },
- callArgsDefault,
- common.Hash{},
- false,
- },
- {
- "pass - Return the transaction hash",
- func() {
- client, txBytes := broadcastTx(s, priv, baseFee, callArgsDefault)
- RegisterBroadcastTx(client, txBytes)
- },
- callArgsDefault,
- hash,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- if tc.expPass {
- // Sign the transaction and get the hash
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParamsWithoutHeader(queryClient, 1)
- ethSigner := gethcore.LatestSigner(s.backend.ChainConfig())
- msg := callArgsDefault.ToTransaction()
- err := msg.Sign(ethSigner, s.backend.clientCtx.Keyring)
- s.Require().NoError(err)
- tc.expHash = msg.AsTransaction().Hash()
- }
- responseHash, err := s.backend.SendTransaction(tc.args)
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expHash, responseHash)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestSign() {
- from, priv := evmtest.PrivKeyEth()
- testCases := []struct {
- name string
- registerMock func()
- fromAddr common.Address
- inputBz hexutil.Bytes
- expPass bool
- }{
- {
- "fail - can't find key in Keyring",
- func() {},
- from,
- nil,
- false,
- },
- {
- "pass - sign nil data",
- func() {
- armor := crypto.EncryptArmorPrivKey(priv, "", "eth_secp256k1")
- err := s.backend.clientCtx.Keyring.ImportPrivKey("test_key", armor, "")
- s.Require().NoError(err)
- },
- from,
- nil,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- responseBz, err := s.backend.Sign(tc.fromAddr, tc.inputBz)
- if tc.expPass {
- signature, _, err := s.backend.clientCtx.Keyring.SignByAddress((sdk.AccAddress)(from.Bytes()), tc.inputBz)
- signature[goethcrypto.RecoveryIDOffset] += 27
- s.Require().NoError(err)
- s.Require().Equal((hexutil.Bytes)(signature), responseBz)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestSignTypedData() {
- from, priv := evmtest.PrivKeyEth()
- testCases := []struct {
- name string
- registerMock func()
- fromAddr common.Address
- inputTypedData apitypes.TypedData
- expPass bool
- }{
- {
- "fail - can't find key in Keyring",
- func() {},
- from,
- apitypes.TypedData{},
- false,
- },
- {
- "fail - empty TypeData",
- func() {
- armor := crypto.EncryptArmorPrivKey(priv, "", "eth_secp256k1")
- err := s.backend.clientCtx.Keyring.ImportPrivKey("test_key", armor, "")
- s.Require().NoError(err)
- },
- from,
- apitypes.TypedData{},
- false,
- },
- // TODO: Generate a TypedData msg
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- responseBz, err := s.backend.SignTypedData(tc.fromAddr, tc.inputTypedData)
-
- if tc.expPass {
- sigHash, _, _ := apitypes.TypedDataAndHash(tc.inputTypedData)
- signature, _, err := s.backend.clientCtx.Keyring.SignByAddress((sdk.AccAddress)(from.Bytes()), sigHash)
- signature[goethcrypto.RecoveryIDOffset] += 27
- s.Require().NoError(err)
- s.Require().Equal((hexutil.Bytes)(signature), responseBz)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func broadcastTx(
- s *BackendSuite,
- priv *ethsecp256k1.PrivKey,
- baseFee math.Int,
- callArgsDefault evm.JsonTxArgs,
-) (client *mocks.Client, txBytes []byte) {
- var header metadata.MD
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client = s.backend.clientCtx.Client.(*mocks.Client)
- armor := crypto.EncryptArmorPrivKey(priv, "", "eth_secp256k1")
- _ = s.backend.clientCtx.Keyring.ImportPrivKey("test_key", armor, "")
- RegisterParams(queryClient, &header, 1)
- _, err := RegisterBlock(client, 1, nil)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, baseFee)
- RegisterParamsWithoutHeader(queryClient, 1)
- ethSigner := gethcore.LatestSigner(s.backend.ChainConfig())
- msg := callArgsDefault.ToTransaction()
- err = msg.Sign(ethSigner, s.backend.clientCtx.Keyring)
- s.Require().NoError(err)
- tx, _ := msg.BuildTx(s.backend.clientCtx.TxConfig.NewTxBuilder(), evm.DefaultEVMDenom)
- txEncoder := s.backend.clientCtx.TxConfig.TxEncoder()
- txBytes, _ = txEncoder(tx)
- return client, txBytes
-}
diff --git a/eth/rpc/backend/tracing.go b/eth/rpc/backend/tracing.go
deleted file mode 100644
index eb823d823..000000000
--- a/eth/rpc/backend/tracing.go
+++ /dev/null
@@ -1,211 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "encoding/json"
- "fmt"
- "math"
-
- tmrpcclient "github.com/cometbft/cometbft/rpc/client"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/pkg/errors"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// TraceTransaction returns the structured logs created during the execution of EVM
-// and returns them as a JSON object.
-func (b *Backend) TraceTransaction(hash common.Hash, config *evm.TraceConfig) (interface{}, error) {
- // Get transaction by hash
- transaction, err := b.GetTxByEthHash(hash)
- if err != nil {
- b.logger.Debug("tx not found", "hash", hash)
- return nil, err
- }
-
- // check if block number is 0
- if transaction.Height == 0 {
- return nil, errors.New("genesis is not traceable")
- }
-
- blk, err := b.TendermintBlockByNumber(rpc.BlockNumber(transaction.Height))
- if err != nil {
- b.logger.Debug("block not found", "height", transaction.Height)
- return nil, err
- }
-
- // check tx index is not out of bound
- if len(blk.Block.Txs) > math.MaxUint32 {
- return nil, fmt.Errorf("tx count %d is overfloing", len(blk.Block.Txs))
- }
- txsLen := uint32(len(blk.Block.Txs)) // #nosec G701 -- checked for int overflow already
- if txsLen < transaction.TxIndex {
- b.logger.Debug("tx index out of bounds", "index", transaction.TxIndex, "hash", hash.String(), "height", blk.Block.Height)
- return nil, fmt.Errorf("transaction not included in block %v", blk.Block.Height)
- }
-
- var predecessors []*evm.MsgEthereumTx
- for _, txBz := range blk.Block.Txs[:transaction.TxIndex] {
- tx, err := b.clientCtx.TxConfig.TxDecoder()(txBz)
- if err != nil {
- b.logger.Debug("failed to decode transaction in block", "height", blk.Block.Height, "error", err.Error())
- continue
- }
- for _, msg := range tx.GetMsgs() {
- ethMsg, ok := msg.(*evm.MsgEthereumTx)
- if !ok {
- continue
- }
-
- predecessors = append(predecessors, ethMsg)
- }
- }
-
- tx, err := b.clientCtx.TxConfig.TxDecoder()(blk.Block.Txs[transaction.TxIndex])
- if err != nil {
- b.logger.Debug("tx not found", "hash", hash)
- return nil, err
- }
-
- // add predecessor messages in current cosmos tx
- index := int(transaction.MsgIndex) // #nosec G701
- for i := 0; i < index; i++ {
- ethMsg, ok := tx.GetMsgs()[i].(*evm.MsgEthereumTx)
- if !ok {
- continue
- }
- predecessors = append(predecessors, ethMsg)
- }
-
- ethMessage, ok := tx.GetMsgs()[transaction.MsgIndex].(*evm.MsgEthereumTx)
- if !ok {
- b.logger.Debug("invalid transaction type", "type", fmt.Sprintf("%T", tx))
- return nil, fmt.Errorf("invalid transaction type %T", tx)
- }
-
- nc, ok := b.clientCtx.Client.(tmrpcclient.NetworkClient)
- if !ok {
- return nil, errors.New("invalid rpc client")
- }
-
- cp, err := nc.ConsensusParams(b.ctx, &blk.Block.Height)
- if err != nil {
- return nil, err
- }
-
- traceTxRequest := evm.QueryTraceTxRequest{
- Msg: ethMessage,
- Predecessors: predecessors,
- BlockNumber: blk.Block.Height,
- BlockTime: blk.Block.Time,
- BlockHash: common.Bytes2Hex(blk.BlockID.Hash),
- ProposerAddress: sdk.ConsAddress(blk.Block.ProposerAddress),
- ChainId: b.chainID.Int64(),
- BlockMaxGas: cp.ConsensusParams.Block.MaxGas,
- }
-
- if config != nil {
- traceTxRequest.TraceConfig = config
- }
-
- // minus one to get the context of block beginning
- contextHeight := transaction.Height - 1
- if contextHeight < 1 {
- // 0 is a special value in `ContextWithHeight`
- contextHeight = 1
- }
- traceResult, err := b.queryClient.TraceTx(rpc.NewContextWithHeight(contextHeight), &traceTxRequest)
- if err != nil {
- return nil, err
- }
-
- // Response format is unknown due to custom tracer config param
- // More information can be found here https://geth.ethereum.org/docs/dapp/tracing-filtered
- var decodedResult interface{}
- err = json.Unmarshal(traceResult.Data, &decodedResult)
- if err != nil {
- return nil, err
- }
-
- return decodedResult, nil
-}
-
-// TraceBlock configures a new tracer according to the provided configuration, and
-// executes all the transactions contained within. The return value will be one item
-// per transaction, dependent on the requested tracer.
-func (b *Backend) TraceBlock(height rpc.BlockNumber,
- config *evm.TraceConfig,
- block *tmrpctypes.ResultBlock,
-) ([]*evm.TxTraceResult, error) {
- txs := block.Block.Txs
- txsLength := len(txs)
-
- if txsLength == 0 {
- // If there are no transactions return empty array
- return []*evm.TxTraceResult{}, nil
- }
-
- txDecoder := b.clientCtx.TxConfig.TxDecoder()
-
- var txsMessages []*evm.MsgEthereumTx
- for i, tx := range txs {
- decodedTx, err := txDecoder(tx)
- if err != nil {
- b.logger.Error("failed to decode transaction", "hash", txs[i].Hash(), "error", err.Error())
- continue
- }
-
- for _, msg := range decodedTx.GetMsgs() {
- ethMessage, ok := msg.(*evm.MsgEthereumTx)
- if !ok {
- // Just considers Ethereum transactions
- continue
- }
- txsMessages = append(txsMessages, ethMessage)
- }
- }
-
- // minus one to get the context at the beginning of the block
- contextHeight := height - 1
- if contextHeight < 1 {
- // 0 is a special value for `ContextWithHeight`.
- contextHeight = 1
- }
- ctxWithHeight := rpc.NewContextWithHeight(int64(contextHeight))
-
- nc, ok := b.clientCtx.Client.(tmrpcclient.NetworkClient)
- if !ok {
- return nil, errors.New("invalid rpc client")
- }
-
- cp, err := nc.ConsensusParams(b.ctx, &block.Block.Height)
- if err != nil {
- return nil, err
- }
-
- traceBlockRequest := &evm.QueryTraceBlockRequest{
- Txs: txsMessages,
- TraceConfig: config,
- BlockNumber: block.Block.Height,
- BlockTime: block.Block.Time,
- BlockHash: common.Bytes2Hex(block.BlockID.Hash),
- ProposerAddress: sdk.ConsAddress(block.Block.ProposerAddress),
- ChainId: b.chainID.Int64(),
- BlockMaxGas: cp.ConsensusParams.Block.MaxGas,
- }
-
- res, err := b.queryClient.TraceBlock(ctxWithHeight, traceBlockRequest)
- if err != nil {
- return nil, err
- }
-
- decodedResults := make([]*evm.TxTraceResult, txsLength)
- if err := json.Unmarshal(res.Data, &decodedResults); err != nil {
- return nil, err
- }
-
- return decodedResults, nil
-}
diff --git a/eth/rpc/backend/tracing_test.go b/eth/rpc/backend/tracing_test.go
deleted file mode 100644
index 53f7b9f85..000000000
--- a/eth/rpc/backend/tracing_test.go
+++ /dev/null
@@ -1,265 +0,0 @@
-package backend
-
-import (
- "fmt"
-
- dbm "github.com/cometbft/cometbft-db"
- abci "github.com/cometbft/cometbft/abci/types"
- tmlog "github.com/cometbft/cometbft/libs/log"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- "github.com/cometbft/cometbft/types"
- "github.com/cosmos/cosmos-sdk/crypto"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
- "github.com/NibiruChain/nibiru/eth/indexer"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-func (s *BackendSuite) TestTraceTransaction() {
- msgEthereumTx, _ := s.buildEthereumTx()
- msgEthereumTx2, _ := s.buildEthereumTx()
-
- txHash := msgEthereumTx.AsTransaction().Hash()
- txHash2 := msgEthereumTx2.AsTransaction().Hash()
-
- priv, _ := ethsecp256k1.GenerateKey()
- from := common.BytesToAddress(priv.PubKey().Address().Bytes())
-
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- RegisterParamsWithoutHeader(queryClient, 1)
-
- armor := crypto.EncryptArmorPrivKey(priv, "", "eth_secp256k1")
- _ = s.backend.clientCtx.Keyring.ImportPrivKey("test_key", armor, "")
-
- ethSigner := gethcore.LatestSigner(s.backend.ChainConfig())
-
- txEncoder := s.backend.clientCtx.TxConfig.TxEncoder()
-
- msgEthereumTx.From = from.String()
- _ = msgEthereumTx.Sign(ethSigner, s.signer)
-
- tx, _ := msgEthereumTx.BuildTx(s.backend.clientCtx.TxConfig.NewTxBuilder(), evm.DefaultEVMDenom)
- txBz, _ := txEncoder(tx)
-
- msgEthereumTx2.From = from.String()
- _ = msgEthereumTx2.Sign(ethSigner, s.signer)
-
- tx2, _ := msgEthereumTx.BuildTx(s.backend.clientCtx.TxConfig.NewTxBuilder(), evm.DefaultEVMDenom)
- txBz2, _ := txEncoder(tx2)
-
- testCases := []struct {
- name string
- registerMock func()
- block *types.Block
- responseBlock []*abci.ResponseDeliverTx
- expResult interface{}
- expPass bool
- }{
- {
- "fail - tx not found",
- func() {},
- &types.Block{Header: types.Header{Height: 1}, Data: types.Data{Txs: []types.Tx{}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "0"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: ""},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- },
- },
- },
- nil,
- false,
- },
- {
- "fail - block not found",
- func() {
- // var header metadata.MD
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockError(client, 1)
- },
- &types.Block{Header: types.Header{Height: 1}, Data: types.Data{Txs: []types.Tx{txBz}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "0"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: ""},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- },
- },
- },
- map[string]interface{}{"test": "hello"},
- false,
- },
- {
- "pass - transaction found in a block with multiple transactions",
- func() {
- var (
- queryClient = s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client = s.backend.clientCtx.Client.(*mocks.Client)
- height int64 = 1
- )
- _, err := RegisterBlockMultipleTxs(client, height, []types.Tx{txBz, txBz2})
- s.Require().NoError(err)
- RegisterTraceTransactionWithPredecessors(queryClient, msgEthereumTx, []*evm.MsgEthereumTx{msgEthereumTx})
- RegisterConsensusParams(client, height)
- },
- &types.Block{Header: types.Header{Height: 1, ChainID: ChainID}, Data: types.Data{Txs: []types.Tx{txBz, txBz2}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "0"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: ""},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- },
- },
- {
- Code: 0,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash2.Hex()},
- {Key: "txIndex", Value: "1"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: ""},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- },
- },
- },
- map[string]interface{}{"test": "hello"},
- true,
- },
- {
- "pass - transaction found",
- func() {
- var (
- queryClient = s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client = s.backend.clientCtx.Client.(*mocks.Client)
- height int64 = 1
- )
- _, err := RegisterBlock(client, height, txBz)
- s.Require().NoError(err)
- RegisterTraceTransaction(queryClient, msgEthereumTx)
- RegisterConsensusParams(client, height)
- },
- &types.Block{Header: types.Header{Height: 1}, Data: types.Data{Txs: []types.Tx{txBz}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "0"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: ""},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- },
- },
- },
- map[string]interface{}{"test": "hello"},
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- db := dbm.NewMemDB()
- s.backend.indexer = indexer.NewKVIndexer(db, tmlog.NewNopLogger(), s.backend.clientCtx)
-
- err := s.backend.indexer.IndexBlock(tc.block, tc.responseBlock)
- s.Require().NoError(err)
- txResult, err := s.backend.TraceTransaction(txHash, nil)
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expResult, txResult)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestTraceBlock() {
- msgEthTx, bz := s.buildEthereumTx()
- emptyBlock := types.MakeBlock(1, []types.Tx{}, nil, nil)
- emptyBlock.ChainID = ChainID
- filledBlock := types.MakeBlock(1, []types.Tx{bz}, nil, nil)
- filledBlock.ChainID = ChainID
- resBlockEmpty := tmrpctypes.ResultBlock{Block: emptyBlock, BlockID: emptyBlock.LastBlockID}
- resBlockFilled := tmrpctypes.ResultBlock{Block: filledBlock, BlockID: filledBlock.LastBlockID}
-
- testCases := []struct {
- name string
- registerMock func()
- expTraceResults []*evm.TxTraceResult
- resBlock *tmrpctypes.ResultBlock
- config *evm.TraceConfig
- expPass bool
- }{
- {
- "pass - no transaction returning empty array",
- func() {},
- []*evm.TxTraceResult{},
- &resBlockEmpty,
- &evm.TraceConfig{},
- true,
- },
- {
- "fail - cannot unmarshal data",
- func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterTraceBlock(queryClient, []*evm.MsgEthereumTx{msgEthTx})
- RegisterConsensusParams(client, 1)
- },
- []*evm.TxTraceResult{},
- &resBlockFilled,
- &evm.TraceConfig{},
- false,
- },
- }
-
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("case %s", tc.name), func() {
- s.SetupTest() // reset test and queries
- tc.registerMock()
-
- traceResults, err := s.backend.TraceBlock(1, tc.config, tc.resBlock)
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(tc.expTraceResults, traceResults)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
diff --git a/eth/rpc/backend/tx_info.go b/eth/rpc/backend/tx_info.go
deleted file mode 100644
index afbf523ca..000000000
--- a/eth/rpc/backend/tx_info.go
+++ /dev/null
@@ -1,420 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "fmt"
- "math"
- "math/big"
-
- errorsmod "cosmossdk.io/errors"
-
- tmrpcclient "github.com/cometbft/cometbft/rpc/client"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/pkg/errors"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// GetTransactionByHash returns the Ethereum format transaction identified by Ethereum transaction hash
-func (b *Backend) GetTransactionByHash(txHash common.Hash) (*rpc.EthTxJsonRPC, error) {
- res, err := b.GetTxByEthHash(txHash)
- hexTx := txHash.Hex()
-
- if err != nil {
- return b.getTransactionByHashPending(txHash)
- }
-
- block, err := b.TendermintBlockByNumber(rpc.BlockNumber(res.Height))
- if err != nil {
- return nil, err
- }
-
- tx, err := b.clientCtx.TxConfig.TxDecoder()(block.Block.Txs[res.TxIndex])
- if err != nil {
- return nil, err
- }
-
- // the `res.MsgIndex` is inferred from tx index, should be within the bound.
- msg, ok := tx.GetMsgs()[res.MsgIndex].(*evm.MsgEthereumTx)
- if !ok {
- return nil, errors.New("invalid ethereum tx")
- }
-
- blockRes, err := b.TendermintBlockResultByNumber(&block.Block.Height)
- if err != nil {
- b.logger.Debug("block result not found", "height", block.Block.Height, "error", err.Error())
- return nil, nil
- }
-
- if res.EthTxIndex == -1 {
- // Fallback to find tx index by iterating all valid eth transactions
- msgs := b.EthMsgsFromTendermintBlock(block, blockRes)
- for i := range msgs {
- if msgs[i].Hash == hexTx {
- if i > math.MaxInt32 {
- return nil, errors.New("tx index overflow")
- }
- res.EthTxIndex = int32(i) //#nosec G701 -- checked for int overflow already
- break
- }
- }
- }
- // if we still unable to find the eth tx index, return error, shouldn't happen.
- if res.EthTxIndex == -1 {
- return nil, errors.New("can't find index of ethereum tx")
- }
-
- baseFee, err := b.BaseFee(blockRes)
- if err != nil {
- // handle the error for pruned node.
- b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", blockRes.Height, "error", err)
- }
-
- height := uint64(res.Height) //#nosec G701 -- checked for int overflow already
- index := uint64(res.EthTxIndex) //#nosec G701 -- checked for int overflow already
- return rpc.NewRPCTxFromMsg(
- msg,
- common.BytesToHash(block.BlockID.Hash.Bytes()),
- height,
- index,
- baseFee,
- b.chainID,
- )
-}
-
-// getTransactionByHashPending find pending tx from mempool
-func (b *Backend) getTransactionByHashPending(txHash common.Hash) (*rpc.EthTxJsonRPC, error) {
- hexTx := txHash.Hex()
- // try to find tx in mempool
- txs, err := b.PendingTransactions()
- if err != nil {
- b.logger.Debug("tx not found", "hash", hexTx, "error", err.Error())
- return nil, nil
- }
-
- for _, tx := range txs {
- msg, err := evm.UnwrapEthereumMsg(tx, txHash)
- if err != nil {
- // not ethereum tx
- continue
- }
-
- if msg.Hash == hexTx {
- // use zero block values since it's not included in a block yet
- rpctx, err := rpc.NewRPCTxFromMsg(
- msg,
- common.Hash{},
- uint64(0),
- uint64(0),
- nil,
- b.chainID,
- )
- if err != nil {
- return nil, err
- }
- return rpctx, nil
- }
- }
-
- b.logger.Debug("tx not found", "hash", hexTx)
- return nil, nil
-}
-
-// GetGasUsed returns gasUsed from transaction, patching to
-// price * gas in the event the tx is reverted.
-func (b *Backend) GetGasUsed(res *eth.TxResult, price *big.Int, gas uint64) uint64 {
- if res.Failed && res.Height < b.cfg.JSONRPC.FixRevertGasRefundHeight {
- return new(big.Int).Mul(price, new(big.Int).SetUint64(gas)).Uint64()
- }
- return res.GasUsed
-}
-
-// GetTransactionReceipt returns the transaction receipt identified by hash.
-func (b *Backend) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error) {
- hexTx := hash.Hex()
- b.logger.Debug("eth_getTransactionReceipt", "hash", hexTx)
-
- res, err := b.GetTxByEthHash(hash)
- if err != nil {
- b.logger.Debug("tx not found", "hash", hexTx, "error", err.Error())
- return nil, nil
- }
- resBlock, err := b.TendermintBlockByNumber(rpc.BlockNumber(res.Height))
- if err != nil {
- b.logger.Debug("block not found", "height", res.Height, "error", err.Error())
- return nil, nil
- }
- tx, err := b.clientCtx.TxConfig.TxDecoder()(resBlock.Block.Txs[res.TxIndex])
- if err != nil {
- b.logger.Debug("decoding failed", "error", err.Error())
- return nil, fmt.Errorf("failed to decode tx: %w", err)
- }
- ethMsg := tx.GetMsgs()[res.MsgIndex].(*evm.MsgEthereumTx)
-
- txData, err := evm.UnpackTxData(ethMsg.Data)
- if err != nil {
- b.logger.Error("failed to unpack tx data", "error", err.Error())
- return nil, err
- }
-
- cumulativeGasUsed := uint64(0)
- blockRes, err := b.TendermintBlockResultByNumber(&res.Height)
- if err != nil {
- b.logger.Debug("failed to retrieve block results", "height", res.Height, "error", err.Error())
- return nil, nil
- }
- for _, txResult := range blockRes.TxsResults[0:res.TxIndex] {
- cumulativeGasUsed += uint64(txResult.GasUsed) // #nosec G701 -- checked for int overflow already
- }
- cumulativeGasUsed += res.CumulativeGasUsed
-
- var status hexutil.Uint
- if res.Failed {
- status = hexutil.Uint(gethcore.ReceiptStatusFailed)
- } else {
- status = hexutil.Uint(gethcore.ReceiptStatusSuccessful)
- }
- chainID, err := b.ChainID()
- if err != nil {
- return nil, err
- }
-
- from, err := ethMsg.GetSender(chainID.ToInt())
- if err != nil {
- return nil, err
- }
-
- // parse tx logs from events
- msgIndex := int(res.MsgIndex) // #nosec G701 -- checked for int overflow already
- logs, err := TxLogsFromEvents(blockRes.TxsResults[res.TxIndex].Events, msgIndex)
- if err != nil {
- b.logger.Debug("failed to parse logs", "hash", hexTx, "error", err.Error())
- }
-
- if res.EthTxIndex == -1 {
- // Fallback to find tx index by iterating all valid eth transactions
- msgs := b.EthMsgsFromTendermintBlock(resBlock, blockRes)
- for i := range msgs {
- if msgs[i].Hash == hexTx {
- res.EthTxIndex = int32(i) // #nosec G701
- break
- }
- }
- }
- // return error if still unable to find the eth tx index
- if res.EthTxIndex == -1 {
- return nil, errors.New("can't find index of ethereum tx")
- }
-
- receipt := map[string]interface{}{
- // Consensus fields: These fields are defined by the Yellow Paper
- "status": status,
- "cumulativeGasUsed": hexutil.Uint64(cumulativeGasUsed),
- "logsBloom": gethcore.BytesToBloom(gethcore.LogsBloom(logs)),
- "logs": logs,
-
- // Implementation fields: These fields are added by geth when processing a transaction.
- // They are stored in the chain database.
- "transactionHash": hash,
- "contractAddress": nil,
- "gasUsed": hexutil.Uint64(b.GetGasUsed(res, txData.GetGasPrice(), txData.GetGas())),
-
- // Inclusion information: These fields provide information about the inclusion of the
- // transaction corresponding to this receipt.
- "blockHash": common.BytesToHash(resBlock.Block.Header.Hash()).Hex(),
- "blockNumber": hexutil.Uint64(res.Height),
- "transactionIndex": hexutil.Uint64(res.EthTxIndex),
-
- // sender and receiver (contract or EOA) addreses
- "from": from,
- "to": txData.GetTo(),
- "type": hexutil.Uint(ethMsg.AsTransaction().Type()),
- }
-
- if logs == nil {
- receipt["logs"] = [][]*gethcore.Log{}
- }
-
- // If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
- if txData.GetTo() == nil {
- receipt["contractAddress"] = crypto.CreateAddress(from, txData.GetNonce())
- }
-
- if dynamicTx, ok := txData.(*evm.DynamicFeeTx); ok {
- baseFee, err := b.BaseFee(blockRes)
- if err != nil {
- // tolerate the error for pruned node.
- b.logger.Error("fetch basefee failed, node is pruned?", "height", res.Height, "error", err)
- } else {
- receipt["effectiveGasPrice"] = hexutil.Big(*dynamicTx.EffectiveGasPrice(baseFee))
- }
- }
-
- return receipt, nil
-}
-
-// GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.
-func (b *Backend) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error) {
- b.logger.Debug("eth_getTransactionByBlockHashAndIndex", "hash", hash.Hex(), "index", idx)
- sc, ok := b.clientCtx.Client.(tmrpcclient.SignClient)
- if !ok {
- return nil, errors.New("invalid rpc client")
- }
-
- block, err := sc.BlockByHash(b.ctx, hash.Bytes())
- if err != nil {
- b.logger.Debug("block not found", "hash", hash.Hex(), "error", err.Error())
- return nil, nil
- }
-
- if block.Block == nil {
- b.logger.Debug("block not found", "hash", hash.Hex())
- return nil, nil
- }
-
- return b.GetTransactionByBlockAndIndex(block, idx)
-}
-
-// GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.
-func (b *Backend) GetTransactionByBlockNumberAndIndex(blockNum rpc.BlockNumber, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error) {
- b.logger.Debug("eth_getTransactionByBlockNumberAndIndex", "number", blockNum, "index", idx)
-
- block, err := b.TendermintBlockByNumber(blockNum)
- if err != nil {
- b.logger.Debug("block not found", "height", blockNum.Int64(), "error", err.Error())
- return nil, nil
- }
-
- if block.Block == nil {
- b.logger.Debug("block not found", "height", blockNum.Int64())
- return nil, nil
- }
-
- return b.GetTransactionByBlockAndIndex(block, idx)
-}
-
-// GetTxByEthHash uses `/tx_query` to find transaction by ethereum tx hash
-// TODO: Don't need to convert once hashing is fixed on Tendermint
-// https://github.com/cometbft/cometbft/issues/6539
-func (b *Backend) GetTxByEthHash(hash common.Hash) (*eth.TxResult, error) {
- if b.indexer != nil {
- return b.indexer.GetByTxHash(hash)
- }
-
- // fallback to tendermint tx indexer
- query := fmt.Sprintf("%s.%s='%s'", evm.TypeMsgEthereumTx, evm.AttributeKeyEthereumTxHash, hash.Hex())
- txResult, err := b.queryTendermintTxIndexer(query, func(txs *rpc.ParsedTxs) *rpc.ParsedTx {
- return txs.GetTxByHash(hash)
- })
- if err != nil {
- return nil, errorsmod.Wrapf(err, "GetTxByEthHash %s", hash.Hex())
- }
- return txResult, nil
-}
-
-// GetTxByTxIndex uses `/tx_query` to find transaction by tx index of valid ethereum txs
-func (b *Backend) GetTxByTxIndex(height int64, index uint) (*eth.TxResult, error) {
- int32Index := int32(index) // #nosec G701 -- checked for int overflow already
- if b.indexer != nil {
- return b.indexer.GetByBlockAndIndex(height, int32Index)
- }
-
- // fallback to tendermint tx indexer
- query := fmt.Sprintf("tx.height=%d AND %s.%s=%d",
- height, evm.TypeMsgEthereumTx,
- evm.AttributeKeyTxIndex, index,
- )
- txResult, err := b.queryTendermintTxIndexer(query, func(txs *rpc.ParsedTxs) *rpc.ParsedTx {
- return txs.GetTxByTxIndex(int(index)) // #nosec G701 -- checked for int overflow already
- })
- if err != nil {
- return nil, errorsmod.Wrapf(err, "GetTxByTxIndex %d %d", height, index)
- }
- return txResult, nil
-}
-
-// queryTendermintTxIndexer query tx in tendermint tx indexer
-func (b *Backend) queryTendermintTxIndexer(query string, txGetter func(*rpc.ParsedTxs) *rpc.ParsedTx) (*eth.TxResult, error) {
- resTxs, err := b.clientCtx.Client.TxSearch(b.ctx, query, false, nil, nil, "")
- if err != nil {
- return nil, err
- }
- if len(resTxs.Txs) == 0 {
- return nil, errors.New("ethereum tx not found")
- }
- txResult := resTxs.Txs[0]
- if !rpc.TxSuccessOrExpectedFailure(&txResult.TxResult) {
- return nil, errors.New("invalid ethereum tx")
- }
-
- var tx sdk.Tx
- if txResult.TxResult.Code != 0 {
- // it's only needed when the tx exceeds block gas limit
- tx, err = b.clientCtx.TxConfig.TxDecoder()(txResult.Tx)
- if err != nil {
- return nil, fmt.Errorf("invalid ethereum tx")
- }
- }
-
- return rpc.ParseTxIndexerResult(txResult, tx, txGetter)
-}
-
-// GetTransactionByBlockAndIndex is the common code shared by `GetTransactionByBlockNumberAndIndex` and `GetTransactionByBlockHashAndIndex`.
-func (b *Backend) GetTransactionByBlockAndIndex(block *tmrpctypes.ResultBlock, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error) {
- blockRes, err := b.TendermintBlockResultByNumber(&block.Block.Height)
- if err != nil {
- return nil, nil
- }
-
- var msg *evm.MsgEthereumTx
- // find in tx indexer
- res, err := b.GetTxByTxIndex(block.Block.Height, uint(idx))
- if err == nil {
- tx, err := b.clientCtx.TxConfig.TxDecoder()(block.Block.Txs[res.TxIndex])
- if err != nil {
- b.logger.Debug("invalid ethereum tx", "height", block.Block.Header, "index", idx)
- return nil, nil
- }
-
- var ok bool
- // msgIndex is inferred from tx events, should be within bound.
- msg, ok = tx.GetMsgs()[res.MsgIndex].(*evm.MsgEthereumTx)
- if !ok {
- b.logger.Debug("invalid ethereum tx", "height", block.Block.Header, "index", idx)
- return nil, nil
- }
- } else {
- i := int(idx) // #nosec G701
- ethMsgs := b.EthMsgsFromTendermintBlock(block, blockRes)
- if i >= len(ethMsgs) {
- b.logger.Debug("block txs index out of bound", "index", i)
- return nil, nil
- }
-
- msg = ethMsgs[i]
- }
-
- baseFee, err := b.BaseFee(blockRes)
- if err != nil {
- // handle the error for pruned node.
- b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", block.Block.Height, "error", err)
- }
-
- height := uint64(block.Block.Height) // #nosec G701 -- checked for int overflow already
- index := uint64(idx) // #nosec G701 -- checked for int overflow already
- return rpc.NewRPCTxFromMsg(
- msg,
- common.BytesToHash(block.Block.Hash()),
- height,
- index,
- baseFee,
- b.chainID,
- )
-}
diff --git a/eth/rpc/backend/tx_info_test.go b/eth/rpc/backend/tx_info_test.go
deleted file mode 100644
index beb708047..000000000
--- a/eth/rpc/backend/tx_info_test.go
+++ /dev/null
@@ -1,671 +0,0 @@
-package backend
-
-import (
- "fmt"
- "math/big"
-
- "cosmossdk.io/math"
- dbm "github.com/cometbft/cometbft-db"
- abci "github.com/cometbft/cometbft/abci/types"
- tmlog "github.com/cometbft/cometbft/libs/log"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- "github.com/cometbft/cometbft/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "google.golang.org/grpc/metadata"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/indexer"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend/mocks"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-func (s *BackendSuite) TestGetTransactionByHash() {
- msgEthereumTx, _ := s.buildEthereumTx()
- txHash := msgEthereumTx.AsTransaction().Hash()
-
- txBz := s.signAndEncodeEthTx(msgEthereumTx)
- block := &types.Block{Header: types.Header{Height: 1, ChainID: "test"}, Data: types.Data{Txs: []types.Tx{txBz}}}
- responseDeliver := []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "0"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: ""},
- {Key: "recipient", Value: ""},
- }},
- },
- },
- }
-
- rpcTransaction, _ := rpc.NewRPCTxFromEthTx(msgEthereumTx.AsTransaction(), common.Hash{}, 0, 0, big.NewInt(1), s.backend.chainID)
-
- testCases := []struct {
- name string
- registerMock func()
- tx *evm.MsgEthereumTx
- expRPCTx *rpc.EthTxJsonRPC
- expPass bool
- }{
- {
- "fail - Block error",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockError(client, 1)
- },
- msgEthereumTx,
- rpcTransaction,
- false,
- },
- {
- "fail - Block Result error",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlock(client, 1, txBz)
- s.Require().NoError(err)
- RegisterBlockResultsError(client, 1)
- },
- msgEthereumTx,
- nil,
- true,
- },
- {
- "pass - Base fee error",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- _, err := RegisterBlock(client, 1, txBz)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFeeError(queryClient)
- },
- msgEthereumTx,
- rpcTransaction,
- true,
- },
- {
- "pass - Transaction found and returned",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- _, err := RegisterBlock(client, 1, txBz)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, math.NewInt(1))
- },
- msgEthereumTx,
- rpcTransaction,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest() // reset
- tc.registerMock()
-
- db := dbm.NewMemDB()
- s.backend.indexer = indexer.NewKVIndexer(db, tmlog.NewNopLogger(), s.backend.clientCtx)
- err := s.backend.indexer.IndexBlock(block, responseDeliver)
- s.Require().NoError(err)
-
- rpcTx, err := s.backend.GetTransactionByHash(common.HexToHash(tc.tx.Hash))
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(rpcTx, tc.expRPCTx)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetTransactionsByHashPending() {
- msgEthereumTx, bz := s.buildEthereumTx()
- rpcTransaction, _ := rpc.NewRPCTxFromEthTx(msgEthereumTx.AsTransaction(), common.Hash{}, 0, 0, big.NewInt(1), s.backend.chainID)
-
- testCases := []struct {
- name string
- registerMock func()
- tx *evm.MsgEthereumTx
- expRPCTx *rpc.EthTxJsonRPC
- expPass bool
- }{
- {
- "fail - Pending transactions returns error",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterUnconfirmedTxsError(client, nil)
- },
- msgEthereumTx,
- nil,
- true,
- },
- {
- "fail - Tx not found return nil",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterUnconfirmedTxs(client, nil, nil)
- },
- msgEthereumTx,
- nil,
- true,
- },
- {
- "pass - Tx found and returned",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterUnconfirmedTxs(client, nil, types.Txs{bz})
- },
- msgEthereumTx,
- rpcTransaction,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest() // reset
- tc.registerMock()
-
- rpcTx, err := s.backend.getTransactionByHashPending(common.HexToHash(tc.tx.Hash))
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(rpcTx, tc.expRPCTx)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetTxByEthHash() {
- msgEthereumTx, bz := s.buildEthereumTx()
- rpcTransaction, _ := rpc.NewRPCTxFromEthTx(msgEthereumTx.AsTransaction(), common.Hash{}, 0, 0, big.NewInt(1), s.backend.chainID)
-
- testCases := []struct {
- name string
- registerMock func()
- tx *evm.MsgEthereumTx
- expRPCTx *rpc.EthTxJsonRPC
- expPass bool
- }{
- {
- "fail - Indexer disabled can't find transaction",
- func() {
- s.backend.indexer = nil
- client := s.backend.clientCtx.Client.(*mocks.Client)
- query := fmt.Sprintf("%s.%s='%s'", evm.TypeMsgEthereumTx, evm.AttributeKeyEthereumTxHash, common.HexToHash(msgEthereumTx.Hash).Hex())
- RegisterTxSearch(client, query, bz)
- },
- msgEthereumTx,
- rpcTransaction,
- false,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest() // reset
- tc.registerMock()
-
- rpcTx, err := s.backend.GetTxByEthHash(common.HexToHash(tc.tx.Hash))
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(rpcTx, tc.expRPCTx)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetTransactionByBlockHashAndIndex() {
- _, bz := s.buildEthereumTx()
-
- testCases := []struct {
- name string
- registerMock func()
- blockHash common.Hash
- expRPCTx *rpc.EthTxJsonRPC
- expPass bool
- }{
- {
- "pass - block not found",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockByHashError(client, common.Hash{}, bz)
- },
- common.Hash{},
- nil,
- true,
- },
- {
- "pass - Block results error",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockByHash(client, common.Hash{}, bz)
- s.Require().NoError(err)
- RegisterBlockResultsError(client, 1)
- },
- common.Hash{},
- nil,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest() // reset
- tc.registerMock()
-
- rpcTx, err := s.backend.GetTransactionByBlockHashAndIndex(tc.blockHash, 1)
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(rpcTx, tc.expRPCTx)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetTransactionByBlockAndIndex() {
- msgEthTx, bz := s.buildEthereumTx()
-
- defaultBlock := types.MakeBlock(1, []types.Tx{bz}, nil, nil)
- defaultResponseDeliverTx := []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: common.HexToHash(msgEthTx.Hash).Hex()},
- {Key: "txIndex", Value: "0"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: ""},
- {Key: "recipient", Value: ""},
- }},
- },
- },
- }
-
- txFromMsg, _ := rpc.NewRPCTxFromMsg(
- msgEthTx,
- common.BytesToHash(defaultBlock.Hash().Bytes()),
- 1,
- 0,
- big.NewInt(1),
- s.backend.chainID,
- )
- testCases := []struct {
- name string
- registerMock func()
- block *tmrpctypes.ResultBlock
- idx hexutil.Uint
- expRPCTx *rpc.EthTxJsonRPC
- expPass bool
- }{
- {
- "pass - block txs index out of bound",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- },
- &tmrpctypes.ResultBlock{Block: types.MakeBlock(1, []types.Tx{bz}, nil, nil)},
- 1,
- nil,
- true,
- },
- {
- "pass - Can't fetch base fee",
- func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFeeError(queryClient)
- },
- &tmrpctypes.ResultBlock{Block: defaultBlock},
- 0,
- txFromMsg,
- true,
- },
- {
- "pass - Gets Tx by transaction index",
- func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- db := dbm.NewMemDB()
- s.backend.indexer = indexer.NewKVIndexer(db, tmlog.NewNopLogger(), s.backend.clientCtx)
- txBz := s.signAndEncodeEthTx(msgEthTx)
- block := &types.Block{Header: types.Header{Height: 1, ChainID: "test"}, Data: types.Data{Txs: []types.Tx{txBz}}}
- err := s.backend.indexer.IndexBlock(block, defaultResponseDeliverTx)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, math.NewInt(1))
- },
- &tmrpctypes.ResultBlock{Block: defaultBlock},
- 0,
- txFromMsg,
- true,
- },
- {
- "pass - returns the Ethereum format transaction by the Ethereum hash",
- func() {
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- _, err := RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, math.NewInt(1))
- },
- &tmrpctypes.ResultBlock{Block: defaultBlock},
- 0,
- txFromMsg,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest() // reset
- tc.registerMock()
-
- rpcTx, err := s.backend.GetTransactionByBlockAndIndex(tc.block, tc.idx)
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(rpcTx, tc.expRPCTx)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetTransactionByBlockNumberAndIndex() {
- msgEthTx, bz := s.buildEthereumTx()
- defaultBlock := types.MakeBlock(1, []types.Tx{bz}, nil, nil)
- txFromMsg, _ := rpc.NewRPCTxFromMsg(
- msgEthTx,
- common.BytesToHash(defaultBlock.Hash().Bytes()),
- 1,
- 0,
- big.NewInt(1),
- s.backend.chainID,
- )
- testCases := []struct {
- name string
- registerMock func()
- blockNum rpc.BlockNumber
- idx hexutil.Uint
- expRPCTx *rpc.EthTxJsonRPC
- expPass bool
- }{
- {
- "fail - block not found return nil",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterBlockError(client, 1)
- },
- 0,
- 0,
- nil,
- true,
- },
- {
- "pass - returns the transaction identified by block number and index",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- _, err := RegisterBlock(client, 1, bz)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- RegisterBaseFee(queryClient, math.NewInt(1))
- },
- 0,
- 0,
- txFromMsg,
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest() // reset
- tc.registerMock()
-
- rpcTx, err := s.backend.GetTransactionByBlockNumberAndIndex(tc.blockNum, tc.idx)
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(rpcTx, tc.expRPCTx)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetTransactionByTxIndex() {
- _, bz := s.buildEthereumTx()
-
- testCases := []struct {
- name string
- registerMock func()
- height int64
- index uint
- expTxResult *eth.TxResult
- expPass bool
- }{
- {
- "fail - Ethereum tx with query not found",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- s.backend.indexer = nil
- RegisterTxSearch(client, "tx.height=0 AND ethereum_tx.txIndex=0", bz)
- },
- 0,
- 0,
- ð.TxResult{},
- false,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest() // reset
- tc.registerMock()
-
- txResults, err := s.backend.GetTxByTxIndex(tc.height, tc.index)
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(txResults, tc.expTxResult)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestQueryTendermintTxIndexer() {
- testCases := []struct {
- name string
- registerMock func()
- txGetter func(*rpc.ParsedTxs) *rpc.ParsedTx
- query string
- expTxResult *eth.TxResult
- expPass bool
- }{
- {
- "fail - Ethereum tx with query not found",
- func() {
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterTxSearchEmpty(client, "")
- },
- func(txs *rpc.ParsedTxs) *rpc.ParsedTx {
- return &rpc.ParsedTx{}
- },
- "",
- ð.TxResult{},
- false,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest() // reset
- tc.registerMock()
-
- txResults, err := s.backend.queryTendermintTxIndexer(tc.query, tc.txGetter)
-
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(txResults, tc.expTxResult)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetTransactionReceipt() {
- msgEthereumTx, _ := s.buildEthereumTx()
- txHash := msgEthereumTx.AsTransaction().Hash()
-
- txBz := s.signAndEncodeEthTx(msgEthereumTx)
-
- testCases := []struct {
- name string
- registerMock func()
- tx *evm.MsgEthereumTx
- block *types.Block
- blockResult []*abci.ResponseDeliverTx
- expTxReceipt map[string]interface{}
- expPass bool
- }{
- {
- "fail - Receipts do not match",
- func() {
- var header metadata.MD
- queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
- client := s.backend.clientCtx.Client.(*mocks.Client)
- RegisterParams(queryClient, &header, 1)
- RegisterParamsWithoutHeader(queryClient, 1)
- _, err := RegisterBlock(client, 1, txBz)
- s.Require().NoError(err)
- _, err = RegisterBlockResults(client, 1)
- s.Require().NoError(err)
- },
- msgEthereumTx,
- &types.Block{Header: types.Header{Height: 1}, Data: types.Data{Txs: []types.Tx{txBz}}},
- []*abci.ResponseDeliverTx{
- {
- Code: 0,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "0"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: ""},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- },
- },
- },
- map[string]interface{}(nil),
- false,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest() // reset
- tc.registerMock()
-
- db := dbm.NewMemDB()
- s.backend.indexer = indexer.NewKVIndexer(db, tmlog.NewNopLogger(), s.backend.clientCtx)
- err := s.backend.indexer.IndexBlock(tc.block, tc.blockResult)
- s.Require().NoError(err)
-
- txReceipt, err := s.backend.GetTransactionReceipt(common.HexToHash(tc.tx.Hash))
- if tc.expPass {
- s.Require().NoError(err)
- s.Require().Equal(txReceipt, tc.expTxReceipt)
- } else {
- s.Require().NotEqual(txReceipt, tc.expTxReceipt)
- }
- })
- }
-}
-
-func (s *BackendSuite) TestGetGasUsed() {
- origin := s.backend.cfg.JSONRPC.FixRevertGasRefundHeight
- testCases := []struct {
- name string
- fixRevertGasRefundHeight int64
- txResult *eth.TxResult
- price *big.Int
- gas uint64
- exp uint64
- }{
- {
- "success txResult",
- 1,
- ð.TxResult{
- Height: 1,
- Failed: false,
- GasUsed: 53026,
- },
- new(big.Int).SetUint64(0),
- 0,
- 53026,
- },
- {
- "fail txResult before cap",
- 2,
- ð.TxResult{
- Height: 1,
- Failed: true,
- GasUsed: 53026,
- },
- new(big.Int).SetUint64(200000),
- 5000000000000,
- 1000000000000000000,
- },
- {
- "fail txResult after cap",
- 2,
- ð.TxResult{
- Height: 3,
- Failed: true,
- GasUsed: 53026,
- },
- new(big.Int).SetUint64(200000),
- 5000000000000,
- 53026,
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.backend.cfg.JSONRPC.FixRevertGasRefundHeight = tc.fixRevertGasRefundHeight
- s.Require().Equal(tc.exp, s.backend.GetGasUsed(tc.txResult, tc.price, tc.gas))
- s.backend.cfg.JSONRPC.FixRevertGasRefundHeight = origin
- })
- }
-}
diff --git a/eth/rpc/backend/utils.go b/eth/rpc/backend/utils.go
deleted file mode 100644
index 4f93b0ea4..000000000
--- a/eth/rpc/backend/utils.go
+++ /dev/null
@@ -1,302 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package backend
-
-import (
- "encoding/json"
- "fmt"
- "math/big"
- "sort"
- "strings"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/consensus/misc"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cometbft/cometbft/libs/log"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
-
- "github.com/cometbft/cometbft/proto/tendermint/crypto"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-type txGasAndReward struct {
- gasUsed uint64
- reward *big.Int
-}
-
-type sortGasAndReward []txGasAndReward
-
-func (s sortGasAndReward) Len() int { return len(s) }
-func (s sortGasAndReward) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
-}
-
-func (s sortGasAndReward) Less(i, j int) bool {
- return s[i].reward.Cmp(s[j].reward) < 0
-}
-
-// getAccountNonce returns the account nonce for the given account address.
-// If the pending value is true, it will iterate over the mempool (pending)
-// txs in order to compute and return the pending tx sequence.
-// Todo: include the ability to specify a blockNumber
-func (b *Backend) getAccountNonce(accAddr common.Address, pending bool, height int64, logger log.Logger) (uint64, error) {
- queryClient := authtypes.NewQueryClient(b.clientCtx)
- adr := sdk.AccAddress(accAddr.Bytes()).String()
- ctx := rpc.NewContextWithHeight(height)
- res, err := queryClient.Account(ctx, &authtypes.QueryAccountRequest{Address: adr})
- if err != nil {
- st, ok := status.FromError(err)
- // treat as account doesn't exist yet
- if ok && st.Code() == codes.NotFound {
- return 0, nil
- }
- return 0, err
- }
- var acc authtypes.AccountI
- if err := b.clientCtx.InterfaceRegistry.UnpackAny(res.Account, &acc); err != nil {
- return 0, err
- }
-
- nonce := acc.GetSequence()
-
- if !pending {
- return nonce, nil
- }
-
- // the account retriever doesn't include the uncommitted transactions on the nonce so we need to
- // to manually add them.
- pendingTxs, err := b.PendingTransactions()
- if err != nil {
- logger.Error("failed to fetch pending transactions", "error", err.Error())
- return nonce, nil
- }
-
- // add the uncommitted txs to the nonce counter
- // only supports `MsgEthereumTx` style tx
- for _, tx := range pendingTxs {
- for _, msg := range (*tx).GetMsgs() {
- ethMsg, ok := msg.(*evm.MsgEthereumTx)
- if !ok {
- // not ethereum tx
- break
- }
-
- sender, err := ethMsg.GetSender(b.chainID)
- if err != nil {
- continue
- }
- if sender == accAddr {
- nonce++
- }
- }
- }
-
- return nonce, nil
-}
-
-// output: targetOneFeeHistory
-func (b *Backend) processBlock(
- tendermintBlock *tmrpctypes.ResultBlock,
- ethBlock *map[string]interface{},
- rewardPercentiles []float64,
- tendermintBlockResult *tmrpctypes.ResultBlockResults,
- targetOneFeeHistory *rpc.OneFeeHistory,
-) error {
- blockHeight := tendermintBlock.Block.Height
- blockBaseFee, err := b.BaseFee(tendermintBlockResult)
- if err != nil {
- return err
- }
-
- // set basefee
- targetOneFeeHistory.BaseFee = blockBaseFee
- cfg := b.ChainConfig()
- if cfg.IsLondon(big.NewInt(blockHeight + 1)) {
- header, err := b.CurrentHeader()
- if err != nil {
- return err
- }
- targetOneFeeHistory.NextBaseFee = misc.CalcBaseFee(cfg, header)
- } else {
- targetOneFeeHistory.NextBaseFee = new(big.Int)
- }
- // set gas used ratio
- gasLimitUint64, ok := (*ethBlock)["gasLimit"].(hexutil.Uint64)
- if !ok {
- return fmt.Errorf("invalid gas limit type: %T", (*ethBlock)["gasLimit"])
- }
-
- gasUsedBig, ok := (*ethBlock)["gasUsed"].(*hexutil.Big)
- if !ok {
- return fmt.Errorf("invalid gas used type: %T", (*ethBlock)["gasUsed"])
- }
-
- gasusedfloat, _ := new(big.Float).SetInt(gasUsedBig.ToInt()).Float64()
-
- if gasLimitUint64 <= 0 {
- return fmt.Errorf("gasLimit of block height %d should be bigger than 0 , current gaslimit %d", blockHeight, gasLimitUint64)
- }
-
- gasUsedRatio := gasusedfloat / float64(gasLimitUint64)
- blockGasUsed := gasusedfloat
- targetOneFeeHistory.GasUsedRatio = gasUsedRatio
-
- rewardCount := len(rewardPercentiles)
- targetOneFeeHistory.Reward = make([]*big.Int, rewardCount)
- for i := 0; i < rewardCount; i++ {
- targetOneFeeHistory.Reward[i] = big.NewInt(0)
- }
-
- // check tendermintTxs
- tendermintTxs := tendermintBlock.Block.Txs
- tendermintTxResults := tendermintBlockResult.TxsResults
- tendermintTxCount := len(tendermintTxs)
-
- var sorter sortGasAndReward
-
- for i := 0; i < tendermintTxCount; i++ {
- eachTendermintTx := tendermintTxs[i]
- eachTendermintTxResult := tendermintTxResults[i]
-
- tx, err := b.clientCtx.TxConfig.TxDecoder()(eachTendermintTx)
- if err != nil {
- b.logger.Debug("failed to decode transaction in block", "height", blockHeight, "error", err.Error())
- continue
- }
- txGasUsed := uint64(eachTendermintTxResult.GasUsed) // #nosec G701
- for _, msg := range tx.GetMsgs() {
- ethMsg, ok := msg.(*evm.MsgEthereumTx)
- if !ok {
- continue
- }
- tx := ethMsg.AsTransaction()
- reward := tx.EffectiveGasTipValue(blockBaseFee)
- if reward == nil {
- reward = big.NewInt(0)
- }
- sorter = append(sorter, txGasAndReward{gasUsed: txGasUsed, reward: reward})
- }
- }
-
- // return an all zero row if there are no transactions to gather data from
- ethTxCount := len(sorter)
- if ethTxCount == 0 {
- return nil
- }
-
- sort.Sort(sorter)
-
- var txIndex int
- sumGasUsed := sorter[0].gasUsed
-
- for i, p := range rewardPercentiles {
- thresholdGasUsed := uint64(blockGasUsed * p / 100) // #nosec G701
- for sumGasUsed < thresholdGasUsed && txIndex < ethTxCount-1 {
- txIndex++
- sumGasUsed += sorter[txIndex].gasUsed
- }
- targetOneFeeHistory.Reward[i] = sorter[txIndex].reward
- }
-
- return nil
-}
-
-// AllTxLogsFromEvents parses all ethereum logs from cosmos events
-func AllTxLogsFromEvents(events []abci.Event) ([][]*gethcore.Log, error) {
- allLogs := make([][]*gethcore.Log, 0, 4)
- for _, event := range events {
- if event.Type != evm.EventTypeTxLog {
- continue
- }
-
- logs, err := ParseTxLogsFromEvent(event)
- if err != nil {
- return nil, err
- }
-
- allLogs = append(allLogs, logs)
- }
- return allLogs, nil
-}
-
-// TxLogsFromEvents parses ethereum logs from cosmos events for specific msg index
-func TxLogsFromEvents(events []abci.Event, msgIndex int) ([]*gethcore.Log, error) {
- for _, event := range events {
- if event.Type != evm.EventTypeTxLog {
- continue
- }
-
- if msgIndex > 0 {
- // not the eth tx we want
- msgIndex--
- continue
- }
-
- return ParseTxLogsFromEvent(event)
- }
- return nil, fmt.Errorf("eth tx logs not found for message index %d", msgIndex)
-}
-
-// ParseTxLogsFromEvent parse tx logs from one event
-func ParseTxLogsFromEvent(event abci.Event) ([]*gethcore.Log, error) {
- logs := make([]*evm.Log, 0, len(event.Attributes))
- for _, attr := range event.Attributes {
- if attr.Key != evm.AttributeKeyTxLog {
- continue
- }
-
- var log evm.Log
- if err := json.Unmarshal([]byte(attr.Value), &log); err != nil {
- return nil, err
- }
-
- logs = append(logs, &log)
- }
- return evm.LogsToEthereum(logs), nil
-}
-
-// ShouldIgnoreGasUsed returns true if the gasUsed in result should be ignored
-// workaround for issue: https://github.com/cosmos/cosmos-sdk/issues/10832
-func ShouldIgnoreGasUsed(res *abci.ResponseDeliverTx) bool {
- return res.GetCode() == 11 && strings.Contains(res.GetLog(), "no block gas left to run tx: out of gas")
-}
-
-// GetLogsFromBlockResults returns the list of event logs from the tendermint block result response
-func GetLogsFromBlockResults(blockRes *tmrpctypes.ResultBlockResults) ([][]*gethcore.Log, error) {
- blockLogs := [][]*gethcore.Log{}
- for _, txResult := range blockRes.TxsResults {
- logs, err := AllTxLogsFromEvents(txResult.Events)
- if err != nil {
- return nil, err
- }
-
- blockLogs = append(blockLogs, logs...)
- }
- return blockLogs, nil
-}
-
-// GetHexProofs returns list of hex data of proof op
-func GetHexProofs(proof *crypto.ProofOps) []string {
- if proof == nil {
- return []string{""}
- }
- proofs := []string{}
- // check for proof
- for _, p := range proof.Ops {
- proof := ""
- if len(p.Data) > 0 {
- proof = hexutil.Encode(p.Data)
- }
- proofs = append(proofs, proof)
- }
- return proofs
-}
diff --git a/eth/rpc/backend/utils_test.go b/eth/rpc/backend/utils_test.go
deleted file mode 100644
index 4c7c14a74..000000000
--- a/eth/rpc/backend/utils_test.go
+++ /dev/null
@@ -1,52 +0,0 @@
-package backend
-
-import (
- "fmt"
-
- "github.com/cometbft/cometbft/proto/tendermint/crypto"
-)
-
-func mookProofs(num int, withData bool) *crypto.ProofOps {
- var proofOps *crypto.ProofOps
- if num > 0 {
- proofOps = new(crypto.ProofOps)
- for i := 0; i < num; i++ {
- proof := crypto.ProofOp{}
- if withData {
- proof.Data = []byte("\n\031\n\003KEY\022\005VALUE\032\013\010\001\030\001 \001*\003\000\002\002")
- }
- proofOps.Ops = append(proofOps.Ops, proof)
- }
- }
- return proofOps
-}
-
-func (s *BackendSuite) TestGetHexProofs() {
- defaultRes := []string{""}
- testCases := []struct {
- name string
- proof *crypto.ProofOps
- exp []string
- }{
- {
- "no proof provided",
- mookProofs(0, false),
- defaultRes,
- },
- {
- "no proof data provided",
- mookProofs(1, false),
- defaultRes,
- },
- {
- "valid proof provided",
- mookProofs(1, true),
- []string{"0x0a190a034b4559120556414c55451a0b0801180120012a03000202"},
- },
- }
- for _, tc := range testCases {
- s.Run(fmt.Sprintf("Case %s", tc.name), func() {
- s.Require().Equal(tc.exp, GetHexProofs(tc.proof))
- })
- }
-}
diff --git a/eth/rpc/block.go b/eth/rpc/block.go
deleted file mode 100644
index 7b58efb92..000000000
--- a/eth/rpc/block.go
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpc
-
-import (
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "math"
- "math/big"
- "strings"
-
- "github.com/spf13/cast"
- "google.golang.org/grpc/metadata"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
-
- grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-// BlockNumber represents a decoded hex string for a block number.
-type BlockNumber int64
-
-const (
- EthPendingBlockNumber = BlockNumber(-2)
- EthLatestBlockNumber = BlockNumber(-1)
- EthEarliestBlockNumber = BlockNumber(0)
-)
-
-const (
- BlockParamEarliest = "earliest"
- BlockParamLatest = "latest"
- BlockParamFinalized = "finalized"
- BlockParamSafe = "safe"
- BlockParamPending = "pending"
-)
-
-// NewBlockNumber creates a new BlockNumber instance.
-func NewBlockNumber(n *big.Int) BlockNumber {
- if !n.IsInt64() {
- // default to latest block if it overflows
- return EthLatestBlockNumber
- }
-
- return BlockNumber(n.Int64())
-}
-
-// NewContextWithHeight wraps a context with the a gRPC block height header. If the
-// provided height is 0, it will return an empty context and the gRPC query will
-// use the latest block height for querying. Note that all metadata gets processed
-// and removed by tendermint layer, so it wont be accessible at gRPC server
-// level.
-func NewContextWithHeight(height int64) context.Context {
- if height == 0 {
- return context.Background()
- }
- return metadata.AppendToOutgoingContext(
- context.Background(),
- grpctypes.GRPCBlockHeightHeader,
- fmt.Sprintf("%d", height),
- )
-}
-
-// UnmarshalJSON parses the given JSON fragment into a BlockNumber. It supports:
-// - "latest", "finalized", "earliest" or "pending" as string arguments
-// - the block number
-//
-// Returned errors:
-// - Invalid block number error when the given argument isn't a known string
-// - Out of range error when the given block number is too large or small
-func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
- input := strings.TrimSpace(string(data))
- if len(input) >= 2 && input[0] == '"' && input[len(input)-1] == '"' {
- input = input[1 : len(input)-1]
- }
-
- switch input {
- case BlockParamEarliest:
- *bn = EthEarliestBlockNumber
- return nil
- case BlockParamLatest, BlockParamFinalized, BlockParamSafe:
- *bn = EthLatestBlockNumber
- return nil
- case BlockParamPending:
- *bn = EthPendingBlockNumber
- return nil
- }
-
- blckNum, err := hexutil.DecodeUint64(input)
- if errors.Is(err, hexutil.ErrMissingPrefix) {
- blckNum = cast.ToUint64(input)
- } else if err != nil {
- return err
- }
-
- if blckNum > math.MaxInt64 {
- return fmt.Errorf("block number larger than int64")
- }
- *bn = BlockNumber(blckNum) // #nosec G701
-
- return nil
-}
-
-// Int64 converts block number to primitive type. This function enforces the
-// first block starting from 1-index.
-func (bn BlockNumber) Int64() int64 {
- if bn < 0 {
- return 0
- } else if bn == 0 {
- return 1
- }
-
- return int64(bn)
-}
-
-// TmHeight is a util function used for the Tendermint RPC client. It returns
-// nil if the block number is "latest". Otherwise, it returns the pointer of the
-// int64 value of the height.
-func (bn BlockNumber) TmHeight() *int64 {
- if bn < 0 {
- return nil
- }
-
- height := bn.Int64()
- return &height
-}
-
-// BlockNumberOrHash represents a block number or a block hash.
-type BlockNumberOrHash struct {
- BlockNumber *BlockNumber `json:"blockNumber,omitempty"`
- BlockHash *common.Hash `json:"blockHash,omitempty"`
-}
-
-func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error {
- type erased BlockNumberOrHash
- e := erased{}
- err := json.Unmarshal(data, &e)
- if err == nil {
- return bnh.checkUnmarshal(BlockNumberOrHash(e))
- }
- var input string
- err = json.Unmarshal(data, &input)
- if err != nil {
- return err
- }
- err = bnh.decodeFromString(input)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func (bnh *BlockNumberOrHash) checkUnmarshal(e BlockNumberOrHash) error {
- if e.BlockNumber != nil && e.BlockHash != nil {
- return fmt.Errorf("cannot specify both BlockHash and BlockNumber, choose one or the other")
- }
- bnh.BlockNumber = e.BlockNumber
- bnh.BlockHash = e.BlockHash
- return nil
-}
-
-func (bnh *BlockNumberOrHash) decodeFromString(input string) error {
- switch input {
- case BlockParamEarliest:
- bn := EthEarliestBlockNumber
- bnh.BlockNumber = &bn
- case BlockParamLatest, BlockParamFinalized:
- bn := EthLatestBlockNumber
- bnh.BlockNumber = &bn
- case BlockParamPending:
- bn := EthPendingBlockNumber
- bnh.BlockNumber = &bn
- default:
- // check if the input is a block hash
- if len(input) == 66 {
- hash := common.Hash{}
- err := hash.UnmarshalText([]byte(input))
- if err != nil {
- return err
- }
- bnh.BlockHash = &hash
- break
- }
- // otherwise take the hex string has int64 value
- blockNumber, err := hexutil.DecodeUint64(input)
- if err != nil {
- return err
- }
-
- bnInt, err := eth.SafeInt64(blockNumber)
- if err != nil {
- return err
- }
-
- bn := BlockNumber(bnInt)
- bnh.BlockNumber = &bn
- }
- return nil
-}
diff --git a/eth/rpc/block_test.go b/eth/rpc/block_test.go
deleted file mode 100644
index fde99b14c..000000000
--- a/eth/rpc/block_test.go
+++ /dev/null
@@ -1,143 +0,0 @@
-package rpc
-
-import (
- "fmt"
- "math/big"
- "testing"
-
- grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
- "github.com/ethereum/go-ethereum/common"
- "github.com/stretchr/testify/suite"
- "google.golang.org/grpc/metadata"
-)
-
-type BlockSuite struct {
- suite.Suite
-}
-
-func TestBlockSuite(t *testing.T) {
- suite.Run(t, new(BlockSuite))
-}
-
-func (s *BlockSuite) TestNewBlockNumber() {
- bigInt := big.NewInt(1)
- bn := NewBlockNumber(bigInt)
- bnInt64 := bn.Int64()
- bnTmHeight := bn.TmHeight()
- s.EqualValues(bnInt64, *bnTmHeight)
- s.EqualValues(bigInt.Int64(), bnInt64)
-}
-
-func (s *BlockSuite) TestNewContextWithHeight() {
- // Test with zero height
- ctxZero := NewContextWithHeight(0)
- _, ok := metadata.FromOutgoingContext(ctxZero)
- s.False(ok, "No metadata should be present for height 0")
-
- // Test with non-zero height
- height := int64(10)
- ctxTen := NewContextWithHeight(height)
- md, ok := metadata.FromOutgoingContext(ctxTen)
- s.True(ok, "Metadata should be present for non-zero height")
- s.NotEmpty(md, "Metadata should not be empty")
-
- heightStr, ok := md[grpctypes.GRPCBlockHeightHeader]
- s.True(ok, grpctypes.GRPCBlockHeightHeader, " metadata should be present")
- s.Require().Len(heightStr, 1,
- fmt.Sprintf("There should be exactly one %s value", grpctypes.GRPCBlockHeightHeader))
- s.Equal(fmt.Sprintf("%d", height), heightStr[0],
- "The height value in metadata should match the provided height")
-}
-
-func (s *BlockSuite) TestUnmarshalBlockNumberOrHash() {
- bnh := new(BlockNumberOrHash)
-
- testCases := []struct {
- msg string
- input []byte
- malleate func()
- expPass bool
- }{
- {
- msg: "JSON input with block hash",
- input: []byte("{\"blockHash\": \"0x579917054e325746fda5c3ee431d73d26255bc4e10b51163862368629ae19739\"}"),
- malleate: func() {
- s.Equal(*bnh.BlockHash, common.HexToHash("0x579917054e325746fda5c3ee431d73d26255bc4e10b51163862368629ae19739"))
- s.Nil(bnh.BlockNumber)
- },
- expPass: true,
- },
- {
- "JSON input with block number",
- []byte("{\"blockNumber\": \"0x35\"}"),
- func() {
- s.Equal(*bnh.BlockNumber, BlockNumber(0x35))
- s.Nil(bnh.BlockHash)
- },
- true,
- },
- {
- "JSON input with block number latest",
- []byte("{\"blockNumber\": \"latest\"}"),
- func() {
- s.Equal(*bnh.BlockNumber, EthLatestBlockNumber)
- s.Nil(bnh.BlockHash)
- },
- true,
- },
- {
- "JSON input with both block hash and block number",
- []byte("{\"blockHash\": \"0x579917054e325746fda5c3ee431d73d26255bc4e10b51163862368629ae19739\", \"blockNumber\": \"0x35\"}"),
- func() {
- },
- false,
- },
- {
- "String input with block hash",
- []byte("\"0x579917054e325746fda5c3ee431d73d26255bc4e10b51163862368629ae19739\""),
- func() {
- s.Equal(*bnh.BlockHash, common.HexToHash("0x579917054e325746fda5c3ee431d73d26255bc4e10b51163862368629ae19739"))
- s.Nil(bnh.BlockNumber)
- },
- true,
- },
- {
- "String input with block number",
- []byte("\"0x35\""),
- func() {
- s.Equal(*bnh.BlockNumber, BlockNumber(0x35))
- s.Nil(bnh.BlockHash)
- },
- true,
- },
- {
- "String input with block number latest",
- []byte("\"latest\""),
- func() {
- s.Equal(*bnh.BlockNumber, EthLatestBlockNumber)
- s.Nil(bnh.BlockHash)
- },
- true,
- },
- {
- "String input with block number overflow",
- []byte("\"0xffffffffffffffffffffffffffffffffffffff\""),
- func() {
- },
- false,
- },
- }
-
- for _, tc := range testCases {
- fmt.Printf("Case %s", tc.msg)
- // reset input
- bnh = new(BlockNumberOrHash)
- err := bnh.UnmarshalJSON(tc.input)
- tc.malleate()
- if tc.expPass {
- s.NoError(err)
- } else {
- s.Error(err)
- }
- }
-}
diff --git a/eth/rpc/events.go b/eth/rpc/events.go
deleted file mode 100644
index 8bd4ac6e8..000000000
--- a/eth/rpc/events.go
+++ /dev/null
@@ -1,265 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpc
-
-import (
- "fmt"
- "strconv"
-
- abci "github.com/cometbft/cometbft/abci/types"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// EventFormat is an enum type for an ethereum tx event. Each event format
-// variant has json-rpc logic to make it so that clients using either format will
-// be compatible, meaning nodes will able to sync without restarting from the
-// first block.
-type EventFormat int
-
-const (
- eventFormatUnknown EventFormat = iota
-
- // Event Format 1
- // ```
- // ethereum_tx(amount, ethereumTxHash, [txIndex, txGasUsed], txHash, [receipient], ethereumTxFailed)
- // tx_log(txLog, txLog, ...)
- // ethereum_tx(amount, ethereumTxHash, [txIndex, txGasUsed], txHash, [receipient], ethereumTxFailed)
- // tx_log(txLog, txLog, ...)
- // ...
- // ```
- eventFormat1
-
- // Event Format 2
- // ```
- // ethereum_tx(ethereumTxHash, txIndex)
- // ethereum_tx(ethereumTxHash, txIndex)
- // ...
- // ethereum_tx(amount, ethereumTxHash, txIndex, txGasUsed, txHash, [receipient], ethereumTxFailed)
- // tx_log(txLog, txLog, ...)
- // ethereum_tx(amount, ethereumTxHash, txIndex, txGasUsed, txHash, [receipient], ethereumTxFailed)
- // tx_log(txLog, txLog, ...)
- // ...
- // ```
- // If the transaction exceeds block gas limit, it only emits the first part.
- eventFormat2
-)
-
-// ParsedTx is eth tx info parsed from ABCI events. Each `ParsedTx` corresponds
-// to one eth tx msg ([evm.MsgEthereumTx]).
-type ParsedTx struct {
- MsgIndex int
-
- // the following fields are parsed from events
-
- Hash common.Hash
- // -1 means uninitialized
- EthTxIndex int32
- GasUsed uint64
- Failed bool
-}
-
-// NewParsedTx initialize a ParsedTx
-func NewParsedTx(msgIndex int) ParsedTx {
- return ParsedTx{MsgIndex: msgIndex, EthTxIndex: -1}
-}
-
-// ParsedTxs is the tx infos parsed from eth tx events.
-type ParsedTxs struct {
- // one item per message
- Txs []ParsedTx
- // map tx hash to msg index
- TxHashes map[common.Hash]int
-}
-
-// ParseTxResult: parses eth tx info from the ABCI events of Eth tx msgs
-// ([evm.MsgEthereumTx]). It supports each [EventFormat].
-func ParseTxResult(
- result *abci.ResponseDeliverTx, tx sdk.Tx,
-) (*ParsedTxs, error) {
- format := eventFormatUnknown
- // the index of current ethereum_tx event in format 1 or the second part of format 2
- eventIndex := -1
-
- p := &ParsedTxs{
- TxHashes: make(map[common.Hash]int),
- }
- for _, event := range result.Events {
- if event.Type != evm.EventTypeEthereumTx {
- continue
- }
-
- if format == eventFormatUnknown {
- // discover the format version by inspect the first ethereum_tx event.
- if len(event.Attributes) > 2 {
- format = eventFormat1
- } else {
- format = eventFormat2
- }
- }
-
- if len(event.Attributes) == 2 {
- // the first part of format 2
- if err := p.newTx(event.Attributes); err != nil {
- return nil, err
- }
- } else {
- // format 1 or second part of format 2
- eventIndex++
- if format == eventFormat1 {
- // append tx
- if err := p.newTx(event.Attributes); err != nil {
- return nil, err
- }
- } else {
- // the second part of format 2, update tx fields
- if err := p.updateTx(eventIndex, event.Attributes); err != nil {
- return nil, err
- }
- }
- }
- }
-
- // some old versions miss some events, fill it with tx result
- gasUsed := uint64(result.GasUsed) // #nosec G701
- if len(p.Txs) == 1 {
- p.Txs[0].GasUsed = gasUsed
- }
-
- // this could only happen if tx exceeds block gas limit
- if result.Code != 0 && tx != nil {
- for i := 0; i < len(p.Txs); i++ {
- p.Txs[i].Failed = true
-
- // replace gasUsed with gasLimit because that's what's actually deducted.
- gasLimit := tx.GetMsgs()[i].(*evm.MsgEthereumTx).GetGas()
- p.Txs[i].GasUsed = gasLimit
- }
- }
- return p, nil
-}
-
-// ParseTxIndexerResult parse tm tx result to a format compatible with the custom tx indexer.
-func ParseTxIndexerResult(
- txResult *tmrpctypes.ResultTx, tx sdk.Tx, getter func(*ParsedTxs) *ParsedTx,
-) (*eth.TxResult, error) {
- txs, err := ParseTxResult(&txResult.TxResult, tx)
- if err != nil {
- return nil, fmt.Errorf("failed to parse tx events: block %d, index %d, %v", txResult.Height, txResult.Index, err)
- }
-
- parsedTx := getter(txs)
- if parsedTx == nil {
- return nil, fmt.Errorf("ethereum tx not found in msgs: block %d, index %d", txResult.Height, txResult.Index)
- }
- index := uint32(parsedTx.MsgIndex) // #nosec G701
- return ð.TxResult{
- Height: txResult.Height,
- TxIndex: txResult.Index,
- MsgIndex: index,
- EthTxIndex: parsedTx.EthTxIndex,
- Failed: parsedTx.Failed,
- GasUsed: parsedTx.GasUsed,
- CumulativeGasUsed: txs.AccumulativeGasUsed(parsedTx.MsgIndex),
- }, nil
-}
-
-// newTx parse a new tx from events, called during parsing.
-func (p *ParsedTxs) newTx(attrs []abci.EventAttribute) error {
- msgIndex := len(p.Txs)
- tx := NewParsedTx(msgIndex)
- if err := fillTxAttributes(&tx, attrs); err != nil {
- return err
- }
- p.Txs = append(p.Txs, tx)
- p.TxHashes[tx.Hash] = msgIndex
- return nil
-}
-
-// updateTx updates an exiting tx from events, called during parsing.
-// In event format 2, we update the tx with the attributes of the second `ethereum_tx` event,
-func (p *ParsedTxs) updateTx(eventIndex int, attrs []abci.EventAttribute) error {
- tx := NewParsedTx(eventIndex)
- if err := fillTxAttributes(&tx, attrs); err != nil {
- return err
- }
- if tx.Hash != p.Txs[eventIndex].Hash {
- // if hash is different, index the new one too
- p.TxHashes[tx.Hash] = eventIndex
- }
- // override the tx because the second event is more trustworthy
- p.Txs[eventIndex] = tx
- return nil
-}
-
-// GetTxByHash find ParsedTx by tx hash, returns nil if not exists.
-func (p *ParsedTxs) GetTxByHash(hash common.Hash) *ParsedTx {
- if idx, ok := p.TxHashes[hash]; ok {
- return &p.Txs[idx]
- }
- return nil
-}
-
-// GetTxByMsgIndex returns ParsedTx by msg index
-func (p *ParsedTxs) GetTxByMsgIndex(i int) *ParsedTx {
- if i < 0 || i >= len(p.Txs) {
- return nil
- }
- return &p.Txs[i]
-}
-
-// GetTxByTxIndex returns ParsedTx by tx index
-func (p *ParsedTxs) GetTxByTxIndex(txIndex int) *ParsedTx {
- if len(p.Txs) == 0 {
- return nil
- }
- // assuming the `EthTxIndex` increase continuously,
- // convert TxIndex to MsgIndex by subtract the begin TxIndex.
- msgIndex := txIndex - int(p.Txs[0].EthTxIndex)
- // GetTxByMsgIndex will check the bound
- return p.GetTxByMsgIndex(msgIndex)
-}
-
-// AccumulativeGasUsed calculates the accumulated gas used within the batch of txs
-func (p *ParsedTxs) AccumulativeGasUsed(msgIndex int) (result uint64) {
- for i := 0; i <= msgIndex; i++ {
- result += p.Txs[i].GasUsed
- }
- return result
-}
-
-// fillTxAttribute parse attributes by name, less efficient than hardcode the
-// index, but more stable against event format changes.
-func fillTxAttribute(tx *ParsedTx, key string, value string) error {
- switch key {
- case evm.AttributeKeyEthereumTxHash:
- tx.Hash = common.HexToHash(value)
- case evm.AttributeKeyTxIndex:
- txIndex, err := strconv.ParseUint(value, 10, 31) // #nosec G701
- if err != nil {
- return err
- }
- tx.EthTxIndex = int32(txIndex) // #nosec G701
- case evm.AttributeKeyTxGasUsed:
- gasUsed, err := strconv.ParseUint(value, 10, 64)
- if err != nil {
- return err
- }
- tx.GasUsed = gasUsed
- case evm.AttributeKeyEthereumTxFailed:
- tx.Failed = len(value) > 0
- }
- return nil
-}
-
-func fillTxAttributes(tx *ParsedTx, attrs []abci.EventAttribute) error {
- for _, attr := range attrs {
- if err := fillTxAttribute(tx, attr.Key, attr.Value); err != nil {
- return err
- }
- }
- return nil
-}
diff --git a/eth/rpc/events_test.go b/eth/rpc/events_test.go
deleted file mode 100644
index 56d9191e2..000000000
--- a/eth/rpc/events_test.go
+++ /dev/null
@@ -1,193 +0,0 @@
-package rpc
-
-import (
- "math/big"
- "testing"
-
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-func TestParseTxResult(t *testing.T) {
- address := "0x57f96e6B86CdeFdB3d412547816a82E3E0EbF9D2"
- txHash := common.BigToHash(big.NewInt(1))
- txHash2 := common.BigToHash(big.NewInt(2))
-
- type TestCase struct {
- name string
- txResp abci.ResponseDeliverTx
- wantEthTxs []*ParsedTx // expected parse result, nil means expect error.
- }
-
- testCases := []TestCase{
- {
- name: "format 1 events",
- txResp: abci.ResponseDeliverTx{
- GasUsed: 21000,
- Events: []abci.Event{
- {Type: "coin_received", Attributes: []abci.EventAttribute{
- {Key: "receiver", Value: "ethm12luku6uxehhak02py4rcz65zu0swh7wjun6msa"},
- {Key: "amount", Value: "1252860basetcro"},
- }},
- {Type: "coin_spent", Attributes: []abci.EventAttribute{
- {Key: "spender", Value: "ethm17xpfvakm2amg962yls6f84z3kell8c5lthdzgl"},
- {Key: "amount", Value: "1252860basetcro"},
- }},
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "10"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: "14A84ED06282645EFBF080E0B7ED80D8D8D6A36337668A12B5F229F81CDD3F57"},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- {Type: "message", Attributes: []abci.EventAttribute{
- {Key: "action", Value: "/ehermint.evm.v1.MsgEthereumTx"},
- {Key: "key", Value: "ethm17xpfvakm2amg962yls6f84z3kell8c5lthdzgl"},
- {Key: "module", Value: "evm"},
- {Key: "sender", Value: address},
- }},
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash2.Hex()},
- {Key: "txIndex", Value: "11"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: "14A84ED06282645EFBF080E0B7ED80D8D8D6A36337668A12B5F229F81CDD3F57"},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- {Key: "ethereumTxFailed", Value: "contract everted"},
- }},
- {Type: evm.EventTypeTxLog, Attributes: []abci.EventAttribute{}},
- },
- },
- wantEthTxs: []*ParsedTx{
- {
- MsgIndex: 0,
- Hash: txHash,
- EthTxIndex: 10,
- GasUsed: 21000,
- Failed: false,
- },
- {
- MsgIndex: 1,
- Hash: txHash2,
- EthTxIndex: 11,
- GasUsed: 21000,
- Failed: true,
- },
- },
- },
- {
- name: "format 2 events",
- txResp: abci.ResponseDeliverTx{
- GasUsed: 21000,
- Events: []abci.Event{
- {Type: "coin_received", Attributes: []abci.EventAttribute{
- {Key: "receiver", Value: "ethm12luku6uxehhak02py4rcz65zu0swh7wjun6msa"},
- {Key: "amount", Value: "1252860basetcro"},
- }},
- {Type: "coin_spent", Attributes: []abci.EventAttribute{
- {Key: "spender", Value: "ethm17xpfvakm2amg962yls6f84z3kell8c5lthdzgl"},
- {Key: "amount", Value: "1252860basetcro"},
- }},
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "0"},
- }},
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "amount", Value: "1000"},
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "0"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: "14A84ED06282645EFBF080E0B7ED80D8D8D6A36337668A12B5F229F81CDD3F57"},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- {Type: "message", Attributes: []abci.EventAttribute{
- {Key: "action", Value: "/ehermint.evm.v1.MsgEthereumTx"},
- {Key: "key", Value: "ethm17xpfvakm2amg962yls6f84z3kell8c5lthdzgl"},
- {Key: "module", Value: "evm"},
- {Key: "sender", Value: address},
- }},
- },
- },
- wantEthTxs: []*ParsedTx{
- {
- MsgIndex: 0,
- Hash: txHash,
- EthTxIndex: 0,
- GasUsed: 21000,
- Failed: false,
- },
- },
- },
- {
- "format 1 events, failed",
- abci.ResponseDeliverTx{
- GasUsed: 21000,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "10"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "21000"},
- {Key: "txHash", Value: "14A84ED06282645EFBF080E0B7ED80D8D8D6A36337668A12B5F229F81CDD3F57"},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash2.Hex()},
- {Key: "txIndex", Value: "10"},
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "0x01"},
- {Key: "txHash", Value: "14A84ED06282645EFBF080E0B7ED80D8D8D6A36337668A12B5F229F81CDD3F57"},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- {Key: "ethereumTxFailed", Value: "contract everted"},
- }},
- {Type: evm.EventTypeTxLog, Attributes: []abci.EventAttribute{}},
- },
- },
- nil,
- },
- {
- name: "format 2 events failed",
- txResp: abci.ResponseDeliverTx{
- GasUsed: 21000,
- Events: []abci.Event{
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "ethereumTxHash", Value: txHash.Hex()},
- {Key: "txIndex", Value: "10"},
- }},
- {Type: evm.EventTypeEthereumTx, Attributes: []abci.EventAttribute{
- {Key: "amount", Value: "1000"},
- {Key: "txGasUsed", Value: "0x01"},
- {Key: "txHash", Value: "14A84ED06282645EFBF080E0B7ED80D8D8D6A36337668A12B5F229F81CDD3F57"},
- {Key: "recipient", Value: "0x775b87ef5D82ca211811C1a02CE0fE0CA3a455d7"},
- }},
- },
- },
- wantEthTxs: nil,
- },
- }
-
- for _, tc := range testCases {
- t.Run(tc.name, func(t *testing.T) {
- parsed, err := ParseTxResult(&tc.txResp, nil) //#nosec G601 -- fine for tests
- if tc.wantEthTxs == nil {
- require.Error(t, err)
- return
- }
- require.NoError(t, err)
- for msgIndex, expTx := range tc.wantEthTxs {
- require.Equal(t, expTx, parsed.GetTxByMsgIndex(msgIndex))
- require.Equal(t, expTx, parsed.GetTxByHash(expTx.Hash))
- require.Equal(t, expTx, parsed.GetTxByTxIndex(int(expTx.EthTxIndex)))
- }
- // non-exists tx hash
- require.Nil(t, parsed.GetTxByHash(common.Hash{}))
- // out of range
- require.Nil(t, parsed.GetTxByMsgIndex(len(tc.wantEthTxs)))
- require.Nil(t, parsed.GetTxByTxIndex(99999999))
- })
- }
-}
diff --git a/eth/rpc/pubsub/pubsub.go b/eth/rpc/pubsub/pubsub.go
deleted file mode 100644
index f5baabd54..000000000
--- a/eth/rpc/pubsub/pubsub.go
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package pubsub
-
-import (
- "sync"
- "sync/atomic"
-
- "github.com/pkg/errors"
-
- coretypes "github.com/cometbft/cometbft/rpc/core/types"
-)
-
-type UnsubscribeFunc func()
-
-// EventBus manages topics and subscriptions. A "topic" is a named channel of
-// communication. A "subscription" is the action taken by a subscriber to express
-// interest in receiving messages broadcasted from a specific topic.
-type EventBus interface {
- // AddTopic: Adds a new topic with the specified name and message source
- AddTopic(name string, src <-chan coretypes.ResultEvent) error
- // RemoveTopic: Removes the specified topic and all its related data,
- // ensuring clean up of resources.
- RemoveTopic(name string)
- Subscribe(name string) (<-chan coretypes.ResultEvent, UnsubscribeFunc, error)
- Topics() []string
-}
-
-// memEventBus is an implemention of the `EventBus` interface.
-type memEventBus struct {
- topics map[string]<-chan coretypes.ResultEvent
- topicsMux *sync.RWMutex
- subscribers map[string]map[uint64]chan<- coretypes.ResultEvent
- subscribersMux *sync.RWMutex
- currentUniqueID uint64
-}
-
-// NewEventBus returns a fresh imlpemention of `memEventBus`, which implements
-// the `EventBus` interface for managing Ethereum topics and subscriptions.
-func NewEventBus() EventBus {
- return &memEventBus{
- topics: make(map[string]<-chan coretypes.ResultEvent),
- topicsMux: new(sync.RWMutex),
- subscribers: make(map[string]map[uint64]chan<- coretypes.ResultEvent),
- subscribersMux: new(sync.RWMutex),
- }
-}
-
-// GenUniqueID atomically increments and returns a unique identifier for a new subscriber.
-// This ID is used internally to manage subscriber-specific channels.
-func (m *memEventBus) GenUniqueID() uint64 {
- return atomic.AddUint64(&m.currentUniqueID, 1)
-}
-
-// Topics returns a list of all topics currently managed by the EventBus. The
-// list is safe for concurrent access and is a snapshot of current topic names.
-func (m *memEventBus) Topics() (topics []string) {
- m.topicsMux.RLock()
- defer m.topicsMux.RUnlock()
-
- topics = make([]string, 0, len(m.topics))
- for topicName := range m.topics {
- topics = append(topics, topicName)
- }
-
- return topics
-}
-
-// AddTopic adds a new topic with the specified name and message source
-func (m *memEventBus) AddTopic(name string, src <-chan coretypes.ResultEvent) error {
- m.topicsMux.RLock()
- _, ok := m.topics[name]
- m.topicsMux.RUnlock()
-
- if ok {
- return errors.New("topic already registered")
- }
-
- m.topicsMux.Lock()
- m.topics[name] = src
- m.topicsMux.Unlock()
-
- go m.publishTopic(name, src)
-
- return nil
-}
-
-// RemoveTopic: Removes the specified topic and all its related data, ensuring
-// clean up of resources.
-func (m *memEventBus) RemoveTopic(name string) {
- m.topicsMux.Lock()
- delete(m.topics, name)
- m.topicsMux.Unlock()
-}
-
-// Subscribe attempts to create a subscription to the specified topic. It returns
-// a channel to receive messages, a function to unsubscribe, and an error if the
-// topic does not exist.
-func (m *memEventBus) Subscribe(name string) (<-chan coretypes.ResultEvent, UnsubscribeFunc, error) {
- m.topicsMux.RLock()
- _, ok := m.topics[name]
- m.topicsMux.RUnlock()
-
- if !ok {
- return nil, nil, errors.Errorf("topic not found: %s", name)
- }
-
- ch := make(chan coretypes.ResultEvent)
- m.subscribersMux.Lock()
- defer m.subscribersMux.Unlock()
-
- id := m.GenUniqueID()
- if _, ok := m.subscribers[name]; !ok {
- m.subscribers[name] = make(map[uint64]chan<- coretypes.ResultEvent)
- }
- m.subscribers[name][id] = ch
-
- unsubscribe := func() {
- m.subscribersMux.Lock()
- defer m.subscribersMux.Unlock()
- delete(m.subscribers[name], id)
- }
-
- return ch, unsubscribe, nil
-}
-
-func (m *memEventBus) publishTopic(name string, src <-chan coretypes.ResultEvent) {
- for {
- msg, ok := <-src
- if !ok {
- m.closeAllSubscribers(name)
- m.topicsMux.Lock()
- delete(m.topics, name)
- m.topicsMux.Unlock()
- return
- }
- m.publishAllSubscribers(name, msg)
- }
-}
-
-// closeAllSubscribers closes all subscriber channels associated with the
-// specified topic and removes the topic from the subscribers map. This function
-// is typically called when a topic is deleted or no longer available to ensure
-// all resources are released properly and to prevent goroutine leaks. It ensures
-// thread-safe execution by locking around the operation.
-func (m *memEventBus) closeAllSubscribers(name string) {
- m.subscribersMux.Lock()
- defer m.subscribersMux.Unlock()
-
- subscribers := m.subscribers[name]
- delete(m.subscribers, name)
- // #nosec G705
- for _, sub := range subscribers {
- close(sub)
- }
-}
-
-// publishAllSubscribers sends a message to all subscribers of the specified
-// topic. It uses a non-blocking send operation to deliver the message to
-// subscriber channels. If a subscriber's channel is not ready to receive the
-// message (i.e., the channel is full), the message is skipped for that
-// subscriber to avoid blocking the publisher. This function ensures thread-safe
-// access to subscribers by using a read lock.
-func (m *memEventBus) publishAllSubscribers(name string, msg coretypes.ResultEvent) {
- m.subscribersMux.RLock()
- defer m.subscribersMux.RUnlock()
- subscribers := m.subscribers[name]
- // #nosec G705
- for _, sub := range subscribers {
- select {
- case sub <- msg:
- default:
- }
- }
-}
diff --git a/eth/rpc/pubsub/pubsub_test.go b/eth/rpc/pubsub/pubsub_test.go
deleted file mode 100644
index e03de763d..000000000
--- a/eth/rpc/pubsub/pubsub_test.go
+++ /dev/null
@@ -1,155 +0,0 @@
-package pubsub
-
-import (
- "log"
- "sort"
- "sync"
- "testing"
- "time"
-
- rpccore "github.com/cometbft/cometbft/rpc/core/types"
- "github.com/stretchr/testify/require"
- "github.com/stretchr/testify/suite"
-)
-
-// subscribeAndPublish: Helper function used to perform concurrent subscription
-// and publishing actions. It concurrently subscribes multiple clients to the
-// specified topic and simultanesouly sends an empty message to the topic channel
-// for each subscription.
-func subscribeAndPublish(t *testing.T, eb EventBus, topic string, topicChan chan rpccore.ResultEvent) {
- var (
- wg sync.WaitGroup
- subscribersCount = 50
- emptyMsg = rpccore.ResultEvent{}
- )
- for i := 0; i < subscribersCount; i++ {
- wg.Add(1)
- // concurrently subscribe to the topic
- go func() {
- defer wg.Done()
- _, _, err := eb.Subscribe(topic)
- require.NoError(t, err)
- }()
-
- // send events to the topic
- wg.Add(1)
- go func() {
- defer wg.Done()
- topicChan <- emptyMsg
- }()
- }
- wg.Wait()
-}
-
-type SuitePubsub struct {
- suite.Suite
-}
-
-func TestSuitePubsub(t *testing.T) {
- suite.Run(t, new(SuitePubsub))
-}
-
-func (s *SuitePubsub) TestAddTopic() {
- q := NewEventBus()
- // dummy vars
- topicA := "guard"
- topicB := "cream"
-
- s.NoError(q.AddTopic(topicA, make(<-chan rpccore.ResultEvent)))
- s.NoError(q.AddTopic(topicB, make(<-chan rpccore.ResultEvent)))
- s.Error(q.AddTopic(topicB, make(<-chan rpccore.ResultEvent)))
-
- topics := q.Topics()
- sort.Strings(topics) // cream should be first
- s.Require().EqualValues([]string{topicB, topicA}, topics)
-}
-
-func (s *SuitePubsub) TestSubscribe() {
- q := NewEventBus()
-
- // dummy vars
- topicA := "0xfoo"
- topicB := "blockchain"
-
- srcA := make(chan rpccore.ResultEvent)
- err := q.AddTopic(topicA, srcA)
- s.NoError(err)
-
- srcB := make(chan rpccore.ResultEvent)
- err = q.AddTopic(topicB, srcB)
- s.NoError(err)
-
- // subscriber channels
- subChanA, _, err := q.Subscribe(topicA)
- s.NoError(err)
- subChanB1, _, err := q.Subscribe(topicB)
- s.NoError(err)
- subChanB2, _, err := q.Subscribe(topicB)
- s.NoError(err)
-
- wg := new(sync.WaitGroup)
- wg.Add(4)
-
- emptyMsg := rpccore.ResultEvent{}
- go func() {
- defer wg.Done()
- msg := <-subChanA
- log.Println(topicA+":", msg)
- s.EqualValues(emptyMsg, msg)
- }()
-
- go func() {
- defer wg.Done()
- msg := <-subChanB1
- log.Println(topicB+":", msg)
- s.EqualValues(emptyMsg, msg)
- }()
-
- go func() {
- defer wg.Done()
- msg := <-subChanB2
- log.Println(topicB+"2:", msg)
- s.EqualValues(emptyMsg, msg)
- }()
-
- go func() {
- defer wg.Done()
-
- time.Sleep(time.Second)
-
- close(srcA)
- close(srcB)
- }()
-
- wg.Wait()
- time.Sleep(time.Second)
-}
-
-// TestConcurrentSubscribeAndPublish: Stress tests the module to make sure that
-// operations are handled properly under concurrent access.
-func (s *SuitePubsub) TestConcurrentSubscribeAndPublish() {
- var (
- wg sync.WaitGroup
- eb = NewEventBus()
- topicName = "topic-name"
- topicCh = make(chan rpccore.ResultEvent)
- runsCount = 5
- )
-
- err := eb.AddTopic(topicName, topicCh)
- s.Require().NoError(err)
-
- for i := 0; i < runsCount; i++ {
- subscribeAndPublish(s.T(), eb, topicName, topicCh)
- }
-
- // close channel to make test end
- wg.Add(1)
- go func() {
- defer wg.Done()
- time.Sleep(2 * time.Second)
- close(topicCh)
- }()
-
- wg.Wait()
-}
diff --git a/eth/rpc/query_client.go b/eth/rpc/query_client.go
deleted file mode 100644
index bc30fd19b..000000000
--- a/eth/rpc/query_client.go
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpc
-
-import (
- "fmt"
-
- "github.com/cosmos/cosmos-sdk/types/tx"
-
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cometbft/cometbft/proto/tendermint/crypto"
-
- "github.com/cosmos/cosmos-sdk/client"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// QueryClient defines a gRPC Client used for:
-// - TM transaction simulation
-// - EVM module queries
-type QueryClient struct {
- tx.ServiceClient
- evm.QueryClient
-}
-
-// NewQueryClient creates a new gRPC query client
-//
-// TODO:🔗 https://github.com/NibiruChain/nibiru/issues/1857
-// test(eth): Test GetProof (rpc/types/query_client.go) in a similar manner to
-// cosmos-sdk/client/rpc/rpc_test.go using a network after EVM is wired into the
-// app keepers:
-func NewQueryClient(clientCtx client.Context) *QueryClient {
- return &QueryClient{
- ServiceClient: tx.NewServiceClient(clientCtx),
- QueryClient: evm.NewQueryClient(clientCtx),
- }
-}
-
-// GetProof performs an ABCI query with the given key and returns a merkle proof. The desired
-// tendermint height to perform the query should be set in the client context. The query will be
-// performed at one below this height (at the IAVL version) in order to obtain the correct merkle
-// proof. Proof queries at height less than or equal to 2 are not supported.
-// Issue: https://github.com/cosmos/cosmos-sdk/issues/6567
-func (QueryClient) GetProof(
- clientCtx client.Context, storeKey string, key []byte,
-) ([]byte, *crypto.ProofOps, error) {
- height := clientCtx.Height
- // ABCI queries at height less than or equal to 2 are not supported.
- // Base app does not support queries for height less than or equal to 1, and
- // the base app uses 0 indexing.
- //
- // Ethereum uses 1 indexing for the initial block height, therefore <= 2 means
- // <= (Eth) height 3.
- if height <= 2 {
- return nil, nil, fmt.Errorf(
- "proof queries at ABCI block height <= 2 are not supported")
- }
-
- abciReq := abci.RequestQuery{
- Path: fmt.Sprintf("store/%s/key", storeKey),
- Data: key,
- Height: height,
- Prove: true,
- }
-
- abciRes, err := clientCtx.QueryABCI(abciReq)
- if err != nil {
- return nil, nil, err
- }
-
- return abciRes.Value, abciRes.ProofOps, nil
-}
diff --git a/eth/rpc/rpc.go b/eth/rpc/rpc.go
deleted file mode 100644
index 88b9f579d..000000000
--- a/eth/rpc/rpc.go
+++ /dev/null
@@ -1,270 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpc
-
-import (
- "context"
- "fmt"
- "math/big"
- "strings"
-
- abci "github.com/cometbft/cometbft/abci/types"
- tmtypes "github.com/cometbft/cometbft/types"
-
- errorsmod "cosmossdk.io/errors"
- tmrpcclient "github.com/cometbft/cometbft/rpc/client"
- "github.com/cosmos/cosmos-sdk/client"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
-
- "github.com/NibiruChain/nibiru/x/evm"
-
- gethcommon "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethmath "github.com/ethereum/go-ethereum/common/math"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- gethparams "github.com/ethereum/go-ethereum/params"
-)
-
-// ErrExceedBlockGasLimit defines the error message when tx execution exceeds the
-// block gas limit. The tx fee is deducted in ante handler, so it shouldn't be
-// ignored in JSON-RPC API.
-const ErrExceedBlockGasLimit = "out of gas in location: block gas meter; gasWanted:"
-
-// ErrStateDBCommit defines the error message when commit after executing EVM
-// transaction, for example transfer native token to a distribution module
-// account using an evm transaction. Note, the transfer amount cannot be set to
-// 0, otherwise this problem will not be triggered.
-const ErrStateDBCommit = "failed to commit stateDB"
-
-// RawTxToEthTx returns a evm MsgEthereum transaction from raw tx bytes.
-func RawTxToEthTx(clientCtx client.Context, txBz tmtypes.Tx) ([]*evm.MsgEthereumTx, error) {
- tx, err := clientCtx.TxConfig.TxDecoder()(txBz)
- if err != nil {
- return nil, errorsmod.Wrap(errortypes.ErrJSONUnmarshal, err.Error())
- }
-
- ethTxs := make([]*evm.MsgEthereumTx, len(tx.GetMsgs()))
- for i, msg := range tx.GetMsgs() {
- ethTx, ok := msg.(*evm.MsgEthereumTx)
- if !ok {
- return nil, fmt.Errorf("invalid message type %T, expected %T", msg, &evm.MsgEthereumTx{})
- }
- ethTx.Hash = ethTx.AsTransaction().Hash().Hex()
- ethTxs[i] = ethTx
- }
- return ethTxs, nil
-}
-
-// EthHeaderFromTendermint: Converts a Tendermint block header to an Eth header.
-func EthHeaderFromTendermint(
- header tmtypes.Header, bloom gethcore.Bloom, baseFee *big.Int,
-) *gethcore.Header {
- txHash := gethcore.EmptyRootHash
- if len(header.DataHash) == 0 {
- txHash = gethcommon.BytesToHash(header.DataHash)
- }
-
- time := uint64(header.Time.UTC().Unix()) // #nosec G701
- return &gethcore.Header{
- ParentHash: gethcommon.BytesToHash(header.LastBlockID.Hash.Bytes()),
- UncleHash: gethcore.EmptyUncleHash,
- Coinbase: gethcommon.BytesToAddress(header.ProposerAddress),
- Root: gethcommon.BytesToHash(header.AppHash),
- TxHash: txHash,
- ReceiptHash: gethcore.EmptyRootHash,
- Bloom: bloom,
- Difficulty: big.NewInt(0),
- Number: big.NewInt(header.Height),
- GasLimit: 0,
- GasUsed: 0,
- Time: time,
- Extra: []byte{},
- MixDigest: gethcommon.Hash{},
- Nonce: gethcore.BlockNonce{},
- BaseFee: baseFee,
- }
-}
-
-// BlockMaxGasFromConsensusParams returns the gas limit for the current block
-// from the chain consensus params.
-func BlockMaxGasFromConsensusParams(
- goCtx context.Context, clientCtx client.Context, blockHeight int64,
-) (int64, error) {
- tmrpcClient, ok := clientCtx.Client.(tmrpcclient.Client)
- if !ok {
- panic("incorrect tm rpc client")
- }
- resConsParams, err := tmrpcClient.ConsensusParams(goCtx, &blockHeight)
- defaultGasLimit := int64(^uint32(0)) // #nosec G701
- if err != nil {
- return defaultGasLimit, err
- }
-
- gasLimit := resConsParams.ConsensusParams.Block.MaxGas
- if gasLimit == -1 {
- // Sets gas limit to max uint32 to not error with javascript dev tooling
- // This -1 value indicating no block gas limit is set to max uint64 with geth hexutils
- // which errors certain javascript dev tooling which only supports up to 53 bits
- gasLimit = defaultGasLimit
- }
-
- return gasLimit, nil
-}
-
-// FormatBlock creates an ethereum block from a tendermint header and ethereum-formatted
-// transactions.
-func FormatBlock(
- header tmtypes.Header, size int, gasLimit int64,
- gasUsed *big.Int, transactions []interface{}, bloom gethcore.Bloom,
- validatorAddr gethcommon.Address, baseFee *big.Int,
-) map[string]interface{} {
- var transactionsRoot gethcommon.Hash
- if len(transactions) == 0 {
- transactionsRoot = gethcore.EmptyRootHash
- } else {
- transactionsRoot = gethcommon.BytesToHash(header.DataHash)
- }
-
- result := map[string]interface{}{
- "number": hexutil.Uint64(header.Height),
- "hash": hexutil.Bytes(header.Hash()),
- "parentHash": gethcommon.BytesToHash(header.LastBlockID.Hash.Bytes()),
- "nonce": gethcore.BlockNonce{}, // PoW specific
- "sha3Uncles": gethcore.EmptyUncleHash, // No uncles in Tendermint
- "logsBloom": bloom,
- "stateRoot": hexutil.Bytes(header.AppHash),
- "miner": validatorAddr,
- "mixHash": gethcommon.Hash{},
- "difficulty": (*hexutil.Big)(big.NewInt(0)),
- "extraData": "0x",
- "size": hexutil.Uint64(size),
- "gasLimit": hexutil.Uint64(gasLimit), // Static gas limit
- "gasUsed": (*hexutil.Big)(gasUsed),
- "timestamp": hexutil.Uint64(header.Time.Unix()),
- "transactionsRoot": transactionsRoot,
- "receiptsRoot": gethcore.EmptyRootHash,
-
- "uncles": []gethcommon.Hash{},
- "transactions": transactions,
- "totalDifficulty": (*hexutil.Big)(big.NewInt(0)),
- }
-
- if baseFee != nil {
- result["baseFeePerGas"] = (*hexutil.Big)(baseFee)
- }
-
- return result
-}
-
-// NewRPCTxFromMsg returns a transaction that will serialize to the RPC
-// representation, with the given location metadata set (if available).
-func NewRPCTxFromMsg(
- msg *evm.MsgEthereumTx,
- blockHash gethcommon.Hash,
- blockNumber, index uint64,
- baseFee *big.Int,
- chainID *big.Int,
-) (*EthTxJsonRPC, error) {
- tx := msg.AsTransaction()
- return NewRPCTxFromEthTx(tx, blockHash, blockNumber, index, baseFee, chainID)
-}
-
-// NewTransactionFromData returns a transaction that will serialize to the RPC
-// representation, with the given location metadata set (if available).
-func NewRPCTxFromEthTx(
- tx *gethcore.Transaction,
- blockHash gethcommon.Hash,
- blockNumber,
- index uint64,
- baseFee *big.Int,
- chainID *big.Int,
-) (*EthTxJsonRPC, error) {
- // Determine the signer. For replay-protected transactions, use the most
- // permissive signer, because we assume that signers are backwards-compatible
- // with old transactions. For non-protected transactions, the homestead
- // signer is used because the return value of ChainId is zero for unprotected
- // transactions.
- var signer gethcore.Signer
- if tx.Protected() {
- signer = gethcore.LatestSignerForChainID(tx.ChainId())
- } else {
- signer = gethcore.HomesteadSigner{}
- }
- from, _ := gethcore.Sender(signer, tx) // #nosec G703
- v, r, s := tx.RawSignatureValues()
- result := &EthTxJsonRPC{
- Type: hexutil.Uint64(tx.Type()),
- From: from,
- Gas: hexutil.Uint64(tx.Gas()),
- GasPrice: (*hexutil.Big)(tx.GasPrice()),
- Hash: tx.Hash(),
- Input: hexutil.Bytes(tx.Data()),
- Nonce: hexutil.Uint64(tx.Nonce()),
- To: tx.To(),
- Value: (*hexutil.Big)(tx.Value()),
- V: (*hexutil.Big)(v),
- R: (*hexutil.Big)(r),
- S: (*hexutil.Big)(s),
- ChainID: (*hexutil.Big)(chainID),
- }
- if blockHash != (gethcommon.Hash{}) {
- result.BlockHash = &blockHash
- result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber))
- result.TransactionIndex = (*hexutil.Uint64)(&index)
- }
- switch tx.Type() {
- case gethcore.AccessListTxType:
- al := tx.AccessList()
- result.Accesses = &al
- result.ChainID = (*hexutil.Big)(tx.ChainId())
- case gethcore.DynamicFeeTxType:
- al := tx.AccessList()
- result.Accesses = &al
- result.ChainID = (*hexutil.Big)(tx.ChainId())
- result.GasFeeCap = (*hexutil.Big)(tx.GasFeeCap())
- result.GasTipCap = (*hexutil.Big)(tx.GasTipCap())
- // if the transaction has been mined, compute the effective gas price
- if baseFee != nil && blockHash != (gethcommon.Hash{}) {
- // price = min(tip, gasFeeCap - baseFee) + baseFee
- price := gethmath.BigMin(new(big.Int).Add(tx.GasTipCap(), baseFee), tx.GasFeeCap())
- result.GasPrice = (*hexutil.Big)(price)
- } else {
- result.GasPrice = (*hexutil.Big)(tx.GasFeeCap())
- }
- }
- return result, nil
-}
-
-// CheckTxFee is an internal function used to check whether the fee of
-// the given transaction is _reasonable_(under the cap).
-func CheckTxFee(gasPrice *big.Int, gas uint64, cap float64) error {
- // Short circuit if there is no cap for transaction fee at all.
- if cap == 0 {
- return nil
- }
- totalfee := new(big.Float).SetInt(new(big.Int).Mul(gasPrice, new(big.Int).SetUint64(gas)))
- oneEther := new(big.Float).SetInt(big.NewInt(gethparams.Ether))
- // quo = rounded(x/y)
- feeEth := new(big.Float).Quo(totalfee, oneEther)
- // no need to check error from parsing
- feeFloat, _ := feeEth.Float64()
- if feeFloat > cap {
- return fmt.Errorf("tx fee (%.2f ether) exceeds the configured cap (%.2f ether)", feeFloat, cap)
- }
- return nil
-}
-
-// TxExceedBlockGasLimit returns true if the tx exceeds block gas limit.
-func TxExceedBlockGasLimit(res *abci.ResponseDeliverTx) bool {
- return strings.Contains(res.Log, ErrExceedBlockGasLimit)
-}
-
-// TxStateDBCommitError returns true if the evm tx commit error.
-func TxStateDBCommitError(res *abci.ResponseDeliverTx) bool {
- return strings.Contains(res.Log, ErrStateDBCommit)
-}
-
-// TxSuccessOrExpectedFailure returns true if the transaction was successful
-// or if it failed with an ExceedBlockGasLimit error or TxStateDBCommitError error
-func TxSuccessOrExpectedFailure(res *abci.ResponseDeliverTx) bool {
- return res.Code == 0 || TxExceedBlockGasLimit(res) || TxStateDBCommitError(res)
-}
diff --git a/eth/rpc/rpc_test.go b/eth/rpc/rpc_test.go
deleted file mode 100644
index 9543400f2..000000000
--- a/eth/rpc/rpc_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpc_test
-
-import (
- "testing"
-
- sdkmath "cosmossdk.io/math"
- cmt "github.com/cometbft/cometbft/types"
- "github.com/cosmos/cosmos-sdk/client"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-type SuiteRPC struct {
- suite.Suite
-}
-
-func TestSuiteRPC(t *testing.T) {
- suite.Run(t, new(SuiteRPC))
-}
-
-func (s *SuiteRPC) TestRawTxToEthTx() {
- type TestCase struct {
- tx cmt.Tx
- clientCtx client.Context
- wantErr string
- }
- type TestCaseSetupFn = func() TestCase
-
- for _, tcSetup := range []TestCaseSetupFn{
- func() TestCase {
- _, _, clientCtx := evmtest.NewEthTxMsgAsCmt(s.T())
- txBz := []byte("tx")
- return TestCase{
- tx: txBz, // invalid bytes
- clientCtx: clientCtx, // valid clientCtx
- wantErr: "failed to unmarshal JSON",
- }
- },
- func() TestCase {
- txBz, _, clientCtx := evmtest.NewEthTxMsgAsCmt(s.T())
- return TestCase{
- tx: txBz, // valid bytes
- clientCtx: clientCtx, // valid clientCtx
- wantErr: "", // happy
- }
- },
- } {
- tc := tcSetup()
- ethTxs, err := rpc.RawTxToEthTx(tc.clientCtx, tc.tx)
- if tc.wantErr != "" {
- s.Require().ErrorContains(err, tc.wantErr, "ethTxs: %s", ethTxs)
- continue
- }
- s.Require().NoError(err, "ethTxs: %s", ethTxs)
- }
-}
-
-func (s *SuiteRPC) TestEthHeaderFromTendermint() {
- for _, block := range []*cmt.Block{
- // Some happy path test cases for good measure
- cmt.MakeBlock(1, []cmt.Tx{}, nil, nil),
- cmt.MakeBlock(420, []cmt.Tx{}, nil, nil),
- } {
- ethHeader := rpc.EthHeaderFromTendermint(
- block.Header, gethcore.Bloom{}, sdkmath.NewInt(1).BigInt())
- s.NotNil(ethHeader)
- s.Equal(block.Header.Height, ethHeader.Number.Int64())
- }
-}
diff --git a/eth/rpc/rpcapi/apis.go b/eth/rpc/rpcapi/apis.go
deleted file mode 100644
index 336674c1e..000000000
--- a/eth/rpc/rpcapi/apis.go
+++ /dev/null
@@ -1,195 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpcapi
-
-import (
- "fmt"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/server"
-
- "github.com/ethereum/go-ethereum/rpc"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/rpc/backend"
- "github.com/NibiruChain/nibiru/eth/rpc/rpcapi/debugapi"
- "github.com/NibiruChain/nibiru/eth/rpc/rpcapi/filtersapi"
-
- rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client"
-)
-
-// RPC namespaces and API version
-const (
- // Cosmos namespaces
- NamespaceCosmos = "cosmos"
-
- // Ethereum namespaces
- NamespaceWeb3 = "web3"
- NamespaceEth = "eth"
- NamespacePersonal = "personal"
- NamespaceNet = "net"
- NamespaceTxPool = "txpool"
- NamespaceDebug = "debug"
- NamespaceMiner = "miner"
-
- apiVersion = "1.0"
-)
-
-func EthereumNamespaces() []string {
- return []string{
- NamespaceWeb3,
- NamespaceEth,
- NamespacePersonal,
- NamespaceNet,
- NamespaceTxPool,
- NamespaceDebug,
- NamespaceMiner,
- }
-}
-
-// APICreator creates the JSON-RPC API implementations.
-type APICreator = func(
- ctx *server.Context,
- clientCtx client.Context,
- tendermintWebsocketClient *rpcclient.WSClient,
- allowUnprotectedTxs bool,
- indexer eth.EVMTxIndexer,
-) []rpc.API
-
-// apiCreators defines the JSON-RPC API namespaces.
-var apiCreators map[string]APICreator
-
-func init() {
- apiCreators = map[string]APICreator{
- NamespaceEth: func(ctx *server.Context,
- clientCtx client.Context,
- tmWSClient *rpcclient.WSClient,
- allowUnprotectedTxs bool,
- indexer eth.EVMTxIndexer,
- ) []rpc.API {
- evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
- return []rpc.API{
- {
- Namespace: NamespaceEth,
- Version: apiVersion,
- Service: NewImplEthAPI(ctx.Logger, evmBackend),
- Public: true,
- },
- {
- Namespace: NamespaceEth,
- Version: apiVersion,
- Service: filtersapi.NewImplFiltersAPI(ctx.Logger, clientCtx, tmWSClient, evmBackend),
- Public: true,
- },
- }
- },
- NamespaceWeb3: func(*server.Context, client.Context, *rpcclient.WSClient, bool, eth.EVMTxIndexer) []rpc.API {
- return []rpc.API{
- {
- Namespace: NamespaceWeb3,
- Version: apiVersion,
- Service: NewImplWeb3API(),
- Public: true,
- },
- }
- },
- NamespaceNet: func(_ *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, _ bool, _ eth.EVMTxIndexer) []rpc.API {
- return []rpc.API{
- {
- Namespace: NamespaceNet,
- Version: apiVersion,
- Service: NewImplNetAPI(clientCtx),
- Public: true,
- },
- }
- },
- NamespacePersonal: func(ctx *server.Context,
- clientCtx client.Context,
- _ *rpcclient.WSClient,
- allowUnprotectedTxs bool,
- indexer eth.EVMTxIndexer,
- ) []rpc.API {
- evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
- return []rpc.API{
- {
- Namespace: NamespacePersonal,
- Version: apiVersion,
- Service: NewImplPersonalAPI(ctx.Logger, evmBackend),
- Public: false,
- },
- }
- },
- NamespaceTxPool: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient, _ bool, _ eth.EVMTxIndexer) []rpc.API {
- return []rpc.API{
- {
- Namespace: NamespaceTxPool,
- Version: apiVersion,
- Service: NewImplTxPoolAPI(ctx.Logger),
- Public: true,
- },
- }
- },
- NamespaceDebug: func(ctx *server.Context,
- clientCtx client.Context,
- _ *rpcclient.WSClient,
- allowUnprotectedTxs bool,
- indexer eth.EVMTxIndexer,
- ) []rpc.API {
- evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
- return []rpc.API{
- {
- Namespace: NamespaceDebug,
- Version: apiVersion,
- Service: debugapi.NewImplDebugAPI(ctx, evmBackend),
- Public: true,
- },
- }
- },
- NamespaceMiner: func(ctx *server.Context,
- clientCtx client.Context,
- _ *rpcclient.WSClient,
- allowUnprotectedTxs bool,
- indexer eth.EVMTxIndexer,
- ) []rpc.API {
- evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer)
- return []rpc.API{
- {
- Namespace: NamespaceMiner,
- Version: apiVersion,
- Service: NewImplMinerAPI(ctx, evmBackend),
- Public: false,
- },
- }
- },
- }
-}
-
-// GetRPCAPIs returns the list of all APIs
-func GetRPCAPIs(ctx *server.Context,
- clientCtx client.Context,
- tmWSClient *rpcclient.WSClient,
- allowUnprotectedTxs bool,
- indexer eth.EVMTxIndexer,
- selectedAPIs []string,
-) []rpc.API {
- var apis []rpc.API
-
- for _, ns := range selectedAPIs {
- if creator, ok := apiCreators[ns]; ok {
- apis = append(apis, creator(ctx, clientCtx, tmWSClient, allowUnprotectedTxs, indexer)...)
- } else {
- ctx.Logger.Error("invalid namespace value", "namespace", ns)
- }
- }
-
- return apis
-}
-
-// RegisterAPINamespace registers a new API namespace with the API creator.
-// This function fails if the namespace is already registered.
-func RegisterAPINamespace(ns string, creator APICreator) error {
- if _, ok := apiCreators[ns]; ok {
- return fmt.Errorf("duplicated api namespace %s", ns)
- }
- apiCreators[ns] = creator
- return nil
-}
diff --git a/eth/rpc/rpcapi/debugapi/api.go b/eth/rpc/rpcapi/debugapi/api.go
deleted file mode 100644
index 7b0bf65d6..000000000
--- a/eth/rpc/rpcapi/debugapi/api.go
+++ /dev/null
@@ -1,338 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package debugapi
-
-import (
- "bytes"
- "errors"
- "fmt"
- "io"
- "os"
- "runtime" // #nosec G702
- "runtime/debug"
- "runtime/pprof"
- "sync"
- "time"
-
- "github.com/davecgh/go-spew/spew"
-
- "github.com/NibiruChain/nibiru/x/evm"
-
- stderrors "github.com/pkg/errors"
-
- "github.com/cosmos/cosmos-sdk/server"
-
- "github.com/cometbft/cometbft/libs/log"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/consensus/ethash"
- "github.com/ethereum/go-ethereum/rlp"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend"
-)
-
-// HandlerT keeps track of the cpu profiler and trace execution
-type HandlerT struct {
- cpuFilename string
- cpuFile io.WriteCloser
- mu sync.Mutex
- traceFilename string
- traceFile io.WriteCloser
-}
-
-// DebugAPI is the collection of tracing APIs exposed over the private debugging
-// endpoint.
-type DebugAPI struct {
- ctx *server.Context
- logger log.Logger
- backend backend.EVMBackend
- handler *HandlerT
-}
-
-// NewImplDebugAPI creates a new API definition for the tracing methods of the
-// Ethereum service.
-func NewImplDebugAPI(
- ctx *server.Context,
- backend backend.EVMBackend,
-) *DebugAPI {
- return &DebugAPI{
- ctx: ctx,
- logger: ctx.Logger.With("module", "debug"),
- backend: backend,
- handler: new(HandlerT),
- }
-}
-
-// TraceTransaction returns the structured logs created during the execution of EVM
-// and returns them as a JSON object.
-func (a *DebugAPI) TraceTransaction(hash common.Hash, config *evm.TraceConfig) (interface{}, error) {
- a.logger.Debug("debug_traceTransaction", "hash", hash)
- return a.backend.TraceTransaction(hash, config)
-}
-
-// TraceBlockByNumber returns the structured logs created during the execution of
-// EVM and returns them as a JSON object.
-func (a *DebugAPI) TraceBlockByNumber(height rpc.BlockNumber, config *evm.TraceConfig) ([]*evm.TxTraceResult, error) {
- a.logger.Debug("debug_traceBlockByNumber", "height", height)
- if height == 0 {
- return nil, errors.New("genesis is not traceable")
- }
- // Get Tendermint Block
- resBlock, err := a.backend.TendermintBlockByNumber(height)
- if err != nil {
- a.logger.Debug("get block failed", "height", height, "error", err.Error())
- return nil, err
- }
-
- return a.backend.TraceBlock(rpc.BlockNumber(resBlock.Block.Height), config, resBlock)
-}
-
-// TraceBlockByHash returns the structured logs created during the execution of
-// EVM and returns them as a JSON object.
-func (a *DebugAPI) TraceBlockByHash(hash common.Hash, config *evm.TraceConfig) ([]*evm.TxTraceResult, error) {
- a.logger.Debug("debug_traceBlockByHash", "hash", hash)
- // Get Tendermint Block
- resBlock, err := a.backend.TendermintBlockByHash(hash)
- if err != nil {
- a.logger.Debug("get block failed", "hash", hash.Hex(), "error", err.Error())
- return nil, err
- }
-
- if resBlock == nil || resBlock.Block == nil {
- a.logger.Debug("block not found", "hash", hash.Hex())
- return nil, errors.New("block not found")
- }
-
- return a.backend.TraceBlock(rpc.BlockNumber(resBlock.Block.Height), config, resBlock)
-}
-
-// BlockProfile turns on goroutine profiling for nsec seconds and writes profile data to
-// file. It uses a profile rate of 1 for most accurate information. If a different rate is
-// desired, set the rate and write the profile manually.
-func (a *DebugAPI) BlockProfile(file string, nsec uint) error {
- a.logger.Debug("debug_blockProfile", "file", file, "nsec", nsec)
- runtime.SetBlockProfileRate(1)
- defer runtime.SetBlockProfileRate(0)
-
- time.Sleep(time.Duration(nsec) * time.Second)
- return writeProfile("block", file, a.logger)
-}
-
-// CpuProfile turns on CPU profiling for nsec seconds and writes
-// profile data to file.
-func (a *DebugAPI) CpuProfile(file string, nsec uint) error { //nolint: golint, stylecheck, revive
- a.logger.Debug("debug_cpuProfile", "file", file, "nsec", nsec)
- if err := a.StartCPUProfile(file); err != nil {
- return err
- }
- time.Sleep(time.Duration(nsec) * time.Second)
- return a.StopCPUProfile()
-}
-
-// GcStats returns GC statistics.
-func (a *DebugAPI) GcStats() *debug.GCStats {
- a.logger.Debug("debug_gcStats")
- s := new(debug.GCStats)
- debug.ReadGCStats(s)
- return s
-}
-
-// GoTrace turns on tracing for nsec seconds and writes
-// trace data to file.
-func (a *DebugAPI) GoTrace(file string, nsec uint) error {
- a.logger.Debug("debug_goTrace", "file", file, "nsec", nsec)
- if err := a.StartGoTrace(file); err != nil {
- return err
- }
- time.Sleep(time.Duration(nsec) * time.Second)
- return a.StopGoTrace()
-}
-
-// MemStats returns detailed runtime memory statistics.
-func (a *DebugAPI) MemStats() *runtime.MemStats {
- a.logger.Debug("debug_memStats")
- s := new(runtime.MemStats)
- runtime.ReadMemStats(s)
- return s
-}
-
-// SetBlockProfileRate sets the rate of goroutine block profile data collection.
-// rate 0 disables block profiling.
-func (a *DebugAPI) SetBlockProfileRate(rate int) {
- a.logger.Debug("debug_setBlockProfileRate", "rate", rate)
- runtime.SetBlockProfileRate(rate)
-}
-
-// Stacks returns a printed representation of the stacks of all goroutines.
-func (a *DebugAPI) Stacks() string {
- a.logger.Debug("debug_stacks")
- buf := new(bytes.Buffer)
- err := pprof.Lookup("goroutine").WriteTo(buf, 2)
- if err != nil {
- a.logger.Error("Failed to create stacks", "error", err.Error())
- }
- return buf.String()
-}
-
-// StartCPUProfile turns on CPU profiling, writing to the given file.
-func (a *DebugAPI) StartCPUProfile(file string) error {
- a.logger.Debug("debug_startCPUProfile", "file", file)
- a.handler.mu.Lock()
- defer a.handler.mu.Unlock()
-
- switch {
- case isCPUProfileConfigurationActivated(a.ctx):
- a.logger.Debug("CPU profiling already in progress using the configuration file")
- return errors.New("CPU profiling already in progress using the configuration file")
- case a.handler.cpuFile != nil:
- a.logger.Debug("CPU profiling already in progress")
- return errors.New("CPU profiling already in progress")
- default:
- fp, err := ExpandHome(file)
- if err != nil {
- a.logger.Debug("failed to get filepath for the CPU profile file", "error", err.Error())
- return err
- }
- f, err := os.Create(fp)
- if err != nil {
- a.logger.Debug("failed to create CPU profile file", "error", err.Error())
- return err
- }
- if err := pprof.StartCPUProfile(f); err != nil {
- a.logger.Debug("cpu profiling already in use", "error", err.Error())
- if err := f.Close(); err != nil {
- a.logger.Debug("failed to close cpu profile file")
- return stderrors.Wrap(err, "failed to close cpu profile file")
- }
- return err
- }
-
- a.logger.Info("CPU profiling started", "profile", file)
- a.handler.cpuFile = f
- a.handler.cpuFilename = file
- return nil
- }
-}
-
-// StopCPUProfile stops an ongoing CPU profile.
-func (a *DebugAPI) StopCPUProfile() error {
- a.logger.Debug("debug_stopCPUProfile")
- a.handler.mu.Lock()
- defer a.handler.mu.Unlock()
-
- switch {
- case isCPUProfileConfigurationActivated(a.ctx):
- a.logger.Debug("CPU profiling already in progress using the configuration file")
- return errors.New("CPU profiling already in progress using the configuration file")
- case a.handler.cpuFile != nil:
- a.logger.Info("Done writing CPU profile", "profile", a.handler.cpuFilename)
- pprof.StopCPUProfile()
- if err := a.handler.cpuFile.Close(); err != nil {
- a.logger.Debug("failed to close cpu file")
- return stderrors.Wrap(err, "failed to close cpu file")
- }
- a.handler.cpuFile = nil
- a.handler.cpuFilename = ""
- return nil
- default:
- a.logger.Debug("CPU profiling not in progress")
- return errors.New("CPU profiling not in progress")
- }
-}
-
-// WriteBlockProfile writes a goroutine blocking profile to the given file.
-func (a *DebugAPI) WriteBlockProfile(file string) error {
- a.logger.Debug("debug_writeBlockProfile", "file", file)
- return writeProfile("block", file, a.logger)
-}
-
-// WriteMemProfile writes an allocation profile to the given file.
-// Note that the profiling rate cannot be set through the API,
-// it must be set on the command line.
-func (a *DebugAPI) WriteMemProfile(file string) error {
- a.logger.Debug("debug_writeMemProfile", "file", file)
- return writeProfile("heap", file, a.logger)
-}
-
-// MutexProfile turns on mutex profiling for nsec seconds and writes profile data to file.
-// It uses a profile rate of 1 for most accurate information. If a different rate is
-// desired, set the rate and write the profile manually.
-func (a *DebugAPI) MutexProfile(file string, nsec uint) error {
- a.logger.Debug("debug_mutexProfile", "file", file, "nsec", nsec)
- runtime.SetMutexProfileFraction(1)
- time.Sleep(time.Duration(nsec) * time.Second)
- defer runtime.SetMutexProfileFraction(0)
- return writeProfile("mutex", file, a.logger)
-}
-
-// SetMutexProfileFraction sets the rate of mutex profiling.
-func (a *DebugAPI) SetMutexProfileFraction(rate int) {
- a.logger.Debug("debug_setMutexProfileFraction", "rate", rate)
- runtime.SetMutexProfileFraction(rate)
-}
-
-// WriteMutexProfile writes a goroutine blocking profile to the given file.
-func (a *DebugAPI) WriteMutexProfile(file string) error {
- a.logger.Debug("debug_writeMutexProfile", "file", file)
- return writeProfile("mutex", file, a.logger)
-}
-
-// FreeOSMemory forces a garbage collection.
-func (a *DebugAPI) FreeOSMemory() {
- a.logger.Debug("debug_freeOSMemory")
- debug.FreeOSMemory()
-}
-
-// SetGCPercent sets the garbage collection target percentage. It returns the previous
-// setting. A negative value disables GC.
-func (a *DebugAPI) SetGCPercent(v int) int {
- a.logger.Debug("debug_setGCPercent", "percent", v)
- return debug.SetGCPercent(v)
-}
-
-// GetHeaderRlp retrieves the RLP encoded for of a single header.
-func (a *DebugAPI) GetHeaderRlp(number uint64) (hexutil.Bytes, error) {
- header, err := a.backend.HeaderByNumber(rpc.BlockNumber(number))
- if err != nil {
- return nil, err
- }
-
- return rlp.EncodeToBytes(header)
-}
-
-// GetBlockRlp retrieves the RLP encoded for of a single block.
-func (a *DebugAPI) GetBlockRlp(number uint64) (hexutil.Bytes, error) {
- block, err := a.backend.EthBlockByNumber(rpc.BlockNumber(number))
- if err != nil {
- return nil, err
- }
-
- return rlp.EncodeToBytes(block)
-}
-
-// PrintBlock retrieves a block and returns its pretty printed form.
-func (a *DebugAPI) PrintBlock(number uint64) (string, error) {
- block, err := a.backend.EthBlockByNumber(rpc.BlockNumber(number))
- if err != nil {
- return "", err
- }
-
- return spew.Sdump(block), nil
-}
-
-// SeedHash retrieves the seed hash of a block.
-func (a *DebugAPI) SeedHash(number uint64) (string, error) {
- _, err := a.backend.HeaderByNumber(rpc.BlockNumber(number))
- if err != nil {
- return "", err
- }
-
- return fmt.Sprintf("0x%x", ethash.SeedHash(number)), nil
-}
-
-// IntermediateRoots executes a block, and returns a list
-// of intermediate roots: the stateroot after each transaction.
-func (a *DebugAPI) IntermediateRoots(hash common.Hash, _ *evm.TraceConfig) ([]common.Hash, error) {
- a.logger.Debug("debug_intermediateRoots", "hash", hash)
- return ([]common.Hash)(nil), nil
-}
diff --git a/eth/rpc/rpcapi/debugapi/trace.go b/eth/rpc/rpcapi/debugapi/trace.go
deleted file mode 100644
index 8dce68952..000000000
--- a/eth/rpc/rpcapi/debugapi/trace.go
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see .
-
-//go:build go1.5
-// +build go1.5
-
-package debugapi
-
-import (
- "errors"
- "os"
- "runtime/trace"
-
- stderrors "github.com/pkg/errors"
-)
-
-// StartGoTrace turns on tracing, writing to the given file.
-func (a *DebugAPI) StartGoTrace(file string) error {
- a.logger.Debug("debug_startGoTrace", "file", file)
- a.handler.mu.Lock()
- defer a.handler.mu.Unlock()
-
- if a.handler.traceFile != nil {
- a.logger.Debug("trace already in progress")
- return errors.New("trace already in progress")
- }
- fp, err := ExpandHome(file)
- if err != nil {
- a.logger.Debug("failed to get filepath for the CPU profile file", "error", err.Error())
- return err
- }
- f, err := os.Create(fp)
- if err != nil {
- a.logger.Debug("failed to create go trace file", "error", err.Error())
- return err
- }
- if err := trace.Start(f); err != nil {
- a.logger.Debug("Go tracing already started", "error", err.Error())
- if err := f.Close(); err != nil {
- a.logger.Debug("failed to close trace file")
- return stderrors.Wrap(err, "failed to close trace file")
- }
-
- return err
- }
- a.handler.traceFile = f
- a.handler.traceFilename = file
- a.logger.Info("Go tracing started", "dump", a.handler.traceFilename)
- return nil
-}
-
-// StopGoTrace stops an ongoing trace.
-func (a *DebugAPI) StopGoTrace() error {
- a.logger.Debug("debug_stopGoTrace")
- a.handler.mu.Lock()
- defer a.handler.mu.Unlock()
-
- trace.Stop()
- if a.handler.traceFile == nil {
- a.logger.Debug("trace not in progress")
- return errors.New("trace not in progress")
- }
- a.logger.Info("Done writing Go trace", "dump", a.handler.traceFilename)
- if err := a.handler.traceFile.Close(); err != nil {
- a.logger.Debug("failed to close trace file")
- return stderrors.Wrap(err, "failed to close trace file")
- }
- a.handler.traceFile = nil
- a.handler.traceFilename = ""
- return nil
-}
diff --git a/eth/rpc/rpcapi/debugapi/trace_fallback.go b/eth/rpc/rpcapi/debugapi/trace_fallback.go
deleted file mode 100644
index 8f4c6caa2..000000000
--- a/eth/rpc/rpcapi/debugapi/trace_fallback.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see .
-
-//go:build !go1.5
-// +build !go1.5
-
-// no-op implementation of tracing methods for Go < 1.5.
-
-package debug
-
-import (
- "errors"
-)
-
-func (*API) StartGoTrace(string file) error {
- a.logger.Debug("debug_stopGoTrace", "file", file)
- return errors.New("tracing is not supported on Go < 1.5")
-}
-
-func (*API) StopGoTrace() error {
- a.logger.Debug("debug_stopGoTrace")
- return errors.New("tracing is not supported on Go < 1.5")
-}
diff --git a/eth/rpc/rpcapi/debugapi/utils.go b/eth/rpc/rpcapi/debugapi/utils.go
deleted file mode 100644
index 95fbad86e..000000000
--- a/eth/rpc/rpcapi/debugapi/utils.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package debugapi
-
-import (
- "os"
- "os/user"
- "path/filepath"
- "runtime/pprof"
- "strings"
-
- "github.com/cometbft/cometbft/libs/log"
- "github.com/cosmos/cosmos-sdk/server"
-)
-
-// isCPUProfileConfigurationActivated: Checks if the "cpu-profile" flag was set
-func isCPUProfileConfigurationActivated(ctx *server.Context) bool {
- // TODO: use same constants as server/start.go
- // constant declared in start.go cannot be imported (cyclical dependency)
- const flagCPUProfile = "cpu-profile"
- if cpuProfile := ctx.Viper.GetString(flagCPUProfile); cpuProfile != "" {
- return true
- }
- return false
-}
-
-// ExpandHome expands home directory in file paths.
-// ~someuser/tmp will not be expanded.
-func ExpandHome(p string) (string, error) {
- if strings.HasPrefix(p, "~/") || strings.HasPrefix(p, "~\\") {
- usr, err := user.Current()
- if err != nil {
- return p, err
- }
- home := usr.HomeDir
- p = home + p[1:]
- }
- return filepath.Clean(p), nil
-}
-
-// writeProfile writes the data to a file
-func writeProfile(name, file string, log log.Logger) error {
- p := pprof.Lookup(name)
- log.Info("Writing profile records", "count", p.Count(), "type", name, "dump", file)
- fp, err := ExpandHome(file)
- if err != nil {
- return err
- }
- f, err := os.Create(fp)
- if err != nil {
- return err
- }
-
- if err := p.WriteTo(f, 0); err != nil {
- if err := f.Close(); err != nil {
- return err
- }
- return err
- }
-
- return f.Close()
-}
diff --git a/eth/rpc/rpcapi/eth_api.go b/eth/rpc/rpcapi/eth_api.go
deleted file mode 100644
index 1283e47b6..000000000
--- a/eth/rpc/rpcapi/eth_api.go
+++ /dev/null
@@ -1,585 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpcapi
-
-import (
- "context"
-
- "github.com/ethereum/go-ethereum/signer/core/apitypes"
-
- gethrpc "github.com/ethereum/go-ethereum/rpc"
-
- "github.com/cometbft/cometbft/libs/log"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/eth/rpc/backend"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// Ethereum API: Allows connection to a full node of the Nibiru blockchain
-// network via Nibiru EVM. Developers can interact with on-chain EVM data and
-// send different types of transactions to the network by utilizing the endpoints
-// provided by the API. The API follows a JSON-RPC standard. If not otherwise
-// specified, the interface is derived from the Alchemy Ethereum API:
-// https://docs.alchemy.com/alchemy/apis/ethereum
-type IEthAPI interface {
- // Getting Blocks
- //
- // Retrieves information from a particular block in the blockchain.
- BlockNumber() (hexutil.Uint64, error)
- GetBlockByNumber(ethBlockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
- GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
- GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint
- GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) *hexutil.Uint
-
- // Reading Transactions
- //
- // Retrieves information on the state data for addresses regardless of whether
- // it is a user or a smart contract.
- GetTransactionByHash(hash common.Hash) (*rpc.EthTxJsonRPC, error)
- GetTransactionCount(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)
- GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error)
- GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error)
- GetTransactionByBlockNumberAndIndex(blockNum rpc.BlockNumber, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error)
- // eth_getBlockReceipts
-
- // Writing Transactions
- //
- // Allows developers to both send ETH from one address to another, write data
- // on-chain, and interact with smart contracts.
- SendRawTransaction(data hexutil.Bytes) (common.Hash, error)
- SendTransaction(args evm.JsonTxArgs) (common.Hash, error)
- // eth_sendPrivateTransaction
- // eth_cancel PrivateTransaction
-
- // Account Information
- //
- // Returns information regarding an address's stored on-chain data.
- Accounts() ([]common.Address, error)
- GetBalance(
- address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
- ) (*hexutil.Big, error)
- GetStorageAt(
- address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash,
- ) (hexutil.Bytes, error)
- GetCode(
- address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
- ) (hexutil.Bytes, error)
- GetProof(
- address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash,
- ) (*rpc.AccountResult, error)
-
- // EVM/Smart Contract Execution
- //
- // Allows developers to read data from the blockchain which includes executing
- // smart contracts. However, no data is published to the Ethereum network.
- Call(
- args evm.JsonTxArgs, blockNrOrHash rpc.BlockNumberOrHash, _ *rpc.StateOverride,
- ) (hexutil.Bytes, error)
-
- // Chain Information
- //
- // Returns information on the Ethereum network and internal settings.
- ProtocolVersion() hexutil.Uint
- GasPrice() (*hexutil.Big, error)
- EstimateGas(
- args evm.JsonTxArgs, blockNrOptional *rpc.BlockNumber,
- ) (hexutil.Uint64, error)
- FeeHistory(
- blockCount gethrpc.DecimalOrHex, lastBlock gethrpc.BlockNumber, rewardPercentiles []float64,
- ) (*rpc.FeeHistoryResult, error)
- MaxPriorityFeePerGas() (*hexutil.Big, error)
- ChainId() (*hexutil.Big, error)
-
- // Getting Uncles
- //
- // Returns information on uncle blocks are which are network rejected blocks
- // and replaced by a canonical block instead.
- GetUncleByBlockHashAndIndex(
- hash common.Hash, idx hexutil.Uint,
- ) map[string]interface{}
- GetUncleByBlockNumberAndIndex(
- number, idx hexutil.Uint,
- ) map[string]interface{}
- GetUncleCountByBlockHash(hash common.Hash) hexutil.Uint
- GetUncleCountByBlockNumber(blockNum rpc.BlockNumber) hexutil.Uint
-
- // Proof of Work
- Hashrate() hexutil.Uint64
- Mining() bool
-
- // Other
- Syncing() (interface{}, error)
- Coinbase() (string, error)
- Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
- GetTransactionLogs(txHash common.Hash) ([]*gethcore.Log, error)
- SignTypedData(
- address common.Address, typedData apitypes.TypedData,
- ) (hexutil.Bytes, error)
- FillTransaction(
- args evm.JsonTxArgs,
- ) (*rpc.SignTransactionResult, error)
- Resend(
- ctx context.Context, args evm.JsonTxArgs,
- gasPrice *hexutil.Big, gasLimit *hexutil.Uint64,
- ) (common.Hash, error)
- GetPendingTransactions() ([]*rpc.EthTxJsonRPC, error)
- // eth_signTransaction (on Ethereum.org)
- // eth_getCompilers (on Ethereum.org)
- // eth_compileSolidity (on Ethereum.org)
- // eth_compileLLL (on Ethereum.org)
- // eth_compileSerpent (on Ethereum.org)
- // eth_getWork (on Ethereum.org)
- // eth_submitWork (on Ethereum.org)
- // eth_submitHashrate (on Ethereum.org)
-}
-
-var _ IEthAPI = (*EthAPI)(nil)
-
-// EthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.
-type EthAPI struct {
- ctx context.Context
- logger log.Logger
- backend backend.EVMBackend
-}
-
-// NewImplEthAPI creates an instance of the public ETH Web3 API.
-func NewImplEthAPI(logger log.Logger, backend backend.EVMBackend) *EthAPI {
- api := &EthAPI{
- ctx: context.Background(),
- logger: logger.With("client", "json-rpc"),
- backend: backend,
- }
-
- return api
-}
-
-// --------------------------------------------------------------------------
-// Blocks
-// --------------------------------------------------------------------------
-
-// BlockNumber returns the current block number.
-func (e *EthAPI) BlockNumber() (hexutil.Uint64, error) {
- e.logger.Debug("eth_blockNumber")
- return e.backend.BlockNumber()
-}
-
-// GetBlockByNumber returns the block identified by number.
-func (e *EthAPI) GetBlockByNumber(ethBlockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) {
- e.logger.Debug("eth_getBlockByNumber", "number", ethBlockNum, "full", fullTx)
- return e.backend.GetBlockByNumber(ethBlockNum, fullTx)
-}
-
-// GetBlockByHash returns the block identified by hash.
-func (e *EthAPI) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error) {
- e.logger.Debug("eth_getBlockByHash", "hash", hash.Hex(), "full", fullTx)
- return e.backend.GetBlockByHash(hash, fullTx)
-}
-
-// --------------------------------------------------------------------------
-// Read Txs
-// --------------------------------------------------------------------------
-
-// GetTransactionByHash returns the transaction identified by hash.
-func (e *EthAPI) GetTransactionByHash(hash common.Hash) (*rpc.EthTxJsonRPC, error) {
- e.logger.Debug("eth_getTransactionByHash", "hash", hash.Hex())
- return e.backend.GetTransactionByHash(hash)
-}
-
-// GetTransactionCount returns the number of transactions at the given address up to the given block number.
-func (e *EthAPI) GetTransactionCount(
- address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
-) (*hexutil.Uint64, error) {
- e.logger.Debug("eth_getTransactionCount", "address", address.Hex(), "block number or hash", blockNrOrHash)
- blockNum, err := e.backend.BlockNumberFromTendermint(blockNrOrHash)
- if err != nil {
- return nil, err
- }
- return e.backend.GetTransactionCount(address, blockNum)
-}
-
-// GetTransactionReceipt returns the transaction receipt identified by hash.
-func (e *EthAPI) GetTransactionReceipt(
- hash common.Hash,
-) (map[string]interface{}, error) {
- hexTx := hash.Hex()
- e.logger.Debug("eth_getTransactionReceipt", "hash", hexTx)
- return e.backend.GetTransactionReceipt(hash)
-}
-
-// GetBlockTransactionCountByHash returns the number of transactions in the block identified by hash.
-func (e *EthAPI) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint {
- e.logger.Debug("eth_getBlockTransactionCountByHash", "hash", hash.Hex())
- return e.backend.GetBlockTransactionCountByHash(hash)
-}
-
-// GetBlockTransactionCountByNumber returns the number of transactions in the block identified by number.
-func (e *EthAPI) GetBlockTransactionCountByNumber(
- blockNum rpc.BlockNumber,
-) *hexutil.Uint {
- e.logger.Debug("eth_getBlockTransactionCountByNumber", "height", blockNum.Int64())
- return e.backend.GetBlockTransactionCountByNumber(blockNum)
-}
-
-// GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.
-func (e *EthAPI) GetTransactionByBlockHashAndIndex(
- hash common.Hash, idx hexutil.Uint,
-) (*rpc.EthTxJsonRPC, error) {
- e.logger.Debug("eth_getTransactionByBlockHashAndIndex", "hash", hash.Hex(), "index", idx)
- return e.backend.GetTransactionByBlockHashAndIndex(hash, idx)
-}
-
-// GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.
-func (e *EthAPI) GetTransactionByBlockNumberAndIndex(
- blockNum rpc.BlockNumber, idx hexutil.Uint,
-) (*rpc.EthTxJsonRPC, error) {
- e.logger.Debug("eth_getTransactionByBlockNumberAndIndex", "number", blockNum, "index", idx)
- return e.backend.GetTransactionByBlockNumberAndIndex(blockNum, idx)
-}
-
-// --------------------------------------------------------------------------
-// Write Txs
-// --------------------------------------------------------------------------
-
-// SendRawTransaction send a raw Ethereum transaction.
-func (e *EthAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) {
- e.logger.Debug("eth_sendRawTransaction", "length", len(data))
- return e.backend.SendRawTransaction(data)
-}
-
-// SendTransaction sends an Ethereum transaction.
-func (e *EthAPI) SendTransaction(
- txArgs evm.JsonTxArgs,
-) (common.Hash, error) {
- e.logger.Debug("eth_sendTransaction", "args", txArgs.String())
- return e.backend.SendTransaction(txArgs)
-}
-
-// --------------------------------------------------------------------------
-// Account Information
-// --------------------------------------------------------------------------
-
-// Accounts returns the list of accounts available to this node.
-func (e *EthAPI) Accounts() ([]common.Address, error) {
- e.logger.Debug("eth_accounts")
- return e.backend.Accounts()
-}
-
-// GetBalance returns the provided account's balance up to the provided block number.
-func (e *EthAPI) GetBalance(
- address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
-) (*hexutil.Big, error) {
- e.logger.Debug("eth_getBalance", "address", address.String(), "block number or hash", blockNrOrHash)
- return e.backend.GetBalance(address, blockNrOrHash)
-}
-
-// GetStorageAt returns the contract storage at the given address, block number, and key.
-func (e *EthAPI) GetStorageAt(
- address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash,
-) (hexutil.Bytes, error) {
- e.logger.Debug("eth_getStorageAt", "address", address.Hex(), "key", key, "block number or hash", blockNrOrHash)
- return e.backend.GetStorageAt(address, key, blockNrOrHash)
-}
-
-// GetCode returns the contract code at the given address and block number.
-func (e *EthAPI) GetCode(
- address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
-) (hexutil.Bytes, error) {
- e.logger.Debug("eth_getCode", "address", address.Hex(), "block number or hash", blockNrOrHash)
- return e.backend.GetCode(address, blockNrOrHash)
-}
-
-// GetProof returns an account object with proof and any storage proofs
-func (e *EthAPI) GetProof(address common.Address,
- storageKeys []string,
- blockNrOrHash rpc.BlockNumberOrHash,
-) (*rpc.AccountResult, error) {
- e.logger.Debug("eth_getProof", "address", address.Hex(), "keys", storageKeys, "block number or hash", blockNrOrHash)
- return e.backend.GetProof(address, storageKeys, blockNrOrHash)
-}
-
-// --------------------------------------------------------------------------
-// EVM/Smart Contract Execution
-// --------------------------------------------------------------------------
-
-// Call performs a raw contract call.
-func (e *EthAPI) Call(args evm.JsonTxArgs,
- blockNrOrHash rpc.BlockNumberOrHash,
- _ *rpc.StateOverride,
-) (hexutil.Bytes, error) {
- e.logger.Debug("eth_call", "args", args.String(), "block number or hash", blockNrOrHash)
-
- blockNum, err := e.backend.BlockNumberFromTendermint(blockNrOrHash)
- if err != nil {
- return nil, err
- }
- data, err := e.backend.DoCall(args, blockNum)
- if err != nil {
- return []byte{}, err
- }
-
- return (hexutil.Bytes)(data.Ret), nil
-}
-
-// --------------------------------------------------------------------------
-// Event Logs
-// --------------------------------------------------------------------------
-// FILTER API at ./filters/api.go
-
-// --------------------------------------------------------------------------
-// Chain Information
-// --------------------------------------------------------------------------
-
-// ProtocolVersion returns the supported Ethereum protocol version.
-func (e *EthAPI) ProtocolVersion() hexutil.Uint {
- e.logger.Debug("eth_protocolVersion")
- return hexutil.Uint(eth.ProtocolVersion)
-}
-
-// GasPrice returns the current gas price based on Ethermint's gas price oracle.
-func (e *EthAPI) GasPrice() (*hexutil.Big, error) {
- e.logger.Debug("eth_gasPrice")
- return e.backend.GasPrice()
-}
-
-// EstimateGas returns an estimate of gas usage for the given smart contract call.
-func (e *EthAPI) EstimateGas(
- args evm.JsonTxArgs, blockNrOptional *rpc.BlockNumber,
-) (hexutil.Uint64, error) {
- e.logger.Debug("eth_estimateGas")
- return e.backend.EstimateGas(args, blockNrOptional)
-}
-
-func (e *EthAPI) FeeHistory(blockCount gethrpc.DecimalOrHex,
- lastBlock gethrpc.BlockNumber,
- rewardPercentiles []float64,
-) (*rpc.FeeHistoryResult, error) {
- e.logger.Debug("eth_feeHistory")
- return e.backend.FeeHistory(blockCount, lastBlock, rewardPercentiles)
-}
-
-// MaxPriorityFeePerGas returns a suggestion for a gas tip cap for dynamic fee
-// transactions.
-func (e *EthAPI) MaxPriorityFeePerGas() (*hexutil.Big, error) {
- e.logger.Debug("eth_maxPriorityFeePerGas")
- head, err := e.backend.CurrentHeader()
- if err != nil {
- return nil, err
- }
- tipcap, err := e.backend.SuggestGasTipCap(head.BaseFee)
- if err != nil {
- return nil, err
- }
- return (*hexutil.Big)(tipcap), nil
-}
-
-// ChainId is the EIP-155 replay-protection chain id for the current ethereum
-// chain config.
-func (e *EthAPI) ChainId() (*hexutil.Big, error) { //nolint
- e.logger.Debug("eth_chainId")
- return e.backend.ChainID()
-}
-
-// --------------------------------------------------------------------------
-// Uncles
-// --------------------------------------------------------------------------
-
-// GetUncleByBlockHashAndIndex returns the uncle identified by hash and index.
-// Always returns nil.
-func (e *EthAPI) GetUncleByBlockHashAndIndex(
- _ common.Hash, _ hexutil.Uint,
-) map[string]interface{} {
- return nil
-}
-
-// GetUncleByBlockNumberAndIndex returns the uncle identified by number and
-// index. Always returns nil.
-func (e *EthAPI) GetUncleByBlockNumberAndIndex(
- _, _ hexutil.Uint,
-) map[string]interface{} {
- return nil
-}
-
-// GetUncleCountByBlockHash returns the number of uncles in the block identified
-// by hash. Always zero.
-func (e *EthAPI) GetUncleCountByBlockHash(_ common.Hash) hexutil.Uint {
- return 0
-}
-
-// GetUncleCountByBlockNumber returns the number of uncles in the block
-// identified by number. Always zero.
-func (e *EthAPI) GetUncleCountByBlockNumber(_ rpc.BlockNumber) hexutil.Uint {
- return 0
-}
-
-// --------------------------------------------------------------------------
-// Proof of Work
-// --------------------------------------------------------------------------
-
-// Hashrate returns the current node's hashrate. Always 0.
-func (e *EthAPI) Hashrate() hexutil.Uint64 {
- e.logger.Debug("eth_hashrate")
- return 0
-}
-
-// Mining returns whether or not this node is currently mining. Always false.
-func (e *EthAPI) Mining() bool {
- e.logger.Debug("eth_mining")
- return false
-}
-
-// --------------------------------------------------------------------------
-// Other
-// --------------------------------------------------------------------------
-
-// Syncing returns false in case the node is currently not syncing with the
-// network. It can be up to date or has not yet received the latest block headers
-// from its pears. In case it is synchronizing:
-//
-// - startingBlock: block number this node started to synchronize from
-// - currentBlock: block number this node is currently importing
-// - highestBlock: block number of the highest block header this node has received from peers
-// - pulledStates: number of state entries processed until now
-// - knownStates: number of known state entries that still need to be pulled
-func (e *EthAPI) Syncing() (interface{}, error) {
- e.logger.Debug("eth_syncing")
- return e.backend.Syncing()
-}
-
-// Coinbase is the address that staking rewards will be send to (alias for Etherbase).
-func (e *EthAPI) Coinbase() (string, error) {
- e.logger.Debug("eth_coinbase")
-
- coinbase, err := e.backend.GetCoinbase()
- if err != nil {
- return "", err
- }
- ethAddr := common.BytesToAddress(coinbase.Bytes())
- return ethAddr.Hex(), nil
-}
-
-// Sign signs the provided data using the private key of address via Geth's signature standard.
-func (e *EthAPI) Sign(
- address common.Address, data hexutil.Bytes,
-) (hexutil.Bytes, error) {
- e.logger.Debug("eth_sign", "address", address.Hex(), "data", common.Bytes2Hex(data))
- return e.backend.Sign(address, data)
-}
-
-// GetTransactionLogs returns the logs given a transaction hash.
-func (e *EthAPI) GetTransactionLogs(txHash common.Hash) ([]*gethcore.Log, error) {
- e.logger.Debug("eth_getTransactionLogs", "hash", txHash)
-
- hexTx := txHash.Hex()
- res, err := e.backend.GetTxByEthHash(txHash)
- if err != nil {
- e.logger.Debug("tx not found", "hash", hexTx, "error", err.Error())
- return nil, nil
- }
-
- if res.Failed {
- // failed, return empty logs
- return nil, nil
- }
-
- resBlockResult, err := e.backend.TendermintBlockResultByNumber(&res.Height)
- if err != nil {
- e.logger.Debug("block result not found", "number", res.Height, "error", err.Error())
- return nil, nil
- }
-
- // parse tx logs from events
- index := int(res.MsgIndex) // #nosec G701
- return backend.TxLogsFromEvents(resBlockResult.TxsResults[res.TxIndex].Events, index)
-}
-
-// SignTypedData signs EIP-712 conformant typed data
-func (e *EthAPI) SignTypedData(
- address common.Address, typedData apitypes.TypedData,
-) (hexutil.Bytes, error) {
- e.logger.Debug(
- "eth_signTypedData", "address", address.Hex(), "data", typedData,
- )
- return e.backend.SignTypedData(address, typedData)
-}
-
-// FillTransaction fills the defaults (nonce, gas, gasPrice or 1559 fields)
-// on a given unsigned transaction, and returns it to the caller for further
-// processing (signing + broadcast).
-func (e *EthAPI) FillTransaction(
- args evm.JsonTxArgs,
-) (*rpc.SignTransactionResult, error) {
- // Set some sanity defaults and terminate on failure
- args, err := e.backend.SetTxDefaults(args)
- if err != nil {
- return nil, err
- }
-
- // Assemble the transaction and obtain rlp
- tx := args.ToTransaction().AsTransaction()
-
- data, err := tx.MarshalBinary()
- if err != nil {
- return nil, err
- }
-
- return &rpc.SignTransactionResult{
- Raw: data,
- Tx: tx,
- }, nil
-}
-
-// Resend accepts an existing transaction and a new gas price and limit. It will
-// remove the given transaction from the pool and reinsert it with the new gas
-// price and limit.
-func (e *EthAPI) Resend(_ context.Context,
- args evm.JsonTxArgs,
- gasPrice *hexutil.Big,
- gasLimit *hexutil.Uint64,
-) (common.Hash, error) {
- e.logger.Debug("eth_resend", "args", args.String())
- return e.backend.Resend(args, gasPrice, gasLimit)
-}
-
-// GetPendingTransactions returns the transactions that are in the transaction
-// pool and have a from address that is one of the accounts this node manages.
-func (e *EthAPI) GetPendingTransactions() ([]*rpc.EthTxJsonRPC, error) {
- e.logger.Debug("eth_getPendingTransactions")
-
- txs, err := e.backend.PendingTransactions()
- if err != nil {
- return nil, err
- }
-
- result := make([]*rpc.EthTxJsonRPC, 0, len(txs))
- for _, tx := range txs {
- for _, msg := range (*tx).GetMsgs() {
- ethMsg, ok := msg.(*evm.MsgEthereumTx)
- if !ok {
- // not valid ethereum tx
- break
- }
-
- rpctx, err := rpc.NewRPCTxFromMsg(
- ethMsg,
- common.Hash{},
- uint64(0),
- uint64(0),
- nil,
- e.backend.ChainConfig().ChainID,
- )
- if err != nil {
- return nil, err
- }
-
- result = append(result, rpctx)
- }
- }
-
- return result, nil
-}
diff --git a/eth/rpc/rpcapi/filtersapi/api.go b/eth/rpc/rpcapi/filtersapi/api.go
deleted file mode 100644
index bb9f5ea69..000000000
--- a/eth/rpc/rpcapi/filtersapi/api.go
+++ /dev/null
@@ -1,646 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package filtersapi
-
-import (
- "context"
- "fmt"
- "math/big"
- "sync"
- "time"
-
- "github.com/cosmos/cosmos-sdk/client"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
-
- "github.com/cometbft/cometbft/libs/log"
-
- coretypes "github.com/cometbft/cometbft/rpc/core/types"
- rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client"
- tmtypes "github.com/cometbft/cometbft/types"
-
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/eth/filters"
- gethrpc "github.com/ethereum/go-ethereum/rpc"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// IFilterAPI
-type IFilterAPI interface {
- NewPendingTransactionFilter() gethrpc.ID
- NewBlockFilter() gethrpc.ID
- NewFilter(criteria filters.FilterCriteria) (gethrpc.ID, error)
- GetFilterChanges(id gethrpc.ID) (interface{}, error)
- GetFilterLogs(ctx context.Context, id gethrpc.ID) ([]*gethcore.Log, error)
- UninstallFilter(id gethrpc.ID) bool
- GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*gethcore.Log, error)
-}
-
-// IFilterEthBackend defines the methods requided by the PublicFilterAPI backend
-type IFilterEthBackend interface {
- GetBlockByNumber(blockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
- HeaderByNumber(blockNum rpc.BlockNumber) (*gethcore.Header, error)
- HeaderByHash(blockHash common.Hash) (*gethcore.Header, error)
- TendermintBlockByHash(hash common.Hash) (*coretypes.ResultBlock, error)
- TendermintBlockResultByNumber(height *int64) (*coretypes.ResultBlockResults, error)
- GetLogs(blockHash common.Hash) ([][]*gethcore.Log, error)
- GetLogsByHeight(*int64) ([][]*gethcore.Log, error)
- BlockBloom(blockRes *coretypes.ResultBlockResults) (gethcore.Bloom, error)
-
- BloomStatus() (uint64, uint64)
-
- RPCFilterCap() int32
- RPCLogsCap() int32
- RPCBlockRangeCap() int32
-}
-
-// consider a filter inactive if it has not been polled for within deadlineForInactivity
-func deadlineForInactivity() time.Duration { return 5 * time.Minute }
-
-// filter is a helper struct that holds meta information over the filter type and
-// associated subscription in the event system.
-type filter struct {
- typ filters.Type
- deadline *time.Timer // filter is inactive when deadline triggers
- hashes []common.Hash
- crit filters.FilterCriteria
- logs []*gethcore.Log
- s *Subscription // associated subscription in event system
-}
-
-// FiltersAPI offers support to create and manage filters. This will allow
-// external clients to retrieve various information related to the Ethereum
-// protocol such as blocks, transactions and logs.
-type FiltersAPI struct {
- logger log.Logger
- clientCtx client.Context
- backend IFilterEthBackend
- events *EventSystem
- filtersMu sync.Mutex
- filters map[gethrpc.ID]*filter
-}
-
-// NewImplFiltersAPI returns a new PublicFilterAPI instance.
-func NewImplFiltersAPI(logger log.Logger, clientCtx client.Context, tmWSClient *rpcclient.WSClient, backend IFilterEthBackend) *FiltersAPI {
- logger = logger.With("api", "filter")
- api := &FiltersAPI{
- logger: logger,
- clientCtx: clientCtx,
- backend: backend,
- filters: make(map[gethrpc.ID]*filter),
- events: NewEventSystem(logger, tmWSClient),
- }
-
- go api.timeoutLoop()
-
- return api
-}
-
-// timeoutLoop runs every 5 minutes and deletes filters that have not been recently used.
-// Tt is started when the api is created.
-func (api *FiltersAPI) timeoutLoop() {
- ticker := time.NewTicker(deadlineForInactivity())
- defer ticker.Stop()
-
- for {
- <-ticker.C
- api.filtersMu.Lock()
- // #nosec G705
- for id, f := range api.filters {
- select {
- case <-f.deadline.C:
- f.s.Unsubscribe(api.events)
- delete(api.filters, id)
- default:
- continue
- }
- }
- api.filtersMu.Unlock()
- }
-}
-
-// NewPendingTransactionFilter creates a filter that fetches pending transaction
-// hashes as transactions enter the pending state.
-//
-// It is part of the filter package because this filter can be used through the
-// `eth_getFilterChanges` polling method that is also used for log filters.
-//
-// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newPendingTransactionFilter
-func (api *FiltersAPI) NewPendingTransactionFilter() gethrpc.ID {
- api.filtersMu.Lock()
- defer api.filtersMu.Unlock()
-
- if len(api.filters) >= int(api.backend.RPCFilterCap()) {
- return gethrpc.ID("error creating pending tx filter: max limit reached")
- }
-
- pendingTxSub, cancelSubs, err := api.events.SubscribePendingTxs()
- if err != nil {
- // wrap error on the ID
- return gethrpc.ID(fmt.Sprintf("error creating pending tx filter: %s", err.Error()))
- }
-
- api.filters[pendingTxSub.ID()] = &filter{
- typ: filters.PendingTransactionsSubscription,
- deadline: time.NewTimer(deadlineForInactivity()),
- hashes: make([]common.Hash, 0),
- s: pendingTxSub,
- }
-
- go func(txsCh <-chan coretypes.ResultEvent, errCh <-chan error) {
- defer cancelSubs()
-
- for {
- select {
- case ev, ok := <-txsCh:
- if !ok {
- api.filtersMu.Lock()
- delete(api.filters, pendingTxSub.ID())
- api.filtersMu.Unlock()
- return
- }
-
- data, ok := ev.Data.(tmtypes.EventDataTx)
- if !ok {
- api.logger.Debug("event data type mismatch", "type", fmt.Sprintf("%T", ev.Data))
- continue
- }
-
- tx, err := api.clientCtx.TxConfig.TxDecoder()(data.Tx)
- if err != nil {
- api.logger.Debug("fail to decode tx", "error", err.Error())
- continue
- }
-
- api.filtersMu.Lock()
- if f, found := api.filters[pendingTxSub.ID()]; found {
- for _, msg := range tx.GetMsgs() {
- ethTx, ok := msg.(*evm.MsgEthereumTx)
- if ok {
- f.hashes = append(f.hashes, ethTx.AsTransaction().Hash())
- }
- }
- }
- api.filtersMu.Unlock()
- case <-errCh:
- api.filtersMu.Lock()
- delete(api.filters, pendingTxSub.ID())
- api.filtersMu.Unlock()
- }
- }
- }(pendingTxSub.eventCh, pendingTxSub.Err())
-
- return pendingTxSub.ID()
-}
-
-// NewPendingTransactions creates a subscription that is triggered each time a
-// transaction enters the transaction pool and was signed from one of the
-// transactions this nodes manages.
-func (api *FiltersAPI) NewPendingTransactions(ctx context.Context) (*gethrpc.Subscription, error) {
- notifier, supported := gethrpc.NotifierFromContext(ctx)
- if !supported {
- return &gethrpc.Subscription{}, gethrpc.ErrNotificationsUnsupported
- }
-
- rpcSub := notifier.CreateSubscription()
-
- ctx, cancelFn := context.WithTimeout(context.Background(), deadlineForInactivity())
- defer cancelFn()
-
- api.events.WithContext(ctx)
-
- pendingTxSub, cancelSubs, err := api.events.SubscribePendingTxs()
- if err != nil {
- return nil, err
- }
-
- go func(txsCh <-chan coretypes.ResultEvent) {
- defer cancelSubs()
-
- for {
- select {
- case ev, ok := <-txsCh:
- if !ok {
- api.filtersMu.Lock()
- delete(api.filters, pendingTxSub.ID())
- api.filtersMu.Unlock()
- return
- }
-
- data, ok := ev.Data.(tmtypes.EventDataTx)
- if !ok {
- api.logger.Debug("event data type mismatch", "type", fmt.Sprintf("%T", ev.Data))
- continue
- }
-
- tx, err := api.clientCtx.TxConfig.TxDecoder()(data.Tx)
- if err != nil {
- api.logger.Debug("fail to decode tx", "error", err.Error())
- continue
- }
-
- for _, msg := range tx.GetMsgs() {
- ethTx, ok := msg.(*evm.MsgEthereumTx)
- if ok {
- _ = notifier.Notify(rpcSub.ID, ethTx.AsTransaction().Hash()) // #nosec G703
- }
- }
- case <-rpcSub.Err():
- pendingTxSub.Unsubscribe(api.events)
- return
- case <-notifier.Closed():
- pendingTxSub.Unsubscribe(api.events)
- return
- }
- }
- }(pendingTxSub.eventCh)
-
- return rpcSub, err
-}
-
-// NewBlockFilter creates a filter that fetches blocks that are imported into the
-// chain. It is part of the filter package since polling goes with
-// eth_getFilterChanges.
-//
-// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newblockfilter
-func (api *FiltersAPI) NewBlockFilter() gethrpc.ID {
- api.filtersMu.Lock()
- defer api.filtersMu.Unlock()
-
- if len(api.filters) >= int(api.backend.RPCFilterCap()) {
- return gethrpc.ID("error creating block filter: max limit reached")
- }
-
- headerSub, cancelSubs, err := api.events.SubscribeNewHeads()
- if err != nil {
- // wrap error on the ID
- return gethrpc.ID(fmt.Sprintf("error creating block filter: %s", err.Error()))
- }
-
- api.filters[headerSub.ID()] = &filter{typ: filters.BlocksSubscription, deadline: time.NewTimer(deadlineForInactivity()), hashes: []common.Hash{}, s: headerSub}
-
- go func(headersCh <-chan coretypes.ResultEvent, errCh <-chan error) {
- defer cancelSubs()
-
- for {
- select {
- case ev, ok := <-headersCh:
- if !ok {
- api.filtersMu.Lock()
- delete(api.filters, headerSub.ID())
- api.filtersMu.Unlock()
- return
- }
-
- data, ok := ev.Data.(tmtypes.EventDataNewBlockHeader)
- if !ok {
- api.logger.Debug("event data type mismatch", "type", fmt.Sprintf("%T", ev.Data))
- continue
- }
-
- api.filtersMu.Lock()
- if f, found := api.filters[headerSub.ID()]; found {
- f.hashes = append(f.hashes, common.BytesToHash(data.Header.Hash()))
- }
- api.filtersMu.Unlock()
- case <-errCh:
- api.filtersMu.Lock()
- delete(api.filters, headerSub.ID())
- api.filtersMu.Unlock()
- return
- }
- }
- }(headerSub.eventCh, headerSub.Err())
-
- return headerSub.ID()
-}
-
-// NewHeads send a notification each time a new (header) block is appended to the
-// chain.
-func (api *FiltersAPI) NewHeads(ctx context.Context) (*gethrpc.Subscription, error) {
- notifier, supported := gethrpc.NotifierFromContext(ctx)
- if !supported {
- return &gethrpc.Subscription{}, gethrpc.ErrNotificationsUnsupported
- }
-
- api.events.WithContext(ctx)
- rpcSub := notifier.CreateSubscription()
-
- headersSub, cancelSubs, err := api.events.SubscribeNewHeads()
- if err != nil {
- return &gethrpc.Subscription{}, err
- }
-
- go func(headersCh <-chan coretypes.ResultEvent) {
- defer cancelSubs()
-
- for {
- select {
- case ev, ok := <-headersCh:
- if !ok {
- headersSub.Unsubscribe(api.events)
- return
- }
-
- data, ok := ev.Data.(tmtypes.EventDataNewBlockHeader)
- if !ok {
- api.logger.Debug("event data type mismatch", "type", fmt.Sprintf("%T", ev.Data))
- continue
- }
-
- var baseFee *big.Int = nil
- // TODO: fetch bloom from events
- header := rpc.EthHeaderFromTendermint(data.Header, gethcore.Bloom{}, baseFee)
- _ = notifier.Notify(rpcSub.ID, header) // #nosec G703
- case <-rpcSub.Err():
- headersSub.Unsubscribe(api.events)
- return
- case <-notifier.Closed():
- headersSub.Unsubscribe(api.events)
- return
- }
- }
- }(headersSub.eventCh)
-
- return rpcSub, err
-}
-
-// Logs creates a subscription that fires for all new log that match the given
-// filter criteria.
-func (api *FiltersAPI) Logs(ctx context.Context, crit filters.FilterCriteria) (*gethrpc.Subscription, error) {
- notifier, supported := gethrpc.NotifierFromContext(ctx)
- if !supported {
- return &gethrpc.Subscription{}, gethrpc.ErrNotificationsUnsupported
- }
-
- api.events.WithContext(ctx)
- rpcSub := notifier.CreateSubscription()
-
- logsSub, cancelSubs, err := api.events.SubscribeLogs(crit)
- if err != nil {
- return &gethrpc.Subscription{}, err
- }
-
- go func(logsCh <-chan coretypes.ResultEvent) {
- defer cancelSubs()
-
- for {
- select {
- case ev, ok := <-logsCh:
- if !ok {
- logsSub.Unsubscribe(api.events)
- return
- }
-
- // filter only events from EVM module txs
- _, isMsgEthereumTx := ev.Events[evm.TypeMsgEthereumTx]
-
- if !isMsgEthereumTx {
- // ignore transaction as it's not from the evm module
- return
- }
-
- // get transaction result data
- dataTx, ok := ev.Data.(tmtypes.EventDataTx)
- if !ok {
- api.logger.Debug("event data type mismatch", "type", fmt.Sprintf("%T", ev.Data))
- continue
- }
-
- txResponse, err := evm.DecodeTxResponse(dataTx.TxResult.Result.Data)
- if err != nil {
- api.logger.Error("fail to decode tx response", "error", err)
- return
- }
-
- logs := FilterLogs(evm.LogsToEthereum(txResponse.Logs), crit.FromBlock, crit.ToBlock, crit.Addresses, crit.Topics)
-
- for _, log := range logs {
- _ = notifier.Notify(rpcSub.ID, log) // #nosec G703
- }
- case <-rpcSub.Err(): // client send an unsubscribe request
- logsSub.Unsubscribe(api.events)
- return
- case <-notifier.Closed(): // connection dropped
- logsSub.Unsubscribe(api.events)
- return
- }
- }
- }(logsSub.eventCh)
-
- return rpcSub, err
-}
-
-// NewFilter creates a new filter and returns the filter id. It can be
-// used to retrieve logs when the state changes. This method cannot be
-// used to fetch logs that are already stored in the state.
-//
-// Default criteria for the from and to block are "latest".
-// Using "latest" as block number will return logs for mined blocks.
-// Using "pending" as block number returns logs for not yet mined (pending) blocks.
-// In case logs are removed (chain reorg) previously returned logs are returned
-// again but with the removed property set to true.
-//
-// In case "fromBlock" > "toBlock" an error is returned.
-//
-// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter
-func (api *FiltersAPI) NewFilter(criteria filters.FilterCriteria) (gethrpc.ID, error) {
- api.filtersMu.Lock()
- defer api.filtersMu.Unlock()
-
- if len(api.filters) >= int(api.backend.RPCFilterCap()) {
- return gethrpc.ID(""), fmt.Errorf("error creating filter: max limit reached")
- }
-
- var (
- filterID = gethrpc.ID("")
- err error
- )
-
- logsSub, cancelSubs, err := api.events.SubscribeLogs(criteria)
- if err != nil {
- return gethrpc.ID(""), err
- }
-
- filterID = logsSub.ID()
-
- api.filters[filterID] = &filter{
- typ: filters.LogsSubscription,
- crit: criteria,
- deadline: time.NewTimer(deadlineForInactivity()),
- hashes: []common.Hash{},
- s: logsSub,
- }
-
- go func(eventCh <-chan coretypes.ResultEvent) {
- defer cancelSubs()
-
- for {
- select {
- case ev, ok := <-eventCh:
- if !ok {
- api.filtersMu.Lock()
- delete(api.filters, filterID)
- api.filtersMu.Unlock()
- return
- }
- dataTx, ok := ev.Data.(tmtypes.EventDataTx)
- if !ok {
- api.logger.Debug("event data type mismatch", "type", fmt.Sprintf("%T", ev.Data))
- continue
- }
-
- txResponse, err := evm.DecodeTxResponse(dataTx.TxResult.Result.Data)
- if err != nil {
- api.logger.Error("fail to decode tx response", "error", err)
- return
- }
-
- logs := FilterLogs(evm.LogsToEthereum(txResponse.Logs), criteria.FromBlock, criteria.ToBlock, criteria.Addresses, criteria.Topics)
-
- api.filtersMu.Lock()
- if f, found := api.filters[filterID]; found {
- f.logs = append(f.logs, logs...)
- }
- api.filtersMu.Unlock()
- case <-logsSub.Err():
- api.filtersMu.Lock()
- delete(api.filters, filterID)
- api.filtersMu.Unlock()
- return
- }
- }
- }(logsSub.eventCh)
-
- return filterID, err
-}
-
-// GetLogs returns logs matching the given argument that are stored within the state.
-//
-// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs
-func (api *FiltersAPI) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*gethcore.Log, error) {
- var filter *Filter
- if crit.BlockHash != nil {
- // Block filter requested, construct a single-shot filter
- filter = NewBlockFilter(api.logger, api.backend, crit)
- } else {
- // Convert the RPC block numbers into internal representations
- begin := gethrpc.LatestBlockNumber.Int64()
- if crit.FromBlock != nil {
- begin = crit.FromBlock.Int64()
- }
- end := gethrpc.LatestBlockNumber.Int64()
- if crit.ToBlock != nil {
- end = crit.ToBlock.Int64()
- }
- // Construct the range filter
- filter = NewRangeFilter(api.logger, api.backend, begin, end, crit.Addresses, crit.Topics)
- }
-
- // Run the filter and return all the logs
- logs, err := filter.Logs(ctx, int(api.backend.RPCLogsCap()), int64(api.backend.RPCBlockRangeCap()))
- if err != nil {
- return nil, err
- }
-
- return returnLogs(logs), err
-}
-
-// UninstallFilter removes the filter with the given filter id.
-//
-// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter
-func (api *FiltersAPI) UninstallFilter(id gethrpc.ID) bool {
- api.filtersMu.Lock()
- f, found := api.filters[id]
- if found {
- delete(api.filters, id)
- }
- api.filtersMu.Unlock()
-
- if !found {
- return false
- }
- f.s.Unsubscribe(api.events)
- return true
-}
-
-// GetFilterLogs returns the logs for the filter with the given id.
-// If the filter could not be found an empty array of logs is returned.
-//
-// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs
-func (api *FiltersAPI) GetFilterLogs(ctx context.Context, id gethrpc.ID) ([]*gethcore.Log, error) {
- api.filtersMu.Lock()
- f, found := api.filters[id]
- api.filtersMu.Unlock()
-
- if !found {
- return returnLogs(nil), fmt.Errorf("filter %s not found", id)
- }
-
- if f.typ != filters.LogsSubscription {
- return returnLogs(nil), fmt.Errorf("filter %s doesn't have a LogsSubscription type: got %d", id, f.typ)
- }
-
- var filter *Filter
- if f.crit.BlockHash != nil {
- // Block filter requested, construct a single-shot filter
- filter = NewBlockFilter(api.logger, api.backend, f.crit)
- } else {
- // Convert the RPC block numbers into internal representations
- begin := gethrpc.LatestBlockNumber.Int64()
- if f.crit.FromBlock != nil {
- begin = f.crit.FromBlock.Int64()
- }
- end := gethrpc.LatestBlockNumber.Int64()
- if f.crit.ToBlock != nil {
- end = f.crit.ToBlock.Int64()
- }
- // Construct the range filter
- filter = NewRangeFilter(api.logger, api.backend, begin, end, f.crit.Addresses, f.crit.Topics)
- }
- // Run the filter and return all the logs
- logs, err := filter.Logs(ctx, int(api.backend.RPCLogsCap()), int64(api.backend.RPCBlockRangeCap()))
- if err != nil {
- return nil, err
- }
- return returnLogs(logs), nil
-}
-
-// GetFilterChanges returns the logs for the filter with the given id since
-// last time it was called. This can be used for polling.
-//
-// For pending transaction and block filters the result is []common.Hash.
-// (pending)Log filters return []Log.
-//
-// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges
-func (api *FiltersAPI) GetFilterChanges(id gethrpc.ID) (interface{}, error) {
- api.filtersMu.Lock()
- defer api.filtersMu.Unlock()
-
- f, found := api.filters[id]
- if !found {
- return nil, fmt.Errorf("filter %s not found", id)
- }
-
- if !f.deadline.Stop() {
- // timer expired but filter is not yet removed in timeout loop
- // receive timer value and reset timer
- <-f.deadline.C
- }
- f.deadline.Reset(deadlineForInactivity())
-
- switch f.typ {
- case filters.PendingTransactionsSubscription, filters.BlocksSubscription:
- hashes := f.hashes
- f.hashes = nil
- return returnHashes(hashes), nil
- case filters.LogsSubscription, filters.MinedAndPendingLogsSubscription:
- logs := make([]*gethcore.Log, len(f.logs))
- copy(logs, f.logs)
- f.logs = []*gethcore.Log{}
- return returnLogs(logs), nil
- default:
- return nil, fmt.Errorf("invalid filter %s type %d", id, f.typ)
- }
-}
diff --git a/eth/rpc/rpcapi/filtersapi/filter_system.go b/eth/rpc/rpcapi/filtersapi/filter_system.go
deleted file mode 100644
index 5d91c0963..000000000
--- a/eth/rpc/rpcapi/filtersapi/filter_system.go
+++ /dev/null
@@ -1,311 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package filtersapi
-
-import (
- "context"
- "fmt"
- "sync"
- "time"
-
- "github.com/pkg/errors"
-
- tmjson "github.com/cometbft/cometbft/libs/json"
- "github.com/cometbft/cometbft/libs/log"
- tmquery "github.com/cometbft/cometbft/libs/pubsub/query"
- coretypes "github.com/cometbft/cometbft/rpc/core/types"
- rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client"
- tmtypes "github.com/cometbft/cometbft/types"
-
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/eth/filters"
- gethrpc "github.com/ethereum/go-ethereum/rpc"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/eth/rpc/pubsub"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-var (
- txEvents = tmtypes.QueryForEvent(tmtypes.EventTx).String()
- evmEvents = tmquery.MustParse(fmt.Sprintf("%s='%s' AND %s.%s='%s'",
- tmtypes.EventTypeKey,
- tmtypes.EventTx,
- sdk.EventTypeMessage,
- sdk.AttributeKeyModule, evm.ModuleName)).String()
- headerEvents = tmtypes.QueryForEvent(tmtypes.EventNewBlockHeader).String()
-)
-
-// EventSystem creates subscriptions, processes events and broadcasts them to the
-// subscription which match the subscription criteria using the Tendermint's RPC client.
-type EventSystem struct {
- logger log.Logger
- ctx context.Context
- tmWSClient *rpcclient.WSClient
-
- // light client mode
- lightMode bool
-
- index filterIndex
- topicChans map[string]chan<- coretypes.ResultEvent
- indexMux *sync.RWMutex
-
- // Channels
- install chan *Subscription // install filter for event notification
- uninstall chan *Subscription // remove filter for event notification
- eventBus pubsub.EventBus
-}
-
-// NewEventSystem creates a new manager that listens for event on the given mux,
-// parses and filters them. It uses the all map to retrieve filter changes. The
-// work loop holds its own index that is used to forward events to filters.
-//
-// The returned manager has a loop that needs to be stopped with the Stop function
-// or by stopping the given mux.
-func NewEventSystem(logger log.Logger, tmWSClient *rpcclient.WSClient) *EventSystem {
- index := make(filterIndex)
- for i := filters.UnknownSubscription; i < filters.LastIndexSubscription; i++ {
- index[i] = make(map[gethrpc.ID]*Subscription)
- }
-
- es := &EventSystem{
- logger: logger,
- ctx: context.Background(),
- tmWSClient: tmWSClient,
- lightMode: false,
- index: index,
- topicChans: make(map[string]chan<- coretypes.ResultEvent, len(index)),
- indexMux: new(sync.RWMutex),
- install: make(chan *Subscription),
- uninstall: make(chan *Subscription),
- eventBus: pubsub.NewEventBus(),
- }
-
- go es.eventLoop()
- go es.consumeEvents()
- return es
-}
-
-// WithContext sets a new context to the EventSystem. This is required to set a timeout context when
-// a new filter is intantiated.
-func (es *EventSystem) WithContext(ctx context.Context) {
- es.ctx = ctx
-}
-
-// subscribe performs a new event subscription to a given Tendermint event.
-// The subscription creates a unidirectional receive event channel to receive the ResultEvent.
-func (es *EventSystem) subscribe(sub *Subscription) (*Subscription, pubsub.UnsubscribeFunc, error) {
- var (
- err error
- cancelFn context.CancelFunc
- )
-
- ctx, cancelFn := context.WithCancel(context.Background())
- defer cancelFn()
-
- existingSubs := es.eventBus.Topics()
- for _, topic := range existingSubs {
- if topic == sub.event {
- eventCh, unsubFn, err := es.eventBus.Subscribe(sub.event)
- if err != nil {
- err := errors.Wrapf(err, "failed to subscribe to topic: %s", sub.event)
- return nil, nil, err
- }
-
- sub.eventCh = eventCh
- return sub, unsubFn, nil
- }
- }
-
- switch sub.typ {
- case filters.LogsSubscription:
- err = es.tmWSClient.Subscribe(ctx, sub.event)
- case filters.BlocksSubscription:
- err = es.tmWSClient.Subscribe(ctx, sub.event)
- case filters.PendingTransactionsSubscription:
- err = es.tmWSClient.Subscribe(ctx, sub.event)
- default:
- err = fmt.Errorf("invalid filter subscription type %d", sub.typ)
- }
-
- if err != nil {
- sub.err <- err
- return nil, nil, err
- }
-
- // wrap events in a go routine to prevent blocking
- es.install <- sub
- <-sub.installed
-
- eventCh, unsubFn, err := es.eventBus.Subscribe(sub.event)
- if err != nil {
- return nil, nil, errors.Wrapf(err, "failed to subscribe to topic after installed: %s", sub.event)
- }
-
- sub.eventCh = eventCh
- return sub, unsubFn, nil
-}
-
-// SubscribeLogs creates a subscription that will write all logs matching the
-// given criteria to the given logs channel. Default value for the from and to
-// block is "latest". If the fromBlock > toBlock an error is returned.
-func (es *EventSystem) SubscribeLogs(crit filters.FilterCriteria) (*Subscription, pubsub.UnsubscribeFunc, error) {
- var from, to gethrpc.BlockNumber
- if crit.FromBlock == nil {
- from = gethrpc.LatestBlockNumber
- } else {
- from = gethrpc.BlockNumber(crit.FromBlock.Int64())
- }
- if crit.ToBlock == nil {
- to = gethrpc.LatestBlockNumber
- } else {
- to = gethrpc.BlockNumber(crit.ToBlock.Int64())
- }
-
- switch {
- // only interested in new mined logs, mined logs within a specific block range, or
- // logs from a specific block number to new mined blocks
- case (from == gethrpc.LatestBlockNumber && to == gethrpc.LatestBlockNumber),
- (from >= 0 && to >= 0 && to >= from),
- (from >= 0 && to == gethrpc.LatestBlockNumber):
- return es.subscribeLogs(crit)
-
- default:
- return nil, nil, fmt.Errorf("invalid from and to block combination: from > to (%d > %d)", from, to)
- }
-}
-
-// subscribeLogs creates a subscription that will write all logs matching the
-// given criteria to the given logs channel.
-func (es *EventSystem) subscribeLogs(crit filters.FilterCriteria) (*Subscription, pubsub.UnsubscribeFunc, error) {
- sub := &Subscription{
- id: gethrpc.NewID(),
- typ: filters.LogsSubscription,
- event: evmEvents,
- logsCrit: crit,
- created: time.Now().UTC(),
- logs: make(chan []*gethcore.Log),
- installed: make(chan struct{}, 1),
- err: make(chan error, 1),
- }
- return es.subscribe(sub)
-}
-
-// SubscribeNewHeads subscribes to new block headers events.
-func (es EventSystem) SubscribeNewHeads() (*Subscription, pubsub.UnsubscribeFunc, error) {
- sub := &Subscription{
- id: gethrpc.NewID(),
- typ: filters.BlocksSubscription,
- event: headerEvents,
- created: time.Now().UTC(),
- headers: make(chan *gethcore.Header),
- installed: make(chan struct{}, 1),
- err: make(chan error, 1),
- }
- return es.subscribe(sub)
-}
-
-// SubscribePendingTxs subscribes to new pending transactions events from the mempool.
-func (es EventSystem) SubscribePendingTxs() (*Subscription, pubsub.UnsubscribeFunc, error) {
- sub := &Subscription{
- id: gethrpc.NewID(),
- typ: filters.PendingTransactionsSubscription,
- event: txEvents,
- created: time.Now().UTC(),
- hashes: make(chan []common.Hash),
- installed: make(chan struct{}, 1),
- err: make(chan error, 1),
- }
- return es.subscribe(sub)
-}
-
-type filterIndex map[filters.Type]map[gethrpc.ID]*Subscription
-
-// eventLoop (un)installs filters and processes mux events.
-func (es *EventSystem) eventLoop() {
- for {
- select {
- case f := <-es.install:
- es.indexMux.Lock()
- es.index[f.typ][f.id] = f
- ch := make(chan coretypes.ResultEvent)
- if err := es.eventBus.AddTopic(f.event, ch); err != nil {
- es.logger.Error("failed to add event topic to event bus", "topic", f.event, "error", err.Error())
- } else {
- es.topicChans[f.event] = ch
- }
- es.indexMux.Unlock()
- close(f.installed)
- case f := <-es.uninstall:
- es.indexMux.Lock()
- delete(es.index[f.typ], f.id)
-
- var channelInUse bool
- // #nosec G705
- for _, sub := range es.index[f.typ] {
- if sub.event == f.event {
- channelInUse = true
- break
- }
- }
-
- // remove topic only when channel is not used by other subscriptions
- if !channelInUse {
- if err := es.tmWSClient.Unsubscribe(es.ctx, f.event); err != nil {
- es.logger.Error("failed to unsubscribe from query", "query", f.event, "error", err.Error())
- }
-
- ch, ok := es.topicChans[f.event]
- if ok {
- es.eventBus.RemoveTopic(f.event)
- close(ch)
- delete(es.topicChans, f.event)
- }
- }
-
- es.indexMux.Unlock()
- close(f.err)
- }
- }
-}
-
-func (es *EventSystem) consumeEvents() {
- for {
- for rpcResp := range es.tmWSClient.ResponsesCh {
- var ev coretypes.ResultEvent
-
- if rpcResp.Error != nil {
- time.Sleep(5 * time.Second)
- continue
- } else if err := tmjson.Unmarshal(rpcResp.Result, &ev); err != nil {
- es.logger.Error("failed to JSON unmarshal ResponsesCh result event", "error", err.Error())
- continue
- }
-
- if len(ev.Query) == 0 {
- // skip empty responses
- continue
- }
-
- es.indexMux.RLock()
- ch, ok := es.topicChans[ev.Query]
- es.indexMux.RUnlock()
- if !ok {
- es.logger.Debug("channel for subscription not found", "topic", ev.Query)
- es.logger.Debug("list of available channels", "channels", es.eventBus.Topics())
- continue
- }
-
- // gracefully handle lagging subscribers
- t := time.NewTimer(time.Second)
- select {
- case <-t.C:
- es.logger.Debug("dropped event during lagging subscription", "topic", ev.Query)
- case ch <- ev:
- }
- }
-
- time.Sleep(time.Second)
- }
-}
diff --git a/eth/rpc/rpcapi/filtersapi/filter_system_test.go b/eth/rpc/rpcapi/filtersapi/filter_system_test.go
deleted file mode 100644
index d55b2c188..000000000
--- a/eth/rpc/rpcapi/filtersapi/filter_system_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package filtersapi
-
-import (
- "context"
- "os"
- "sync"
- "testing"
- "time"
-
- "github.com/cometbft/cometbft/libs/log"
- coretypes "github.com/cometbft/cometbft/rpc/core/types"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/eth/filters"
- "github.com/ethereum/go-ethereum/rpc"
-
- "github.com/NibiruChain/nibiru/eth/rpc/pubsub"
-)
-
-func makeSubscription(id, event string) *Subscription {
- return &Subscription{
- id: rpc.ID(id),
- typ: filters.LogsSubscription,
- event: event,
- created: time.Now(),
- logs: make(chan []*gethcore.Log),
- hashes: make(chan []common.Hash),
- headers: make(chan *gethcore.Header),
- installed: make(chan struct{}),
- eventCh: make(chan coretypes.ResultEvent),
- err: make(chan error),
- }
-}
-
-func TestFilterSystem(t *testing.T) {
- index := make(filterIndex)
- for i := filters.UnknownSubscription; i < filters.LastIndexSubscription; i++ {
- index[i] = make(map[rpc.ID]*Subscription)
- }
- es := &EventSystem{
- logger: log.NewTMLogger(log.NewSyncWriter(os.Stdout)),
- ctx: context.Background(),
- lightMode: false,
- index: index,
- topicChans: make(map[string]chan<- coretypes.ResultEvent, len(index)),
- indexMux: new(sync.RWMutex),
- install: make(chan *Subscription),
- uninstall: make(chan *Subscription),
- eventBus: pubsub.NewEventBus(),
- }
- go es.eventLoop()
-
- event := "event"
- sub := makeSubscription("1", event)
- es.install <- sub
- <-sub.installed
- ch, ok := es.topicChans[sub.event]
- if !ok {
- t.Error("expect topic channel exist")
- }
-
- sub = makeSubscription("2", event)
- es.install <- sub
- <-sub.installed
- newCh, ok := es.topicChans[sub.event]
- if !ok {
- t.Error("expect topic channel exist")
- }
-
- if newCh != ch {
- t.Error("expect topic channel unchanged")
- }
-}
diff --git a/eth/rpc/rpcapi/filtersapi/filters.go b/eth/rpc/rpcapi/filtersapi/filters.go
deleted file mode 100644
index 4710dff8c..000000000
--- a/eth/rpc/rpcapi/filtersapi/filters.go
+++ /dev/null
@@ -1,268 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package filtersapi
-
-import (
- "context"
- "encoding/binary"
- "fmt"
- "math/big"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/backend"
-
- "github.com/cometbft/cometbft/libs/log"
- tmrpctypes "github.com/cometbft/cometbft/rpc/core/types"
- "github.com/pkg/errors"
-
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/eth/filters"
-)
-
-// BloomIV represents the bit indexes and value inside the bloom filter that belong
-// to some key.
-type BloomIV struct {
- I [3]uint
- V [3]byte
-}
-
-// Filter can be used to retrieve and filter logs.
-type Filter struct {
- logger log.Logger
- backend IFilterEthBackend
- criteria filters.FilterCriteria
-
- bloomFilters [][]BloomIV // Filter the system is matching for
-}
-
-// NewBlockFilter creates a new filter which directly inspects the contents of
-// a block to figure out whether it is interesting or not.
-func NewBlockFilter(logger log.Logger, backend IFilterEthBackend, criteria filters.FilterCriteria) *Filter {
- // Create a generic filter and convert it into a block filter
- return newFilter(logger, backend, criteria, nil)
-}
-
-// NewRangeFilter creates a new filter which uses a bloom filter on blocks to
-// figure out whether a particular block is interesting or not.
-func NewRangeFilter(logger log.Logger, backend IFilterEthBackend, begin, end int64, addresses []common.Address, topics [][]common.Hash) *Filter {
- // Flatten the address and topic filter clauses into a single bloombits filter
- // system. Since the bloombits are not positional, nil topics are permitted,
- // which get flattened into a nil byte slice.
- var filtersBz [][][]byte //nolint: prealloc
- if len(addresses) > 0 {
- filter := make([][]byte, len(addresses))
- for i, address := range addresses {
- filter[i] = address.Bytes()
- }
- filtersBz = append(filtersBz, filter)
- }
-
- for _, topicList := range topics {
- filter := make([][]byte, len(topicList))
- for i, topic := range topicList {
- filter[i] = topic.Bytes()
- }
- filtersBz = append(filtersBz, filter)
- }
-
- // Create a generic filter and convert it into a range filter
- criteria := filters.FilterCriteria{
- FromBlock: big.NewInt(begin),
- ToBlock: big.NewInt(end),
- Addresses: addresses,
- Topics: topics,
- }
-
- return newFilter(logger, backend, criteria, createBloomFilters(filtersBz, logger))
-}
-
-// newFilter returns a new Filter
-func newFilter(logger log.Logger, backend IFilterEthBackend, criteria filters.FilterCriteria, bloomFilters [][]BloomIV) *Filter {
- return &Filter{
- logger: logger,
- backend: backend,
- criteria: criteria,
- bloomFilters: bloomFilters,
- }
-}
-
-const (
- maxToOverhang = 600
-)
-
-// Logs searches the blockchain for matching log entries, returning all from the
-// first block that contains matches, updating the start of the filter accordingly.
-func (f *Filter) Logs(_ context.Context, logLimit int, blockLimit int64) ([]*gethcore.Log, error) {
- logs := []*gethcore.Log{}
- var err error
-
- // If we're doing singleton block filtering, execute and return
- if f.criteria.BlockHash != nil && *f.criteria.BlockHash != (common.Hash{}) {
- resBlock, err := f.backend.TendermintBlockByHash(*f.criteria.BlockHash)
- if err != nil {
- return nil, fmt.Errorf("failed to fetch header by hash %s: %w", f.criteria.BlockHash, err)
- }
-
- blockRes, err := f.backend.TendermintBlockResultByNumber(&resBlock.Block.Height)
- if err != nil {
- f.logger.Debug("failed to fetch block result from Tendermint", "height", resBlock.Block.Height, "error", err.Error())
- return nil, nil
- }
-
- bloom, err := f.backend.BlockBloom(blockRes)
- if err != nil {
- return nil, err
- }
-
- return f.blockLogs(blockRes, bloom)
- }
-
- // Figure out the limits of the filter range
- header, err := f.backend.HeaderByNumber(rpc.EthLatestBlockNumber)
- if err != nil {
- return nil, fmt.Errorf("failed to fetch header by number (latest): %w", err)
- }
-
- if header == nil || header.Number == nil {
- f.logger.Debug("header not found or has no number")
- return nil, nil
- }
-
- head := header.Number.Int64()
- if f.criteria.FromBlock.Int64() < 0 {
- f.criteria.FromBlock = big.NewInt(head)
- } else if f.criteria.FromBlock.Int64() == 0 {
- f.criteria.FromBlock = big.NewInt(1)
- }
- if f.criteria.ToBlock.Int64() < 0 {
- f.criteria.ToBlock = big.NewInt(head)
- } else if f.criteria.ToBlock.Int64() == 0 {
- f.criteria.ToBlock = big.NewInt(1)
- }
-
- if f.criteria.ToBlock.Int64()-f.criteria.FromBlock.Int64() > blockLimit {
- return nil, fmt.Errorf("maximum [from, to] blocks distance: %d", blockLimit)
- }
-
- // check bounds
- if f.criteria.FromBlock.Int64() > head {
- return []*gethcore.Log{}, nil
- } else if f.criteria.ToBlock.Int64() > head+maxToOverhang {
- f.criteria.ToBlock = big.NewInt(head + maxToOverhang)
- }
-
- from := f.criteria.FromBlock.Int64()
- to := f.criteria.ToBlock.Int64()
-
- for height := from; height <= to; height++ {
- blockRes, err := f.backend.TendermintBlockResultByNumber(&height)
- if err != nil {
- f.logger.Debug("failed to fetch block result from Tendermint", "height", height, "error", err.Error())
- return nil, nil
- }
-
- bloom, err := f.backend.BlockBloom(blockRes)
- if err != nil {
- return nil, err
- }
-
- filtered, err := f.blockLogs(blockRes, bloom)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to fetch block by number %d", height)
- }
-
- // check logs limit
- if len(logs)+len(filtered) > logLimit {
- return nil, fmt.Errorf("query returned more than %d results", logLimit)
- }
- logs = append(logs, filtered...)
- }
- return logs, nil
-}
-
-// blockLogs returns the logs matching the filter criteria within a single block.
-func (f *Filter) blockLogs(blockRes *tmrpctypes.ResultBlockResults, bloom gethcore.Bloom) ([]*gethcore.Log, error) {
- if !bloomFilter(bloom, f.criteria.Addresses, f.criteria.Topics) {
- return []*gethcore.Log{}, nil
- }
-
- logsList, err := backend.GetLogsFromBlockResults(blockRes)
- if err != nil {
- return []*gethcore.Log{}, errors.Wrapf(err, "failed to fetch logs block number %d", blockRes.Height)
- }
-
- unfiltered := make([]*gethcore.Log, 0)
- for _, logs := range logsList {
- unfiltered = append(unfiltered, logs...)
- }
-
- logs := FilterLogs(unfiltered, nil, nil, f.criteria.Addresses, f.criteria.Topics)
- if len(logs) == 0 {
- return []*gethcore.Log{}, nil
- }
-
- return logs, nil
-}
-
-func createBloomFilters(filters [][][]byte, logger log.Logger) [][]BloomIV {
- bloomFilters := make([][]BloomIV, 0)
- for _, filter := range filters {
- // Gather the bit indexes of the filter rule, special casing the nil filter
- if len(filter) == 0 {
- continue
- }
- bloomIVs := make([]BloomIV, len(filter))
-
- // Transform the filter rules (the addresses and topics) to the bloom index and value arrays
- // So it can be used to compare with the bloom of the block header. If the rule has any nil
- // clauses. The rule will be ignored.
- for i, clause := range filter {
- if clause == nil {
- bloomIVs = nil
- break
- }
-
- iv, err := calcBloomIVs(clause)
- if err != nil {
- bloomIVs = nil
- logger.Error("calcBloomIVs error: %v", err)
- break
- }
-
- bloomIVs[i] = iv
- }
- // Accumulate the filter rules if no nil rule was within
- if bloomIVs != nil {
- bloomFilters = append(bloomFilters, bloomIVs)
- }
- }
- return bloomFilters
-}
-
-// calcBloomIVs returns BloomIV for the given data,
-// revised from https://github.com/ethereum/go-ethereum/blob/401354976bb44f0ad4455ca1e0b5c0dc31d9a5f5/core/types/bloom9.go#L139
-func calcBloomIVs(data []byte) (BloomIV, error) {
- hashbuf := make([]byte, 6)
- biv := BloomIV{}
-
- sha := crypto.NewKeccakState()
- sha.Reset()
- if _, err := sha.Write(data); err != nil {
- return BloomIV{}, err
- }
- if _, err := sha.Read(hashbuf); err != nil {
- return BloomIV{}, err
- }
-
- // The actual bits to flip
- biv.V[0] = byte(1 << (hashbuf[1] & 0x7))
- biv.V[1] = byte(1 << (hashbuf[3] & 0x7))
- biv.V[2] = byte(1 << (hashbuf[5] & 0x7))
- // The indices for the bytes to OR in
- biv.I[0] = gethcore.BloomByteLength - uint((binary.BigEndian.Uint16(hashbuf)&0x7ff)>>3) - 1
- biv.I[1] = gethcore.BloomByteLength - uint((binary.BigEndian.Uint16(hashbuf[2:])&0x7ff)>>3) - 1
- biv.I[2] = gethcore.BloomByteLength - uint((binary.BigEndian.Uint16(hashbuf[4:])&0x7ff)>>3) - 1
-
- return biv, nil
-}
diff --git a/eth/rpc/rpcapi/filtersapi/subscription.go b/eth/rpc/rpcapi/filtersapi/subscription.go
deleted file mode 100644
index fc2ac0f91..000000000
--- a/eth/rpc/rpcapi/filtersapi/subscription.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package filtersapi
-
-import (
- "time"
-
- coretypes "github.com/cometbft/cometbft/rpc/core/types"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/eth/filters"
- "github.com/ethereum/go-ethereum/rpc"
-)
-
-// Subscription defines a wrapper for the private subscription
-type Subscription struct {
- id rpc.ID
- typ filters.Type
- event string
- created time.Time
- logsCrit filters.FilterCriteria
- logs chan []*gethcore.Log
- hashes chan []common.Hash
- headers chan *gethcore.Header
- installed chan struct{} // closed when the filter is installed
- eventCh <-chan coretypes.ResultEvent
- err chan error
-}
-
-// ID returns the underlying subscription RPC identifier.
-func (s Subscription) ID() rpc.ID {
- return s.id
-}
-
-// Unsubscribe from the current subscription to Tendermint Websocket. It sends an error to the
-// subscription error channel if unsubscribe fails.
-func (s *Subscription) Unsubscribe(es *EventSystem) {
- go func() {
- uninstallLoop:
- for {
- // write uninstall request and consume logs/hashes. This prevents
- // the eventLoop broadcast method to deadlock when writing to the
- // filter event channel while the subscription loop is waiting for
- // this method to return (and thus not reading these events).
- select {
- case es.uninstall <- s:
- break uninstallLoop
- case <-s.logs:
- case <-s.hashes:
- case <-s.headers:
- }
- }
- }()
-}
-
-// Err returns the error channel
-func (s *Subscription) Err() <-chan error {
- return s.err
-}
-
-// Event returns the tendermint result event channel
-func (s *Subscription) Event() <-chan coretypes.ResultEvent {
- return s.eventCh
-}
diff --git a/eth/rpc/rpcapi/filtersapi/utils.go b/eth/rpc/rpcapi/filtersapi/utils.go
deleted file mode 100644
index 47d27de2e..000000000
--- a/eth/rpc/rpcapi/filtersapi/utils.go
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package filtersapi
-
-import (
- "math/big"
-
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-)
-
-// FilterLogs creates a slice of logs matching the given criteria.
-// [] -> anything
-// [A] -> A in first position of log topics, anything after
-// [null, B] -> anything in first position, B in second position
-// [A, B] -> A in first position and B in second position
-// [[A, B], [A, B]] -> A or B in first position, A or B in second position
-func FilterLogs(logs []*gethcore.Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []*gethcore.Log {
- var ret []*gethcore.Log
-Logs:
- for _, log := range logs {
- if fromBlock != nil && fromBlock.Int64() >= 0 && fromBlock.Uint64() > log.BlockNumber {
- continue
- }
- if toBlock != nil && toBlock.Int64() >= 0 && toBlock.Uint64() < log.BlockNumber {
- continue
- }
- if len(addresses) > 0 && !includes(addresses, log.Address) {
- continue
- }
- // If the to filtered topics is greater than the amount of topics in logs, skip.
- if len(topics) > len(log.Topics) {
- continue
- }
- for i, sub := range topics {
- match := len(sub) == 0 // empty rule set == wildcard
- for _, topic := range sub {
- if log.Topics[i] == topic {
- match = true
- break
- }
- }
- if !match {
- continue Logs
- }
- }
- ret = append(ret, log)
- }
- return ret
-}
-
-func includes(addresses []common.Address, a common.Address) bool {
- for _, addr := range addresses {
- if addr == a {
- return true
- }
- }
-
- return false
-}
-
-// https://github.com/ethereum/go-ethereum/blob/v1.10.14/eth/filters/filter.go#L321
-func bloomFilter(bloom gethcore.Bloom, addresses []common.Address, topics [][]common.Hash) bool {
- if len(addresses) > 0 {
- var included bool
- for _, addr := range addresses {
- if gethcore.BloomLookup(bloom, addr) {
- included = true
- break
- }
- }
- if !included {
- return false
- }
- }
-
- for _, sub := range topics {
- included := len(sub) == 0 // empty rule set == wildcard
- for _, topic := range sub {
- if gethcore.BloomLookup(bloom, topic) {
- included = true
- break
- }
- }
- if !included {
- return false
- }
- }
- return true
-}
-
-// returnHashes is a helper that will return an empty hash array case the given hash array is nil,
-// otherwise the given hashes array is returned.
-func returnHashes(hashes []common.Hash) []common.Hash {
- if hashes == nil {
- return []common.Hash{}
- }
- return hashes
-}
-
-// returnLogs is a helper that will return an empty log array in case the given logs array is nil,
-// otherwise the given logs array is returned.
-func returnLogs(logs []*gethcore.Log) []*gethcore.Log {
- if logs == nil {
- return []*gethcore.Log{}
- }
- return logs
-}
diff --git a/eth/rpc/rpcapi/miner_api.go b/eth/rpc/rpcapi/miner_api.go
deleted file mode 100644
index 298d8c4a5..000000000
--- a/eth/rpc/rpcapi/miner_api.go
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpcapi
-
-import (
- "errors"
-
- "github.com/cosmos/cosmos-sdk/server"
-
- "github.com/NibiruChain/nibiru/eth/rpc/backend"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
-
- "github.com/cometbft/cometbft/libs/log"
-)
-
-// MinerAPI is the private miner prefixed set of APIs in the Miner JSON-RPC spec.
-type MinerAPI struct {
- ctx *server.Context
- logger log.Logger
- backend backend.EVMBackend
-}
-
-// NewImplMinerAPI creates an instance of the Miner API.
-func NewImplMinerAPI(
- ctx *server.Context,
- backend backend.EVMBackend,
-) *MinerAPI {
- return &MinerAPI{
- ctx: ctx,
- logger: ctx.Logger.With("api", "miner"),
- backend: backend,
- }
-}
-
-// SetEtherbase sets the etherbase of the miner
-func (api *MinerAPI) SetEtherbase(etherbase common.Address) bool {
- api.logger.Debug("miner_setEtherbase")
- return api.backend.SetEtherbase(etherbase)
-}
-
-// SetGasPrice sets the minimum accepted gas price for the miner.
-func (api *MinerAPI) SetGasPrice(gasPrice hexutil.Big) bool {
- api.logger.Info(api.ctx.Viper.ConfigFileUsed())
- return api.backend.SetGasPrice(gasPrice)
-}
-
-// ------------------------------------------------
-// Unsupported functions on the Miner API
-// ------------------------------------------------
-
-// GetHashrate returns the current hashrate for local CPU miner and remote miner.
-// Unsupported in Ethermint
-func (api *MinerAPI) GetHashrate() uint64 {
- api.logger.Debug("miner_getHashrate")
- api.logger.Debug("Unsupported rpc function: miner_getHashrate")
- return 0
-}
-
-// SetExtra sets the extra data string that is included when this miner mines a block.
-// Unsupported in Ethermint
-func (api *MinerAPI) SetExtra(_ string) (bool, error) {
- api.logger.Debug("miner_setExtra")
- api.logger.Debug("Unsupported rpc function: miner_setExtra")
- return false, errors.New("unsupported rpc function: miner_setExtra")
-}
-
-// SetGasLimit sets the gaslimit to target towards during mining.
-// Unsupported in Ethermint
-func (api *MinerAPI) SetGasLimit(_ hexutil.Uint64) bool {
- api.logger.Debug("miner_setGasLimit")
- api.logger.Debug("Unsupported rpc function: miner_setGasLimit")
- return false
-}
-
-// Start starts the miner with the given number of threads. If threads is nil,
-// the number of workers started is equal to the number of logical CPUs that are
-// usable by this process. If mining is already running, this method adjust the
-// number of threads allowed to use and updates the minimum price required by the
-// transaction pool.
-// Unsupported in Ethermint
-func (api *MinerAPI) Start(_ *int) error {
- api.logger.Debug("miner_start")
- api.logger.Debug("Unsupported rpc function: miner_start")
- return errors.New("unsupported rpc function: miner_start")
-}
-
-// Stop terminates the miner, both at the consensus engine level as well as at
-// the block creation level.
-// Unsupported in Ethermint
-func (api *MinerAPI) Stop() {
- api.logger.Debug("miner_stop")
- api.logger.Debug("Unsupported rpc function: miner_stop")
-}
diff --git a/eth/rpc/rpcapi/net_api.go b/eth/rpc/rpcapi/net_api.go
deleted file mode 100644
index 9325a19ad..000000000
--- a/eth/rpc/rpcapi/net_api.go
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpcapi
-
-import (
- "context"
- "fmt"
-
- rpcclient "github.com/cometbft/cometbft/rpc/client"
- "github.com/cosmos/cosmos-sdk/client"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-// NetAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.
-type NetAPI struct {
- networkVersion uint64
- // TODO: epic: test(eth-rpc): "github.com/NibiruChain/nibiru/x/common/testutil/cli"
- // Validator.RPCClient should be used to test APIs that depend on the CometBFT
- // RPC client.
- tmClient rpcclient.Client
-}
-
-// NewImplNetAPI creates an instance of the public Net Web3 API.
-func NewImplNetAPI(clientCtx client.Context) *NetAPI {
- // parse the chainID from a integer string
- chainIDEpoch, err := eth.ParseChainID(clientCtx.ChainID)
- if err != nil {
- panic(err)
- }
-
- return &NetAPI{
- networkVersion: chainIDEpoch.Uint64(),
- tmClient: clientCtx.Client.(rpcclient.Client),
- }
-}
-
-// Version returns the current ethereum protocol version.
-func (s *NetAPI) Version() string {
- return fmt.Sprintf("%d", s.networkVersion)
-}
-
-// Listening returns if client is actively listening for network connections.
-func (s *NetAPI) Listening() bool {
- ctx := context.Background()
- netInfo, err := s.tmClient.NetInfo(ctx)
- if err != nil {
- return false
- }
- return netInfo.Listening
-}
-
-// PeerCount returns the number of peers currently connected to the client.
-func (s *NetAPI) PeerCount() int {
- ctx := context.Background()
- netInfo, err := s.tmClient.NetInfo(ctx)
- if err != nil {
- return 0
- }
- return len(netInfo.Peers)
-}
diff --git a/eth/rpc/rpcapi/personal_api.go b/eth/rpc/rpcapi/personal_api.go
deleted file mode 100644
index 1ea0f6f52..000000000
--- a/eth/rpc/rpcapi/personal_api.go
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpcapi
-
-import (
- "context"
- "fmt"
- "os"
- "time"
-
- "github.com/NibiruChain/nibiru/app/appconst"
- "github.com/NibiruChain/nibiru/eth/rpc/backend"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/crypto/hd"
-
- "github.com/cometbft/cometbft/libs/log"
-
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/crypto"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// PersonalAPI is the personal_ prefixed set of APIs in the Web3 JSON-RPC spec.
-type PersonalAPI struct {
- backend backend.EVMBackend
- logger log.Logger
- hdPathIter eth.HDPathIterator
-}
-
-// NewImplPersonalAPI creates an instance of the public Personal Eth API.
-func NewImplPersonalAPI(
- logger log.Logger,
- backend backend.EVMBackend,
-) *PersonalAPI {
- cfg := sdk.GetConfig()
- basePath := cfg.GetFullBIP44Path()
-
- iterator, err := eth.NewHDPathIterator(basePath, true)
- if err != nil {
- panic(err)
- }
-
- return &PersonalAPI{
- logger: logger.With("api", "personal"),
- hdPathIter: iterator,
- backend: backend,
- }
-}
-
-// ImportRawKey armors and encrypts a given raw hex encoded ECDSA key and stores it into the key directory.
-// The name of the key will have the format "personal_", where is the total number of
-// keys stored on the keyring.
-//
-// NOTE: The key will be both armored and encrypted using the same passphrase.
-func (api *PersonalAPI) ImportRawKey(privkey, password string) (common.Address, error) {
- api.logger.Debug("personal_importRawKey")
- return api.backend.ImportRawKey(privkey, password)
-}
-
-// ListAccounts will return a list of addresses for accounts this node manages.
-func (api *PersonalAPI) ListAccounts() ([]common.Address, error) {
- api.logger.Debug("personal_listAccounts")
- return api.backend.ListAccounts()
-}
-
-// LockAccount will lock the account associated with the given address when it's unlocked.
-// It removes the key corresponding to the given address from the API's local keys.
-func (api *PersonalAPI) LockAccount(address common.Address) bool {
- api.logger.Debug("personal_lockAccount", "address", address.String())
- api.logger.Info("personal_lockAccount not supported")
- // TODO: Not supported. See underlying issue https://github.com/99designs/keyring/issues/85
- return false
-}
-
-// NewAccount will create a new account and returns the address for the new
-// account.
-func (api *PersonalAPI) NewAccount(password string) (common.Address, error) {
- api.logger.Debug("personal_newAccount")
-
- name := "key_" + time.Now().UTC().Format(time.RFC3339)
-
- // create the mnemonic and save the account
- hdPath := api.hdPathIter()
-
- info, err := api.backend.NewMnemonic(name, keyring.English, hdPath.String(), password, hd.EthSecp256k1)
- if err != nil {
- return common.Address{}, err
- }
-
- pubKey, err := info.GetPubKey()
- if err != nil {
- return common.Address{}, err
- }
- addr := common.BytesToAddress(pubKey.Address().Bytes())
- api.logger.Info("Your new key was generated", "address", addr.String())
-
- binPath := fmt.Sprintf("%s/.%s/%s",
- os.Getenv("HOME"), appconst.BinaryName, name)
- api.logger.Info("Please backup your key file!", "path", binPath)
- api.logger.Info("Please remember your password!")
- return addr, nil
-}
-
-// UnlockAccount will unlock the account associated with the given address with
-// the given password for duration seconds. It returns an indication if the
-// account was unlocked.
-func (api *PersonalAPI) UnlockAccount(
- _ context.Context, addr common.Address, _ string, _ *uint64,
-) (isUnlocked bool, err error) {
- api.logger.Debug("personal_unlockAccount", "address", addr.String())
- // TODO: feat(eth-rpc): Implement a way to lock and unlock the keyring
- // securely on the Ethereum "peronsal" RPC namespace.
- return false, nil // Not yet supported.
-}
-
-// SendTransaction will create a transaction from the given arguments and
-// tries to sign it with the key associated with args.To. If the given password isn't
-// able to decrypt the key it fails.
-func (api *PersonalAPI) SendTransaction(
- _ context.Context, args evm.JsonTxArgs, _ string,
-) (common.Hash, error) {
- api.logger.Debug("personal_sendTransaction", "address", args.To.String())
- return api.backend.SendTransaction(args)
-}
-
-// Sign calculates an Ethereum ECDSA signature for:
-// keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))
-//
-// Note, the produced signature conforms to the secp256k1 curve R, S and V values,
-// where the V value will be 27 or 28 for legacy reasons.
-//
-// The key used to calculate the signature is decrypted with the given password.
-//
-// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
-func (api *PersonalAPI) Sign(_ context.Context, data hexutil.Bytes, addr common.Address, _ string) (hexutil.Bytes, error) {
- api.logger.Debug("personal_sign", "data", data, "address", addr.String())
- return api.backend.Sign(addr, data)
-}
-
-// EcRecover returns the address for the account that was used to create the signature.
-// Note, this function is compatible with eth_sign and personal_sign. As such it recovers
-// the address of:
-// hash = keccak256("\x19Ethereum Signed Message:\n"${message length}${message})
-// addr = ecrecover(hash, signature)
-//
-// Note, the signature must conform to the secp256k1 curve R, S and V values, where
-// the V value must be 27 or 28 for legacy reasons.
-//
-// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecove
-func (api *PersonalAPI) EcRecover(_ context.Context, data, sig hexutil.Bytes) (common.Address, error) {
- api.logger.Debug("personal_ecRecover", "data", data, "sig", sig)
-
- if len(sig) != crypto.SignatureLength {
- return common.Address{}, fmt.Errorf("signature must be %d bytes long", crypto.SignatureLength)
- }
-
- if sig[crypto.RecoveryIDOffset] != 27 && sig[crypto.RecoveryIDOffset] != 28 {
- return common.Address{}, fmt.Errorf("invalid Ethereum signature (V is not 27 or 28)")
- }
-
- sig[crypto.RecoveryIDOffset] -= 27 // Transform yellow paper V from 27/28 to 0/1
-
- pubkey, err := crypto.SigToPub(accounts.TextHash(data), sig)
- if err != nil {
- return common.Address{}, err
- }
-
- return crypto.PubkeyToAddress(*pubkey), nil
-}
-
-// Unpair deletes a pairing between wallet and ethermint.
-func (api *PersonalAPI) Unpair(_ context.Context, url, pin string) error {
- api.logger.Debug("personal_unpair", "url", url, "pin", pin)
- api.logger.Info("personal_unpair for smartcard wallet not supported")
- // TODO: Smartcard wallet not supported yet, refer to: https://github.com/ethereum/go-ethereum/blob/master/accounts/scwallet/README.md
- return fmt.Errorf("smartcard wallet not supported yet")
-}
-
-// InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key.
-func (api *PersonalAPI) InitializeWallet(_ context.Context, url string) (string, error) {
- api.logger.Debug("personal_initializeWallet", "url", url)
- api.logger.Info("personal_initializeWallet for smartcard wallet not supported")
- // TODO: Smartcard wallet not supported yet, refer to: https://github.com/ethereum/go-ethereum/blob/master/accounts/scwallet/README.md
- return "", fmt.Errorf("smartcard wallet not supported yet")
-}
-
-// RawWallet is a JSON representation of an accounts.Wallet interface, with its
-// data contents extracted into plain fields.
-type RawWallet struct {
- URL string `json:"url"`
- Status string `json:"status"`
- Failure string `json:"failure,omitempty"`
- Accounts []accounts.Account `json:"accounts,omitempty"`
-}
-
-// ListWallets will return a list of wallets this node manages.
-func (api *PersonalAPI) ListWallets() []RawWallet {
- api.logger.Debug("personal_ListWallets")
- api.logger.Info("currently wallet level that manages accounts is not supported")
- return ([]RawWallet)(nil)
-}
diff --git a/eth/rpc/rpcapi/txpool_api.go b/eth/rpc/rpcapi/txpool_api.go
deleted file mode 100644
index ab2bc0055..000000000
--- a/eth/rpc/rpcapi/txpool_api.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpcapi
-
-import (
- "github.com/cometbft/cometbft/libs/log"
-
- "github.com/ethereum/go-ethereum/common/hexutil"
-
- "github.com/NibiruChain/nibiru/eth/rpc"
-)
-
-// TxPoolAPI offers and API for the transaction pool. It only operates on data
-// that is non-confidential.
-type TxPoolAPI struct {
- logger log.Logger
-}
-
-// NewImplTxPoolAPI creates a new tx pool service that gives information about the transaction pool.
-func NewImplTxPoolAPI(logger log.Logger) *TxPoolAPI {
- return &TxPoolAPI{
- logger: logger.With("module", "txpool"),
- }
-}
-
-// Content returns the transactions contained within the transaction pool
-func (api *TxPoolAPI) Content() (
- map[string]map[string]map[string]*rpc.EthTxJsonRPC, error,
-) {
- api.logger.Debug("txpool_content")
- content := map[string]map[string]map[string]*rpc.EthTxJsonRPC{
- "pending": make(map[string]map[string]*rpc.EthTxJsonRPC),
- "queued": make(map[string]map[string]*rpc.EthTxJsonRPC),
- }
- return content, nil
-}
-
-// Inspect returns the content of the transaction pool and flattens it into an
-func (api *TxPoolAPI) Inspect() (map[string]map[string]map[string]string, error) {
- api.logger.Debug("txpool_inspect")
- content := map[string]map[string]map[string]string{
- "pending": make(map[string]map[string]string),
- "queued": make(map[string]map[string]string),
- }
- return content, nil
-}
-
-// Status returns the number of pending and queued transaction in the pool.
-func (api *TxPoolAPI) Status() map[string]hexutil.Uint {
- api.logger.Debug("txpool_status")
- return map[string]hexutil.Uint{
- "pending": hexutil.Uint(0),
- "queued": hexutil.Uint(0),
- }
-}
diff --git a/eth/rpc/rpcapi/web3_api.go b/eth/rpc/rpcapi/web3_api.go
deleted file mode 100644
index 1cdc3030b..000000000
--- a/eth/rpc/rpcapi/web3_api.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpcapi
-
-import (
- appconst "github.com/NibiruChain/nibiru/app/appconst"
-
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/crypto"
-)
-
-// APIWeb3 is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.
-type APIWeb3 struct{}
-
-// NewImplWeb3API creates an instance of the Web3 API.
-func NewImplWeb3API() *APIWeb3 {
- return &APIWeb3{}
-}
-
-// ClientVersion returns the client version in the Web3 user agent format.
-func (a *APIWeb3) ClientVersion() string {
- return appconst.RuntimeVersion()
-}
-
-// Sha3 returns the keccak-256 hash of the passed-in input.
-func (a *APIWeb3) Sha3(input string) hexutil.Bytes {
- return crypto.Keccak256(hexutil.Bytes(input))
-}
diff --git a/eth/rpc/rpcapi/websockets.go b/eth/rpc/rpcapi/websockets.go
deleted file mode 100644
index c168b9054..000000000
--- a/eth/rpc/rpcapi/websockets.go
+++ /dev/null
@@ -1,704 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpcapi
-
-import (
- "bytes"
- "context"
- "encoding/json"
- "fmt"
- "io"
- "math/big"
- "net"
- "net/http"
- "strconv"
- "sync"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/gorilla/mux"
- "github.com/gorilla/websocket"
- "github.com/pkg/errors"
-
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/eth/filters"
- "github.com/ethereum/go-ethereum/params"
- gethrpc "github.com/ethereum/go-ethereum/rpc"
-
- "github.com/cometbft/cometbft/libs/log"
- rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client"
- tmtypes "github.com/cometbft/cometbft/types"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/app/server/config"
- "github.com/NibiruChain/nibiru/eth/rpc"
- "github.com/NibiruChain/nibiru/eth/rpc/pubsub"
- rpcfilters "github.com/NibiruChain/nibiru/eth/rpc/rpcapi/filtersapi"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-type WebsocketsServer interface {
- Start()
-}
-
-type SubscriptionResponseJSON struct {
- Jsonrpc string `json:"jsonrpc"`
- Result interface{} `json:"result"`
- ID float64 `json:"id"`
-}
-
-type SubscriptionNotification struct {
- Jsonrpc string `json:"jsonrpc"`
- Method string `json:"method"`
- Params *SubscriptionResult `json:"params"`
-}
-
-type SubscriptionResult struct {
- Subscription gethrpc.ID `json:"subscription"`
- Result interface{} `json:"result"`
-}
-
-type ErrorResponseJSON struct {
- Jsonrpc string `json:"jsonrpc"`
- Error *ErrorMessageJSON `json:"error"`
- ID *big.Int `json:"id"`
-}
-
-type ErrorMessageJSON struct {
- Code *big.Int `json:"code"`
- Message string `json:"message"`
-}
-
-type websocketsServer struct {
- rpcAddr string // listen address of rest-server
- wsAddr string // listen address of ws server
- certFile string
- keyFile string
- api *pubSubAPI
- logger log.Logger
-}
-
-func NewWebsocketsServer(
- clientCtx client.Context,
- logger log.Logger,
- tmWSClient *rpcclient.WSClient,
- cfg *config.Config,
-) WebsocketsServer {
- logger = logger.With("api", "websocket-server")
- _, port, _ := net.SplitHostPort(cfg.JSONRPC.Address) // #nosec G703
-
- return &websocketsServer{
- rpcAddr: "localhost:" + port, // FIXME: this shouldn't be hardcoded to localhost
- wsAddr: cfg.JSONRPC.WsAddress,
- certFile: cfg.TLS.CertificatePath,
- keyFile: cfg.TLS.KeyPath,
- api: newPubSubAPI(clientCtx, logger, tmWSClient),
- logger: logger,
- }
-}
-
-func (s *websocketsServer) Start() {
- ws := mux.NewRouter()
- ws.Handle("/", s)
-
- go func() {
- var err error
- if s.certFile == "" || s.keyFile == "" {
- //#nosec G114 -- http functions have no support for timeouts
- err = http.ListenAndServe(s.wsAddr, ws)
- } else {
- //#nosec G114 -- http functions have no support for timeouts
- err = http.ListenAndServeTLS(s.wsAddr, s.certFile, s.keyFile, ws)
- }
-
- if err != nil {
- if err == http.ErrServerClosed {
- return
- }
-
- s.logger.Error("failed to start HTTP server for WS", "error", err.Error())
- }
- }()
-}
-
-func (s *websocketsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- upgrader := websocket.Upgrader{
- CheckOrigin: func(r *http.Request) bool {
- return true
- },
- }
-
- conn, err := upgrader.Upgrade(w, r, nil)
- if err != nil {
- s.logger.Debug("websocket upgrade failed", "error", err.Error())
- return
- }
-
- s.readLoop(&wsConn{
- mux: new(sync.Mutex),
- conn: conn,
- })
-}
-
-func (s *websocketsServer) sendErrResponse(wsConn *wsConn, msg string) {
- res := &ErrorResponseJSON{
- Jsonrpc: "2.0",
- Error: &ErrorMessageJSON{
- Code: big.NewInt(-32600),
- Message: msg,
- },
- ID: nil,
- }
-
- _ = wsConn.WriteJSON(res) // #nosec G703
-}
-
-type wsConn struct {
- conn *websocket.Conn
- mux *sync.Mutex
-}
-
-func (w *wsConn) WriteJSON(v interface{}) error {
- w.mux.Lock()
- defer w.mux.Unlock()
-
- return w.conn.WriteJSON(v)
-}
-
-func (w *wsConn) Close() error {
- w.mux.Lock()
- defer w.mux.Unlock()
-
- return w.conn.Close()
-}
-
-func (w *wsConn) ReadMessage() (messageType int, p []byte, err error) {
- // not protected by write mutex
-
- return w.conn.ReadMessage()
-}
-
-func (s *websocketsServer) readLoop(wsConn *wsConn) {
- // subscriptions of current connection
- subscriptions := make(map[gethrpc.ID]pubsub.UnsubscribeFunc)
- defer func() {
- // cancel all subscriptions when connection closed
- // #nosec G705
- for _, unsubFn := range subscriptions {
- unsubFn()
- }
- }()
-
- for {
- _, mb, err := wsConn.ReadMessage()
- if err != nil {
- _ = wsConn.Close() // #nosec G703
- s.logger.Error("read message error, breaking read loop", "error", err.Error())
- return
- }
-
- if isBatch(mb) {
- if err := s.tcpGetAndSendResponse(wsConn, mb); err != nil {
- s.sendErrResponse(wsConn, err.Error())
- }
- continue
- }
-
- var msg map[string]interface{}
- if err = json.Unmarshal(mb, &msg); err != nil {
- s.sendErrResponse(wsConn, err.Error())
- continue
- }
-
- // check if method == eth_subscribe or eth_unsubscribe
- method, ok := msg["method"].(string)
- if !ok {
- // otherwise, call the usual rpc server to respond
- if err := s.tcpGetAndSendResponse(wsConn, mb); err != nil {
- s.sendErrResponse(wsConn, err.Error())
- }
-
- continue
- }
-
- var connID float64
- switch id := msg["id"].(type) {
- case string:
- connID, err = strconv.ParseFloat(id, 64)
- case float64:
- connID = id
- default:
- err = fmt.Errorf("unknown type")
- }
- if err != nil {
- s.sendErrResponse(
- wsConn,
- fmt.Errorf("invalid type for connection ID: %T", msg["id"]).Error(),
- )
- continue
- }
-
- switch method {
- case "eth_subscribe":
- params, ok := s.getParamsAndCheckValid(msg, wsConn)
- if !ok {
- continue
- }
-
- subID := gethrpc.NewID()
- unsubFn, err := s.api.subscribe(wsConn, subID, params)
- if err != nil {
- s.sendErrResponse(wsConn, err.Error())
- continue
- }
- subscriptions[subID] = unsubFn
-
- res := &SubscriptionResponseJSON{
- Jsonrpc: "2.0",
- ID: connID,
- Result: subID,
- }
-
- if err := wsConn.WriteJSON(res); err != nil {
- break
- }
- case "eth_unsubscribe":
- params, ok := s.getParamsAndCheckValid(msg, wsConn)
- if !ok {
- continue
- }
-
- id, ok := params[0].(string)
- if !ok {
- s.sendErrResponse(wsConn, "invalid parameters")
- continue
- }
-
- subID := gethrpc.ID(id)
- unsubFn, ok := subscriptions[subID]
- if ok {
- delete(subscriptions, subID)
- unsubFn()
- }
-
- res := &SubscriptionResponseJSON{
- Jsonrpc: "2.0",
- ID: connID,
- Result: ok,
- }
-
- if err := wsConn.WriteJSON(res); err != nil {
- break
- }
- default:
- // otherwise, call the usual rpc server to respond
- if err := s.tcpGetAndSendResponse(wsConn, mb); err != nil {
- s.sendErrResponse(wsConn, err.Error())
- }
- }
- }
-}
-
-// tcpGetAndSendResponse sends error response to client if params is invalid
-func (s *websocketsServer) getParamsAndCheckValid(msg map[string]interface{}, wsConn *wsConn) ([]interface{}, bool) {
- params, ok := msg["params"].([]interface{})
- if !ok {
- s.sendErrResponse(wsConn, "invalid parameters")
- return nil, false
- }
-
- if len(params) == 0 {
- s.sendErrResponse(wsConn, "empty parameters")
- return nil, false
- }
-
- return params, true
-}
-
-// tcpGetAndSendResponse connects to the rest-server over tcp, posts a JSON-RPC request, and sends the response
-// to the client over websockets
-func (s *websocketsServer) tcpGetAndSendResponse(wsConn *wsConn, mb []byte) error {
- req, err := http.NewRequestWithContext(context.Background(), "POST", "http://"+s.rpcAddr, bytes.NewBuffer(mb))
- if err != nil {
- return errors.Wrap(err, "Could not build request")
- }
-
- req.Header.Set("Content-Type", "application/json")
- client := &http.Client{}
- resp, err := client.Do(req)
- if err != nil {
- return errors.Wrap(err, "Could not perform request")
- }
-
- defer resp.Body.Close()
-
- body, err := io.ReadAll(resp.Body)
- if err != nil {
- return errors.Wrap(err, "could not read body from response")
- }
-
- var wsSend interface{}
- err = json.Unmarshal(body, &wsSend)
- if err != nil {
- return errors.Wrap(err, "failed to unmarshal rest-server response")
- }
-
- return wsConn.WriteJSON(wsSend)
-}
-
-// pubSubAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec
-type pubSubAPI struct {
- events *rpcfilters.EventSystem
- logger log.Logger
- clientCtx client.Context
-}
-
-// newPubSubAPI creates an instance of the ethereum PubSub API.
-func newPubSubAPI(clientCtx client.Context, logger log.Logger, tmWSClient *rpcclient.WSClient) *pubSubAPI {
- logger = logger.With("module", "websocket-client")
- return &pubSubAPI{
- events: rpcfilters.NewEventSystem(logger, tmWSClient),
- logger: logger,
- clientCtx: clientCtx,
- }
-}
-
-func (api *pubSubAPI) subscribe(wsConn *wsConn, subID gethrpc.ID, params []interface{}) (pubsub.UnsubscribeFunc, error) {
- method, ok := params[0].(string)
- if !ok {
- return nil, errors.New("invalid parameters")
- }
-
- switch method {
- case "newHeads":
- // TODO: handle extra params
- return api.subscribeNewHeads(wsConn, subID)
- case "logs":
- if len(params) > 1 {
- return api.subscribeLogs(wsConn, subID, params[1])
- }
- return api.subscribeLogs(wsConn, subID, nil)
- case "newPendingTransactions":
- return api.subscribePendingTransactions(wsConn, subID)
- case "syncing":
- return api.subscribeSyncing(wsConn, subID)
- default:
- return nil, errors.Errorf("unsupported method %s", method)
- }
-}
-
-func (api *pubSubAPI) subscribeNewHeads(wsConn *wsConn, subID gethrpc.ID) (pubsub.UnsubscribeFunc, error) {
- sub, unsubFn, err := api.events.SubscribeNewHeads()
- if err != nil {
- return nil, errors.Wrap(err, "error creating block filter")
- }
-
- // TODO: use events
- baseFee := big.NewInt(params.InitialBaseFee)
-
- go func() {
- headersCh := sub.Event()
- errCh := sub.Err()
- for {
- select {
- case event, ok := <-headersCh:
- if !ok {
- return
- }
-
- data, ok := event.Data.(tmtypes.EventDataNewBlockHeader)
- if !ok {
- api.logger.Debug("event data type mismatch", "type", fmt.Sprintf("%T", event.Data))
- continue
- }
-
- header := rpc.EthHeaderFromTendermint(data.Header, gethcore.Bloom{}, baseFee)
-
- // write to ws conn
- res := &SubscriptionNotification{
- Jsonrpc: "2.0",
- Method: "eth_subscription",
- Params: &SubscriptionResult{
- Subscription: subID,
- Result: header,
- },
- }
-
- err = wsConn.WriteJSON(res)
- if err != nil {
- api.logger.Error("error writing header, will drop peer", "error", err.Error())
-
- try(func() {
- if err != websocket.ErrCloseSent {
- _ = wsConn.Close() // #nosec G703
- }
- }, api.logger, "closing websocket peer sub")
- }
- case err, ok := <-errCh:
- if !ok {
- return
- }
- api.logger.Debug("dropping NewHeads WebSocket subscription", "subscription-id", subID, "error", err.Error())
- }
- }
- }()
-
- return unsubFn, nil
-}
-
-func try(fn func(), l log.Logger, desc string) {
- defer func() {
- if x := recover(); x != nil {
- if err, ok := x.(error); ok {
- // debug.PrintStack()
- l.Debug("panic during "+desc, "error", err.Error())
- return
- }
-
- l.Debug(fmt.Sprintf("panic during %s: %+v", desc, x))
- return
- }
- }()
-
- fn()
-}
-
-func (api *pubSubAPI) subscribeLogs(wsConn *wsConn, subID gethrpc.ID, extra interface{}) (pubsub.UnsubscribeFunc, error) {
- crit := filters.FilterCriteria{}
-
- if extra != nil {
- params, ok := extra.(map[string]interface{})
- if !ok {
- err := errors.New("invalid criteria")
- api.logger.Debug("invalid criteria", "type", fmt.Sprintf("%T", extra))
- return nil, err
- }
-
- if params["address"] != nil {
- address, isString := params["address"].(string)
- addresses, isSlice := params["address"].([]interface{})
- if !isString && !isSlice {
- err := errors.New("invalid addresses; must be address or array of addresses")
- api.logger.Debug("invalid addresses", "type", fmt.Sprintf("%T", params["address"]))
- return nil, err
- }
-
- if ok {
- crit.Addresses = []common.Address{common.HexToAddress(address)}
- }
-
- if isSlice {
- crit.Addresses = []common.Address{}
- for _, addr := range addresses {
- address, ok := addr.(string)
- if !ok {
- err := errors.New("invalid address")
- api.logger.Debug("invalid address", "type", fmt.Sprintf("%T", addr))
- return nil, err
- }
-
- crit.Addresses = append(crit.Addresses, common.HexToAddress(address))
- }
- }
- }
-
- if params["topics"] != nil {
- topics, ok := params["topics"].([]interface{})
- if !ok {
- err := errors.Errorf("invalid topics: %s", topics)
- api.logger.Error("invalid topics", "type", fmt.Sprintf("%T", topics))
- return nil, err
- }
-
- crit.Topics = make([][]common.Hash, len(topics))
-
- addCritTopic := func(topicIdx int, topic interface{}) error {
- tstr, ok := topic.(string)
- if !ok {
- err := errors.Errorf("invalid topic: %s", topic)
- api.logger.Error("invalid topic", "type", fmt.Sprintf("%T", topic))
- return err
- }
-
- crit.Topics[topicIdx] = []common.Hash{common.HexToHash(tstr)}
- return nil
- }
-
- for topicIdx, subtopics := range topics {
- if subtopics == nil {
- continue
- }
-
- // in case we don't have list, but a single topic value
- if topic, ok := subtopics.(string); ok {
- if err := addCritTopic(topicIdx, topic); err != nil {
- return nil, err
- }
-
- continue
- }
-
- // in case we actually have a list of subtopics
- subtopicsList, ok := subtopics.([]interface{})
- if !ok {
- err := errors.New("invalid subtopics")
- api.logger.Error("invalid subtopic", "type", fmt.Sprintf("%T", subtopics))
- return nil, err
- }
-
- subtopicsCollect := make([]common.Hash, len(subtopicsList))
- for idx, subtopic := range subtopicsList {
- tstr, ok := subtopic.(string)
- if !ok {
- err := errors.Errorf("invalid subtopic: %s", subtopic)
- api.logger.Error("invalid subtopic", "type", fmt.Sprintf("%T", subtopic))
- return nil, err
- }
-
- subtopicsCollect[idx] = common.HexToHash(tstr)
- }
-
- crit.Topics[topicIdx] = subtopicsCollect
- }
- }
- }
-
- sub, unsubFn, err := api.events.SubscribeLogs(crit)
- if err != nil {
- api.logger.Error("failed to subscribe logs", "error", err.Error())
- return nil, err
- }
-
- go func() {
- ch := sub.Event()
- errCh := sub.Err()
- for {
- select {
- case event, ok := <-ch:
- if !ok {
- return
- }
-
- dataTx, ok := event.Data.(tmtypes.EventDataTx)
- if !ok {
- api.logger.Debug("event data type mismatch", "type", fmt.Sprintf("%T", event.Data))
- continue
- }
-
- txResponse, err := evm.DecodeTxResponse(dataTx.TxResult.Result.Data)
- if err != nil {
- api.logger.Error("failed to decode tx response", "error", err.Error())
- return
- }
-
- logs := rpcfilters.FilterLogs(evm.LogsToEthereum(txResponse.Logs), crit.FromBlock, crit.ToBlock, crit.Addresses, crit.Topics)
- if len(logs) == 0 {
- continue
- }
-
- for _, ethLog := range logs {
- res := &SubscriptionNotification{
- Jsonrpc: "2.0",
- Method: "eth_subscription",
- Params: &SubscriptionResult{
- Subscription: subID,
- Result: ethLog,
- },
- }
-
- err = wsConn.WriteJSON(res)
- if err != nil {
- try(func() {
- if err != websocket.ErrCloseSent {
- _ = wsConn.Close() // #nosec G703
- }
- }, api.logger, "closing websocket peer sub")
- }
- }
- case err, ok := <-errCh:
- if !ok {
- return
- }
- api.logger.Debug("dropping Logs WebSocket subscription", "subscription-id", subID, "error", err.Error())
- }
- }
- }()
-
- return unsubFn, nil
-}
-
-func (api *pubSubAPI) subscribePendingTransactions(wsConn *wsConn, subID gethrpc.ID) (pubsub.UnsubscribeFunc, error) {
- sub, unsubFn, err := api.events.SubscribePendingTxs()
- if err != nil {
- return nil, errors.Wrap(err, "error creating block filter: %s")
- }
-
- go func() {
- txsCh := sub.Event()
- errCh := sub.Err()
- for {
- select {
- case ev := <-txsCh:
- data, ok := ev.Data.(tmtypes.EventDataTx)
- if !ok {
- api.logger.Debug("event data type mismatch", "type", fmt.Sprintf("%T", ev.Data))
- continue
- }
-
- fmt.Printf("data.Tx: %s\n", collections.HumanizeBytes(data.Tx))
- ethTxs, err := rpc.RawTxToEthTx(api.clientCtx, data.Tx)
- if err != nil {
- // not ethereum tx
- continue
- }
-
- for _, ethTx := range ethTxs {
- // write to ws conn
- res := &SubscriptionNotification{
- Jsonrpc: "2.0",
- Method: "eth_subscription",
- Params: &SubscriptionResult{
- Subscription: subID,
- Result: ethTx.Hash,
- },
- }
-
- err = wsConn.WriteJSON(res)
- if err != nil {
- api.logger.Debug("error writing header, will drop peer", "error", err.Error())
-
- try(func() {
- if err != websocket.ErrCloseSent {
- _ = wsConn.Close() // #nosec G703
- }
- }, api.logger, "closing websocket peer sub")
- }
- }
- case err, ok := <-errCh:
- if !ok {
- return
- }
- api.logger.Debug("dropping PendingTransactions WebSocket subscription", subID, "error", err.Error())
- }
- }
- }()
-
- return unsubFn, nil
-}
-
-func (api *pubSubAPI) subscribeSyncing(_ *wsConn, _ gethrpc.ID) (pubsub.UnsubscribeFunc, error) {
- return nil, errors.New("syncing subscription is not implemented")
-}
-
-// copy from github.com/ethereum/go-ethereum/rpc/json.go
-// isBatch returns true when the first non-whitespace characters is '['
-func isBatch(raw []byte) bool {
- for _, c := range raw {
- // skip insignificant whitespace (http://www.ietf.org/rfc/rfc4627.txt)
- if c == 0x20 || c == 0x09 || c == 0x0a || c == 0x0d {
- continue
- }
- return c == '['
- }
- return false
-}
diff --git a/eth/rpc/types.go b/eth/rpc/types.go
deleted file mode 100644
index dfcec77ab..000000000
--- a/eth/rpc/types.go
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package rpc
-
-// TODO: docs(eth-rpc): Explain types further.
-
-import (
- "math/big"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-)
-
-// Copied the Account and StorageResult types since they are registered under an
-// internal pkg on geth.
-
-// AccountResult struct for account proof
-type AccountResult struct {
- Address common.Address `json:"address"`
- AccountProof []string `json:"accountProof"`
- Balance *hexutil.Big `json:"balance"`
- CodeHash common.Hash `json:"codeHash"`
- Nonce hexutil.Uint64 `json:"nonce"`
- StorageHash common.Hash `json:"storageHash"`
- StorageProof []StorageResult `json:"storageProof"`
-}
-
-// StorageResult defines the format for storage proof return
-type StorageResult struct {
- Key string `json:"key"`
- Value *hexutil.Big `json:"value"`
- Proof []string `json:"proof"`
-}
-
-// EthTxJsonRPC represents a transaction that will serialize to the RPC representation of a transaction
-type EthTxJsonRPC struct {
- BlockHash *common.Hash `json:"blockHash"`
- BlockNumber *hexutil.Big `json:"blockNumber"`
- From common.Address `json:"from"`
- Gas hexutil.Uint64 `json:"gas"`
- GasPrice *hexutil.Big `json:"gasPrice"`
- GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
- GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
- Hash common.Hash `json:"hash"`
- Input hexutil.Bytes `json:"input"`
- Nonce hexutil.Uint64 `json:"nonce"`
- To *common.Address `json:"to"`
- TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
- Value *hexutil.Big `json:"value"`
- Type hexutil.Uint64 `json:"type"`
- Accesses *gethcore.AccessList `json:"accessList,omitempty"`
- ChainID *hexutil.Big `json:"chainId,omitempty"`
- V *hexutil.Big `json:"v"`
- R *hexutil.Big `json:"r"`
- S *hexutil.Big `json:"s"`
-}
-
-// StateOverride is the collection of overridden accounts.
-type StateOverride map[common.Address]OverrideAccount
-
-// OverrideAccount indicates the overriding fields of account during the execution of
-// a message call.
-// Note, state and stateDiff can't be specified at the same time. If state is
-// set, message execution will only use the data in the given state. Otherwise
-// if statDiff is set, all diff will be applied first and then execute the call
-// message.
-type OverrideAccount struct {
- Nonce *hexutil.Uint64 `json:"nonce"`
- Code *hexutil.Bytes `json:"code"`
- Balance **hexutil.Big `json:"balance"`
- State *map[common.Hash]common.Hash `json:"state"`
- StateDiff *map[common.Hash]common.Hash `json:"stateDiff"`
-}
-
-type FeeHistoryResult struct {
- OldestBlock *hexutil.Big `json:"oldestBlock"`
- Reward [][]*hexutil.Big `json:"reward,omitempty"`
- BaseFee []*hexutil.Big `json:"baseFeePerGas,omitempty"`
- GasUsedRatio []float64 `json:"gasUsedRatio"`
-}
-
-// SignTransactionResult represents a RLP encoded signed transaction.
-type SignTransactionResult struct {
- Raw hexutil.Bytes `json:"raw"`
- Tx *gethcore.Transaction `json:"tx"`
-}
-
-type OneFeeHistory struct {
- BaseFee, NextBaseFee *big.Int // base fee for each block
- Reward []*big.Int // each element of the array will have the tip provided to miners for the percentile given
- GasUsedRatio float64 // the ratio of gas used to the gas limit for each block
-}
diff --git a/eth/safe_math.go b/eth/safe_math.go
deleted file mode 100644
index d1ca9544d..000000000
--- a/eth/safe_math.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package eth
-
-import (
- fmt "fmt"
- math "math"
- "math/big"
-
- errorsmod "cosmossdk.io/errors"
- sdkmath "cosmossdk.io/math"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
-)
-
-const maxBitLen = 256
-
-// SafeNewIntFromBigInt constructs Int from big.Int, return error if more than 256bits
-func SafeNewIntFromBigInt(i *big.Int) (sdkmath.Int, error) {
- if !IsValidInt256(i) {
- return sdkmath.NewInt(0), fmt.Errorf("big int out of bound: %s", i)
- } else if i == nil {
- return sdkmath.Int{}, fmt.Errorf("received nil pointer for *big.Int")
- }
- return sdkmath.NewIntFromBigInt(i), nil
-}
-
-// IsValidInt256 check the bound of 256 bit number
-func IsValidInt256(i *big.Int) bool {
- return i == nil || i.BitLen() <= maxBitLen
-}
-
-// SafeInt64 checks for overflows while casting a uint64 to int64 value.
-func SafeInt64(value uint64) (int64, error) {
- if value > uint64(math.MaxInt64) {
- return 0, errorsmod.Wrapf(errortypes.ErrInvalidHeight, "uint64 value %v cannot exceed %v", value, int64(math.MaxInt64))
- }
-
- return int64(value), nil // #nosec G701 -- checked for int overflow already
-}
diff --git a/eth/safe_math_test.go b/eth/safe_math_test.go
deleted file mode 100644
index a956251cf..000000000
--- a/eth/safe_math_test.go
+++ /dev/null
@@ -1,120 +0,0 @@
-package eth_test
-
-import (
- fmt "fmt"
- "math/big"
- "testing"
-
- "cosmossdk.io/math"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-const maxInt64 = 9223372036854775807
-
-type SuiteSafeMath struct {
- suite.Suite
-}
-
-func TestTypesSuite(t *testing.T) {
- suite.Run(t, new(SuiteSafeMath))
-}
-
-func (s *SuiteSafeMath) TestSafeNewIntFromBigInt() {
- tests := []struct {
- name string
- input *big.Int
- expectErr bool
- }{
- {
- name: "Valid input within 256-bit limit",
- input: big.NewInt(maxInt64), // Use max int64 as a valid test case
- expectErr: false,
- },
- {
- name: "Invalid input exceeding 256-bit limit",
- input: new(big.Int).Lsh(big.NewInt(1), 257), // Shift 1 left by 257 places, creating a 258-bit number
- expectErr: true,
- },
- {
- name: "Nil input",
- input: nil,
- expectErr: true,
- },
- }
-
- for _, tc := range tests {
- s.Run(tc.name, func() {
- result, err := eth.SafeNewIntFromBigInt(tc.input)
- if tc.expectErr {
- s.Error(err, fmt.Sprintf("result: %s", result))
- } else {
- s.NoError(err, fmt.Sprintf("result: %s", result))
- s.Equal(math.NewIntFromBigInt(tc.input), result, "The results should be equal")
- }
- })
- }
-}
-
-func (s *SuiteSafeMath) TestIsValidInt256() {
- tests := []struct {
- name string
- input *big.Int
- expectValid bool
- }{
- {
- name: "Valid 256-bit number",
- input: new(big.Int).Lsh(big.NewInt(1), 255), // Exactly 256-bit number
- expectValid: true,
- },
- {
- name: "Invalid 257-bit number",
- input: new(big.Int).Lsh(big.NewInt(1), 256), // 257-bit number
- expectValid: false,
- },
- {
- name: "Nil input",
- input: nil,
- expectValid: true,
- },
- }
-
- for _, tc := range tests {
- s.Run(tc.name, func() {
- result := eth.IsValidInt256(tc.input)
- s.Equal(tc.expectValid, result, "Validity check did not match expected")
- })
- }
-}
-
-func (s *SuiteSafeMath) TestSafeInt64() {
- tests := []struct {
- name string
- input uint64
- expectErr bool
- }{
- {
- name: "Valid conversion",
- input: maxInt64, // Maximum value for int64
- expectErr: false,
- },
- {
- name: "Invalid conversion causes overflow",
- input: uint64(maxInt64) + 1, // Exceeds maximum int64 value
- expectErr: true,
- },
- }
-
- for _, tc := range tests {
- s.Run(tc.name, func() {
- result, err := eth.SafeInt64(tc.input)
- if tc.expectErr {
- s.Error(err, "Expected an error due to overflow but did not get one")
- } else {
- s.NoError(err, "Did not expect an error but got one")
- s.Equal(int64(tc.input), result, "The results should match")
- }
- })
- }
-}
diff --git a/eth/state_encoder.go b/eth/state_encoder.go
deleted file mode 100644
index 4c329b029..000000000
--- a/eth/state_encoder.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package eth
-
-import (
- fmt "fmt"
-
- "github.com/NibiruChain/collections"
- ethcommon "github.com/ethereum/go-ethereum/common"
-)
-
-// BytesToHex converts a byte array to a hexadecimal string
-func BytesToHex(bz []byte) string {
- return fmt.Sprintf("%x", bz)
-}
-
-// EthAddr: (alias) 20 byte address of an Ethereum account.
-type EthAddr = ethcommon.Address
-
-// EthHash: (alias) 32 byte Keccak256 hash of arbitrary data.
-type EthHash = ethcommon.Hash //revive:disable-line:exported
-
-var (
- // Implements a `collections.ValueEncoder` for the `[]byte` type
- ValueEncoderBytes collections.ValueEncoder[[]byte] = veBytes{}
- KeyEncoderBytes collections.KeyEncoder[[]byte] = keBytes{}
-
- // Implements a `collections.ValueEncoder` for an Ethereum address.
- ValueEncoderEthAddr collections.ValueEncoder[EthAddr] = veEthAddr{}
- // keEthHash: Implements a `collections.KeyEncoder` for an Ethereum address.
- KeyEncoderEthAddr collections.KeyEncoder[EthAddr] = keEthAddr{}
-
- // keEthHash: Implements a `collections.KeyEncoder` for an Ethereum hash.
- KeyEncoderEthHash collections.KeyEncoder[EthHash] = keEthHash{}
-)
-
-// collections ValueEncoder[[]byte]
-type veBytes struct{}
-
-func (_ veBytes) Encode(value []byte) []byte { return value }
-func (_ veBytes) Decode(bz []byte) []byte { return bz }
-func (_ veBytes) Stringify(value []byte) string { return BytesToHex(value) }
-func (_ veBytes) Name() string { return "[]byte" }
-
-// veEthAddr: Implements a `collections.ValueEncoder` for an Ethereum address.
-type veEthAddr struct{}
-
-func (_ veEthAddr) Encode(value EthAddr) []byte { return value.Bytes() }
-func (_ veEthAddr) Decode(bz []byte) EthAddr { return ethcommon.BytesToAddress(bz) }
-func (_ veEthAddr) Stringify(value EthAddr) string { return value.Hex() }
-func (_ veEthAddr) Name() string { return "EthAddr" }
-
-type keBytes struct{}
-
-// Encode encodes the type T into bytes.
-func (_ keBytes) Encode(key []byte) []byte { return key }
-
-// Decode decodes the given bytes back into T.
-// And it also must return the bytes of the buffer which were read.
-func (_ keBytes) Decode(bz []byte) (int, []byte) { return len(bz), bz }
-
-// Stringify returns a string representation of T.
-func (_ keBytes) Stringify(key []byte) string { return BytesToHex(key) }
-
-// keEthAddr: Implements a `collections.KeyEncoder` for an Ethereum address.
-type keEthAddr struct{}
-
-func (_ keEthAddr) Encode(value EthAddr) []byte { return value.Bytes() }
-func (_ keEthAddr) Decode(bz []byte) (int, EthAddr) {
- return ethcommon.AddressLength, ethcommon.BytesToAddress(bz)
-}
-func (_ keEthAddr) Stringify(value EthAddr) string { return value.Hex() }
-
-// keEthHash: Implements a `collections.KeyEncoder` for an Ethereum hash.
-type keEthHash struct{}
-
-func (_ keEthHash) Encode(value EthHash) []byte { return value.Bytes() }
-func (_ keEthHash) Decode(bz []byte) (int, EthHash) {
- return ethcommon.HashLength, ethcommon.BytesToHash(bz)
-}
-func (_ keEthHash) Stringify(value EthHash) string { return value.Hex() }
diff --git a/eth/state_encoder_test.go b/eth/state_encoder_test.go
deleted file mode 100644
index 837bc4fd6..000000000
--- a/eth/state_encoder_test.go
+++ /dev/null
@@ -1,97 +0,0 @@
-package eth_test
-
-import (
- "testing"
-
- "github.com/NibiruChain/collections"
- gethcommon "github.com/ethereum/go-ethereum/common"
- "github.com/stretchr/testify/require"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-func assertBijectiveKey[T any](t *testing.T, encoder collections.KeyEncoder[T], key T) {
- encodedKey := encoder.Encode(key)
- readLen, decodedKey := encoder.Decode(encodedKey)
- require.Equal(t, len(encodedKey), readLen, "encoded key and read bytes must have same size")
- require.Equal(t, key, decodedKey, "encoding and decoding produces different keys")
- wantStr := encoder.Stringify(key)
- gotStr := encoder.Stringify(decodedKey)
- require.Equal(t, wantStr, gotStr,
- "encoding and decoding produce different string representations")
-}
-
-func assertBijectiveValue[T any](t *testing.T, encoder collections.ValueEncoder[T], value T) {
- encodedValue := encoder.Encode(value)
- decodedValue := encoder.Decode(encodedValue)
- require.Equal(t, value, decodedValue, "encoding and decoding produces different values")
-
- wantStr := encoder.Stringify(value)
- gotStr := encoder.Stringify(decodedValue)
- require.Equal(t, wantStr, gotStr,
- "encoding and decoding produce different string representations")
- require.NotEmpty(t, encoder.Name())
-}
-
-type SuiteEncoders struct {
- suite.Suite
-}
-
-func TestSuiteEncoders_RunAll(t *testing.T) {
- suite.Run(t, new(SuiteEncoders))
-}
-
-func (s *SuiteEncoders) TestEncoderBytes() {
- testCases := []struct {
- name string
- value string
- }{
- {"dec-like number", "-1000.5858"},
- {"Nibiru bech32 addr", "nibi1rlvdjfmxkyfj4tzu73p8m4g2h4y89xccf9622l"},
- {"Nibiru EVM addr", "0xA52c829E935C30F4C7dcD66739Cf91BF79dD9253"},
- {"normal text with special symbols", "abc123日本語!!??foobar"},
- }
- for _, tc := range testCases {
- s.Run("bijectivity: []byte encoders "+tc.name, func() {
- given := []byte(tc.value)
- assertBijectiveKey(s.T(), eth.KeyEncoderBytes, given)
- assertBijectiveValue(s.T(), eth.ValueEncoderBytes, given)
- })
- }
-}
-
-func (s *SuiteEncoders) TestEncoderEthAddr() {
- testCases := []struct {
- name string
- given eth.EthAddr
- wantPanic bool
- }{
- {
- name: "Nibiru EVM addr",
- given: gethcommon.BytesToAddress([]byte("0xA52c829E935C30F4C7dcD66739Cf91BF79dD9253")),
- },
- {
- name: "Nibiru EVM addr length above 20 bytes",
- given: gethcommon.BytesToAddress([]byte("0xA52c829E935C30F4C7dcD66739Cf91BF79dD92532456BF123421")),
- },
- {
- name: "Nibiru Bech 32 addr (hypothetically)",
- given: eth.EthAddr([]byte("nibi1rlvdjfmxkyfj4tzu73p8m4g2h4y89xccf9622l")),
- },
- }
- for _, tc := range testCases {
- s.Run("bijectivity: []byte encoders "+tc.name, func() {
- given := tc.given
- runTest := func() {
- assertBijectiveKey(s.T(), eth.KeyEncoderEthAddr, given)
- assertBijectiveValue(s.T(), eth.ValueEncoderEthAddr, given)
- }
- if tc.wantPanic {
- s.Require().Panics(runTest)
- } else {
- s.Require().NotPanics(runTest)
- }
- })
- }
-}
diff --git a/eth/web3.pb.go b/eth/web3.pb.go
deleted file mode 100644
index 2b5f8477b..000000000
--- a/eth/web3.pb.go
+++ /dev/null
@@ -1,399 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: eth/types/v1/web3.proto
-
-package eth
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// ExtensionOptionsWeb3Tx is an extension option that specifies the typed chain id,
-// the fee payer as well as its signature data.
-type ExtensionOptionsWeb3Tx struct {
- // typed_data_chain_id is used only in EIP712 Domain and should match
- // Ethereum network ID in a Web3 provider (e.g. Metamask).
- TypedDataChainID uint64 `protobuf:"varint,1,opt,name=typed_data_chain_id,json=typedDataChainId,proto3" json:"typedDataChainID,omitempty"`
- // fee_payer is an account address for the fee payer. It will be validated
- // during EIP712 signature checking.
- FeePayer string `protobuf:"bytes,2,opt,name=fee_payer,json=feePayer,proto3" json:"feePayer,omitempty"`
- // fee_payer_sig is a signature data from the fee paying account,
- // allows to perform fee delegation when using EIP712 Domain.
- FeePayerSig []byte `protobuf:"bytes,3,opt,name=fee_payer_sig,json=feePayerSig,proto3" json:"feePayerSig,omitempty"`
-}
-
-func (m *ExtensionOptionsWeb3Tx) Reset() { *m = ExtensionOptionsWeb3Tx{} }
-func (m *ExtensionOptionsWeb3Tx) String() string { return proto.CompactTextString(m) }
-func (*ExtensionOptionsWeb3Tx) ProtoMessage() {}
-func (*ExtensionOptionsWeb3Tx) Descriptor() ([]byte, []int) {
- return fileDescriptor_db915af92325df9f, []int{0}
-}
-func (m *ExtensionOptionsWeb3Tx) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *ExtensionOptionsWeb3Tx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_ExtensionOptionsWeb3Tx.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *ExtensionOptionsWeb3Tx) XXX_Merge(src proto.Message) {
- xxx_messageInfo_ExtensionOptionsWeb3Tx.Merge(m, src)
-}
-func (m *ExtensionOptionsWeb3Tx) XXX_Size() int {
- return m.Size()
-}
-func (m *ExtensionOptionsWeb3Tx) XXX_DiscardUnknown() {
- xxx_messageInfo_ExtensionOptionsWeb3Tx.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ExtensionOptionsWeb3Tx proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*ExtensionOptionsWeb3Tx)(nil), "eth.types.v1.ExtensionOptionsWeb3Tx")
-}
-
-func init() { proto.RegisterFile("eth/types/v1/web3.proto", fileDescriptor_db915af92325df9f) }
-
-var fileDescriptor_db915af92325df9f = []byte{
- // 303 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0x2d, 0xc9, 0xd0,
- 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0x4f, 0x4d, 0x32, 0xd6, 0x2b, 0x28,
- 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x49, 0x2d, 0xc9, 0xd0, 0x03, 0x4b, 0xe8, 0x95, 0x19, 0x4a, 0x89,
- 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, 0x1a, 0xa5, 0xaf, 0x8c, 0x5c, 0x62,
- 0xae, 0x15, 0x25, 0xa9, 0x79, 0xc5, 0x99, 0xf9, 0x79, 0xfe, 0x05, 0x25, 0x99, 0xf9, 0x79, 0xc5,
- 0xe1, 0xa9, 0x49, 0xc6, 0x21, 0x15, 0x42, 0x89, 0x5c, 0xc2, 0x20, 0xcd, 0x29, 0xf1, 0x29, 0x89,
- 0x25, 0x89, 0xf1, 0xc9, 0x19, 0x89, 0x99, 0x79, 0xf1, 0x99, 0x29, 0x12, 0x8c, 0x0a, 0x8c, 0x1a,
- 0x2c, 0x4e, 0x46, 0x8f, 0xee, 0xc9, 0x0b, 0x84, 0x80, 0xa4, 0x5d, 0x12, 0x4b, 0x12, 0x9d, 0x41,
- 0x92, 0x9e, 0x2e, 0xaf, 0xee, 0xc9, 0x4b, 0x95, 0xa0, 0x89, 0xe9, 0xe4, 0xe7, 0x66, 0x96, 0xa4,
- 0xe6, 0x16, 0x94, 0x54, 0x06, 0x09, 0xa0, 0xc9, 0xa5, 0x08, 0x19, 0x73, 0x71, 0xa6, 0xa5, 0xa6,
- 0xc6, 0x17, 0x24, 0x56, 0xa6, 0x16, 0x49, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x3a, 0x89, 0xbd, 0xba,
- 0x27, 0x2f, 0x94, 0x96, 0x9a, 0x1a, 0x00, 0x12, 0x43, 0xd2, 0xcc, 0x01, 0x13, 0x13, 0xb2, 0xe5,
- 0xe2, 0x85, 0x6b, 0x8a, 0x2f, 0xce, 0x4c, 0x97, 0x60, 0x56, 0x60, 0xd4, 0xe0, 0x71, 0x92, 0x7c,
- 0x75, 0x4f, 0x5e, 0x14, 0xa6, 0x28, 0x38, 0x33, 0x1d, 0x49, 0x2f, 0x37, 0x92, 0xb0, 0x15, 0x4b,
- 0xc7, 0x02, 0x79, 0x06, 0x27, 0xeb, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0,
- 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88,
- 0x52, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xf7, 0xcb, 0x4c, 0xca,
- 0x2c, 0x2a, 0x05, 0xbb, 0x56, 0x3f, 0x0f, 0xcc, 0xd6, 0x4f, 0x2d, 0xc9, 0x48, 0x62, 0x03, 0x87,
- 0x9d, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x69, 0x4a, 0xc0, 0x7d, 0x7a, 0x01, 0x00, 0x00,
-}
-
-func (m *ExtensionOptionsWeb3Tx) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ExtensionOptionsWeb3Tx) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *ExtensionOptionsWeb3Tx) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.FeePayerSig) > 0 {
- i -= len(m.FeePayerSig)
- copy(dAtA[i:], m.FeePayerSig)
- i = encodeVarintWeb3(dAtA, i, uint64(len(m.FeePayerSig)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.FeePayer) > 0 {
- i -= len(m.FeePayer)
- copy(dAtA[i:], m.FeePayer)
- i = encodeVarintWeb3(dAtA, i, uint64(len(m.FeePayer)))
- i--
- dAtA[i] = 0x12
- }
- if m.TypedDataChainID != 0 {
- i = encodeVarintWeb3(dAtA, i, uint64(m.TypedDataChainID))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintWeb3(dAtA []byte, offset int, v uint64) int {
- offset -= sovWeb3(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *ExtensionOptionsWeb3Tx) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.TypedDataChainID != 0 {
- n += 1 + sovWeb3(uint64(m.TypedDataChainID))
- }
- l = len(m.FeePayer)
- if l > 0 {
- n += 1 + l + sovWeb3(uint64(l))
- }
- l = len(m.FeePayerSig)
- if l > 0 {
- n += 1 + l + sovWeb3(uint64(l))
- }
- return n
-}
-
-func sovWeb3(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozWeb3(x uint64) (n int) {
- return sovWeb3(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *ExtensionOptionsWeb3Tx) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowWeb3
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ExtensionOptionsWeb3Tx: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ExtensionOptionsWeb3Tx: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field TypedDataChainID", wireType)
- }
- m.TypedDataChainID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowWeb3
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.TypedDataChainID |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field FeePayer", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowWeb3
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthWeb3
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthWeb3
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.FeePayer = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field FeePayerSig", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowWeb3
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthWeb3
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthWeb3
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.FeePayerSig = append(m.FeePayerSig[:0], dAtA[iNdEx:postIndex]...)
- if m.FeePayerSig == nil {
- m.FeePayerSig = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipWeb3(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthWeb3
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipWeb3(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowWeb3
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowWeb3
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowWeb3
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthWeb3
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupWeb3
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthWeb3
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthWeb3 = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowWeb3 = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupWeb3 = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/go.mod b/go.mod
index a5a516f40..38f59f412 100644
--- a/go.mod
+++ b/go.mod
@@ -1,88 +1,95 @@
module github.com/NibiruChain/nibiru
-go 1.21
+go 1.22.2
+
+toolchain go1.22.3
require (
+ cosmossdk.io/api v0.7.5 // indirect
+ cosmossdk.io/client/v2 v2.0.0-beta.1 // indirect
+ cosmossdk.io/core v0.11.0
cosmossdk.io/errors v1.0.1
- cosmossdk.io/math v1.3.0
- cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d
- github.com/CosmWasm/wasmd v0.44.0
- github.com/CosmWasm/wasmvm v1.5.0
- github.com/MakeNowJust/heredoc/v2 v2.0.1
- github.com/NibiruChain/collections v0.5.0
- github.com/armon/go-metrics v0.4.1
+ cosmossdk.io/log v1.3.1
+ cosmossdk.io/store v1.1.0
+ cosmossdk.io/tools/confix v0.1.1
+ cosmossdk.io/x/circuit v0.1.0 // indirect
+ cosmossdk.io/x/evidence v0.1.0
+ cosmossdk.io/x/feegrant v0.1.0
+ cosmossdk.io/x/upgrade v0.1.1
+ github.com/CosmWasm/wasmd v0.50.0
+ github.com/CosmWasm/wasmvm v1.5.2
+ github.com/NibiruChain/collections v0.50.0
+ github.com/cometbft/cometbft v0.38.6
+ github.com/cometbft/cometbft-db v0.9.1
+ github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
- // EVM-specific deps
- github.com/btcsuite/btcd v0.23.3
- github.com/btcsuite/btcd/btcutil v1.1.3
- github.com/cometbft/cometbft v0.37.4
- github.com/cometbft/cometbft-db v0.11.0
- github.com/cosmos/cosmos-proto v1.0.0-beta.4
- github.com/cosmos/cosmos-sdk v0.47.10
+ // migration to v0.50
+ github.com/cosmos/cosmos-sdk v0.51.0
github.com/cosmos/go-bip39 v1.0.0
- github.com/cosmos/gogoproto v1.4.10
- github.com/cosmos/ibc-go/v7 v7.3.2
+ github.com/cosmos/gogoproto v1.4.12
+ github.com/cosmos/ibc-go/v8 v8.0.0
github.com/ethereum/go-ethereum v1.10.17
- github.com/gogo/protobuf v1.3.3
+ github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/mock v1.6.0
- github.com/golang/protobuf v1.5.3
- github.com/google/gofuzz v1.2.0
+ github.com/golang/protobuf v1.5.4
+ github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1
- github.com/holiman/uint256 v1.2.4 // indirect
+ github.com/hashicorp/go-metrics v0.5.3
github.com/pkg/errors v0.9.1
- github.com/prometheus/client_golang v1.18.0
+ github.com/prometheus/client_golang v1.19.1
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.6.0
github.com/spf13/cobra v1.8.0
- github.com/spf13/pflag v1.0.5
- github.com/spf13/viper v1.16.0
- github.com/stretchr/testify v1.8.4
- github.com/tidwall/gjson v1.17.0
- github.com/tidwall/sjson v1.2.5
- github.com/tyler-smith/go-bip39 v1.1.0
- google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe
- google.golang.org/grpc v1.61.0
- google.golang.org/protobuf v1.32.0
- gopkg.in/yaml.v2 v2.4.0
+ github.com/spf13/pflag v1.0.5 // indirect
+ github.com/spf13/viper v1.18.2
+ github.com/stretchr/testify v1.9.0
+ google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be // indirect
+ google.golang.org/grpc v1.64.0
+ google.golang.org/protobuf v1.34.1 // indirect
+ gopkg.in/yaml.v2 v2.4.0 // indirect
)
require (
cosmossdk.io/collections v0.4.0
- github.com/davecgh/go-spew v1.1.1
- github.com/gorilla/websocket v1.5.0
- golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb
- golang.org/x/text v0.14.0
+ cosmossdk.io/math v1.3.0
+ github.com/cosmos/cosmos-db v1.0.2
+ github.com/cosmos/ibc-go/modules/capability v1.0.0
+ github.com/cosmos/rosetta v0.50.6
+ github.com/rs/cors v1.11.0
+ golang.org/x/net v0.25.0
+ golang.org/x/sync v0.7.0
)
require (
- cloud.google.com/go v0.111.0 // indirect
- cloud.google.com/go/compute v1.23.3 // indirect
- cloud.google.com/go/compute/metadata v0.2.3 // indirect
- cloud.google.com/go/iam v1.1.5 // indirect
- cloud.google.com/go/storage v1.30.1 // indirect
- cosmossdk.io/api v0.7.0 // indirect
- cosmossdk.io/core v0.10.0 // indirect
+ cloud.google.com/go v0.112.2 // indirect
+ cloud.google.com/go/auth v0.2.2 // indirect
+ cloud.google.com/go/auth/oauth2adapt v0.2.1 // indirect
+ cloud.google.com/go/compute/metadata v0.3.0 // indirect
+ cloud.google.com/go/iam v1.1.7 // indirect
+ cloud.google.com/go/storage v1.40.0 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
- cosmossdk.io/log v1.3.1 // indirect
- cosmossdk.io/tools/rosetta v0.2.1 // indirect
- filippo.io/edwards25519 v1.0.0 // indirect
+ cosmossdk.io/x/nft v0.1.0 // indirect
+ cosmossdk.io/x/tx v0.13.3 // indirect
+ filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
- github.com/99designs/keyring v1.2.1 // indirect
- github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
+ github.com/99designs/keyring v1.2.2 // indirect
+ github.com/DataDog/datadog-go v4.8.3+incompatible // indirect
github.com/DataDog/zstd v1.5.5 // indirect
+ github.com/Microsoft/go-winio v0.6.1 // indirect
+ github.com/PuerkitoBio/purell v1.1.1 // indirect
+ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
- github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
- github.com/aws/aws-sdk-go v1.44.203 // indirect
+ github.com/aws/aws-sdk-go v1.51.25 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
- github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
- github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
+ github.com/bits-and-blooms/bitset v1.10.0 // indirect
+ github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
- github.com/cespare/xxhash/v2 v2.2.0 // indirect
+ github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
@@ -91,150 +98,155 @@ require (
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
- github.com/confio/ics23/go v0.9.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
- github.com/cosmos/cosmos-db v1.0.2 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
- github.com/cosmos/iavl v0.21.0-beta.1 // indirect
+ github.com/cosmos/iavl v1.1.4 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
- github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect
+ github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
- github.com/creachadair/taskgroup v0.4.2 // indirect
- github.com/danieljoos/wincred v1.1.2 // indirect
+ github.com/creachadair/atomicfile v0.3.4 // indirect
+ github.com/creachadair/tomledit v0.0.26 // indirect
+ github.com/danieljoos/wincred v1.2.1 // indirect
+ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
- github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
+ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
- github.com/docker/distribution v2.8.2+incompatible // indirect
+ github.com/distribution/reference v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
- github.com/edsrzf/mmap-go v1.0.0 // indirect
- github.com/felixge/httpsnoop v1.0.2 // indirect
- github.com/fsnotify/fsnotify v1.6.0 // indirect
- github.com/getsentry/sentry-go v0.23.0 // indirect
+ github.com/emicklei/dot v1.6.2 // indirect
+ github.com/fatih/color v1.17.0 // indirect
+ github.com/felixge/httpsnoop v1.0.4 // indirect
+ github.com/fsnotify/fsnotify v1.7.0 // indirect
+ github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gin-gonic/gin v1.9.1 // indirect
- github.com/go-kit/kit v0.12.0 // indirect
+ github.com/go-kit/kit v0.13.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
- github.com/go-logr/logr v1.2.4 // indirect
+ github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
- github.com/golang/glog v1.1.2 // indirect
+ github.com/golang/glog v1.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/s2a-go v0.1.7 // indirect
- github.com/google/uuid v1.4.0 // indirect
+ github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
- github.com/googleapis/gax-go/v2 v2.12.0 // indirect
- github.com/gorilla/handlers v1.5.1 // indirect
- github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
+ github.com/googleapis/gax-go/v2 v2.12.3 // indirect
+ github.com/gorilla/handlers v1.5.2 // indirect
+ github.com/gorilla/websocket v1.5.1 // indirect
+ github.com/goware/urlx v0.3.2 // indirect
+ github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
- github.com/gtank/merlin v0.1.1 // indirect
- github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.4 // indirect
+ github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
+ github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
- github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
+ github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
- github.com/hdevalence/ed25519consensus v0.1.0 // indirect
- github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
+ github.com/hashicorp/yamux v0.1.1 // indirect
+ github.com/hdevalence/ed25519consensus v0.2.0 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
+ github.com/iancoleman/strcase v0.3.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
github.com/jmhodges/levigo v1.0.0 // indirect
- github.com/klauspost/compress v1.16.7 // indirect
+ github.com/klauspost/compress v1.17.8 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
- github.com/lib/pq v1.10.7 // indirect
+ github.com/lib/pq v1.10.9 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
- github.com/linxGnu/grocksdb v1.8.12 // indirect
+ github.com/linxGnu/grocksdb v1.8.14 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
- github.com/mattn/go-runewidth v0.0.9 // indirect
- github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
- github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
- github.com/olekukonko/tablewriter v0.0.5 // indirect
+ github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
+ github.com/oklog/run v1.1.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
- github.com/pelletier/go-toml/v2 v2.0.8 // indirect
- github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
- github.com/prometheus/client_model v0.5.0 // indirect
- github.com/prometheus/common v0.45.0 // indirect
- github.com/prometheus/procfs v0.12.0 // indirect
- github.com/prometheus/tsdb v0.7.1 // indirect
+ github.com/pelletier/go-toml/v2 v2.2.2 // indirect
+ github.com/petermattis/goid v0.0.0-20240327183114-c42a807a84ba // indirect
+ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
+ github.com/prometheus/client_model v0.6.1 // indirect
+ github.com/prometheus/common v0.53.0 // indirect
+ github.com/prometheus/procfs v0.14.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
- github.com/rjeczalik/notify v0.9.1 // indirect
- github.com/rogpeppe/go-internal v1.11.0 // indirect
- github.com/rs/cors v1.8.3 // indirect
+ github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/zerolog v1.32.0 // indirect
+ github.com/sagikazarmark/locafero v0.4.0 // indirect
+ github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
- github.com/spf13/afero v1.9.5 // indirect
- github.com/spf13/jwalterweatherman v1.1.0 // indirect
- github.com/stretchr/objx v0.5.0 // indirect
- github.com/subosito/gotenv v1.4.2 // indirect
+ github.com/sourcegraph/conc v0.3.0 // indirect
+ github.com/spf13/afero v1.11.0 // indirect
+ github.com/subosito/gotenv v1.6.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
- github.com/tidwall/btree v1.6.0 // indirect
- github.com/tidwall/match v1.1.1 // indirect
- github.com/tidwall/pretty v1.2.0 // indirect
+ github.com/tidwall/btree v1.7.0 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
- github.com/ulikunitz/xz v0.5.11 // indirect
+ github.com/ulikunitz/xz v0.5.12 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
- go.etcd.io/bbolt v1.3.8 // indirect
+ go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
- go.opentelemetry.io/otel v1.19.0 // indirect
- go.opentelemetry.io/otel/metric v1.19.0 // indirect
- go.opentelemetry.io/otel/trace v1.19.0 // indirect
- golang.org/x/crypto v0.21.0 // indirect
- golang.org/x/net v0.23.0 // indirect
- golang.org/x/oauth2 v0.16.0 // indirect
- golang.org/x/sync v0.5.0 // indirect
- golang.org/x/sys v0.18.0 // indirect
- golang.org/x/term v0.18.0 // indirect
- google.golang.org/api v0.149.0 // indirect
- google.golang.org/appengine v1.6.8 // indirect
- google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect
- google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect
+ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.50.0 // indirect
+ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 // indirect
+ go.opentelemetry.io/otel v1.25.0 // indirect
+ go.opentelemetry.io/otel/metric v1.25.0 // indirect
+ go.opentelemetry.io/otel/trace v1.25.0 // indirect
+ go.uber.org/multierr v1.11.0 // indirect
+ golang.org/x/crypto v0.23.0 // indirect
+ golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
+ golang.org/x/mod v0.17.0 // indirect
+ golang.org/x/oauth2 v0.19.0 // indirect
+ golang.org/x/sys v0.20.0 // indirect
+ golang.org/x/term v0.20.0 // indirect
+ golang.org/x/text v0.15.0 // indirect
+ golang.org/x/time v0.5.0 // indirect
+ golang.org/x/tools v0.21.0 // indirect
+ google.golang.org/api v0.175.0 // indirect
+ google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be // indirect
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
+ gotest.tools/v3 v3.5.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
pgregory.net/rapid v1.1.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
replace (
- cosmossdk.io/api => cosmossdk.io/api v0.3.1
+ github.com/cosmos/cosmos-sdk v0.51.0 => github.com/cosmos/cosmos-sdk v0.50.6
- github.com/cosmos/iavl => github.com/cosmos/iavl v0.20.0
+ // github.com/cosmos/iavl => github.com/cosmos/iavl v0.20.0
github.com/ethereum/go-ethereum => ./geth
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
-
github.com/linxGnu/grocksdb => github.com/linxGnu/grocksdb v1.8.12
// pin version! 126854af5e6d has issues with the store so that queries fail
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
+
+// replace github.com/cometbft/cometbft/libs/os => github.com/cometbft/cometbft/libs/os v1.0.0-alpha.2.0.20240429102542-490e9bc3de65
diff --git a/go.sum b/go.sum
index 77a205df5..17db634d6 100644
--- a/go.sum
+++ b/go.sum
@@ -4,7 +4,6 @@ cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSR
cloud.google.com/go v0.43.0/go.mod h1:BOSR3VbTLkk6FDC/TcffxP4NF/FFBGA5ku+jvKOP7pg=
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
-cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
@@ -18,7 +17,6 @@ cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOY
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI=
cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk=
-cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY=
cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg=
cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8=
cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0=
@@ -34,8 +32,8 @@ cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w9
cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc=
cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU=
cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA=
-cloud.google.com/go v0.111.0 h1:YHLKNupSD1KqjDbQ3+LVdQ81h/UJbJyZG203cEfnQgM=
-cloud.google.com/go v0.111.0/go.mod h1:0mibmpKP1TyOOFYQY5izo0LnT+ecvOQ0Sg3OdmMiNRU=
+cloud.google.com/go v0.112.2 h1:ZaGT6LiG7dBzi6zNOvVZwacaXlmf3lRqnC4DQzqyRQw=
+cloud.google.com/go v0.112.2/go.mod h1:iEqjp//KquGIJV/m+Pk3xecgKNhV+ry+vVTsy4TbDms=
cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw=
cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY=
cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI=
@@ -50,6 +48,10 @@ cloud.google.com/go/asset v1.8.0/go.mod h1:mUNGKhiqIdbr8X7KNayoYvyc4HbbFO9URsjby
cloud.google.com/go/assuredworkloads v1.5.0/go.mod h1:n8HOZ6pff6re5KYfBXcFvSViQjDwxFkAkmUFffJRbbY=
cloud.google.com/go/assuredworkloads v1.6.0/go.mod h1:yo2YOk37Yc89Rsd5QMVECvjaMKymF9OP+QXWlKXUkXw=
cloud.google.com/go/assuredworkloads v1.7.0/go.mod h1:z/736/oNmtGAyU47reJgGN+KVoYoxeLBoj4XkKYscNI=
+cloud.google.com/go/auth v0.2.2 h1:gmxNJs4YZYcw6YvKRtVBaF2fyUE6UrWPyzU8jHvYfmI=
+cloud.google.com/go/auth v0.2.2/go.mod h1:2bDNJWtWziDT3Pu1URxHHbkHE/BbOCuyUiKIGcNvafo=
+cloud.google.com/go/auth/oauth2adapt v0.2.1 h1:VSPmMmUlT8CkIZ2PzD9AlLN+R3+D1clXMWHHa6vG/Ag=
+cloud.google.com/go/auth/oauth2adapt v0.2.1/go.mod h1:tOdK/k+D2e4GEwfBRA48dKNQiDsqIXxLh7VU319eV0g=
cloud.google.com/go/automl v1.5.0/go.mod h1:34EjfoFGMZ5sgJ9EoLsRtdPSNZLcfflJR39VbVNS2M0=
cloud.google.com/go/automl v1.6.0/go.mod h1:ugf8a6Fx+zP0D59WLhqgTDsQI9w07o64uf/Is3Nh5p8=
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
@@ -73,10 +75,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz
cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU=
cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U=
cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU=
-cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiVlk=
-cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI=
-cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
-cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
+cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc=
+cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I=
cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4=
cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0=
@@ -114,8 +114,8 @@ cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y97
cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc=
cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY=
cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc=
-cloud.google.com/go/iam v1.1.5 h1:1jTsCu4bcsNsE4iiqNT5SHwrDRCfRmIaaaVFhRveTJI=
-cloud.google.com/go/iam v1.1.5/go.mod h1:rB6P/Ic3mykPbFio+vo7403drjlgvoWfYpJhMXEbzv8=
+cloud.google.com/go/iam v1.1.7 h1:z4VHOhwKLF/+UYXAJDFwGtNF0b6gjsW1Pk9Ml0U/IoM=
+cloud.google.com/go/iam v1.1.7/go.mod h1:J4PMPg8TtyurAUvSmPj8FF3EDgY1SPRZxcUGrn7WXGA=
cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic=
cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI=
cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8=
@@ -173,12 +173,11 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
-cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y=
cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc=
cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s=
-cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM=
-cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E=
+cloud.google.com/go/storage v1.40.0 h1:VEpDQV5CJxFmJ6ueWNsKxcr1QAYOXEgxDa+sBbJahPw=
+cloud.google.com/go/storage v1.40.0/go.mod h1:Rrj7/hKlG87BLqDJYtwR0fbPld8uJPbQ2ucUMY7Ir0g=
cloud.google.com/go/talent v1.1.0/go.mod h1:Vl4pt9jiHKvOgF9KoZo6Kob9oV4lwd/ZD5Cto54zDRw=
cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g=
cloud.google.com/go/videointelligence v1.6.0/go.mod h1:w0DIDlVRKtwPCn/C4iwZIJdvC69yInhW0cfi+p546uU=
@@ -191,12 +190,14 @@ cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuW
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE=
-cosmossdk.io/api v0.3.1 h1:NNiOclKRR0AOlO4KIqeaG6PS6kswOMhHD0ir0SscNXE=
-cosmossdk.io/api v0.3.1/go.mod h1:DfHfMkiNA2Uhy8fj0JJlOCYOBp4eWUUJ1te5zBGNyIw=
+cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ=
+cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
+cosmossdk.io/client/v2 v2.0.0-beta.1 h1:XkHh1lhrLYIT9zKl7cIOXUXg2hdhtjTPBUfqERNA1/Q=
+cosmossdk.io/client/v2 v2.0.0-beta.1/go.mod h1:JEUSu9moNZQ4kU3ir1DKD5eU4bllmAexrGWjmb9k8qU=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
-cosmossdk.io/core v0.10.0 h1:NP28Ol9YyRODmZLJg2ko/mUl40hMegeMzhJnG+XPkcY=
-cosmossdk.io/core v0.10.0/go.mod h1:MygXNld9DvMgYY4yE76DM/mdZpgfeyRjy6FPjEEehlY=
+cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo=
+cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w=
cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc=
cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU=
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
@@ -205,52 +206,65 @@ cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI=
cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
-cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d h1:E/8y0oG3u9hBR8l4F9MtC0LdZIamPCUwUoLlrHrX86I=
-cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d/go.mod h1:xbjky3L3DJEylaho6gXplkrMvJ5sFgv+qNX+Nn47bzY=
-cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw=
-cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw=
+cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk=
+cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng=
+cosmossdk.io/tools/confix v0.1.1 h1:aexyRv9+y15veH3Qw16lxQwo+ki7r2I+g0yNTEFEQM8=
+cosmossdk.io/tools/confix v0.1.1/go.mod h1:nQVvP1tHsGXS83PonPVWJtSbddIqyjEw99L4M3rPJyQ=
+cosmossdk.io/x/circuit v0.1.0 h1:IAej8aRYeuOMritczqTlljbUVHq1E85CpBqaCTwYgXs=
+cosmossdk.io/x/circuit v0.1.0/go.mod h1:YDzblVE8+E+urPYQq5kq5foRY/IzhXovSYXb4nwd39w=
+cosmossdk.io/x/evidence v0.1.0 h1:J6OEyDl1rbykksdGynzPKG5R/zm6TacwW2fbLTW4nCk=
+cosmossdk.io/x/evidence v0.1.0/go.mod h1:hTaiiXsoiJ3InMz1uptgF0BnGqROllAN8mwisOMMsfw=
+cosmossdk.io/x/feegrant v0.1.0 h1:c7s3oAq/8/UO0EiN1H5BIjwVntujVTkYs35YPvvrdQk=
+cosmossdk.io/x/feegrant v0.1.0/go.mod h1:4r+FsViJRpcZif/yhTn+E0E6OFfg4n0Lx+6cCtnZElU=
+cosmossdk.io/x/nft v0.1.0 h1:VhcsFiEK33ODN27kxKLa0r/CeFd8laBfbDBwYqCyYCM=
+cosmossdk.io/x/nft v0.1.0/go.mod h1:ec4j4QAO4mJZ+45jeYRnW7awLHby1JZANqe1hNZ4S3g=
+cosmossdk.io/x/tx v0.13.3 h1:Ha4mNaHmxBc6RMun9aKuqul8yHiL78EKJQ8g23Zf73g=
+cosmossdk.io/x/tx v0.13.3/go.mod h1:I8xaHv0rhUdIvIdptKIqzYy27+n2+zBVaxO6fscFhys=
+cosmossdk.io/x/upgrade v0.1.1 h1:aoPe2gNvH+Gwt/Pgq3dOxxQVU3j5P6Xf+DaUJTDZATc=
+cosmossdk.io/x/upgrade v0.1.1/go.mod h1:MNLptLPcIFK9CWt7Ra//8WUZAxweyRDNcbs5nkOcQy0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
-filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek=
-filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
+filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
+filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw=
git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4=
-github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o=
-github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA=
-github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
-github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
+github.com/99designs/keyring v1.2.2 h1:pZd3neh/EmUzWONb35LxQfvuY7kiSXAq3HQd97+XBn0=
+github.com/99designs/keyring v1.2.2/go.mod h1:wes/FrByc8j7lFOAGLGSNEg8f/PaI3cgTBqhFkHUrPk=
+github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
+github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
-github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM=
-github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4=
-github.com/CosmWasm/wasmd v0.44.0 h1:2sbcoCAvfjCs1O0SWt53xULKjkV06dbSFthEViIC6Zg=
-github.com/CosmWasm/wasmd v0.44.0/go.mod h1:tDyYN050qUcdd7LOxGeo2e185sEShyO3nJGl2Cf59+k=
-github.com/CosmWasm/wasmvm v1.5.0 h1:3hKeT9SfwfLhxTGKH3vXaKFzBz1yuvP8SlfwfQXbQfw=
-github.com/CosmWasm/wasmvm v1.5.0/go.mod h1:fXB+m2gyh4v9839zlIXdMZGeLAxqUdYdFQqYsTha2hc=
+github.com/CosmWasm/wasmd v0.50.0 h1:NVaGqCSTRfb9UTDHJwT6nQIWcb6VjlQl88iI+u1+qjE=
+github.com/CosmWasm/wasmd v0.50.0/go.mod h1:UjmShW4l9YxaMytwJZ7IB7MWzHiynSZP3DdWrG0FRtk=
+github.com/CosmWasm/wasmvm v1.5.2 h1:+pKB1Mz9GZVt1vadxB+EDdD1FOz3dMNjIKq/58/lrag=
+github.com/CosmWasm/wasmvm v1.5.2/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
+github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q=
+github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
-github.com/MakeNowJust/heredoc/v2 v2.0.1 h1:rlCHh70XXXv7toz95ajQWOWQnN4WNLt0TdpZYIR/J6A=
-github.com/MakeNowJust/heredoc/v2 v2.0.1/go.mod h1:6/2Abh5s+hc3g9nbWLe9ObDIOhaRrqsyY9MWy+4JdRM=
-github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
-github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE=
-github.com/NibiruChain/collections v0.5.0 h1:33pXpVTe1PK/tfdZlAJF1JF7AdzGNARG+iL9G/z3X7k=
-github.com/NibiruChain/collections v0.5.0/go.mod h1:43L6yjuF0BMre/mw4gqn/kUOZz1c2Y3huZ/RQfBFrOQ=
+github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
+github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
+github.com/NibiruChain/collections v0.50.0 h1:zjwZ17G1f/0hoKUeoljIQval0HERF8NmojfQYKEOymw=
+github.com/NibiruChain/collections v0.50.0/go.mod h1:u3NETehzjViSEZLmSjps0Akd8mWVfw3FXSh8lswf5PU=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
+github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
+github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
+github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
-github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o=
github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
@@ -265,7 +279,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
-github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
@@ -275,15 +288,13 @@ github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
-github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA=
-github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
-github.com/aws/aws-sdk-go v1.44.203 h1:pcsP805b9acL3wUqa4JR2vg1k2wnItkDYNvfmcy6F+U=
-github.com/aws/aws-sdk-go v1.44.203/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
+github.com/aws/aws-sdk-go v1.51.25 h1:DjTT8mtmsachhV6yrXR8+yhnG6120dazr720nopRsls=
+github.com/aws/aws-sdk-go v1.51.25/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/aws/aws-sdk-go-v2 v1.2.0/go.mod h1:zEQs02YRBw1DjK0PoJv3ygDYOFTre1ejlJWl8FwAuQo=
github.com/aws/aws-sdk-go-v2/config v1.1.1/go.mod h1:0XsVy9lBI/BCXm+2Tuvt39YmdHwS5unDQmxZOYe8F5Y=
@@ -294,6 +305,7 @@ github.com/aws/aws-sdk-go-v2/service/route53 v1.1.1/go.mod h1:rLiOUrPLW/Er5kRcQ7
github.com/aws/aws-sdk-go-v2/service/sso v1.1.1/go.mod h1:SuZJxklHxLAXgLTc1iFXbEWkXs7QRTQpCLGaKIprQW0=
github.com/aws/aws-sdk-go-v2/service/sts v1.1.1/go.mod h1:Wi0EBZwiz/K44YliU0EKxqTCJGUfYTWXrrBwkq736bM=
github.com/aws/smithy-go v1.1.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
+github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -303,26 +315,20 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s=
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
+github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88=
+github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs=
-github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
+github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c=
github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y=
-github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
-github.com/btcsuite/btcd v0.23.3 h1:4KH/JKy9WiCd+iUS9Mu0Zp7Dnj17TGdKrg9xc/FGj24=
-github.com/btcsuite/btcd v0.23.3/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
-github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
-github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
-github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
-github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
-github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
-github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
+github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ensb7o3sC0=
+github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ=
github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0=
-github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
@@ -337,8 +343,8 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku
github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
-github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
-github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
+github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY=
+github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE=
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
@@ -350,13 +356,12 @@ github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq
github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4=
github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
-github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
-github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
-github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
+github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
@@ -402,12 +407,10 @@ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE
github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI=
github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA=
github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M=
-github.com/cometbft/cometbft v0.37.4 h1:xyvvEqlyfK8MgNIIKVJaMsuIp03wxOcFmVkT26+Ikpg=
-github.com/cometbft/cometbft v0.37.4/go.mod h1:Cmg5Hp4sNpapm7j+x0xRyt2g0juQfmB752ous+pA0G8=
-github.com/cometbft/cometbft-db v0.11.0 h1:M3Lscmpogx5NTbb1EGyGDaFRdsoLWrUWimFEyf7jej8=
-github.com/cometbft/cometbft-db v0.11.0/go.mod h1:GDPJAC/iFHNjmZZPN8V8C1yr/eyityhi2W1hz2MGKSc=
-github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4=
-github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak=
+github.com/cometbft/cometbft v0.38.6 h1:QSgpCzrGWJ2KUq1qpw+FCfASRpE27T6LQbfEHscdyOk=
+github.com/cometbft/cometbft v0.38.6/go.mod h1:8rSPxzUJYquCN8uuBgbUHOMg2KAwvr7CyUw+6ukO4nw=
+github.com/cometbft/cometbft-db v0.9.1 h1:MIhVX5ja5bXNHF8EYrThkG9F7r9kSfv8BX4LWaxWJ4M=
+github.com/cometbft/cometbft-db v0.9.1/go.mod h1:iliyWaoV0mRwBJoizElCwwRA9Tf7jZJOURcRZF9m60U=
github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ=
github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q=
@@ -422,57 +425,62 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk=
github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis=
-github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0E=
-github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U=
github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAKs=
github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA=
-github.com/cosmos/cosmos-proto v1.0.0-beta.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48OdY7lIWTLG7oU=
-github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co=
-github.com/cosmos/cosmos-sdk v0.47.10 h1:Wxf5yEN3jZbG4fftxAMKB6rpd8ME0mxuCVihpz65dt0=
-github.com/cosmos/cosmos-sdk v0.47.10/go.mod h1:UWpgWkhcsBIATS68uUC0del7IiBN4hPv/vqg8Zz23uw=
-github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
+github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
+github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
+github.com/cosmos/cosmos-sdk v0.50.6 h1:efR3MsvMHX5sxS3be+hOobGk87IzlZbSpsI2x/Vw3hk=
+github.com/cosmos/cosmos-sdk v0.50.6/go.mod h1:lVkRY6cdMJ0fG3gp8y4hFrsKZqF4z7y0M2UXFb9Yt40=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE=
github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI=
github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU=
-github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI=
-github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek=
-github.com/cosmos/iavl v0.20.0 h1:fTVznVlepH0KK8NyKq8w+U7c2L6jofa27aFX6YGlm38=
-github.com/cosmos/iavl v0.20.0/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A=
-github.com/cosmos/ibc-go/v7 v7.3.2 h1:FeUDcBX7VYY0e0iRmcVkPPUjYfAqIc//QuHXo8JHz9c=
-github.com/cosmos/ibc-go/v7 v7.3.2/go.mod h1:IMeOXb7gwpZ+/nOG5BuUkdW4weM1ezvN4PQPws4uzOI=
+github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE=
+github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY=
+github.com/cosmos/iavl v1.1.4 h1:Z0cVVjeQqOUp78/nWt/uhQy83vYluWlAMGQ4zbH9G34=
+github.com/cosmos/iavl v1.1.4/go.mod h1:vCYmRQUJU1wwj0oRD3wMEtOM9sJNDP+GFMaXmIxZ/rU=
+github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE=
+github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco=
+github.com/cosmos/ibc-go/v8 v8.0.0 h1:QKipnr/NGwc+9L7NZipURvmSIu+nw9jOIWTJuDBqOhg=
+github.com/cosmos/ibc-go/v8 v8.0.0/go.mod h1:C6IiJom0F3cIQCD5fKwVPDrDK9j/xTu563AWuOmXois=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0=
-github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw=
-github.com/cosmos/ledger-cosmos-go v0.12.4/go.mod h1:fjfVWRf++Xkygt9wzCsjEBdjcf7wiiY35fv3ctT+k4M=
+github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM=
+github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8=
+github.com/cosmos/rosetta v0.50.6 h1:+Hgog7CUHevZuPxZaoqR8klTs1G3ukAcoVTIMporBmw=
+github.com/cosmos/rosetta v0.50.6/go.mod h1:KUnwp2i9W0766Dv78HYNV5YKym+imaKmDvXc2W0Y1wA=
github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM=
github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFgWl/ENIznEoYQI4=
-github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
-github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
-github.com/creachadair/taskgroup v0.4.2 h1:jsBLdAJE42asreGss2xZGZ8fJra7WtwnHWeJFxv2Li8=
-github.com/creachadair/taskgroup v0.4.2/go.mod h1:qiXUOSrbwAY3u0JPGTzObbE3yf9hcXHDKBZ2ZjpCbgM=
+github.com/creachadair/atomicfile v0.3.4 h1:AjNK7To+S1p+nk7uJXJMZFpcV9XHOyAaULyDeU6LEqM=
+github.com/creachadair/atomicfile v0.3.4/go.mod h1:ByEUbfQyms+tRtE7Wk7WdS6PZeyMzfSFlNX1VoKEh6E=
+github.com/creachadair/mds v0.13.3 h1:OqXNRorXKsuvfjor+0ixtrpA4IINApH8zgm23XLlngk=
+github.com/creachadair/mds v0.13.3/go.mod h1:4vrFYUzTXMJpMBU+OA292I6IUxKWCCfZkgXg+/kBZMo=
+github.com/creachadair/tomledit v0.0.26 h1:MoDdgHIHZ5PctBVsAZDjxdxreWUEa9ObPKTRkk5PPwA=
+github.com/creachadair/tomledit v0.0.26/go.mod h1:SJi1OxKpMyR141tq1lzsbPtIg3j8TeVPM/ZftfieD7o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
-github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
-github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
+github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs=
+github.com/danieljoos/wincred v1.2.1/go.mod h1:uGaFL9fDn3OLTvzCGulzE+SzjEe5NGlh5FdCcyfPwps=
github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
+github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
-github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
+github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=
+github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
-github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4=
-github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc=
+github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg=
+github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
@@ -490,9 +498,9 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y=
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
+github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
+github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
-github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
-github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v1.6.2/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
@@ -510,8 +518,9 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
-github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
+github.com/emicklei/dot v1.6.2 h1:08GN+DD79cy/tzN6uLCT84+2Wk9u+wvqP+Hkx/dIR8A=
+github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s=
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -525,10 +534,10 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
-github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
-github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o=
-github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
-github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
+github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
+github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
+github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
+github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
@@ -539,15 +548,15 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
-github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
-github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
+github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
+github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
-github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE=
-github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
+github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
+github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
@@ -566,8 +575,9 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
-github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4=
-github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs=
+github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU=
+github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg=
+github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
@@ -576,8 +586,8 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
-github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
-github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
+github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
+github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E=
@@ -599,10 +609,12 @@ github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
-github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
-github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
+github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
+github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
+github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
+github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
@@ -615,13 +627,12 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG
github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c=
github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0=
github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4=
-github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog=
github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
-github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo=
-github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
+github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
+github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -656,8 +667,8 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
-github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
-github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
+github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
+github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
@@ -708,7 +719,6 @@ github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
-github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
@@ -722,8 +732,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
-github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8=
github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8=
github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg=
@@ -738,14 +748,13 @@ github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99
github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c=
github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo=
github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY=
-github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas=
-github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU=
+github.com/googleapis/gax-go/v2 v2.12.3 h1:5/zPPDvw8Q1SuXjrqrZslrqT7dL/uJT2CQii/cLCKqA=
+github.com/googleapis/gax-go/v2 v2.12.3/go.mod h1:AKloxT6GtNbaLm8QTNSidHUVsHYcBHwWRvkNFJUQcS4=
github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4=
-github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
-github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
-github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
+github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE=
+github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
@@ -754,13 +763,15 @@ github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWS
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
-github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
+github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
+github.com/goware/urlx v0.3.2 h1:gdoo4kBHlkqZNaf6XlQ12LGtQOmpKJrR04Rc3RnpJEo=
+github.com/goware/urlx v0.3.2/go.mod h1:h8uwbJy68o+tQXCGZNa9D73WN8n0r9OBae5bUnLcgjw=
github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI=
-github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw=
-github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y=
+github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
+github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
@@ -769,15 +780,10 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0Q
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
-github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
-github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is=
github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
-github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc=
-github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o=
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
-github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE=
github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
@@ -785,11 +791,17 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-getter v1.7.4 h1:3yQjWuxICvSpYwqSayAdKRFcvBl1y/vogCxczWSmix0=
github.com/hashicorp/go-getter v1.7.4/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744=
+github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
+github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE=
+github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
+github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI=
+github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0=
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
@@ -797,38 +809,40 @@ github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoD
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
-github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE=
+github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
-github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs=
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
+github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
+github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
-github.com/hdevalence/ed25519consensus v0.1.0 h1:jtBwzzcHuTmFrQN6xQZn6CQEO/V9f7HsjsjeEZ6auqU=
-github.com/hdevalence/ed25519consensus v0.1.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo=
-github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
+github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
+github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
+github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU=
+github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
-github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
-github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
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/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ=
github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
+github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
+github.com/iancoleman/strcase v0.3.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/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ=
@@ -848,13 +862,12 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y
github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE=
github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0=
github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po=
-github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
-github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
-github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
+github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls=
+github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
@@ -889,8 +902,8 @@ github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs
github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
-github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
-github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
+github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
+github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 h1:2U0HzY8BJ8hVwDKIzp7y4voR9CX/nvcfymLmg2UiOio=
github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
@@ -899,7 +912,6 @@ github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPR
github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
-github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
@@ -917,8 +929,8 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
-github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
-github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
+github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
+github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
@@ -940,6 +952,7 @@ github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
@@ -955,17 +968,12 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
-github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-tty v0.0.0-20180907095812-13ff1204f104/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
-github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
-github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM=
-github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94=
-github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM=
github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g=
github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
@@ -983,7 +991,6 @@ github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
-github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A=
github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
@@ -1013,24 +1020,27 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
+github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a h1:dlRvE5fWabOchtH7znfiFCcOvmIYgOeAS5ifBXBlh9Q=
+github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
+github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
+github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
-github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
-github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
-github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
+github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
+github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
-github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q=
-github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo=
+github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q=
+github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
@@ -1056,14 +1066,14 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T
github.com/paulbellamy/ratecounter v0.2.0/go.mod h1:Hfx1hDpSGoqxkVVpBi/IlYD7kChlfo5C6hzIHwPqfFE=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
-github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
-github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
+github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
+github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
-github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 h1:hDSdbBuw3Lefr6R18ax0tZ2BJeNB3NehB3trOwYBsdU=
-github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
+github.com/petermattis/goid v0.0.0-20240327183114-c42a807a84ba h1:3jPgmsFGBID1wFfU2AbYocNcN4wqU68UaHSdMjiw/7U=
+github.com/petermattis/goid v0.0.0-20240327183114-c42a807a84ba/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
@@ -1075,10 +1085,10 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
-github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
github.com/pkg/term v0.0.0-20180730021639-bffc007b7fd5/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
+github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
@@ -1086,16 +1096,16 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
-github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
-github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
+github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
+github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
-github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
-github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
+github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
+github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
@@ -1104,17 +1114,16 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
-github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM=
-github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY=
+github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE=
+github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
-github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
-github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
-github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA=
+github.com/prometheus/procfs v0.14.0 h1:Lw4VdGGoKEZilJsayHf0B+9YgLGREba2C6xr+Fdfq6s=
+github.com/prometheus/procfs v0.14.0/go.mod h1:XL+Iwz8k8ZabyZfMFHPiilCniixqQarAy5Mu67pHlNQ=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
@@ -1124,26 +1133,27 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqn
github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4=
github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI=
github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc=
-github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE=
github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
-github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
-github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
+github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
+github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
-github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo=
-github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
+github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po=
+github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
-github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
-github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
+github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
+github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
+github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
+github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
@@ -1165,12 +1175,14 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
+github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
+github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
-github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM=
-github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ=
+github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
+github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
@@ -1179,15 +1191,13 @@ github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tL
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
-github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
-github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
-github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc=
-github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg=
+github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
+github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
@@ -1195,8 +1205,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
-github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
+github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
+github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
@@ -1208,30 +1219,23 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
-github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
-github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
+github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
+github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
+github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
-github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg=
-github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
+github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI=
+github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
-github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
-github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
-github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
-github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
-github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM=
-github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
-github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4=
github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
@@ -1243,8 +1247,6 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs=
github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs=
-github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
-github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
@@ -1252,13 +1254,11 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
-github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
-github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
+github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
+github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
-github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
-github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y=
github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
@@ -1269,7 +1269,6 @@ github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPyS
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
-github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -1284,8 +1283,8 @@ github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp
github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw=
github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
-go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=
-go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
+go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6ejyAJc760RwW4SnVDiTYTzwnXuxo=
+go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY=
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
@@ -1298,24 +1297,34 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
-go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs=
-go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY=
-go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE=
-go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8=
-go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o=
-go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A=
-go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg=
-go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo=
+go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.50.0 h1:zvpPXY7RfYAGSdYQLjp6zxdJNSYD/+FFoCTQN9IPxBs=
+go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.50.0/go.mod h1:BMn8NB1vsxTljvuorms2hyOs8IBuuBEq0pl7ltOfy30=
+go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 h1:cEPbyTSEHlQR89XVlyo78gqluF8Y3oMeBkXGWzQsfXY=
+go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0/go.mod h1:DKdbWcT4GH1D0Y3Sqt/PFXt2naRKDWtU+eE6oLdFNA8=
+go.opentelemetry.io/otel v1.25.0 h1:gldB5FfhRl7OJQbUHt/8s0a7cE8fbsPAtdpRaApKy4k=
+go.opentelemetry.io/otel v1.25.0/go.mod h1:Wa2ds5NOXEMkCmUou1WA7ZBfLTHWIsp034OVD7AO+Vg=
+go.opentelemetry.io/otel/metric v1.25.0 h1:LUKbS7ArpFL/I2jJHdJcqMGxkRdxpPHE0VU/D4NuEwA=
+go.opentelemetry.io/otel/metric v1.25.0/go.mod h1:rkDLUSd2lC5lq2dFNrX9LGAbINP5B7WBkC78RXCpH5s=
+go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw=
+go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc=
+go.opentelemetry.io/otel/trace v1.25.0 h1:tqukZGLwQYRIFtSQM2u2+yfMVTgGVeqRLPUYx1Dq6RM=
+go.opentelemetry.io/otel/trace v1.25.0/go.mod h1:hCCs70XM/ljO+BeQkyFnbK28SBIJ/Emuha+ccrCRT7I=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
+go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
+go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
+go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
+go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
+go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
+go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -1329,7 +1338,6 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190909091759-094676da4a83/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@@ -1337,13 +1345,12 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
-golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
-golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
+golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
+golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -1359,8 +1366,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
-golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb h1:xIApU0ow1zwMa2uL1VDNeQlNVFTWMQxZUZCMDy0Q4Us=
-golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
+golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
+golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
@@ -1391,8 +1398,8 @@ golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
-golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
-golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
+golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -1435,7 +1442,6 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
-golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
@@ -1444,7 +1450,6 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
-golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
@@ -1460,8 +1465,9 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
-golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
+golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
+golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1487,8 +1493,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A=
-golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ=
-golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o=
+golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg=
+golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -1504,8 +1510,8 @@ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
-golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
+golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -1567,7 +1573,6 @@ golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1576,7 +1581,6 @@ golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -1585,10 +1589,11 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -1608,7 +1613,6 @@ golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -1616,8 +1620,9 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
+golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -1625,8 +1630,9 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
-golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
+golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
+golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1636,18 +1642,20 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
-golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
+golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
+golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -1669,6 +1677,7 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@@ -1703,7 +1712,6 @@ golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
@@ -1712,8 +1720,9 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
-golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
+golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
+golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -1721,8 +1730,9 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
-golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
+golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU=
+golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU=
@@ -1778,8 +1788,8 @@ google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ
google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s=
google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s=
google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70=
-google.golang.org/api v0.149.0 h1:b2CqT6kG+zqJIVKRQ3ELJVLN1PwHZ6DJ3dW8yl82rgY=
-google.golang.org/api v0.149.0/go.mod h1:Mwn1B7JTXrzXtnvmzQE2BD6bYZQ8DShKZDZbeN9I7qI=
+google.golang.org/api v0.175.0 h1:9bMDh10V9cBuU8N45Wlc3cKkItfqMRV0Fi8UscLEtbY=
+google.golang.org/api v0.175.0/go.mod h1:Rra+ltKu14pps/4xTycZfobMgLpbosoaaL7c+SEMrO8=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
@@ -1788,8 +1798,6 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
-google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
-google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@@ -1831,10 +1839,8 @@ google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
@@ -1901,12 +1907,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw
google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM=
google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM=
google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s=
-google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac h1:ZL/Teoy/ZGnzyrqK/Optxxp2pmVh+fmJ97slxSRyzUg=
-google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k=
-google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe h1:0poefMBYvYbs7g5UkjS6HcxBPaTRAmznle9jnxYoAI8=
-google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
+google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be h1:g4aX8SUFA8V5F4LrSY5EclyGYw1OZN4HS1jTyjB9ZDc=
+google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be/go.mod h1:FeSdT5fk+lkxatqJP38MsUicGqHax5cLtmy/6TAuxO4=
+google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be h1:Zz7rLWqp0ApfsR/l7+zSHhY3PMiH2xqgxlfYfAfNpoU=
+google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be/go.mod h1:dvdCTIoAGbkWbcIKBniID56/7XHTt6WfxXNMxuziJ+w=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 h1:AgADTJarZTBqgjiUzRgfaBchgYB3/WFTC80GPwsMcRI=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
@@ -1948,8 +1954,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu
google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
-google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0=
-google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
+google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
+google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
@@ -1966,8 +1972,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
-google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
+google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
+google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -2002,7 +2008,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/proto/nibiru/devgas/v1/genesis.proto b/proto/nibiru/devgas/v1/genesis.proto
index ed28cb9bd..1d9919768 100644
--- a/proto/nibiru/devgas/v1/genesis.proto
+++ b/proto/nibiru/devgas/v1/genesis.proto
@@ -21,7 +21,7 @@ message ModuleParams {
// developer_shares defines the proportion of the transaction fees to be
// distributed to the registered contract owner
string developer_shares = 2 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// allowed_denoms defines the list of denoms that are allowed to be paid to
diff --git a/proto/nibiru/inflation/v1/genesis.proto b/proto/nibiru/inflation/v1/genesis.proto
index 773bfaef5..8eb59b67f 100644
--- a/proto/nibiru/inflation/v1/genesis.proto
+++ b/proto/nibiru/inflation/v1/genesis.proto
@@ -26,7 +26,7 @@ message Params {
// polynomial_factors takes in the variables to calculate polynomial
// inflation
repeated string polynomial_factors = 2[
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// inflation_distribution of the minted denom
diff --git a/proto/nibiru/inflation/v1/inflation.proto b/proto/nibiru/inflation/v1/inflation.proto
index cad921ede..101ea8d86 100644
--- a/proto/nibiru/inflation/v1/inflation.proto
+++ b/proto/nibiru/inflation/v1/inflation.proto
@@ -12,19 +12,19 @@ message InflationDistribution {
// staking_rewards defines the proportion of the minted_denom that is
// to be allocated as staking rewards
string staking_rewards = 1 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// community_pool defines the proportion of the minted_denom that is to
// be allocated to the community pool
string community_pool = 2 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// strategic_reserves defines the proportion of the minted_denom that
// is to be allocated to the strategic reserves module address
string strategic_reserves = 3 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}
diff --git a/proto/nibiru/inflation/v1/query.proto b/proto/nibiru/inflation/v1/query.proto
index e7b6ec57a..642607da4 100644
--- a/proto/nibiru/inflation/v1/query.proto
+++ b/proto/nibiru/inflation/v1/query.proto
@@ -104,7 +104,7 @@ message QueryInflationRateRequest {}
message QueryInflationRateResponse {
// inflation_rate by which the total supply increases within one period
string inflation_rate = 1 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}
diff --git a/proto/nibiru/inflation/v1/tx.proto b/proto/nibiru/inflation/v1/tx.proto
index 36626a3f9..2648bfe1f 100644
--- a/proto/nibiru/inflation/v1/tx.proto
+++ b/proto/nibiru/inflation/v1/tx.proto
@@ -37,7 +37,7 @@ message MsgEditInflationParams {
string sender = 1;
bool inflation_enabled = 2;
repeated string polynomial_factors = 3 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = true
];
InflationDistribution inflation_distribution = 4
diff --git a/proto/nibiru/oracle/v1/event.proto b/proto/nibiru/oracle/v1/event.proto
index 82284e9b1..70059dc0a 100644
--- a/proto/nibiru/oracle/v1/event.proto
+++ b/proto/nibiru/oracle/v1/event.proto
@@ -12,7 +12,7 @@ option go_package = "github.com/NibiruChain/nibiru/x/oracle/types";
message EventPriceUpdate {
string pair = 1;
string price = 2 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
int64 timestamp_ms = 3;
diff --git a/proto/nibiru/oracle/v1/oracle.proto b/proto/nibiru/oracle/v1/oracle.proto
index e9f545623..1147a67cc 100644
--- a/proto/nibiru/oracle/v1/oracle.proto
+++ b/proto/nibiru/oracle/v1/oracle.proto
@@ -18,7 +18,7 @@ message Params {
// received for a ballot to pass.
string vote_threshold = 2 [
(gogoproto.moretags) = "yaml:\"vote_threshold\"",
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// RewardBand defines a maxium divergence that a price vote can have from the
@@ -31,7 +31,7 @@ message Params {
// deviation, the band is taken to be 1 standard deviation.a price
string reward_band = 3 [
(gogoproto.moretags) = "yaml:\"reward_band\"",
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// The set of whitelisted markets, or asset pairs, for the module.
@@ -45,7 +45,7 @@ message Params {
// penalty for failing a voting period.
string slash_fraction = 5 [
(gogoproto.moretags) = "yaml:\"slash_fraction\"",
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// SlashWindow returns the number of voting periods that specify a
@@ -55,7 +55,7 @@ message Params {
uint64 slash_window = 6 [ (gogoproto.moretags) = "yaml:\"slash_window\"" ];
string min_valid_per_window = 7 [
(gogoproto.moretags) = "yaml:\"min_valid_per_window\"",
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
@@ -75,7 +75,7 @@ message Params {
// The validator fee ratio that is given to validators every epoch.
string validator_fee_ratio = 10 [
(gogoproto.moretags) = "yaml:\"validator_fee_ratio\"",
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
@@ -125,7 +125,7 @@ message ExchangeRateTuple {
string exchange_rate = 2 [
(gogoproto.moretags) = "yaml:\"exchange_rate\"",
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}
@@ -133,7 +133,7 @@ message ExchangeRateTuple {
message DatedPrice {
string exchange_rate = 1 [
(gogoproto.moretags) = "yaml:\"exchange_rate\"",
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
diff --git a/proto/nibiru/oracle/v1/query.proto b/proto/nibiru/oracle/v1/query.proto
index 993640b40..fb5a6a632 100644
--- a/proto/nibiru/oracle/v1/query.proto
+++ b/proto/nibiru/oracle/v1/query.proto
@@ -105,7 +105,7 @@ message QueryExchangeRateRequest {
message QueryExchangeRateResponse {
// exchange_rate defines the exchange rate of assets voted by validators
string exchange_rate = 1 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}
diff --git a/proto/nibiru/oracle/v1/state.proto b/proto/nibiru/oracle/v1/state.proto
index 96d9bd959..3a4aab398 100644
--- a/proto/nibiru/oracle/v1/state.proto
+++ b/proto/nibiru/oracle/v1/state.proto
@@ -18,7 +18,7 @@ message PriceSnapshot {
];
string price = 2 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
diff --git a/proto/nibiru/oracle/v1/tx.proto b/proto/nibiru/oracle/v1/tx.proto
index 299023008..882cf311f 100644
--- a/proto/nibiru/oracle/v1/tx.proto
+++ b/proto/nibiru/oracle/v1/tx.proto
@@ -103,13 +103,13 @@ message MsgEditOracleParams {
// vote_threshold: [cosmossdk.io/math.LegacyDec] TODO:
string vote_threshold = 3 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = true
];
// reward_band: [cosmossdk.io/math.LegacyDec] TODO:
string reward_band = 4 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = true
];
@@ -117,7 +117,7 @@ message MsgEditOracleParams {
// slash_fraction: [cosmossdk.io/math.LegacyDec] TODO:
string slash_fraction = 6 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = true
];
@@ -128,7 +128,7 @@ message MsgEditOracleParams {
// min_valid_per_window: [cosmossdk.io/math.LegacyDec] TODO:
string min_valid_per_window = 8 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = true
];
@@ -144,7 +144,7 @@ message MsgEditOracleParams {
// VoteThreshold: [cosmossdk.io/math.LegacyDec] TODO:
string validator_fee_ratio = 11 [
- (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
+ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = true
];
}
diff --git a/simapp/sim_test.go b/simapp/sim_test.go
index 52466eac9..faa8cf0d5 100644
--- a/simapp/sim_test.go
+++ b/simapp/sim_test.go
@@ -9,23 +9,20 @@ import (
"strings"
"testing"
- dbm "github.com/cometbft/cometbft-db"
+ "cosmossdk.io/log"
+ storetypes "cosmossdk.io/store/types"
+ evidencetypes "cosmossdk.io/x/evidence/types"
abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cometbft/cometbft/libs/log"
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
+ dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
- sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
- capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
- evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
@@ -33,15 +30,16 @@ import (
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
+ capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
"github.com/stretchr/testify/require"
"github.com/NibiruChain/nibiru/app"
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
- epochstypes "github.com/NibiruChain/nibiru/x/epochs/types"
- inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
- oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
- tokenfactorytypes "github.com/NibiruChain/nibiru/x/tokenfactory/types"
+ // devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
+ // epochstypes "github.com/NibiruChain/nibiru/x/epochs/types"
+ // inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
+ // oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
+ // sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
+ // tokenfactorytypes "github.com/NibiruChain/nibiru/x/tokenfactory/types"
)
// SimAppChainID hardcoded chainID for simulation
@@ -251,8 +249,8 @@ func TestAppImportExport(t *testing.T) {
}
}()
- ctxA := oldApp.NewContext(true, tmproto.Header{Height: oldApp.LastBlockHeight()})
- ctxB := newApp.NewContext(true, tmproto.Header{Height: oldApp.LastBlockHeight()})
+ ctxA := oldApp.NewContext(true)
+ ctxB := newApp.NewContext(true)
newApp.ModuleManager.InitGenesis(ctxB, oldApp.AppCodec(), genesisState)
newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)
@@ -276,19 +274,19 @@ func TestAppImportExport(t *testing.T) {
{oldApp.GetKey(evidencetypes.StoreKey), newApp.GetKey(evidencetypes.StoreKey), [][]byte{}},
{oldApp.GetKey(capabilitytypes.StoreKey), newApp.GetKey(capabilitytypes.StoreKey), [][]byte{}},
{oldApp.GetKey(authzkeeper.StoreKey), newApp.GetKey(authzkeeper.StoreKey), [][]byte{authzkeeper.GrantKey, authzkeeper.GrantQueuePrefix}},
- {oldApp.GetKey(devgastypes.StoreKey), newApp.GetKey(devgastypes.StoreKey), [][]byte{}},
- {oldApp.GetKey(epochstypes.StoreKey), newApp.GetKey(epochstypes.StoreKey), [][]byte{}},
- {oldApp.GetKey(inflationtypes.StoreKey), newApp.GetKey(inflationtypes.StoreKey), [][]byte{}},
- {oldApp.GetKey(oracletypes.StoreKey), newApp.GetKey(oracletypes.StoreKey), [][]byte{}},
- {oldApp.GetKey(sudotypes.StoreKey), newApp.GetKey(sudotypes.StoreKey), [][]byte{}},
- {oldApp.GetKey(tokenfactorytypes.StoreKey), newApp.GetKey(tokenfactorytypes.StoreKey), [][]byte{}},
+ // {oldApp.GetKey(devgastypes.StoreKey), newApp.GetKey(devgastypes.StoreKey), [][]byte{}},
+ // {oldApp.GetKey(epochstypes.StoreKey), newApp.GetKey(epochstypes.StoreKey), [][]byte{}},
+ // {oldApp.GetKey(inflationtypes.StoreKey), newApp.GetKey(inflationtypes.StoreKey), [][]byte{}},
+ // {oldApp.GetKey(oracletypes.StoreKey), newApp.GetKey(oracletypes.StoreKey), [][]byte{}},
+ // {oldApp.GetKey(sudotypes.StoreKey), newApp.GetKey(sudotypes.StoreKey), [][]byte{}},
+ // {oldApp.GetKey(tokenfactorytypes.StoreKey), newApp.GetKey(tokenfactorytypes.StoreKey), [][]byte{}},
}
for _, skp := range storeKeysPrefixes {
storeA := ctxA.KVStore(skp.A)
storeB := ctxB.KVStore(skp.B)
- failedKVAs, failedKVBs := sdk.DiffKVStores(storeA, storeB, skp.Prefixes)
+ failedKVAs, failedKVBs := simtestutil.DiffKVStores(storeA, storeB, skp.Prefixes)
require.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare")
fmt.Printf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), skp.A, skp.B)
@@ -365,7 +363,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
newApp := app.NewNibiruApp(log.NewNopLogger(), newDB, nil, true, encoding, appOptions, baseapp.SetChainID(SimAppChainID))
require.Equal(t, "Nibiru", newApp.Name())
- newApp.InitChain(abci.RequestInitChain{
+ newApp.InitChain(&abci.RequestInitChain{
ChainId: SimAppChainID,
AppStateBytes: exported.AppState,
})
diff --git a/simapp/state_test.go b/simapp/state_test.go
index bd7dde960..dd832a9d9 100644
--- a/simapp/state_test.go
+++ b/simapp/state_test.go
@@ -151,11 +151,11 @@ func AppStateRandomizedFn(
// number of bonded accounts
var initialStake, numInitiallyBonded int64
appParams.GetOrGenerate(
- cdc, sims.StakePerAccount, &initialStake, r,
+ sims.StakePerAccount, &initialStake, r,
func(r *rand.Rand) { initialStake = r.Int63n(1e12) },
)
appParams.GetOrGenerate(
- cdc, sims.InitiallyBondedValidators, &numInitiallyBonded, r,
+ sims.InitiallyBondedValidators, &numInitiallyBonded, r,
func(r *rand.Rand) { numInitiallyBonded = int64(r.Intn(300)) },
)
diff --git a/x/README.md b/x/README.md
deleted file mode 100644
index 75ea21f45..000000000
--- a/x/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Nibiru Modules
-
-See [BlockChain Modules - Nibiru Docs](https://nibiru.fi/docs/dev/x/)
diff --git a/x/common/codec.go b/x/common/codec.go
index 8bb5f7bf4..958936f7a 100644
--- a/x/common/codec.go
+++ b/x/common/codec.go
@@ -1,9 +1,11 @@
package common
import (
- "cosmossdk.io/collections"
- collcodec "cosmossdk.io/collections/codec"
sdkmath "cosmossdk.io/math"
+
+ coll "cosmossdk.io/collections"
+ collcodec "cosmossdk.io/collections/codec"
+
sdk "github.com/cosmos/cosmos-sdk/types"
)
@@ -116,11 +118,11 @@ func (cdc mathIntKeyCodec) Size(key sdkmath.Int) int {
}
func (cdc mathIntKeyCodec) EncodeJSON(value sdkmath.Int) ([]byte, error) {
- return collections.StringKey.EncodeJSON(value.String())
+ return coll.StringKey.EncodeJSON(value.String())
}
func (cdc mathIntKeyCodec) DecodeJSON(b []byte) (v sdkmath.Int, err error) {
- s, err := collections.StringKey.DecodeJSON(b)
+ s, err := coll.StringKey.DecodeJSON(b)
if err != nil {
return
}
diff --git a/x/common/dec.go b/x/common/dec.go
index 2a62e2c47..0d1e2ffac 100644
--- a/x/common/dec.go
+++ b/x/common/dec.go
@@ -6,7 +6,6 @@ import (
"strings"
"cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
@@ -40,7 +39,7 @@ var (
// - NOTE, MustSqrtDec panics if it is called on a negative number, similar to the
// sdk.NewCoin and SqrtBigInt functions. A panic safe version of MustSqrtDec
// is available in the SqrtDec method.
-func MustSqrtDec(dec sdk.Dec) sdk.Dec {
+func MustSqrtDec(dec math.LegacyDec) math.LegacyDec {
sqrtBigInt := MustSqrtBigInt(dec.BigInt())
precision := math.LegacyNewDecFromBigInt(PRECISION_MULT)
return math.LegacyNewDecFromBigInt(sqrtBigInt).Quo(precision)
@@ -53,8 +52,8 @@ func MustSqrtDec(dec sdk.Dec) sdk.Dec {
// The big.Int.Sqrt method is part of the standard library,
// thoroughly tested, works at seemingly unbound precision (e.g. for numbers as
// large as 10**99.
-func SqrtDec(dec sdk.Dec) (sdk.Dec, error) {
- var sqrtDec sdk.Dec
+func SqrtDec(dec math.LegacyDec) (math.LegacyDec, error) {
+ var sqrtDec math.LegacyDec
var panicErr error = TryCatch(func() {
sqrtDec = MustSqrtDec(dec)
})()
@@ -180,7 +179,7 @@ func BankersRound(quo, rem, halfPrecision *big.Int) *big.Int {
// Clamp return the value if it is within the clampValue, otherwise return the clampValue.
// e.g. Clamp(1.5, 1) = 1, Clamp(-1.5, 1) = -1, Clamp(0.5, 1) = 0.5
-func Clamp(value sdk.Dec, clampValue sdk.Dec) sdk.Dec {
+func Clamp(value math.LegacyDec, clampValue math.LegacyDec) math.LegacyDec {
if value.GT(clampValue) {
return clampValue
} else if value.LT(clampValue.Neg()) {
diff --git a/x/common/dec_test.go b/x/common/dec_test.go
index 70f0a892a..bb3c8a9d0 100644
--- a/x/common/dec_test.go
+++ b/x/common/dec_test.go
@@ -6,7 +6,6 @@ import (
"testing"
"cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
@@ -44,8 +43,8 @@ func TestSqrtBigInt(t *testing.T) {
func TestSqrtDec(t *testing.T) {
testCases := []struct {
- dec sdk.Dec
- sqrtDec sdk.Dec
+ dec math.LegacyDec
+ sqrtDec math.LegacyDec
}{
// --------------------------------------------------------------------
// Cases: 1 or higher
@@ -133,9 +132,9 @@ func TestBankersRound(t *testing.T) {
func TestClamp(t *testing.T) {
tests := []struct {
- value sdk.Dec
- clampValue sdk.Dec
- expected sdk.Dec
+ value math.LegacyDec
+ clampValue math.LegacyDec
+ expected math.LegacyDec
description string
}{
{
diff --git a/x/common/ewma/ewma.go b/x/common/ewma/ewma.go
index 7967d32e5..323b018cf 100644
--- a/x/common/ewma/ewma.go
+++ b/x/common/ewma/ewma.go
@@ -2,16 +2,15 @@ package ewma
import (
"cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
)
type MovingAverage interface {
- Add(sdk.Dec)
- Value() sdk.Dec
- Set(sdk.Dec)
+ Add(math.LegacyDec)
+ Value() math.LegacyDec
+ Set(math.LegacyDec)
}
-func NewMovingAverage(span sdk.Dec) MovingAverage {
+func NewMovingAverage(span math.LegacyDec) MovingAverage {
return &variableEWMA{
value: math.LegacyZeroDec(),
decay: math.LegacyMustNewDecFromStr("2").Quo(span.Add(math.LegacyOneDec())),
@@ -19,11 +18,11 @@ func NewMovingAverage(span sdk.Dec) MovingAverage {
}
type variableEWMA struct {
- decay sdk.Dec
- value sdk.Dec
+ decay math.LegacyDec
+ value math.LegacyDec
}
-func (v *variableEWMA) Add(dec sdk.Dec) {
+func (v *variableEWMA) Add(dec math.LegacyDec) {
if v.value.IsZero() {
v.value = dec
@@ -34,10 +33,10 @@ func (v *variableEWMA) Add(dec sdk.Dec) {
v.value = v.value.Mul(math.LegacyOneDec().Sub(v.decay)).Add(dec.Mul(v.decay))
}
-func (v *variableEWMA) Value() sdk.Dec {
+func (v *variableEWMA) Value() math.LegacyDec {
return v.value
}
-func (v *variableEWMA) Set(dec sdk.Dec) {
+func (v *variableEWMA) Set(dec math.LegacyDec) {
v.value = dec
}
diff --git a/x/common/testutil/action/account.go b/x/common/testutil/action/account.go
index 9670faf6c..3ed74e303 100644
--- a/x/common/testutil/action/account.go
+++ b/x/common/testutil/action/account.go
@@ -1,54 +1,54 @@
package action
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/app"
- inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-type fundAccount struct {
- Account sdk.AccAddress
- Amount sdk.Coins
-}
-
-func FundAccount(account sdk.AccAddress, amount sdk.Coins) Action {
- return &fundAccount{Account: account, Amount: amount}
-}
-
-func (c fundAccount) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- err := app.BankKeeper.MintCoins(ctx, inflationtypes.ModuleName, c.Amount)
- if err != nil {
- return ctx, err
- }
-
- err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, inflationtypes.ModuleName, c.Account, c.Amount)
- if err != nil {
- return ctx, err
- }
-
- return ctx, nil
-}
-
-type fundModule struct {
- Module string
- Amount sdk.Coins
-}
-
-func FundModule(module string, amount sdk.Coins) Action {
- return fundModule{Module: module, Amount: amount}
-}
-
-func (c fundModule) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- err := app.BankKeeper.MintCoins(ctx, inflationtypes.ModuleName, c.Amount)
- if err != nil {
- return ctx, err
- }
-
- err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, inflationtypes.ModuleName, c.Module, c.Amount)
- if err != nil {
- return ctx, err
- }
-
- return ctx, nil
-}
+// import (
+// sdk "github.com/cosmos/cosmos-sdk/types"
+
+// "github.com/NibiruChain/nibiru/app"
+// // inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
+// )
+
+// type fundAccount struct {
+// Account sdk.AccAddress
+// Amount sdk.Coins
+// }
+
+// func FundAccount(account sdk.AccAddress, amount sdk.Coins) Action {
+// return &fundAccount{Account: account, Amount: amount}
+// }
+
+// func (c fundAccount) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
+// err := app.BankKeeper.MintCoins(ctx, inflationtypes.ModuleName, c.Amount)
+// if err != nil {
+// return ctx, err
+// }
+
+// err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, inflationtypes.ModuleName, c.Account, c.Amount)
+// if err != nil {
+// return ctx, err
+// }
+
+// return ctx, nil
+// }
+
+// type fundModule struct {
+// Module string
+// Amount sdk.Coins
+// }
+
+// func FundModule(module string, amount sdk.Coins) Action {
+// return fundModule{Module: module, Amount: amount}
+// }
+
+// func (c fundModule) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
+// err := app.BankKeeper.MintCoins(ctx, inflationtypes.ModuleName, c.Amount)
+// if err != nil {
+// return ctx, err
+// }
+
+// err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, inflationtypes.ModuleName, c.Module, c.Amount)
+// if err != nil {
+// return ctx, err
+// }
+
+// return ctx, nil
+// }
diff --git a/x/common/testutil/action/block.go b/x/common/testutil/action/block.go
index bb19c4629..b71641cc9 100644
--- a/x/common/testutil/action/block.go
+++ b/x/common/testutil/action/block.go
@@ -1,151 +1,150 @@
package action
-import (
- "time"
+// import (
+// "time"
- "github.com/cometbft/cometbft/abci/types"
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
+// "github.com/cometbft/cometbft/abci/types"
+// sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/NibiruChain/nibiru/app"
-)
+// "github.com/NibiruChain/nibiru/app"
+// )
-type increaseBlockNumberBy struct {
- numBlocks int64
-}
+// type increaseBlockNumberBy struct {
+// numBlocks int64
+// }
-func (i increaseBlockNumberBy) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- app.EndBlocker(ctx, types.RequestEndBlock{Height: ctx.BlockHeight()})
+// func (i increaseBlockNumberBy) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
+// app.EndBlocker(ctx, types.RequestEndBlock{Height: ctx.BlockHeight()})
- ctx = ctx.WithBlockHeight(ctx.BlockHeight() + i.numBlocks)
+// ctx = ctx.WithBlockHeight(ctx.BlockHeight() + i.numBlocks)
- return ctx, nil
-}
+// return ctx, nil
+// }
-// IncreaseBlockNumberBy increases the block number by the given number of blocks
-func IncreaseBlockNumberBy(numBlocks int64) Action {
- return increaseBlockNumberBy{numBlocks: numBlocks}
-}
+// // IncreaseBlockNumberBy increases the block number by the given number of blocks
+// func IncreaseBlockNumberBy(numBlocks int64) Action {
+// return increaseBlockNumberBy{numBlocks: numBlocks}
+// }
-type increaseBlockTimeBy struct {
- seconds time.Duration
-}
+// type increaseBlockTimeBy struct {
+// seconds time.Duration
+// }
-func (i increaseBlockTimeBy) Do(_ *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Second * i.seconds))
+// func (i increaseBlockTimeBy) Do(_ *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
+// ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Second * i.seconds))
- return ctx, nil
-}
-
-func IncreaseBlockTimeBy(seconds time.Duration) Action {
- return increaseBlockTimeBy{seconds: seconds}
-}
-
-type setBlockTime struct {
- blockTime time.Time
-}
-
-func (s setBlockTime) Do(_ *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- return ctx.WithBlockTime(s.blockTime), nil
-}
-
-// SetBlockTime sets the block time to the given value
-func SetBlockTime(blockTime time.Time) Action {
- return setBlockTime{blockTime: blockTime}
-}
-
-type setBlockNumber struct {
- blockNumber int64
-}
-
-func (s setBlockNumber) Do(_ *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- return ctx.WithBlockHeight(s.blockNumber), nil
-}
-
-// SetBlockNumber sets the block number to the given value
-func SetBlockNumber(blockNumber int64) Action {
- return setBlockNumber{blockNumber: blockNumber}
-}
-
-type moveToNextBlock struct{}
-
-func (m moveToNextBlock) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- app.EndBlock(types.RequestEndBlock{})
- app.Commit()
-
- newHeader := tmproto.Header{
- Height: ctx.BlockHeight() + 1,
- Time: ctx.BlockTime().Add(time.Second * 5),
- }
-
- app.BeginBlock(types.RequestBeginBlock{
- Header: newHeader,
- })
-
- return app.NewContext(
- false,
- newHeader,
- ).WithBlockTime(newHeader.Time), nil
-}
-
-func MoveToNextBlock() Action {
- return moveToNextBlock{}
-}
-
-type moveToNextBlockWithDuration struct {
- blockDuration time.Duration
-}
-
-func (m moveToNextBlockWithDuration) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- app.EndBlock(types.RequestEndBlock{Height: ctx.BlockHeight()})
- app.Commit()
-
- newHeader := tmproto.Header{
- Height: ctx.BlockHeight() + 1,
- Time: ctx.BlockTime().Add(m.blockDuration),
- }
-
- app.BeginBlock(types.RequestBeginBlock{
- Header: newHeader,
- })
-
- return app.NewContext(
- false,
- newHeader,
- ).WithBlockTime(newHeader.Time), nil
-}
-
-func MoveToNextBlockWithDuration(blockDuration time.Duration) Action {
- return moveToNextBlockWithDuration{
- blockDuration: blockDuration,
- }
-}
-
-type moveToNextBlockWithTime struct {
- blockTime time.Time
-}
-
-func (m moveToNextBlockWithTime) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- app.EndBlock(types.RequestEndBlock{Height: ctx.BlockHeight()})
- app.Commit()
-
- newHeader := tmproto.Header{
- Height: ctx.BlockHeight() + 1,
- Time: m.blockTime,
- }
-
- app.BeginBlock(types.RequestBeginBlock{
- Header: newHeader,
- })
-
- return app.NewContext(
- false,
- newHeader,
- ).WithBlockTime(newHeader.Time), nil
-}
-
-func MoveToNextBlockWithTime(blockTime time.Time) Action {
- return moveToNextBlockWithTime{
- blockTime: blockTime,
- }
-}
+// return ctx, nil
+// }
+
+// func IncreaseBlockTimeBy(seconds time.Duration) Action {
+// return increaseBlockTimeBy{seconds: seconds}
+// }
+
+// type setBlockTime struct {
+// blockTime time.Time
+// }
+
+// func (s setBlockTime) Do(_ *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
+// return ctx.WithBlockTime(s.blockTime), nil
+// }
+
+// // SetBlockTime sets the block time to the given value
+// func SetBlockTime(blockTime time.Time) Action {
+// return setBlockTime{blockTime: blockTime}
+// }
+
+// type setBlockNumber struct {
+// blockNumber int64
+// }
+
+// func (s setBlockNumber) Do(_ *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
+// return ctx.WithBlockHeight(s.blockNumber), nil
+// }
+
+// // SetBlockNumber sets the block number to the given value
+// func SetBlockNumber(blockNumber int64) Action {
+// return setBlockNumber{blockNumber: blockNumber}
+// }
+
+// // type moveToNextBlock struct{}
+
+// // func (m moveToNextBlock) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
+// // app.EndBlock(types.RequestEndBlock{})
+// // app.Commit()
+
+// // newHeader := tmproto.Header{
+// // Height: ctx.BlockHeight() + 1,
+// // Time: ctx.BlockTime().Add(time.Second * 5),
+// // }
+
+// // app.BeginBlock(types.RequestBeginBlock{
+// // Header: newHeader,
+// // })
+
+// // return app.NewContext(
+// // false,
+// // newHeader,
+// // ).WithBlockTime(newHeader.Time), nil
+// // }
+
+// // func MoveToNextBlock() Action {
+// // return moveToNextBlock{}
+// // }
+
+// // type moveToNextBlockWithDuration struct {
+// // blockDuration time.Duration
+// // }
+
+// // func (m moveToNextBlockWithDuration) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
+// // app.EndBlock(types.RequestEndBlock{Height: ctx.BlockHeight()})
+// // app.Commit()
+
+// // newHeader := tmproto.Header{
+// // Height: ctx.BlockHeight() + 1,
+// // Time: ctx.BlockTime().Add(m.blockDuration),
+// // }
+
+// // app.BeginBlock(types.RequestBeginBlock{
+// // Header: newHeader,
+// // })
+
+// // return app.NewContext(
+// // false,
+// // newHeader,
+// // ).WithBlockTime(newHeader.Time), nil
+// // }
+
+// // func MoveToNextBlockWithDuration(blockDuration time.Duration) Action {
+// // return moveToNextBlockWithDuration{
+// // blockDuration: blockDuration,
+// // }
+// // }
+
+// // type moveToNextBlockWithTime struct {
+// // blockTime time.Time
+// // }
+
+// // func (m moveToNextBlockWithTime) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
+// // app.EndBlock(types.RequestEndBlock{Height: ctx.BlockHeight()})
+// // app.Commit()
+
+// // newHeader := tmproto.Header{
+// // Height: ctx.BlockHeight() + 1,
+// // Time: m.blockTime,
+// // }
+
+// // app.BeginBlock(types.RequestBeginBlock{
+// // Header: newHeader,
+// // })
+
+// // return app.NewContext(
+// // false,
+// // newHeader,
+// // ).WithBlockTime(newHeader.Time), nil
+// // }
+
+// // func MoveToNextBlockWithTime(blockTime time.Time) Action {
+// // return moveToNextBlockWithTime{
+// // blockTime: blockTime,
+// // }
+// // }
diff --git a/x/common/testutil/assertion/balances.go b/x/common/testutil/assertion/balances.go
index 309505c4c..aa96e54c5 100644
--- a/x/common/testutil/assertion/balances.go
+++ b/x/common/testutil/assertion/balances.go
@@ -23,7 +23,7 @@ type allBalancesEqual struct {
func (b allBalancesEqual) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
coins := app.BankKeeper.GetAllBalances(ctx, b.Account)
- if !coins.IsEqual(b.Amount) {
+ if !coins.Equal(b.Amount) {
return ctx, fmt.Errorf(
"account %s balance not equal, expected %s, got %s",
b.Account.String(),
diff --git a/x/common/testutil/cli/network.go b/x/common/testutil/cli/network.go
index cd2b5333f..fa824abfd 100644
--- a/x/common/testutil/cli/network.go
+++ b/x/common/testutil/cli/network.go
@@ -9,17 +9,25 @@ import (
"net/http"
"net/url"
"os"
+ "os/signal"
"path/filepath"
"strings"
+
"sync"
+ "syscall"
"time"
- "github.com/cometbft/cometbft/libs/log"
- "github.com/cosmos/cosmos-sdk/store/pruning/types"
+ "cosmossdk.io/log"
+ "cosmossdk.io/store/pruning/types"
+ "github.com/cosmos/cosmos-sdk/codec"
+ "github.com/cosmos/cosmos-sdk/codec/testutil"
+ net "github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/testutil/sims"
+ authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
+ "golang.org/x/sync/errgroup"
"cosmossdk.io/math"
- dbm "github.com/cometbft/cometbft-db"
+ dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
sdktestutil "github.com/cosmos/cosmos-sdk/testutil"
@@ -131,6 +139,8 @@ type (
grpc *grpc.Server
grpcWeb *http.Server
secretMnemonic string
+ errGroup *errgroup.Group
+ cancelFn context.CancelFunc
}
)
@@ -236,7 +246,7 @@ func New(logger Logger, baseDir string, cfg Config) (*Network, error) {
apiListenAddr = cfg.APIAddress
} else {
var err error
- apiListenAddr, _, err = server.FreeTCPAddr()
+ apiListenAddr, _, _, err = net.FreeTCPAddr()
if err != nil {
return nil, err
}
@@ -252,7 +262,7 @@ func New(logger Logger, baseDir string, cfg Config) (*Network, error) {
if cfg.RPCAddress != "" {
tmCfg.RPC.ListenAddress = cfg.RPCAddress
} else {
- rpcAddr, _, err := server.FreeTCPAddr()
+ rpcAddr, _, _, err := net.FreeTCPAddr()
if err != nil {
return nil, err
}
@@ -262,7 +272,7 @@ func New(logger Logger, baseDir string, cfg Config) (*Network, error) {
if cfg.GRPCAddress != "" {
appCfg.GRPC.Address = cfg.GRPCAddress
} else {
- _, grpcPort, err := server.FreeTCPAddr()
+ _, grpcPort, _, err := net.FreeTCPAddr()
if err != nil {
return nil, err
}
@@ -270,17 +280,13 @@ func New(logger Logger, baseDir string, cfg Config) (*Network, error) {
}
appCfg.GRPC.Enable = true
- _, grpcWebPort, err := server.FreeTCPAddr()
- if err != nil {
- return nil, err
- }
- appCfg.GRPCWeb.Address = fmt.Sprintf("0.0.0.0:%s", grpcWebPort)
+ // GRPCWeb now uses the same address than
appCfg.GRPCWeb.Enable = true
}
loggerNoOp := log.NewNopLogger()
if cfg.EnableTMLogging {
- loggerNoOp = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
+ loggerNoOp = log.NewLogger(os.Stdout)
}
ctx.Logger = loggerNoOp
@@ -304,13 +310,13 @@ func New(logger Logger, baseDir string, cfg Config) (*Network, error) {
tmCfg.Moniker = nodeDirName
monikers[i] = nodeDirName
- proxyAddr, _, err := server.FreeTCPAddr()
+ proxyAddr, _, _, err := net.FreeTCPAddr()
if err != nil {
return nil, err
}
tmCfg.ProxyApp = proxyAddr
- p2pAddr, _, err := server.FreeTCPAddr()
+ p2pAddr, _, _, err := net.FreeTCPAddr()
if err != nil {
return nil, err
}
@@ -376,8 +382,18 @@ func New(logger Logger, baseDir string, cfg Config) (*Network, error) {
return nil, err
}
+ interfaceRegistry := testutil.CodecOptions{}.NewInterfaceRegistry()
+ cdc := codec.NewProtoCodec(interfaceRegistry)
+ txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
+
+ valAddrCodec := txConfig.SigningContext().ValidatorAddressCodec()
+ valStr, err := valAddrCodec.BytesToString(sdk.ValAddress(addr))
+ if err != nil {
+ return nil, err
+ }
+
createValMsg, err := stakingtypes.NewMsgCreateValidator(
- sdk.ValAddress(addr),
+ valStr,
valPubKeys[i],
sdk.NewCoin(cfg.BondDenom, cfg.BondedTokens),
stakingtypes.NewDescription(nodeDirName, "", "", "", ""),
@@ -411,7 +427,7 @@ func New(logger Logger, baseDir string, cfg Config) (*Network, error) {
WithKeybase(kb).
WithTxConfig(cfg.TxConfig)
- err = tx.Sign(txFactory, nodeDirName, txBuilder, true)
+ err = tx.Sign(nil, txFactory, nodeDirName, txBuilder, true)
if err != nil {
return nil, err
}
@@ -482,7 +498,7 @@ func New(logger Logger, baseDir string, cfg Config) (*Network, error) {
// Ensure we cleanup incase any test was abruptly halted (e.g. SIGINT) as
// any defer in a test would not be called.
- server.TrapSignal(network.Cleanup)
+ trapSignal(network.Cleanup)
return network, err
}
@@ -688,3 +704,27 @@ func (n *Network) keyBaseAndInfoForAddr(addr sdk.AccAddress) (keyring.Keyring, *
return nil, nil, fmt.Errorf("address not found in any of the known validators keyrings: %s", addr.String())
}
+
+// trapSignal traps SIGINT and SIGTERM and calls os.Exit once a signal is received.
+func trapSignal(cleanupFunc func()) {
+ sigs := make(chan os.Signal, 1)
+ signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
+
+ go func() {
+ sig := <-sigs
+
+ if cleanupFunc != nil {
+ cleanupFunc()
+ }
+ exitCode := 128
+
+ switch sig {
+ case syscall.SIGINT:
+ exitCode += int(syscall.SIGINT)
+ case syscall.SIGTERM:
+ exitCode += int(syscall.SIGTERM)
+ }
+
+ os.Exit(exitCode)
+ }()
+}
diff --git a/x/common/testutil/cli/query.go b/x/common/testutil/cli/query.go
index 871cc525a..5f570742c 100644
--- a/x/common/testutil/cli/query.go
+++ b/x/common/testutil/cli/query.go
@@ -4,20 +4,18 @@ import (
"fmt"
"github.com/cosmos/cosmos-sdk/x/auth/client/cli"
+ "github.com/cosmos/gogoproto/proto"
"github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/codec"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
tmcli "github.com/cometbft/cometbft/libs/cli"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- oraclecli "github.com/NibiruChain/nibiru/x/oracle/client/cli"
- oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
- sudocli "github.com/NibiruChain/nibiru/x/sudo/cli"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
+ // oraclecli "github.com/NibiruChain/nibiru/x/oracle/client/cli"
+ // oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
+ // sudocli "github.com/NibiruChain/nibiru/x/sudo/cli"
+ // sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
)
// ExecQueryOption defines a type which customizes a CLI query operation.
@@ -48,7 +46,7 @@ func WithQueryEncodingType(e EncodingType) ExecQueryOption {
func (chain Network) ExecQuery(
cmd *cobra.Command,
args []string,
- result codec.ProtoMarshaler,
+ result proto.Message,
opts ...ExecQueryOption,
) error {
return ExecQuery(chain.Validators[0].ClientCtx, cmd, args, result, opts...)
@@ -59,7 +57,7 @@ func ExecQuery(
clientCtx client.Context,
cmd *cobra.Command,
args []string,
- result codec.ProtoMarshaler,
+ result proto.Message,
opts ...ExecQueryOption,
) error {
var options queryOptions
@@ -90,13 +88,13 @@ func ExecQuery(
}
}
-func QueryOracleExchangeRate(clientCtx client.Context, pair asset.Pair) (*oracletypes.QueryExchangeRateResponse, error) {
- var queryResp oracletypes.QueryExchangeRateResponse
- if err := ExecQuery(clientCtx, oraclecli.GetCmdQueryExchangeRates(), []string{pair.String()}, &queryResp); err != nil {
- return nil, err
- }
- return &queryResp, nil
-}
+// func QueryOracleExchangeRate(clientCtx client.Context, pair asset.Pair) (*oracletypes.QueryExchangeRateResponse, error) {
+// var queryResp oracletypes.QueryExchangeRateResponse
+// if err := ExecQuery(clientCtx, oraclecli.GetCmdQueryExchangeRates(), []string{pair.String()}, &queryResp); err != nil {
+// return nil, err
+// }
+// return &queryResp, nil
+// }
func QueryTx(ctx client.Context, txHash string) (*sdk.TxResponse, error) {
var queryResp sdk.TxResponse
@@ -114,15 +112,15 @@ func QueryTx(ctx client.Context, txHash string) (*sdk.TxResponse, error) {
return &queryResp, nil
}
-func QuerySudoers(clientCtx client.Context) (*sudotypes.QuerySudoersResponse, error) {
- var queryResp sudotypes.QuerySudoersResponse
- if err := ExecQuery(
- clientCtx,
- sudocli.CmdQuerySudoers(),
- []string{},
- &queryResp,
- ); err != nil {
- return nil, err
- }
- return &queryResp, nil
-}
+// func QuerySudoers(clientCtx client.Context) (*sudotypes.QuerySudoersResponse, error) {
+// var queryResp sudotypes.QuerySudoersResponse
+// if err := ExecQuery(
+// clientCtx,
+// sudocli.CmdQuerySudoers(),
+// []string{},
+// &queryResp,
+// ); err != nil {
+// return nil, err
+// }
+// return &queryResp, nil
+// }
diff --git a/x/common/testutil/cli/tx.go b/x/common/testutil/cli/tx.go
index 37f644c19..41451e656 100644
--- a/x/common/testutil/cli/tx.go
+++ b/x/common/testutil/cli/tx.go
@@ -1,19 +1,16 @@
package cli
import (
- "context"
"fmt"
"cosmossdk.io/math"
"github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdktestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"
- "github.com/NibiruChain/nibiru/x/common"
"github.com/NibiruChain/nibiru/x/common/denoms"
)
@@ -125,53 +122,53 @@ func (network *Network) ExecTxCmd(
return resp, nil
}
-func (chain *Network) BroadcastMsgs(
- from sdk.AccAddress, msgs ...sdk.Msg,
-) (*sdk.TxResponse, error) {
- cfg := chain.Config
- kb, info, err := chain.keyBaseAndInfoForAddr(from)
- if err != nil {
- return nil, err
- }
-
- rpc := chain.Validators[0].RPCClient
- txBuilder := cfg.TxConfig.NewTxBuilder()
- err = txBuilder.SetMsgs(msgs...)
- if err != nil {
- return nil, err
- }
-
- txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(cfg.BondDenom, math.NewInt(1000))))
- txBuilder.SetGasLimit(uint64(1 * common.TO_MICRO))
-
- acc, err := cfg.AccountRetriever.GetAccount(chain.Validators[0].ClientCtx, from)
- if err != nil {
- return nil, err
- }
-
- txFactory := tx.Factory{}
- txFactory = txFactory.
- WithChainID(cfg.ChainID).
- WithKeybase(kb).
- WithTxConfig(cfg.TxConfig).
- WithAccountRetriever(cfg.AccountRetriever).
- WithAccountNumber(acc.GetAccountNumber()).
- WithSequence(acc.GetSequence())
-
- err = tx.Sign(txFactory, info.Name, txBuilder, true)
- if err != nil {
- return nil, err
- }
-
- txBytes, err := cfg.TxConfig.TxEncoder()(txBuilder.GetTx())
- if err != nil {
- return nil, err
- }
-
- respRaw, err := rpc.BroadcastTxSync(context.Background(), txBytes)
- if err != nil {
- return nil, err
- }
-
- return sdk.NewResponseFormatBroadcastTx(respRaw), err
-}
+// func (chain *Network) BroadcastMsgs(
+// from sdk.AccAddress, msgs ...sdk.Msg,
+// ) (*sdk.TxResponse, error) {
+// cfg := chain.Config
+// kb, info, err := chain.keyBaseAndInfoForAddr(from)
+// if err != nil {
+// return nil, err
+// }
+
+// rpc := chain.Validators[0].RPCClient
+// txBuilder := cfg.TxConfig.NewTxBuilder()
+// err = txBuilder.SetMsgs(msgs...)
+// if err != nil {
+// return nil, err
+// }
+
+// txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(cfg.BondDenom, math.NewInt(1000))))
+// txBuilder.SetGasLimit(uint64(1 * common.TO_MICRO))
+
+// acc, err := cfg.AccountRetriever.GetAccount(chain.Validators[0].ClientCtx, from)
+// if err != nil {
+// return nil, err
+// }
+
+// txFactory := tx.Factory{}
+// txFactory = txFactory.
+// WithChainID(cfg.ChainID).
+// WithKeybase(kb).
+// WithTxConfig(cfg.TxConfig).
+// WithAccountRetriever(cfg.AccountRetriever).
+// WithAccountNumber(acc.GetAccountNumber()).
+// WithSequence(acc.GetSequence())
+
+// err = tx.Sign(ctx, txFactory, info.Name, txBuilder, true)
+// if err != nil {
+// return nil, err
+// }
+
+// txBytes, err := cfg.TxConfig.TxEncoder()(txBuilder.GetTx())
+// if err != nil {
+// return nil, err
+// }
+
+// respRaw, err := rpc.BroadcastTxSync(context.Background(), txBytes)
+// if err != nil {
+// return nil, err
+// }
+
+// return sdk.NewResponseFormatBroadcastTx(respRaw), err
+// }
diff --git a/x/common/testutil/cli/tx_test.go b/x/common/testutil/cli/tx_test.go
index e226c8fab..9545828cc 100644
--- a/x/common/testutil/cli/tx_test.go
+++ b/x/common/testutil/cli/tx_test.go
@@ -1,75 +1,75 @@
package cli_test
-import (
- "testing"
+// import (
+// "testing"
- sdk "github.com/cosmos/cosmos-sdk/types"
+// sdk "github.com/cosmos/cosmos-sdk/types"
- "cosmossdk.io/math"
- bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
+// "cosmossdk.io/math"
+// bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
+// banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/common/testutil/cli"
-)
+// "github.com/NibiruChain/nibiru/x/common/denoms"
+// "github.com/NibiruChain/nibiru/x/common/testutil"
+// "github.com/NibiruChain/nibiru/x/common/testutil/cli"
+// )
-func (s *IntegrationTestSuite) TestSendTx() {
- fromAddr := s.network.Validators[0].Address
- toAddr := testutil.AccAddress()
- sendCoin := sdk.NewCoin(denoms.NIBI, math.NewInt(42))
- txResp, err := s.network.BroadcastMsgs(fromAddr, &banktypes.MsgSend{
- FromAddress: fromAddr.String(),
- ToAddress: toAddr.String(),
- Amount: sdk.NewCoins(sendCoin),
- },
- )
- s.NoError(err)
- s.EqualValues(0, txResp.Code)
-}
+// func (s *IntegrationTestSuite) TestSendTx() {
+// fromAddr := s.network.Validators[0].Address
+// toAddr := testutil.AccAddress()
+// sendCoin := sdk.NewCoin(denoms.NIBI, math.NewInt(42))
+// txResp, err := s.network.BroadcastMsgs(fromAddr, &banktypes.MsgSend{
+// FromAddress: fromAddr.String(),
+// ToAddress: toAddr.String(),
+// Amount: sdk.NewCoins(sendCoin),
+// },
+// )
+// s.NoError(err)
+// s.EqualValues(0, txResp.Code)
+// }
-func (s *IntegrationTestSuite) TestExecTx() {
- fromAddr := s.network.Validators[0].Address
- toAddr := testutil.AccAddress()
- sendCoin := sdk.NewCoin(denoms.NIBI, math.NewInt(69))
- args := []string{fromAddr.String(), toAddr.String(), sendCoin.String()}
- txResp, err := s.network.ExecTxCmd(bankcli.NewSendTxCmd(), fromAddr, args)
- s.NoError(err)
- s.EqualValues(0, txResp.Code)
+// func (s *IntegrationTestSuite) TestExecTx() {
+// fromAddr := s.network.Validators[0].Address
+// toAddr := testutil.AccAddress()
+// sendCoin := sdk.NewCoin(denoms.NIBI, math.NewInt(69))
+// args := []string{fromAddr.String(), toAddr.String(), sendCoin.String()}
+// txResp, err := s.network.ExecTxCmd(bankcli.NewSendTxCmd(), fromAddr, args)
+// s.NoError(err)
+// s.EqualValues(0, txResp.Code)
- s.T().Run("test tx option changes", func(t *testing.T) {
- defaultOpts := cli.DEFAULT_TX_OPTIONS
- opts := cli.WithTxOptions(cli.TxOptionChanges{
- BroadcastMode: &defaultOpts.BroadcastMode,
- CanFail: &defaultOpts.CanFail,
- Fees: &defaultOpts.Fees,
- Gas: &defaultOpts.Gas,
- KeyringBackend: &defaultOpts.KeyringBackend,
- SkipConfirmation: &defaultOpts.SkipConfirmation,
- })
- txResp, err = s.network.ExecTxCmd(bankcli.NewSendTxCmd(), fromAddr, args, opts)
- s.NoError(err)
- s.EqualValues(0, txResp.Code)
- })
+// s.T().Run("test tx option changes", func(t *testing.T) {
+// defaultOpts := cli.DEFAULT_TX_OPTIONS
+// opts := cli.WithTxOptions(cli.TxOptionChanges{
+// BroadcastMode: &defaultOpts.BroadcastMode,
+// CanFail: &defaultOpts.CanFail,
+// Fees: &defaultOpts.Fees,
+// Gas: &defaultOpts.Gas,
+// KeyringBackend: &defaultOpts.KeyringBackend,
+// SkipConfirmation: &defaultOpts.SkipConfirmation,
+// })
+// txResp, err = s.network.ExecTxCmd(bankcli.NewSendTxCmd(), fromAddr, args, opts)
+// s.NoError(err)
+// s.EqualValues(0, txResp.Code)
+// })
- s.T().Run("fail when validators are missing", func(t *testing.T) {
- networkNoVals := new(cli.Network)
- *networkNoVals = *s.network
- networkNoVals.Validators = []*cli.Validator{}
- _, err := networkNoVals.ExecTxCmd(bankcli.NewTxCmd(), fromAddr, args)
- s.Error(err)
- s.Contains(err.Error(), "")
- })
-}
+// s.T().Run("fail when validators are missing", func(t *testing.T) {
+// networkNoVals := new(cli.Network)
+// *networkNoVals = *s.network
+// networkNoVals.Validators = []*cli.Validator{}
+// _, err := networkNoVals.ExecTxCmd(bankcli.NewTxCmd(), fromAddr, args)
+// s.Error(err)
+// s.Contains(err.Error(), "")
+// })
+// }
-func (s *IntegrationTestSuite) TestFillWalletFromValidator() {
- toAddr := testutil.AccAddress()
- val := s.network.Validators[0]
- funds := sdk.NewCoins(
- sdk.NewInt64Coin(denoms.NIBI, 420),
- )
- feeDenom := denoms.NIBI
- s.NoError(cli.FillWalletFromValidator(
- toAddr, funds, val, feeDenom,
- ))
-}
+// func (s *IntegrationTestSuite) TestFillWalletFromValidator() {
+// toAddr := testutil.AccAddress()
+// val := s.network.Validators[0]
+// funds := sdk.NewCoins(
+// sdk.NewInt64Coin(denoms.NIBI, 420),
+// )
+// feeDenom := denoms.NIBI
+// s.NoError(cli.FillWalletFromValidator(
+// toAddr, funds, val, feeDenom,
+// ))
+// }
diff --git a/x/common/testutil/cli/util.go b/x/common/testutil/cli/util.go
index bd018371a..4336e6345 100644
--- a/x/common/testutil/cli/util.go
+++ b/x/common/testutil/cli/util.go
@@ -1,28 +1,37 @@
package cli
import (
+ "context"
+
+ cmtjson "github.com/cometbft/cometbft/libs/json"
+ cmtos "github.com/cometbft/cometbft/libs/os"
+
"encoding/json"
"fmt"
"os"
"path/filepath"
"testing"
- "time"
+ "cosmossdk.io/log"
tmtypes "github.com/cometbft/cometbft/abci/types"
sdkcodec "github.com/cosmos/cosmos-sdk/codec"
+ addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
+ "github.com/cosmos/cosmos-sdk/server"
+ "golang.org/x/sync/errgroup"
"github.com/NibiruChain/nibiru/app/codec"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server/api"
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
- srvtypes "github.com/cosmos/cosmos-sdk/server/types"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
+ gentypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
+ cometconfig "github.com/cometbft/cometbft/config"
tmos "github.com/cometbft/cometbft/libs/os"
"github.com/cometbft/cometbft/node"
"github.com/cometbft/cometbft/p2p"
@@ -31,6 +40,7 @@ import (
"github.com/cometbft/cometbft/rpc/client/local"
"github.com/cometbft/cometbft/types"
tmtime "github.com/cometbft/cometbft/types/time"
+ servercmtlog "github.com/cosmos/cosmos-sdk/server/log"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
@@ -51,17 +61,18 @@ func startInProcess(cfg Config, val *Validator) error {
}
app := cfg.AppConstructor(*val)
+ cmtApp := server.NewCometABCIWrapper(app)
genDocProvider := node.DefaultGenesisDocProviderFunc(tmCfg)
tmNode, err := node.NewNode(
tmCfg,
pvm.LoadOrGenFilePV(tmCfg.PrivValidatorKeyFile(), tmCfg.PrivValidatorStateFile()),
nodeKey,
- proxy.NewLocalClientCreator(app),
+ proxy.NewLocalClientCreator(cmtApp),
genDocProvider,
- node.DefaultDBProvider,
+ cometconfig.DefaultDBProvider,
node.DefaultMetricsProvider(tmCfg.Instrumentation),
- logger.With("module", val.Moniker),
+ servercmtlog.CometLoggerWrapper{Logger: logger.With("module", val.Moniker)},
)
if err != nil {
return err
@@ -89,41 +100,33 @@ func startInProcess(cfg Config, val *Validator) error {
app.RegisterTendermintService(val.ClientCtx)
}
- if val.APIAddress != "" {
- apiSrv := api.New(val.ClientCtx, logger.With("module", "api-server"))
- app.RegisterAPIRoutes(apiSrv, val.AppConfig.API)
-
- errCh := make(chan error)
-
- go func() {
- if err := apiSrv.Start(*val.AppConfig); err != nil {
- errCh <- err
- }
- }()
-
- select {
- case err := <-errCh:
- return err
- case <-time.After(srvtypes.ServerStartTime): // assume server started successfully
- }
-
- val.api = apiSrv
- }
+ grpcCfg := val.AppConfig.GRPC
+ ctx := context.Background()
+ ctx, val.cancelFn = context.WithCancel(ctx)
+ val.errGroup, ctx = errgroup.WithContext(ctx)
- if val.AppConfig.GRPC.Enable {
- grpcSrv, err := servergrpc.StartGRPCServer(val.ClientCtx, app, val.AppConfig.GRPC)
+ if grpcCfg.Enable {
+ grpcSrv, err := servergrpc.NewGRPCServer(val.ClientCtx, app, grpcCfg)
if err != nil {
return err
}
+ // Start the gRPC server in a goroutine. Note, the provided ctx will ensure
+ // that the server is gracefully shut down.
+ val.errGroup.Go(func() error {
+ return servergrpc.StartGRPCServer(ctx, logger.With(log.ModuleKey, "grpc-server"), grpcCfg, grpcSrv)
+ })
+
val.grpc = grpcSrv
+ }
- if val.AppConfig.GRPCWeb.Enable {
- val.grpcWeb, err = servergrpc.StartGRPCWeb(grpcSrv, *val.AppConfig)
- if err != nil {
- return err
- }
- }
+ if val.APIAddress != "" {
+ apiSrv := api.New(val.ClientCtx, logger.With(log.ModuleKey, "api-server"), val.grpc)
+ app.RegisterAPIRoutes(apiSrv, val.AppConfig.API)
+
+ val.errGroup.Go(func() error {
+ return apiSrv.Start(ctx, *val.AppConfig)
+ })
}
return nil
@@ -144,21 +147,31 @@ func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error {
initCfg := genutiltypes.NewInitConfig(cfg.ChainID, gentxsDir, vals[i].NodeID, vals[i].PubKey)
genFile := tmCfg.GenesisFile()
- genDoc, err := types.GenesisDocFromFile(genFile)
+ appGenesis, err := gentypes.AppGenesisFromFile(genFile)
if err != nil {
return err
}
appState, err := genutil.GenAppStateFromConfig(cfg.Codec, cfg.TxConfig,
- tmCfg, initCfg, *genDoc, banktypes.GenesisBalancesIterator{}, genutiltypes.DefaultMessageValidator)
+ tmCfg, initCfg, appGenesis, banktypes.GenesisBalancesIterator{}, genutiltypes.DefaultMessageValidator, addresscodec.NewBech32Codec("nibivaloper"))
if err != nil {
return err
}
// overwrite each validator's genesis file to have a canonical genesis time
- if err := genutil.ExportGenesisFileWithTime(genFile, cfg.ChainID, nil, appState, genTime); err != nil {
+ appGenesis = gentypes.NewAppGenesisWithVersion(cfg.ChainID, appState)
+ appGenesis.GenesisTime = genTime
+ appGenesis.Consensus.Validators = nil
+
+ if err := appGenesis.ValidateAndComplete(); err != nil {
+ return err
+ }
+
+ genDocBytes, err := cmtjson.MarshalIndent(appGenesis, "", " ")
+ if err != nil {
return err
}
+ return cmtos.WriteFile(genFile, genDocBytes, 0644)
}
return nil
@@ -232,6 +245,7 @@ func FillWalletFromValidator(
val.Address,
addr,
balance,
+ addresscodec.NewBech32Codec("nibi"),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewInt64Coin(feesDenom, 10000)),
diff --git a/x/common/testutil/client_ctx.go b/x/common/testutil/client_ctx.go
index 76a88332c..8536b9685 100644
--- a/x/common/testutil/client_ctx.go
+++ b/x/common/testutil/client_ctx.go
@@ -6,7 +6,7 @@ import (
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
- "github.com/cometbft/cometbft/libs/log"
+ "cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/types/module"
@@ -21,7 +21,7 @@ import (
func SetupClientCtx(t *testing.T) context.Context {
home := t.TempDir()
logger := log.NewNopLogger()
- cfg, err := genutiltest.CreateDefaultTendermintConfig(home)
+ cfg, err := genutiltest.CreateDefaultCometConfig(home)
require.NoError(t, err)
appCodec := moduletestutil.MakeTestEncodingConfig().Codec
diff --git a/x/common/testutil/genesis/oracle_genesis.go b/x/common/testutil/genesis/oracle_genesis.go
index 024fca05c..85425a0a0 100644
--- a/x/common/testutil/genesis/oracle_genesis.go
+++ b/x/common/testutil/genesis/oracle_genesis.go
@@ -1,27 +1,27 @@
package genesis
-import (
- "cosmossdk.io/math"
+// import (
+// "cosmossdk.io/math"
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
-)
+// "github.com/NibiruChain/nibiru/app"
+// "github.com/NibiruChain/nibiru/x/common/asset"
+// "github.com/NibiruChain/nibiru/x/common/denoms"
+// oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
+// )
-func AddOracleGenesis(gen app.GenesisState) app.GenesisState {
- gen[oracletypes.ModuleName] = app.MakeEncodingConfig().Codec.
- MustMarshalJSON(OracleGenesis())
- return gen
-}
+// func AddOracleGenesis(gen app.GenesisState) app.GenesisState {
+// gen[oracletypes.ModuleName] = app.MakeEncodingConfig().Codec.
+// MustMarshalJSON(OracleGenesis())
+// return gen
+// }
-func OracleGenesis() *oracletypes.GenesisState {
- oracleGenesis := oracletypes.DefaultGenesisState()
- oracleGenesis.ExchangeRates = []oracletypes.ExchangeRateTuple{
- {Pair: asset.Registry.Pair(denoms.ETH, denoms.NUSD), ExchangeRate: math.LegacyNewDec(1_000)},
- {Pair: asset.Registry.Pair(denoms.NIBI, denoms.NUSD), ExchangeRate: math.LegacyNewDec(10)},
- }
- oracleGenesis.Params.VotePeriod = 1_000
+// func OracleGenesis() *oracletypes.GenesisState {
+// oracleGenesis := oracletypes.DefaultGenesisState()
+// oracleGenesis.ExchangeRates = []oracletypes.ExchangeRateTuple{
+// {Pair: asset.Registry.Pair(denoms.ETH, denoms.NUSD), ExchangeRate: math.LegacyNewDec(1_000)},
+// {Pair: asset.Registry.Pair(denoms.NIBI, denoms.NUSD), ExchangeRate: math.LegacyNewDec(10)},
+// }
+// oracleGenesis.Params.VotePeriod = 1_000
- return oracleGenesis
-}
+// return oracleGenesis
+// }
diff --git a/x/common/testutil/genesis/sudo_genesis.go b/x/common/testutil/genesis/sudo_genesis.go
index 475a2649c..2ed9e9a2f 100644
--- a/x/common/testutil/genesis/sudo_genesis.go
+++ b/x/common/testutil/genesis/sudo_genesis.go
@@ -1,41 +1,41 @@
package genesis
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/app"
-
- "github.com/NibiruChain/nibiru/x/sudo"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
-
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
-)
-
-func AddSudoGenesis(gen app.GenesisState) (
- genState app.GenesisState,
- rootPrivKey cryptotypes.PrivKey,
- rootAddr sdk.AccAddress,
-) {
- sudoGenesis, rootPrivKey, rootAddr := SudoGenesis()
- gen[sudotypes.ModuleName] = app.MakeEncodingConfig().Codec.
- MustMarshalJSON(sudoGenesis)
- return gen, rootPrivKey, rootAddr
-}
-
-func SudoGenesis() (
- genState *sudotypes.GenesisState,
- rootPrivKey cryptotypes.PrivKey,
- rootAddr sdk.AccAddress,
-) {
- sudoGenesis := sudo.DefaultGenesis()
-
- // Set the root user
- privKeys, addrs := testutil.PrivKeyAddressPairs(1)
- rootPrivKey = privKeys[0]
- rootAddr = addrs[0]
- sudoGenesis.Sudoers.Root = rootAddr.String()
-
- return sudoGenesis, rootPrivKey, rootAddr
-}
+// import (
+// sdk "github.com/cosmos/cosmos-sdk/types"
+
+// "github.com/NibiruChain/nibiru/app"
+
+// "github.com/NibiruChain/nibiru/x/sudo"
+// sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
+
+// cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
+
+// "github.com/NibiruChain/nibiru/x/common/testutil"
+// )
+
+// func AddSudoGenesis(gen app.GenesisState) (
+// genState app.GenesisState,
+// rootPrivKey cryptotypes.PrivKey,
+// rootAddr sdk.AccAddress,
+// ) {
+// sudoGenesis, rootPrivKey, rootAddr := SudoGenesis()
+// gen[sudotypes.ModuleName] = app.MakeEncodingConfig().Codec.
+// MustMarshalJSON(sudoGenesis)
+// return gen, rootPrivKey, rootAddr
+// }
+
+// func SudoGenesis() (
+// genState *sudotypes.GenesisState,
+// rootPrivKey cryptotypes.PrivKey,
+// rootAddr sdk.AccAddress,
+// ) {
+// sudoGenesis := sudo.DefaultGenesis()
+
+// // Set the root user
+// privKeys, addrs := testutil.PrivKeyAddressPairs(1)
+// rootPrivKey = privKeys[0]
+// rootAddr = addrs[0]
+// sudoGenesis.Sudoers.Root = rootAddr.String()
+
+// return sudoGenesis, rootPrivKey, rootAddr
+// }
diff --git a/x/common/testutil/sample.go b/x/common/testutil/sample.go
index fc23896f8..fe9013bd5 100644
--- a/x/common/testutil/sample.go
+++ b/x/common/testutil/sample.go
@@ -3,18 +3,16 @@ package testutil
import (
"math/rand"
- "github.com/cosmos/cosmos-sdk/store"
- "github.com/cosmos/cosmos-sdk/store/types"
-
+ "cosmossdk.io/log"
+ "cosmossdk.io/store"
+ "cosmossdk.io/store/metrics"
+ "cosmossdk.io/store/types"
+ cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
+ dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
-
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
- tmdb "github.com/cometbft/cometbft-db"
- "github.com/cometbft/cometbft/libs/log"
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
-
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
@@ -53,11 +51,11 @@ func PrivKeyAddressPairs(n int) (keys []cryptotypes.PrivKey, addrs []sdk.AccAddr
}
func BlankContext(storeKeyName string) sdk.Context {
- storeKey := sdk.NewKVStoreKey(storeKeyName)
- db := tmdb.NewMemDB()
- stateStore := store.NewCommitMultiStore(db)
+ storeKey := types.NewKVStoreKey(storeKeyName)
+ db := dbm.NewMemDB()
+ stateStore := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
stateStore.MountStoreWithDB(storeKey, types.StoreTypeIAVL, db)
- ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
+ ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger())
return ctx
}
diff --git a/x/common/testutil/testapp/test_util.go b/x/common/testutil/testapp/test_util.go
index 84518568d..7c535ccdd 100644
--- a/x/common/testutil/testapp/test_util.go
+++ b/x/common/testutil/testapp/test_util.go
@@ -90,7 +90,7 @@ func genesisStateWithValSet(
MinSelfDelegation: math.ZeroInt(),
}
validators = append(validators, validator)
- delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), math.LegacyOneDec()))
+ delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), sdk.ValAddress(val.Address).String(), math.LegacyOneDec()))
}
// set validators and delegations
stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations)
diff --git a/x/common/testutil/testapp/testapp.go b/x/common/testutil/testapp/testapp.go
index 94280dfc8..f2491552c 100644
--- a/x/common/testutil/testapp/testapp.go
+++ b/x/common/testutil/testapp/testapp.go
@@ -2,13 +2,14 @@ package testapp
import (
"encoding/json"
+
"time"
- "cosmossdk.io/math"
- tmdb "github.com/cometbft/cometbft-db"
+ ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
+
+ "cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cometbft/cometbft/libs/log"
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
+ tmdb "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -16,12 +17,10 @@ import (
"github.com/NibiruChain/nibiru/app"
"github.com/NibiruChain/nibiru/app/appconst"
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
"github.com/NibiruChain/nibiru/x/common/testutil"
- epochstypes "github.com/NibiruChain/nibiru/x/epochs/types"
- inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
+ // epochstypes "github.com/NibiruChain/nibiru/x/epochs/types"
+ // inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
+ // sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
)
func init() {
@@ -37,45 +36,42 @@ func NewNibiruTestAppAndContext() (*app.NibiruApp, sdk.Context) {
// Set up base app
encoding := app.MakeEncodingConfig()
var appGenesis app.GenesisState = app.NewDefaultGenesisState(encoding.Codec)
- genModEpochs := epochstypes.DefaultGenesisFromTime(time.Now().UTC())
+ // genModEpochs := epochstypes.DefaultGenesisFromTime(time.Now().UTC())
- // Set happy genesis: epochs
- appGenesis[epochstypes.ModuleName] = encoding.Codec.MustMarshalJSON(
- genModEpochs,
- )
+ // // Set happy genesis: epochs
+ // appGenesis[epochstypes.ModuleName] = encoding.Codec.MustMarshalJSON(
+ // genModEpochs,
+ // )
// Set happy genesis: sudo
- sudoGenesis := new(sudotypes.GenesisState)
- sudoGenesis.Sudoers = DefaultSudoers()
- appGenesis[sudotypes.ModuleName] = encoding.Codec.MustMarshalJSON(sudoGenesis)
+ // sudoGenesis := new(sudotypes.GenesisState)
+ // sudoGenesis.Sudoers = DefaultSudoers()
+ // appGenesis[sudotypes.ModuleName] = encoding.Codec.MustMarshalJSON(sudoGenesis)
app := NewNibiruTestApp(appGenesis)
ctx := NewContext(app)
// Set defaults for certain modules.
- app.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), math.LegacyNewDec(20000))
- app.OracleKeeper.SetPrice(ctx, "xxx:yyy", math.LegacyNewDec(20000))
- app.SudoKeeper.Sudoers.Set(ctx, DefaultSudoers())
+ // app.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), math.LegacyNewDec(20000))
+ // app.OracleKeeper.SetPrice(ctx, "xxx:yyy", math.LegacyNewDec(20000))
+ // app.SudoKeeper.Sudoers.Set(ctx, DefaultSudoers())
return app, ctx
}
// NewContext: Returns a fresh sdk.Context corresponding to the given NibiruApp.
func NewContext(nibiru *app.NibiruApp) sdk.Context {
- return nibiru.NewContext(false, tmproto.Header{
- Height: 1,
- Time: time.Now().UTC(),
- })
+ return nibiru.NewContext(false)
}
// DefaultSudoers: State for the x/sudo module for the default test app.
-func DefaultSudoers() sudotypes.Sudoers {
- addr := DefaultSudoRoot().String()
- return sudotypes.Sudoers{
- Root: addr,
- Contracts: []string{addr},
- }
-}
+// func DefaultSudoers() sudotypes.Sudoers {
+// addr := DefaultSudoRoot().String()
+// return sudotypes.Sudoers{
+// Root: addr,
+// Contracts: []string{addr},
+// }
+// }
func DefaultSudoRoot() sdk.AccAddress {
return sdk.MustAccAddressFromBech32(testutil.ADDR_SUDO_ROOT)
@@ -84,13 +80,13 @@ func DefaultSudoRoot() sdk.AccAddress {
// SetDefaultSudoGenesis: Sets the sudo module genesis state to a valid
// default. See "DefaultSudoers".
func SetDefaultSudoGenesis(gen app.GenesisState) {
- sudoGen := new(sudotypes.GenesisState)
- encoding := app.MakeEncodingConfig()
- encoding.Codec.MustUnmarshalJSON(gen[sudotypes.ModuleName], sudoGen)
- if err := sudoGen.Validate(); err != nil {
- sudoGen.Sudoers = DefaultSudoers()
- gen[sudotypes.ModuleName] = encoding.Codec.MustMarshalJSON(sudoGen)
- }
+ // sudoGen := new(sudotypes.GenesisState)
+ // encoding := app.MakeEncodingConfig()
+ // encoding.Codec.MustUnmarshalJSON(gen[sudotypes.ModuleName], sudoGen)
+ // if err := sudoGen.Validate(); err != nil {
+ // sudoGen.Sudoers = DefaultSudoers()
+ // gen[sudotypes.ModuleName] = encoding.Codec.MustMarshalJSON(sudoGen)
+ // }
}
// NewNibiruTestAppAndZeroTimeCtx: Runs NewNibiruTestAppAndZeroTimeCtx with the
@@ -111,7 +107,7 @@ func NewNibiruTestApp(gen app.GenesisState, baseAppOptions ...func(*baseapp.Base
encoding := app.MakeEncodingConfig()
SetDefaultSudoGenesis(gen)
- app := app.NewNibiruApp(
+ application := app.NewNibiruApp(
logger,
db,
/*traceStore=*/ nil,
@@ -131,12 +127,12 @@ func NewNibiruTestApp(gen app.GenesisState, baseAppOptions ...func(*baseapp.Base
panic(err)
}
- app.InitChain(abci.RequestInitChain{
+ application.InitChain(&abci.RequestInitChain{
ConsensusParams: sims.DefaultConsensusParams,
AppStateBytes: stateBytes,
})
- return app
+ return application
}
// FundAccount is a utility function that funds an account by minting and
@@ -146,11 +142,11 @@ func FundAccount(
bankKeeper bankkeeper.Keeper, ctx sdk.Context, addr sdk.AccAddress,
amounts sdk.Coins,
) error {
- if err := bankKeeper.MintCoins(ctx, inflationtypes.ModuleName, amounts); err != nil {
+ if err := bankKeeper.MintCoins(ctx, ibctransfertypes.ModuleName, amounts); err != nil {
return err
}
- return bankKeeper.SendCoinsFromModuleToAccount(ctx, inflationtypes.ModuleName, addr, amounts)
+ return bankKeeper.SendCoinsFromModuleToAccount(ctx, ibctransfertypes.ModuleName, addr, amounts)
}
// FundModuleAccount is a utility function that funds a module account by
@@ -160,11 +156,12 @@ func FundModuleAccount(
bankKeeper bankkeeper.Keeper, ctx sdk.Context,
recipientMod string, amounts sdk.Coins,
) error {
- if err := bankKeeper.MintCoins(ctx, inflationtypes.ModuleName, amounts); err != nil {
- return err
- }
+ // if err := bankKeeper.MintCoins(ctx, inflationtypes.ModuleName, amounts); err != nil {
+ // return err
+ // }
- return bankKeeper.SendCoinsFromModuleToModule(ctx, inflationtypes.ModuleName, recipientMod, amounts)
+ // return bankKeeper.SendCoinsFromModuleToModule(ctx, inflationtypes.ModuleName, recipientMod, amounts)
+ return nil
}
// EnsureNibiruPrefix sets the account address prefix to Nibiru's rather than
diff --git a/x/devgas/v1/README.md b/x/devgas/v1/README.md
deleted file mode 100644
index 0564fc282..000000000
--- a/x/devgas/v1/README.md
+++ /dev/null
@@ -1,509 +0,0 @@
-# devgas
-
-The `devgas` module of Nibiru Chain shares contract execution fees with smart contract
-developers.
-
-This aims to increase the adoption of Nibiru by offering CosmWasm smart
-contract developers a direct source of income based on usage. Developers can
-register their smart contracts and every time someone interacts with a
-registered smart contract, the contract deployer or their assigned withdrawal
-account receives a part of the transaction fees.
-
-Table of Contents
-
-- [Register a Contract Withdrawal Address](#register-a-contract-withdrawal-address)
- - [Register Args](#register-args)
- - [Description](#description)
- - [Permissions](#permissions)
- - [Exceptions](#exceptions)
-- [Update a Contract's Withdrawal Address](#update-a-contracts-withdrawal-address)
- - [Update Exception](#update-exception)
-- [Concepts](#concepts)
- - [FeeShare](#feeshare)
- - [Registration](#registration)
- - [Fee Distribution](#fee-distribution)
- - [WASM Transaction Fees](#wasm-transaction-fees)
-- [State](#state)
- - [State: FeeShare](#state-feeshare)
- - [State: ContractAddress](#state-contractaddress)
- - [DeployerAddress](#deployeraddress)
- - [WithdrawerAddress](#withdraweraddress)
- - [Genesis State](#genesis-state)
-- [State Transitions](#state-transitions)
-- [Register Fee Share](#register-fee-share)
- - [Update Fee Split](#update-fee-split)
- - [Cancel Fee Split](#cancel-fee-split)
-- [TxMsgs - devgas](#txmsgs---devgas)
-- [`MsgRegisterFeeShare`](#msgregisterfeeshare)
- - [`MsgUpdateFeeShare`](#msgupdatefeeshare)
- - [`MsgCancelFeeShare`](#msgcancelfeeshare)
-- [Ante](#ante)
-- [Handling](#handling)
-- [Events](#events)
- - [Event: Register Fee Split](#event-register-fee-split)
- - [Event: Update Fee Split](#event-update-fee-split)
- - [Event: Cancel Fee Split](#event-cancel-fee-split)
-- [Module Parameters](#module-parameters)
-- [Enable FeeShare Module](#enable-feeshare-module)
- - [Developer Shares Amount](#developer-shares-amount)
- - [Allowed Denominations](#allowed-denominations)
-- [Clients](#clients)
-- [Command Line Interface](#command-line-interface)
- - [Queries](#queries)
- - [Transactions](#transactions)
-- [gRPC Queries](#grpc-queries)
- - [gRPC Transactions](#grpc-transactions)
-
-# Register a Contract Withdrawal Address
-
-```bash
-nibid tx devgas register [contract_bech32] [withdraw_bech32] --from [key]
-```
-
-Registers the withdrawal address for the given contract.
-
-### Register Args
-
-`contract_bech32 (string, required)`: The bech32 address of the contract whose
-interaction fees will be shared.
-
-`withdraw_bech32 (string, required)`: The bech32 address where the interaction
-fees will be sent every block.
-
-
-### Description
-
-This command registers the withdrawal address for the given contract. Any time
-a user interacts with your contract, the funds will be sent to the withdrawal
-address. It can be any valid address, such as a DAO, normal account, another
-contract, or a multi-sig.
-
-### Permissions
-
-This command can only be run by the admin of the contract. If there is no
-admin, then it can only be run by the contract creator.
-
-### Exceptions
-
-- `withdraw_bech32` can not be the community pool (distribution) address. This
- is a limitation of the way the SDK handles this module account
-
-- For contracts created or administered by a contract factory, the withdrawal
- address can only be the same as the contract address. This can be registered
- by anyone, but it's unchangeable. This is helpful for SubDAOs or public goods
- to save fees in the treasury.
-
-If you create a contract like this, it's best to create an execution method for
-withdrawing fees to an account. To do this, you'll need to save the withdrawal
-address in the contract's state before uploading a non-migratable contract.
-
-## Update a Contract's Withdrawal Address
-
-This can be changed at any time so long as you are still the admin or creator
-of a contract with the command:
-
-```bash
-nibid tx devgas update [contract] [new_withdraw_address]
-```
-
-### Update Exception
-
-This can not be done if the contract was created from or is administered by
-another contract (a contract factory). There is not currently a way for a
-contract to change its own withdrawal address directly.
-
-# Concepts
-
-### FeeShare
-
-The DevGas (`x/devgas`) module is a revenue-per-gas model, which allows
-developers to get paid for deploying their decentralized applications (dApps)
-on Nibiru. This helps developers to generate revenue every time a user
-invokes their contracts to execute a transaction on the chain.
-
-This registration is permissionless to sign up for and begin earning fees from.
-By default, 50% of all gas fees for Execute Messages are shared. This
-can be changed by governance and implemented by the `x/devgas` module.
-
-### Registration
-
-Developers register their contract applications to gain their cut of fees per
-execution. Any contract can be registered by a developer by submitting a signed
-transaction. After the transaction is executed successfully, the developer will
-start receiving a portion of the transaction fees paid when a user interacts
-with the registered contract. The developer can have the funds sent to their
-wallet, a DAO, or any other wallet address on the Nibiru.
-
-::: tip
-**NOTE**: If your contract is part of a development project, please ensure that
-the deployer of the contract (or the factory/DAO that deployed the contract) is
-an account that is owned by that project. This avoids the situation, that an
-individual deployer who leaves your project could become malicious.
-:::
-
-### Fee Distribution
-
-As described above, developers will earn a portion of the transaction fee after
-registering their contracts. To understand how transaction fees are
-distributed, we will look at the following in detail:
-
-* The transactions eligible are only [Wasm Execute Txs](https://github.com/CosmWasm/wasmd/blob/main/proto/cosmwasm/wasm/v1/tx.proto#L115-L127) (`MsgExecuteContract`).
-
-### WASM Transaction Fees
-
-Users pay transaction fees to pay to interact with smart contracts on Nibiru.
-When a transaction is executed, the entire fee amount (`gas limit * gas price`)
-is sent to the `FeeCollector` module account during the [Cosmos SDK
-AnteHandler](https://docs.cosmos.network/main/modules/auth/#antehandlers)
-execution.
-
-After this step, the `FeeCollector` sends 50% of the funds and splits them
-between contracts that were executed on the transaction. If the fees paid are
-not accepted by governance, there is no payout to the developers (for example,
-niche base tokens) for tax purposes. If a user sends a message and it does not
-interact with any contracts (ex: bankSend), then the entire fee is sent to the
-`FeeCollector` as expected.
-
-# State
-
-The `x/devgas` module keeps the following objects in the state:
-
-| State Object | Description | Key | Value | Store |
-| :-------------------- | :------------------------------------ | :---------------------------------------------------------------- | :----------------- | :---- |
-| `FeeShare` | Fee split bytecode | `[]byte{1} + []byte(contract_address)` | `[]byte{feeshare}` | KV |
-| `DeployerFeeShares` | Contract by deployer address bytecode | `[]byte{2} + []byte(deployer_address) + []byte(contract_address)` | `[]byte{1}` | KV |
-| `FeeSharesByWithdrawer` | Contract by withdraw address bytecode | `[]byte{3} + []byte(withdraw_address) + []byte(contract_address)` | `[]byte{1}` | KV |
-
-### State: FeeShare
-
-A `FeeShare` defines an instance that organizes fee distribution conditions for
-the owner of a given smart contract
-
-```go
-type FeeShare struct {
- // contract_address is the bech32 address of a registered contract in string form
- ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
- // deployer_address is the bech32 address of message sender. It must be the
- // same as the contracts admin address.
- DeployerAddress string `protobuf:"bytes,2,opt,name=deployer_address,json=deployerAddress,proto3" json:"deployer_address,omitempty"`
- // withdrawer_address is the bech32 address of account receiving the
- // transaction fees.
- WithdrawerAddress string `protobuf:"bytes,3,opt,name=withdrawer_address,json=withdrawerAddress,proto3" json:"withdrawer_address,omitempty"`
-}
-```
-
-#### State: ContractAddress
-
-`ContractAddress` defines the contract address that has been registered for fee distribution.
-
-#### DeployerAddress
-
-A `DeployerAddress` is the admin address for a registered contract.
-
-#### WithdrawerAddress
-
-The `WithdrawerAddress` is the address that receives transaction fees for a registered contract.
-
-### Genesis State
-
-The `x/devgas` module's `GenesisState` defines the state necessary for initializing the chain from a previously exported height. It contains the module parameters and the fee share for registered contracts:
-
-```go
-// GenesisState defines the module's genesis state.
-type GenesisState struct {
- // module parameters
- Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
- // active registered contracts for fee distribution
- FeeShares []FeeShare `protobuf:"bytes,2,rep,name=feeshares,json=feeshares,proto3" json:"feeshares"`
-}
-```
-
-# State Transitions
-
-The `x/devgas` module allows for three types of state transitions:
-`RegisterFeeShare`, `UpdateFeeShare` and `CancelFeeShare`. The logic for
-distributing transaction fees is handled through the [Ante
-handler](/app/ante.go).
-
-## Register Fee Share
-
-A developer registers a contract for receiving transaction fees by defining the
-contract address and the withdrawal address for fees to be paid too. If this is
-not set, the developer can not get income from the contract. This is opt-in for
-tax purposes. When registering for fees to be paid, you MUST be the admin of
-said wasm contract. The withdrawal address can be the same as the contract's
-address if you so choose.
-
-1. User submits a `RegisterFeeShare` to register a contract address, along with
- a withdrawal address that they would like to receive the fees to
-2. Check if the following conditions pass:
- 1. `x/devgas` module is enabled via Governance
- 2. the contract was not previously registered
- 3. deployer has a valid account (it has done at least one transaction)
- 4. the contract address exists
- 5. the deployer signing the transaction is the admin of the contract
- 6. the contract is already deployed
-3. Store an instance of the provided share.
-
-All transactions sent to the registered contract occurring after registration
-will have their fees distributed to the developer, according to the global
-`DeveloperShares` parameter in governance.
-
-### Update Fee Split
-
-A developer updates the withdraw address for a registered contract, defining
-the contract address and the new withdraw address.
-
-1. The user submits a `UpdateFeeShare`
-2. Check if the following conditions pass:
- 1. `x/devgas` module is enabled
- 2. the contract is registered
- 3. the signer of the transaction is the same as the contract admin per the
- WasmVM
-3. Update the fee with the new withdrawal address.
-
-After this update, the developer receives the fees on the new withdrawal
-address.
-
-### Cancel Fee Split
-
-A developer cancels receiving fees for a registered contract, defining the
-contract address.
-
-1. The user submits a `CancelFeeShare`
-2. Check if the following conditions pass:
- 1. `x/devgas` module is enabled
- 2. the contract is registered
- 3. the signer of the transaction is the same as the contract admin per the
- WasmVM
-3. Remove share from storage
-
-The developer no longer receives fees from transactions sent to this contract.
-All fees go to the community.
-
-# TxMsgs - devgas
-
-This section defines the `sdk.Msg` concrete types that result in the state
-transitions defined on the previous section.
-
-## `MsgRegisterFeeShare`
-
-Defines a transaction signed by a developer to register a contract for
-transaction fee distribution. The sender must be an EOA that corresponds to the
-contract deployer address.
-
-```go
-type MsgRegisterFeeShare struct {
- // contract_address in bech32 format
- ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
- // deployer_address is the bech32 address of message sender. It must be the
- // same the contract's admin address
- DeployerAddress string `protobuf:"bytes,2,opt,name=deployer_address,json=deployerAddress,proto3" json:"deployer_address,omitempty"`
- // withdrawer_address is the bech32 address of account receiving the
- // transaction fees
- WithdrawerAddress string `protobuf:"bytes,3,opt,name=withdrawer_address,json=withdrawerAddress,proto3" json:"withdrawer_address,omitempty"`
-}
-```
-
-The message content stateless validation fails if:
-
-- Contract bech32 address is invalid
-- Deployer bech32 address is invalid
-- Withdraw bech32 address is invalid
-
-### `MsgUpdateFeeShare`
-
-Defines a transaction signed by a developer to update the withdraw address of a contract registered for transaction fee distribution. The sender must be the admin of the contract.
-
-```go
-type MsgUpdateFeeShare struct {
- // contract_address in bech32 format
- ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
- // deployer_address is the bech32 address of message sender. It must be the
- // same the contract's admin address
- DeployerAddress string `protobuf:"bytes,2,opt,name=deployer_address,json=deployerAddress,proto3" json:"deployer_address,omitempty"`
- // withdrawer_address is the bech32 address of account receiving the
- // transaction fees
- WithdrawerAddress string `protobuf:"bytes,3,opt,name=withdrawer_address,json=withdrawerAddress,proto3" json:"withdrawer_address,omitempty"`
-}
-```
-
-The message content stateless validation fails if:
-
-- Contract bech32 address is invalid
-- Deployer bech32 address is invalid
-- Withdraw bech32 address is invalid
-
-### `MsgCancelFeeShare`
-
-Defines a transaction signed by a developer to remove the information for a registered contract. Transaction fees will no longer be distributed to the developer for this smart contract. The sender must be an admin that corresponds to the contract.
-
-```go
-type MsgCancelFeeShare struct {
- // contract_address in bech32 format
- ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
- // deployer_address is the bech32 address of message sender. It must be the
- // same the contract's admin address
- DeployerAddress string `protobuf:"bytes,2,opt,name=deployer_address,json=deployerAddress,proto3" json:"deployer_address,omitempty"`
-}
-```
-
-The message content stateless validation fails if:
-
-- Contract bech32 address is invalid
-- Contract bech32 address is zero
-- Deployer bech32 address is invalid
-
-# Ante
-
-The fees module uses the ante handler to distribute fees between developers and the community.
-
-## Handling
-
-An [Ante Decorator](/x/devgas/ante/ante.go) executes custom logic after each
-successful WasmExecuteMsg transaction. All fees paid by a user for transaction
-execution are sent to the `FeeCollector` module account during the
-`AnteHandler` execution before being redistributed to the registered contract
-developers.
-
-If the `x/devgas` module is disabled or the Wasm Execute Msg transaction
-targets an unregistered contract, the handler returns `nil`, without performing
-any actions. In this case, 100% of the transaction fees remain in the
-`FeeCollector` module, to be distributed elsewhere.
-
-If the `x/devgas` module is enabled and a Wasm Execute Msg transaction
-targets a registered contract, the handler sends a percentage of the
-transaction fees (paid by the user) to the withdraw address set for that
-contract.
-
-1. The user submits an Execute transaction (`MsgExecuteContract`) to a smart
- contract and the transaction is executed successfully
-2. Check if
- * fees module is enabled
- * the smart contract is registered to receive fee split
-3. Calculate developer fees according to the `DeveloperShares` parameter.
-4. Check what fees governance allows to be paid in
-5. Check which contracts the user executed that also have been registered.
-6. Calculate the total amount of fees to be paid to the developer(s). If
-multiple, split the 50% between all registered withdrawal addresses.
-7. Distribute the remaining amount in the `FeeCollector` to validators
-according to the [SDK Distribution
-Scheme](https://docs.cosmos.network/main/modules/distribution/03_begin_block.html#the-distribution-scheme).
-
-# Events
-
-The `x/devgas` module emits the following events:
-
-### Event: Register Fee Split
-
-| Type | Attribute Key | Attribute Value |
-| :------------------- | :--------------------- | :------------------------ |
-| `register_feeshare` | `"contract"` | `{msg.ContractAddress}` |
-| `register_feeshare` | `"sender"` | `{msg.DeployerAddress}` |
-| `register_feeshare` | `"withdrawer_address"` | `{msg.WithdrawerAddress}` |
-
-### Event: Update Fee Split
-
-| Type | Attribute Key | Attribute Value |
-| :----------------- | :--------------------- | :------------------------ |
-| `update_feeshare` | `"contract"` | `{msg.ContractAddress}` |
-| `update_feeshare` | `"sender"` | `{msg.DeployerAddress}` |
-| `update_feeshare` | `"withdrawer_address"` | `{msg.WithdrawerAddress}` |
-
-### Event: Cancel Fee Split
-
-| Type | Attribute Key | Attribute Value |
-| :----------------- | :------------ | :---------------------- |
-| `cancel_feeshare` | `"contract"` | `{msg.ContractAddress}` |
-| `cancel_feeshare` | `"sender"` | `{msg.DeployerAddress}` |
-
-# Module Parameters
-
-The fee Split module contains the following parameters:
-
-| Key | Type | Default Value |
-| :------------------------- | :---------- | :--------------- |
-| `EnableFeeShare` | bool | `true` |
-| `DeveloperShares` | sdk.Dec | `50%` |
-| `AllowedDenoms` | []string{} | `[]string(nil)` |
-
-## Enable FeeShare Module
-
-The `EnableFeeShare` parameter toggles all state transitions in the module.
-When the parameter is disabled, it will prevent any transaction fees from being
-distributed to contract deplorers and it will disallow contract registrations,
-updates or cancellations.
-
-### Developer Shares Amount
-
-The `DeveloperShares` parameter is the percentage of transaction fees that are
-sent to the contract deplorers.
-
-### Allowed Denominations
-
-The `AllowedDenoms` parameter is used to specify which fees coins will be paid
-to contract developers. If this is empty, all fees paid will be split. If not,
-only fees specified here will be paid out to the withdrawal address.
-
-# Clients
-
-## Command Line Interface
-
-Find below a list of `nibid` commands added with the `x/devgas` module. You
-can obtain the full list by using the `nibid -h` command. A CLI command can
-look like this:
-
-```bash
-nibid query feeshare params
-```
-
-### Queries
-
-| Command | Subcommand | Description |
-| :----------------- | :--------------------- | :--------------------------------------- |
-| `query` `feeshare` | `params` | Get devgas params |
-| `query` `feeshare` | `contract` | Get the devgas for a given contract |
-| `query` `feeshare` | `contracts` | Get all feeshares |
-| `query` `feeshare` | `deployer-contracts` | Get all feeshares of a given deployer |
-| `query` `feeshare` | `withdrawer-contracts` | Get all feeshares of a given withdrawer |
-
-### Transactions
-
-| Command | Subcommand | Description |
-| :-------------- | :--------- | :----------------------------------------- |
-| `tx` `feeshare` | `register` | Register a contract for receiving devgas |
-| `tx` `feeshare` | `update` | Update the withdraw address for a contract |
-| `tx` `feeshare` | `cancel` | Remove the devgas for a contract |
-
-## gRPC Queries
-
-| Verb | Method | Description |
-| :----- | :------------------------------------------------ | :--------------------------------------- |
-| `gRPC` | `nibiru.devgas.v1.Query/Params` | Get devgas params |
-| `gRPC` | `nibiru.devgas.v1.Query/FeeShare` | Get the devgas for a given contract |
-| `gRPC` | `nibiru.devgas.v1.Query/FeeShares` | Get all feeshares |
-| `gRPC` | `nibiru.devgas.v1.Query/DeployerFeeShares` | Get all feeshares of a given deployer |
-| `gRPC` | `nibiru.devgas.v1.Query/FeeSharesByWithdrawer` | Get all feeshares of a given withdrawer |
-| `GET` | `/nibiru.devgas/v1/params` | Get devgas params |
-| `GET` | `/nibiru.devgas/v1/feeshares/{contract_address}` | Get the devgas for a given contract |
-| `GET` | `/nibiru.devgas/v1/feeshares` | Get all feeshares |
-| `GET` | `/nibiru.devgas/v1/feeshares/{deployer_address}` | Get all feeshares of a given deployer |
-| `GET` | `/nibiru.devgas/v1/feeshares/{withdraw_address}` | Get all feeshares of a given withdrawer |
-
-### gRPC Transactions
-
-| Verb | Method | Description |
-| :----- | :----------------------------------------- | :----------------------------------------- |
-| `gRPC` | `nibiru.devgas.v1.Msg/RegisterFeeShare` | Register a contract for receiving devgas |
-| `gRPC` | `nibiru.devgas.v1.Msg/UpdateFeeShare` | Update the withdraw address for a contract |
-| `gRPC` | `nibiru.devgas.v1.Msg/CancelFeeShare` | Remove the devgas for a contract |
-| `POST` | `/nibiru.devgas/v1/tx/register_feeshare` | Register a contract for receiving devgas |
-| `POST` | `/nibiru.devgas/v1/tx/update_feeshare` | Update the withdraw address for a contract |
-| `POST` | `/nibiru.devgas/v1/tx/cancel_feeshare` | Remove the devgas for a contract |
-
-## Credits: Evmos and Juno
-
-> "This module is a heavily modified fork of
-[evmos/x/revenue](https://github.com/evmos/evmos/tree/main/x/revenue)" - Juno Network
-
-This module is a heavily modified fork of Juno's heavily modified fork. 🙃
diff --git a/x/devgas/v1/ante/ante.go b/x/devgas/v1/ante/ante.go
deleted file mode 100644
index 1583138bd..000000000
--- a/x/devgas/v1/ante/ante.go
+++ /dev/null
@@ -1,181 +0,0 @@
-package ante
-
-import (
- "encoding/json"
-
- wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
-
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-var _ sdk.AnteDecorator = (*DevGasPayoutDecorator)(nil)
-
-// DevGasPayoutDecorator Run his after we already deduct the fee from the
-// account with the ante.NewDeductFeeDecorator() decorator. We pull funds from
-// the FeeCollector ModuleAccount
-type DevGasPayoutDecorator struct {
- bankKeeper BankKeeper
- devgasKeeper IDevGasKeeper
-}
-
-func NewDevGasPayoutDecorator(
- bk BankKeeper, fs IDevGasKeeper,
-) DevGasPayoutDecorator {
- return DevGasPayoutDecorator{
- bankKeeper: bk,
- devgasKeeper: fs,
- }
-}
-
-func (a DevGasPayoutDecorator) AnteHandle(
- ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler,
-) (newCtx sdk.Context, err error) {
- feeTx, ok := tx.(sdk.FeeTx)
- if !ok {
- return ctx, sdkerrors.ErrTxDecode.Wrap("Tx must be a FeeTx")
- }
-
- err = a.devGasPayout(
- ctx, feeTx,
- )
- if err != nil {
- return ctx, sdkerrors.ErrInsufficientFunds.Wrap(err.Error())
- }
-
- return next(ctx, tx, simulate)
-}
-
-// devGasPayout takes the total fees and redistributes 50% (or param set) to
-// the contract developers provided they opted-in to payments.
-func (a DevGasPayoutDecorator) devGasPayout(
- ctx sdk.Context,
- tx sdk.FeeTx,
-) error {
- params := a.devgasKeeper.GetParams(ctx)
- if !params.EnableFeeShare {
- return nil
- }
-
- toPay, err := a.getWithdrawAddressesFromMsgs(ctx, tx.GetMsgs())
- if err != nil {
- return err
- }
-
- // Do nothing if no one needs payment
- if len(toPay) == 0 {
- return nil
- }
-
- feesPaidOutput, err := a.settleFeePayments(ctx, toPay, params, tx.GetFee())
- if err != nil {
- return err
- }
-
- bz, err := json.Marshal(feesPaidOutput)
- if err != nil {
- return devgastypes.ErrFeeSharePayment.Wrapf("failed to marshal feesPaidOutput: %s", err.Error())
- }
-
- return ctx.EventManager().EmitTypedEvent(
- &devgastypes.EventPayoutDevGas{Payouts: string(bz)},
- )
-}
-
-type FeeSharePayoutEventOutput struct {
- WithdrawAddress sdk.AccAddress `json:"withdraw_address"`
- FeesPaid sdk.Coins `json:"fees_paid"`
-}
-
-// settleFeePayments sends the funds to the contract developers
-func (a DevGasPayoutDecorator) settleFeePayments(
- ctx sdk.Context, toPay []sdk.AccAddress, params devgastypes.ModuleParams, totalFees sdk.Coins,
-) ([]FeeSharePayoutEventOutput, error) {
- allowedFees := getAllowedFees(params, totalFees)
-
- numPairs := len(toPay)
- feesPaidOutput := make([]FeeSharePayoutEventOutput, numPairs)
- if numPairs > 0 {
- govPercent := params.DeveloperShares
- splitFees := FeePayLogic(allowedFees, govPercent, numPairs)
-
- // pay fees evenly between all withdraw addresses
- for i, withdrawAddr := range toPay {
- err := a.bankKeeper.SendCoinsFromModuleToAccount(ctx, authtypes.FeeCollectorName, withdrawAddr, splitFees)
- feesPaidOutput[i] = FeeSharePayoutEventOutput{
- WithdrawAddress: withdrawAddr,
- FeesPaid: splitFees,
- }
-
- if err != nil {
- return nil, devgastypes.ErrFeeSharePayment.Wrapf("failed to pay allowedFees to contract developer: %s", err.Error())
- }
- }
- }
-
- return feesPaidOutput, nil
-}
-
-// getAllowedFees gets the allowed fees to be paid based on the module
-// parameters of x/devgas
-func getAllowedFees(params devgastypes.ModuleParams, totalFees sdk.Coins) sdk.Coins {
- // Get only allowed governance fees to be paid (helps for taxes)
- var allowedFees sdk.Coins
- if len(params.AllowedDenoms) == 0 {
- // If empty, we allow all denoms to be used as payment
- allowedFees = totalFees
- } else {
- for _, fee := range totalFees.Sort() {
- for _, allowed := range params.AllowedDenoms {
- if fee.Denom == allowed {
- allowedFees = allowedFees.Add(fee)
- }
- }
- }
- }
-
- return allowedFees
-}
-
-// getWithdrawAddressesFromMsgs returns a list of all contract addresses that
-// have opted-in to receiving payments
-func (a DevGasPayoutDecorator) getWithdrawAddressesFromMsgs(ctx sdk.Context, msgs []sdk.Msg) ([]sdk.AccAddress, error) {
- toPay := make([]sdk.AccAddress, 0)
- for _, msg := range msgs {
- if _, ok := msg.(*wasmtypes.MsgExecuteContract); ok {
- contractAddr, err := sdk.AccAddressFromBech32(
- msg.(*wasmtypes.MsgExecuteContract).Contract,
- )
- if err != nil {
- return nil, err
- }
-
- shareData, _ := a.devgasKeeper.GetFeeShare(ctx, contractAddr)
-
- withdrawAddr := shareData.GetWithdrawerAddr()
- if withdrawAddr != nil && !withdrawAddr.Empty() {
- toPay = append(toPay, withdrawAddr)
- }
- }
- }
-
- return toPay, nil
-}
-
-// FeePayLogic takes the total fees and splits them based on the governance
-// params and the number of contracts we are executing on. This returns the
-// amount of fees each contract developer should get. tested in ante_test.go
-func FeePayLogic(fees sdk.Coins, govPercent sdk.Dec, numPairs int) sdk.Coins {
- var splitFees sdk.Coins
- for _, c := range fees.Sort() {
- rewardAmount := govPercent.MulInt(c.Amount).QuoInt64(int64(numPairs)).RoundInt()
- if !rewardAmount.IsZero() {
- splitFees = splitFees.Add(sdk.NewCoin(c.Denom, rewardAmount))
- }
- }
-
- return splitFees
-}
diff --git a/x/devgas/v1/ante/ante_test.go b/x/devgas/v1/ante/ante_test.go
deleted file mode 100644
index fe520bca7..000000000
--- a/x/devgas/v1/ante/ante_test.go
+++ /dev/null
@@ -1,293 +0,0 @@
-package ante_test
-
-import (
- "fmt"
- "strings"
- "testing"
-
- "cosmossdk.io/math"
- wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
- sdkclienttx "github.com/cosmos/cosmos-sdk/client/tx"
- "github.com/stretchr/testify/suite"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- devgasante "github.com/NibiruChain/nibiru/x/devgas/v1/ante"
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-type AnteTestSuite struct {
- suite.Suite
-}
-
-func TestAnteSuite(t *testing.T) {
- testapp.EnsureNibiruPrefix()
- suite.Run(t, new(AnteTestSuite))
-}
-
-func (suite *AnteTestSuite) TestFeeLogic() {
- // We expect all to pass
- feeCoins := sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(500)), sdk.NewCoin("utoken", math.NewInt(250)))
-
- testCases := []struct {
- name string
- incomingFee sdk.Coins
- govPercent sdk.Dec
- numContracts int
- expectedFeePayment sdk.Coins
- }{
- {
- "100% fee / 1 contract",
- feeCoins,
- math.LegacyNewDecWithPrec(100, 2),
- 1,
- sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(500)), sdk.NewCoin("utoken", math.NewInt(250))),
- },
- {
- "100% fee / 2 contracts",
- feeCoins,
- math.LegacyNewDecWithPrec(100, 2),
- 2,
- sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(250)), sdk.NewCoin("utoken", math.NewInt(125))),
- },
- {
- "100% fee / 10 contracts",
- feeCoins,
- math.LegacyNewDecWithPrec(100, 2),
- 10,
- sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(50)), sdk.NewCoin("utoken", math.NewInt(25))),
- },
- {
- "67% fee / 7 contracts",
- feeCoins,
- math.LegacyNewDecWithPrec(67, 2),
- 7,
- sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(48)), sdk.NewCoin("utoken", math.NewInt(24))),
- },
- {
- "50% fee / 1 contracts",
- feeCoins,
- math.LegacyNewDecWithPrec(50, 2),
- 1,
- sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(250)), sdk.NewCoin("utoken", math.NewInt(125))),
- },
- {
- "50% fee / 2 contracts",
- feeCoins,
- math.LegacyNewDecWithPrec(50, 2),
- 2,
- sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(125)), sdk.NewCoin("utoken", math.NewInt(62))),
- },
- {
- "50% fee / 3 contracts",
- feeCoins,
- math.LegacyNewDecWithPrec(50, 2),
- 3,
- sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(83)), sdk.NewCoin("utoken", math.NewInt(42))),
- },
- {
- "25% fee / 2 contracts",
- feeCoins,
- math.LegacyNewDecWithPrec(25, 2),
- 2,
- sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(62)), sdk.NewCoin("utoken", math.NewInt(31))),
- },
- {
- "15% fee / 3 contracts",
- feeCoins,
- math.LegacyNewDecWithPrec(15, 2),
- 3,
- sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(25)), sdk.NewCoin("utoken", math.NewInt(12))),
- },
- {
- "1% fee / 2 contracts",
- feeCoins,
- math.LegacyNewDecWithPrec(1, 2),
- 2,
- sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(2)), sdk.NewCoin("utoken", math.NewInt(1))),
- },
- }
-
- for _, tc := range testCases {
- coins := devgasante.FeePayLogic(tc.incomingFee, tc.govPercent, tc.numContracts)
-
- for _, coin := range coins {
- for _, expectedCoin := range tc.expectedFeePayment {
- if coin.Denom == expectedCoin.Denom {
- suite.Require().Equal(expectedCoin.Amount.Int64(), coin.Amount.Int64(), tc.name)
- }
- }
- }
- }
-}
-
-func (suite *AnteTestSuite) TestDevGasPayout() {
- txGasCoins := sdk.NewCoins(
- sdk.NewCoin("unibi", math.NewInt(1_000)),
- sdk.NewCoin("utoken", math.NewInt(500)),
- )
-
- _, addrs := testutil.PrivKeyAddressPairs(11)
- contracts := addrs[:5]
- withdrawAddrs := addrs[5:10]
- deployerAddr := addrs[10]
- wasmExecMsgs := []*wasmtypes.MsgExecuteContract{
- {Contract: contracts[0].String()},
- {Contract: contracts[1].String()},
- {Contract: contracts[2].String()},
- {Contract: contracts[3].String()},
- {Contract: contracts[4].String()},
- }
- devGasForWithdrawer := func(
- contractIdx int, withdrawerIdx int,
- ) devgastypes.FeeShare {
- return devgastypes.FeeShare{
- ContractAddress: contracts[contractIdx].String(),
- DeployerAddress: deployerAddr.String(),
- WithdrawerAddress: withdrawAddrs[withdrawerIdx].String(),
- }
- }
-
- testCases := []struct {
- name string
- devGasState []devgastypes.FeeShare
- wantWithdrawerRoyalties sdk.Coins
- wantErr bool
- setup func() (*app.NibiruApp, sdk.Context)
- }{
- {
- name: "1 contract, 1 exec, 1 withdrawer",
- devGasState: []devgastypes.FeeShare{
- devGasForWithdrawer(0, 0),
- },
- // The expected royalty is gas / num_withdrawers / 2. Thus, We
- // divide gas by (num_withdrawers * 2). The 2 comes from 50% split.
- // wantWithdrawerRoyalties: num_withdrawers * 2 = 2
- wantWithdrawerRoyalties: txGasCoins.QuoInt(math.NewInt(2)),
- wantErr: false,
- setup: func() (*app.NibiruApp, sdk.Context) {
- bapp, ctx := testapp.NewNibiruTestAppAndContext()
- err := testapp.FundModuleAccount(
- bapp.BankKeeper, ctx, authtypes.FeeCollectorName, txGasCoins)
- suite.NoError(err)
- return bapp, ctx
- },
- },
- {
- name: "1 contract, 4 exec, 2 withdrawer",
- devGasState: []devgastypes.FeeShare{
- devGasForWithdrawer(0, 0),
- devGasForWithdrawer(1, 0),
- devGasForWithdrawer(2, 1),
- devGasForWithdrawer(3, 1),
- },
- // The expected royalty is gas / num_withdrawers / 2. Thus, We
- // divide gas by (num_withdrawers * 2). The 2 comes from 50% split.
- // wantWithdrawerRoyalties: num_withdrawers * 2 = 4
- wantWithdrawerRoyalties: txGasCoins.QuoInt(math.NewInt(4)),
- wantErr: false,
- setup: func() (*app.NibiruApp, sdk.Context) {
- bapp, ctx := testapp.NewNibiruTestAppAndContext()
- err := testapp.FundModuleAccount(
- bapp.BankKeeper, ctx, authtypes.FeeCollectorName, txGasCoins)
- suite.NoError(err)
- return bapp, ctx
- },
- },
- {
- name: "err: empty fee collector module account",
- devGasState: []devgastypes.FeeShare{
- devGasForWithdrawer(0, 0),
- },
- // The expected royalty is gas / num_withdrawers / 2. Thus, We
- // divide gas by (num_withdrawers * 2). The 2 comes from 50% split.
- // wantWithdrawerRoyalties: num_withdrawers * 2 = 2
- wantWithdrawerRoyalties: txGasCoins.QuoInt(math.NewInt(2)),
- wantErr: true,
- setup: func() (*app.NibiruApp, sdk.Context) {
- bapp, ctx := testapp.NewNibiruTestAppAndContext()
- return bapp, ctx
- },
- },
- {
- name: "happy: no registered dev gas contracts",
- devGasState: []devgastypes.FeeShare{},
- // The expected royalty is gas / num_withdrawers / 2. Thus, We
- // divide gas by (num_withdrawers * 2). The 2 comes from 50% split.
- // wantWithdrawerRoyalties: num_withdrawers * 2 = 2
- wantWithdrawerRoyalties: txGasCoins.QuoInt(math.NewInt(2)),
- wantErr: false,
- setup: func() (*app.NibiruApp, sdk.Context) {
- bapp, ctx := testapp.NewNibiruTestAppAndContext()
- return bapp, ctx
- },
- },
- }
-
- var nextMockAnteHandler sdk.AnteHandler = func(
- ctx sdk.Context, tx sdk.Tx, simulate bool,
- ) (newCtx sdk.Context, err error) {
- return ctx, nil
- }
-
- for _, tc := range testCases {
- suite.T().Run(tc.name, func(t *testing.T) {
- bapp, ctx := tc.setup()
- ctx = ctx.WithChainID("mock-chain-id")
- anteDecorator := devgasante.NewDevGasPayoutDecorator(
- bapp.BankKeeper, bapp.DevGasKeeper,
- )
-
- t.Log("set dev gas state based on test case")
- for _, devGas := range tc.devGasState {
- bapp.DevGasKeeper.SetFeeShare(ctx, devGas)
- }
-
- t.Log("build tx and call AnteHandle")
- encCfg := app.MakeEncodingConfig()
- txMsgs := []sdk.Msg{}
- for _, wasmExecMsg := range wasmExecMsgs {
- txMsgs = append(txMsgs, wasmExecMsg)
- }
- txBuilder, err := sdkclienttx.Factory{}.
- WithFees(txGasCoins.String()).
- WithChainID(ctx.ChainID()).
- WithTxConfig(encCfg.TxConfig).
- BuildUnsignedTx(txMsgs...)
- suite.NoError(err)
- tx := txBuilder.GetTx()
- simulate := true
- ctx, err = anteDecorator.AnteHandle(
- ctx, tx, simulate, nextMockAnteHandler,
- )
- if tc.wantErr {
- suite.Error(err)
- return
- }
- suite.NoError(err)
-
- t.Log("tc withdrawers should have the expected funds")
- for _, devGas := range tc.devGasState {
- withdrawerCoins := bapp.BankKeeper.SpendableCoins(
- ctx, devGas.GetWithdrawerAddr(),
- )
- wantWithdrawerRoyalties := tc.wantWithdrawerRoyalties.Sub(
- sdk.NewInt64Coin(txGasCoins[0].Denom, 1),
- sdk.NewInt64Coin(txGasCoins[1].Denom, 1),
- )
- suite.True(
- withdrawerCoins.IsAllGTE(wantWithdrawerRoyalties),
- strings.Join([]string{
- fmt.Sprintf("withdrawerCoins: %v\n", withdrawerCoins),
- fmt.Sprintf("tc.wantWithdrawerRoyalties: %v\n", tc.wantWithdrawerRoyalties),
- }, " "),
- )
- }
- })
- }
-}
diff --git a/x/devgas/v1/ante/expected_keepers.go b/x/devgas/v1/ante/expected_keepers.go
deleted file mode 100644
index eefe11c35..000000000
--- a/x/devgas/v1/ante/expected_keepers.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package ante
-
-// Interfaces needed for the for the Nibiru Chain ante handler
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-type BankKeeper interface {
- SendCoinsFromAccountToModule(
- ctx sdk.Context, senderAddr sdk.AccAddress,
- recipientModule string, amt sdk.Coins,
- ) error
- SendCoinsFromModuleToAccount(
- ctx sdk.Context, senderModule string,
- recipientAddr sdk.AccAddress, amt sdk.Coins,
- ) error
-}
-
-type IDevGasKeeper interface {
- GetParams(ctx sdk.Context) devgastypes.ModuleParams
- GetFeeShare(ctx sdk.Context, contract sdk.Address) (devgastypes.FeeShare, bool)
-}
diff --git a/x/devgas/v1/client/cli/cli_test.go b/x/devgas/v1/client/cli/cli_test.go
deleted file mode 100644
index e2209046e..000000000
--- a/x/devgas/v1/client/cli/cli_test.go
+++ /dev/null
@@ -1,228 +0,0 @@
-package cli_test
-
-import (
- "bytes"
- "context"
- "fmt"
- "io"
- "testing"
-
- abci "github.com/cometbft/cometbft/abci/types"
- sdktestutil "github.com/cosmos/cosmos-sdk/testutil"
- "github.com/stretchr/testify/suite"
-
- rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock"
- sdkclient "github.com/cosmos/cosmos-sdk/client"
- sdktestutilcli "github.com/cosmos/cosmos-sdk/testutil/cli"
- sdk "github.com/cosmos/cosmos-sdk/types"
- testutilmod "github.com/cosmos/cosmos-sdk/types/module/testutil"
-
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
- devgas "github.com/NibiruChain/nibiru/x/devgas/v1"
- "github.com/NibiruChain/nibiru/x/devgas/v1/client/cli"
-)
-
-// CLITestSuite: Tests all tx commands for the module.
-type CLITestSuite struct {
- suite.Suite
-
- keyring keyring.Keyring
- encCfg testutilmod.TestEncodingConfig
- baseCtx sdkclient.Context
- clientCtx sdkclient.Context
-
- testAcc sdktestutil.TestAccount
-}
-
-func TestCLITestSuite(t *testing.T) {
- suite.Run(t, new(CLITestSuite))
-}
-
-// Runs once before the entire test suite.
-func (s *CLITestSuite) SetupSuite() {
- s.encCfg = testutilmod.MakeTestEncodingConfig(devgas.AppModuleBasic{})
- s.keyring = keyring.NewInMemory(s.encCfg.Codec)
- s.baseCtx = sdkclient.Context{}.
- WithKeyring(s.keyring).
- WithTxConfig(s.encCfg.TxConfig).
- WithCodec(s.encCfg.Codec).
- WithClient(sdktestutilcli.MockTendermintRPC{Client: rpcclientmock.Client{}}).
- WithAccountRetriever(sdkclient.MockAccountRetriever{}).
- WithOutput(io.Discard).
- WithChainID("test-chain")
-
- var outBuf bytes.Buffer
- ctxGen := func() sdkclient.Context {
- bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{})
- c := sdktestutilcli.NewMockTendermintRPC(abci.ResponseQuery{
- Value: bz,
- })
- return s.baseCtx.WithClient(c)
- }
- s.clientCtx = ctxGen().WithOutput(&outBuf)
-
- testAccs := sdktestutil.CreateKeyringAccounts(s.T(), s.keyring, 1)
- s.testAcc = testAccs[0]
-}
-
-// Flags for broadcasting transactions
-func commonTxArgs() []string {
- return []string{
- "--yes=true", // skip confirmation
- "--broadcast-mode=sync",
- "--fees=1unibi",
- "--chain-id=test-chain",
- }
-}
-
-type TestCase struct {
- name string
- args []string
- extraArgs []string
- wantErr string
-}
-
-func (tc TestCase) NewCtx(s *CLITestSuite) sdkclient.Context {
- return s.baseCtx
-}
-
-func (tc TestCase) Run(s *CLITestSuite) {
- s.Run(tc.name, func() {
- ctx := svrcmd.CreateExecuteContext(context.Background())
-
- cmd := cli.NewTxCmd()
- cmd.SetContext(ctx)
- args := append(tc.args, commonTxArgs()...)
- cmd.SetArgs(append(args, tc.extraArgs...))
-
- s.Require().NoError(sdkclient.SetCmdClientContextHandler(tc.NewCtx(s), cmd))
-
- err := cmd.Execute()
- if tc.wantErr != "" {
- s.Require().Error(err)
- s.ErrorContains(err, tc.wantErr)
- return
- }
- s.Require().NoError(err)
- })
-}
-
-func (s *CLITestSuite) TestCmdRegisterFeeShare() {
- _, addrs := testutil.PrivKeyAddressPairs(3)
-
- testCases := []TestCase{
- {
- name: "happy path: devgas register",
- args: []string{"register", addrs[0].String(), addrs[1].String()},
- extraArgs: []string{fmt.Sprintf("--from=%s", s.testAcc.Address)},
- wantErr: "",
- },
- {
- name: "sad: fee payer",
- args: []string{"register", addrs[0].String(), addrs[1].String()},
- extraArgs: []string{
- fmt.Sprintf("--from=%s", s.testAcc.Address),
- fmt.Sprintf("--fee-payer=%s", "invalid-fee-payer"),
- },
- wantErr: "decoding bech32 failed",
- },
- {
- name: "sad: contract addr",
- args: []string{"register", "sadcontract", addrs[1].String()},
- extraArgs: []string{
- fmt.Sprintf("--from=%s", s.testAcc.Address),
- },
- wantErr: "invalid contract address",
- },
- {
- name: "sad: withdraw addr",
- args: []string{"register", addrs[0].String(), "sadwithdraw"},
- extraArgs: []string{
- fmt.Sprintf("--from=%s", s.testAcc.Address),
- },
- wantErr: "invalid withdraw address",
- },
- }
-
- for _, tc := range testCases {
- tc.Run(s)
- }
-}
-
-func (s *CLITestSuite) TestCmdCancelFeeShare() {
- _, addrs := testutil.PrivKeyAddressPairs(1)
- testCases := []TestCase{
- {
- name: "happy path: devgas cancel",
- args: []string{"cancel", addrs[0].String()},
- extraArgs: []string{fmt.Sprintf("--from=%s", s.testAcc.Address)},
- wantErr: "",
- },
- {
- name: "sad: fee payer",
- args: []string{"cancel", addrs[0].String()},
- extraArgs: []string{
- fmt.Sprintf("--from=%s", s.testAcc.Address),
- fmt.Sprintf("--fee-payer=%s", "invalid-fee-payer"),
- },
- wantErr: "decoding bech32 failed",
- },
- {
- name: "sad: contract addr",
- args: []string{"cancel", "sadcontract"},
- extraArgs: []string{
- fmt.Sprintf("--from=%s", s.testAcc.Address),
- },
- wantErr: "invalid deployer address",
- },
- }
-
- for _, tc := range testCases {
- tc.Run(s)
- }
-}
-
-func (s *CLITestSuite) TestCmdUpdateFeeShare() {
- _, addrs := testutil.PrivKeyAddressPairs(3)
-
- testCases := []TestCase{
- {
- name: "happy path: devgas update",
- args: []string{"update", addrs[0].String(), addrs[1].String()},
- extraArgs: []string{fmt.Sprintf("--from=%s", s.testAcc.Address)},
- wantErr: "",
- },
- {
- name: "sad: fee payer",
- args: []string{"update", addrs[0].String(), addrs[1].String()},
- extraArgs: []string{
- fmt.Sprintf("--from=%s", s.testAcc.Address),
- fmt.Sprintf("--fee-payer=%s", "invalid-fee-payer"),
- },
- wantErr: "decoding bech32 failed",
- },
- {
- name: "sad: contract addr",
- args: []string{"update", "sadcontract", addrs[1].String()},
- extraArgs: []string{
- fmt.Sprintf("--from=%s", s.testAcc.Address),
- },
- wantErr: "invalid contract",
- },
- {
- name: "sad: new withdraw addr",
- args: []string{"update", addrs[0].String(), "saddeployer"},
- extraArgs: []string{
- fmt.Sprintf("--from=%s", s.testAcc.Address),
- },
- wantErr: "invalid withdraw address",
- },
- }
-
- for _, tc := range testCases {
- tc.Run(s)
- }
-}
diff --git a/x/devgas/v1/client/cli/query.go b/x/devgas/v1/client/cli/query.go
deleted file mode 100644
index 4dcda6481..000000000
--- a/x/devgas/v1/client/cli/query.go
+++ /dev/null
@@ -1,180 +0,0 @@
-package cli
-
-import (
- "context"
- "fmt"
-
- "github.com/spf13/cobra"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/version"
-
- "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-// GetQueryCmd returns the cli query commands for this module
-func GetQueryCmd() *cobra.Command {
- feesQueryCmd := &cobra.Command{
- Use: types.ModuleName,
- Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- feesQueryCmd.AddCommand(
- GetCmdQueryFeeShares(),
- GetCmdQueryFeeShare(),
- GetCmdQueryParams(),
- GetCmdQueryFeeSharesByWithdrawer(),
- )
-
- return feesQueryCmd
-}
-
-// GetCmdQueryFeeShares implements a command to return all registered contracts
-// for fee distribution
-func GetCmdQueryFeeShares() *cobra.Command {
- cmd := &cobra.Command{
- Use: "contracts [deployer_addr]",
- Short: "Query dev gas contracts registered with a deployer",
- Long: "Query dev gas contracts registered with a deployer",
- Args: cobra.ExactArgs(1),
- Example: fmt.Sprintf("%s query %s deployer-contracts ",
- version.AppName, types.ModuleName,
- ),
-
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- deployer := args[0]
- req := &types.QueryFeeSharesRequest{
- Deployer: deployer,
- }
- if err := req.ValidateBasic(); err != nil {
- return err
- }
-
- res, err := queryClient.FeeShares(context.Background(), req)
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
-
-// GetCmdQueryFeeShare implements a command to return a registered contract for fee
-// distribution
-func GetCmdQueryFeeShare() *cobra.Command {
- cmd := &cobra.Command{
- Use: "contract [contract_address]",
- Args: cobra.ExactArgs(1),
- Short: "Query a registered contract for fee distribution by its bech32 address",
- Long: "Query a registered contract for fee distribution by its bech32 address",
- Example: fmt.Sprintf("%s query feeshare contract ", version.AppName),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
-
- queryClient := types.NewQueryClient(clientCtx)
-
- req := &types.QueryFeeShareRequest{ContractAddress: args[0]}
- if err := req.ValidateBasic(); err != nil {
- return err
- }
-
- // Query store
- res, err := queryClient.FeeShare(context.Background(), req)
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
- flags.AddQueryFlagsToCmd(cmd)
- return cmd
-}
-
-// GetCmdQueryParams implements a command to return the current FeeShare
-// parameters.
-func GetCmdQueryParams() *cobra.Command {
- cmd := &cobra.Command{
- Use: "params",
- Short: "Query the current feeshare module parameters",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- params := &types.QueryParamsRequest{}
-
- res, err := queryClient.Params(context.Background(), params)
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(&res.Params)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
-
-// GetCmdQueryFeeSharesByWithdrawer implements a command that returns all
-// contracts that have registered for fee distribution with a given withdraw
-// address
-func GetCmdQueryFeeSharesByWithdrawer() *cobra.Command {
- cmd := &cobra.Command{
- Use: "withdrawer-contracts [withdraw_address]",
- Args: cobra.ExactArgs(1),
- Short: "Query all contracts that have been registered for feeshare distribution with a given withdrawer address",
- Long: "Query all contracts that have been registered for feeshare distribution with a given withdrawer address",
- Example: fmt.Sprintf("%s query feeshare withdrawer-contracts ", version.AppName),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
-
- queryClient := types.NewQueryClient(clientCtx)
-
- withdrawReq := &types.QueryFeeSharesByWithdrawerRequest{
- WithdrawerAddress: args[0],
- }
-
- if err := withdrawReq.ValidateBasic(); err != nil {
- return err
- }
-
- // Query store
- goCtx := context.Background()
- res, err := queryClient.FeeSharesByWithdrawer(goCtx, withdrawReq)
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
- flags.AddQueryFlagsToCmd(cmd)
- return cmd
-}
diff --git a/x/devgas/v1/client/cli/tx.go b/x/devgas/v1/client/cli/tx.go
deleted file mode 100644
index e059af0dc..000000000
--- a/x/devgas/v1/client/cli/tx.go
+++ /dev/null
@@ -1,146 +0,0 @@
-package cli
-
-import (
- "fmt"
-
- "github.com/spf13/cobra"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/client/tx"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-// NewTxCmd returns a root CLI command handler for certain modules/FeeShare
-// transaction commands.
-func NewTxCmd() *cobra.Command {
- txCmd := &cobra.Command{
- Use: types.ModuleName,
- Short: "FeeShare subcommands",
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- txCmd.AddCommand(
- CmdRegisterFeeShare(),
- CmdCancelFeeShare(),
- CmdUpdateFeeShare(),
- )
- return txCmd
-}
-
-// CmdRegisterFeeShare returns a CLI command handler for registering a
-// contract for fee distribution
-func CmdRegisterFeeShare() *cobra.Command {
- cmd := &cobra.Command{
- Use: "register [contract_bech32] [withdraw_bech32]",
- Short: "Register a contract for fee distribution. Only the contract admin can register a contract.",
- Long: "Register a contract for feeshare distribution. **NOTE** Please ensure, that the admin of the contract (or the DAO/factory that deployed the contract) is an account that is owned by your project, to avoid that an individual admin who leaves your project becomes malicious.",
- Args: cobra.ExactArgs(2),
- RunE: func(cmd *cobra.Command, args []string) error {
- cliCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- deployer := cliCtx.GetFromAddress()
-
- contract := args[0]
- withdrawer := args[1]
-
- msg := &types.MsgRegisterFeeShare{
- ContractAddress: contract,
- DeployerAddress: deployer.String(),
- WithdrawerAddress: withdrawer,
- }
-
- if err := msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
- return cmd
-}
-
-// CmdCancelFeeShare returns a CLI command handler for canceling a
-// contract for fee distribution
-func CmdCancelFeeShare() *cobra.Command {
- cmd := &cobra.Command{
- Use: "cancel [contract_bech32]",
- Short: "Cancel a contract from feeshare distribution",
- Long: "Cancel a contract from feeshare distribution. The withdraw address will no longer receive fees from users interacting with the contract.\nOnly the contract admin can cancel a contract.",
- Args: cobra.ExactArgs(1),
- RunE: func(cmd *cobra.Command, args []string) error {
- cliCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- deployer := cliCtx.GetFromAddress()
-
- contract := args[0]
-
- msg := &types.MsgCancelFeeShare{
- ContractAddress: contract,
- DeployerAddress: deployer.String(),
- }
-
- if err := msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
- return cmd
-}
-
-// CmdUpdateFeeShare returns a CLI command handler for updating the withdraw
-// address of a contract for fee distribution
-func CmdUpdateFeeShare() *cobra.Command {
- cmd := &cobra.Command{
- Use: "update [contract_bech32] [new_withdraw_bech32]",
- Short: "Update withdrawer address for a contract registered for feeshare distribution.",
- Long: "Update withdrawer address for a contract registered for feeshare distribution. \nOnly the contract admin can update the withdrawer address.",
- Args: cobra.ExactArgs(2),
- RunE: func(cmd *cobra.Command, args []string) error {
- cliCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- deployer := cliCtx.GetFromAddress()
-
- contract := args[0]
- if _, err := sdk.AccAddressFromBech32(contract); err != nil {
- return fmt.Errorf("invalid contract bech32 address %w", err)
- }
-
- withdrawer := args[1]
-
- msg := &types.MsgUpdateFeeShare{
- ContractAddress: contract,
- DeployerAddress: deployer.String(),
- WithdrawerAddress: withdrawer,
- }
-
- if err := msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
- return cmd
-}
diff --git a/x/devgas/v1/exported/exported.go b/x/devgas/v1/exported/exported.go
deleted file mode 100644
index 1f7886bb1..000000000
--- a/x/devgas/v1/exported/exported.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package exported
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
- paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
-)
-
-type (
- ParamSet = paramtypes.ParamSet
-
- // Subspace defines an interface that implements the legacy x/params
- // Subspace type.
- //
- // NOTE: This is used solely for migration of x/params managed parameters.
- Subspace interface {
- GetParamSet(ctx sdk.Context, ps ParamSet)
- }
-)
diff --git a/x/devgas/v1/genesis.go b/x/devgas/v1/genesis.go
deleted file mode 100644
index f0e877ec2..000000000
--- a/x/devgas/v1/genesis.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package devgas
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/devgas/v1/keeper"
- "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-// InitGenesis import module genesis
-func InitGenesis(
- ctx sdk.Context,
- k keeper.Keeper,
- data types.GenesisState,
-) {
- if err := data.Validate(); err != nil {
- panic(err)
- }
-
- k.ModuleParams.Set(ctx, data.Params.Sanitize())
-
- for _, share := range data.FeeShare {
- // Set initial contracts receiving transaction fees
- k.SetFeeShare(ctx, share)
- }
-}
-
-// ExportGenesis export module state
-func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
- return &types.GenesisState{
- Params: k.GetParams(ctx),
- FeeShare: k.DevGasStore.Iterate(ctx, collections.Range[string]{}).Values(),
- }
-}
diff --git a/x/devgas/v1/genesis_test.go b/x/devgas/v1/genesis_test.go
deleted file mode 100644
index cf2a017a9..000000000
--- a/x/devgas/v1/genesis_test.go
+++ /dev/null
@@ -1,132 +0,0 @@
-package devgas_test
-
-import (
- "fmt"
- "testing"
-
- "cosmossdk.io/math"
- "github.com/stretchr/testify/suite"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- devgas "github.com/NibiruChain/nibiru/x/devgas/v1"
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-type GenesisTestSuite struct {
- suite.Suite
-
- app *app.NibiruApp
- ctx sdk.Context
-
- genesis devgastypes.GenesisState
-}
-
-func TestGenesisTestSuite(t *testing.T) {
- suite.Run(t, new(GenesisTestSuite))
-}
-
-func (s *GenesisTestSuite) SetupTest() {
- app, ctx := testapp.NewNibiruTestAppAndContext()
-
- s.app = app
- s.ctx = ctx
-
- s.genesis = *devgastypes.DefaultGenesisState()
-}
-
-func (s *GenesisTestSuite) TestGenesis() {
- randomAddr := testutil.AccAddress().String()
- testCases := []struct {
- name string
- genesis devgastypes.GenesisState
- expPanic bool
- }{
- {
- name: "default genesis",
- genesis: s.genesis,
- expPanic: false,
- },
- {
- name: "custom genesis - feeshare disabled",
- genesis: devgastypes.GenesisState{
- Params: devgastypes.ModuleParams{
- EnableFeeShare: false,
- DeveloperShares: devgastypes.DefaultDeveloperShares,
- AllowedDenoms: []string{"unibi"},
- },
- },
- expPanic: false,
- },
- {
- name: "custom genesis - feeshare enabled, 0% developer shares",
- genesis: devgastypes.GenesisState{
- Params: devgastypes.ModuleParams{
- EnableFeeShare: true,
- DeveloperShares: math.LegacyNewDecWithPrec(0, 2),
- AllowedDenoms: []string{"unibi"},
- },
- },
- expPanic: false,
- },
- {
- name: "custom genesis - feeshare enabled, 100% developer shares",
- genesis: devgastypes.GenesisState{
- Params: devgastypes.ModuleParams{
- EnableFeeShare: true,
- DeveloperShares: math.LegacyNewDecWithPrec(100, 2),
- AllowedDenoms: []string{"unibi"},
- },
- },
- expPanic: false,
- },
- {
- name: "custom genesis - feeshare enabled, all denoms allowed",
- genesis: devgastypes.GenesisState{
- Params: devgastypes.ModuleParams{
- EnableFeeShare: true,
- DeveloperShares: math.LegacyNewDecWithPrec(10, 2),
- AllowedDenoms: []string{},
- },
- FeeShare: []devgastypes.FeeShare{
- {
- ContractAddress: randomAddr,
- DeployerAddress: randomAddr,
- WithdrawerAddress: randomAddr,
- },
- },
- },
- expPanic: false,
- },
- {
- name: "empty genesis",
- genesis: devgastypes.GenesisState{},
- expPanic: true,
- },
- }
-
- for _, tc := range testCases {
- s.T().Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) {
- s.SetupTest() // reset
-
- if tc.expPanic {
- s.Require().Panics(func() {
- devgas.InitGenesis(s.ctx, s.app.DevGasKeeper, tc.genesis)
- })
- } else {
- s.Require().NotPanics(func() {
- devgas.InitGenesis(s.ctx, s.app.DevGasKeeper, tc.genesis)
- })
-
- params := s.app.DevGasKeeper.GetParams(s.ctx)
- s.Require().EqualValues(tc.genesis.Params, params)
-
- gen := devgas.ExportGenesis(s.ctx, s.app.DevGasKeeper)
- s.NoError(gen.Validate())
- }
- })
- }
-}
diff --git a/x/devgas/v1/keeper/feeshare.go b/x/devgas/v1/keeper/feeshare.go
deleted file mode 100644
index cd1493469..000000000
--- a/x/devgas/v1/keeper/feeshare.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package keeper
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-// GetFeeShare returns the FeeShare for a registered contract
-func (k Keeper) GetFeeShare(
- ctx sdk.Context,
- contract sdk.Address,
-) (devGas types.FeeShare, isFound bool) {
- isFound = true
- devGas, err := k.DevGasStore.Get(ctx, contract.String())
- if err != nil {
- isFound = false
- }
- return devGas, isFound
-}
-
-// SetFeeShare stores the FeeShare for a registered contract, then iterates
-// over every registered Indexer and instructs them to create the relationship
-// between the primary key PK and the object v.
-func (k Keeper) SetFeeShare(ctx sdk.Context, feeshare types.FeeShare) {
- k.DevGasStore.Insert(ctx, feeshare.ContractAddress, feeshare)
-}
-
-// IsFeeShareRegistered checks if a contract was registered for receiving
-// transaction fees
-func (k Keeper) IsFeeShareRegistered(
- ctx sdk.Context,
- contract sdk.Address,
-) (isRegistered bool) {
- _, err := k.DevGasStore.Get(ctx, contract.String())
- return err == nil
-}
diff --git a/x/devgas/v1/keeper/grpc_query.go b/x/devgas/v1/keeper/grpc_query.go
deleted file mode 100644
index ae7a5a6c9..000000000
--- a/x/devgas/v1/keeper/grpc_query.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package keeper
-
-import (
- "context"
-
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-var _ types.QueryServer = Querier{}
-
-// Querier defines a wrapper around the x/FeeShare keeper providing gRPC method
-// handlers.
-type Querier struct {
- Keeper
-}
-
-func NewQuerier(k Keeper) Querier {
- return Querier{Keeper: k}
-}
-
-// Fee
-
-// TODO FeeSharesAll returns all FeeShares that have been registered for fee
-// distribution
-func (q Querier) FeeShares(
- goCtx context.Context,
- req *types.QueryFeeSharesRequest,
-) (*types.QueryFeeSharesResponse, error) {
- if req == nil {
- return nil, status.Error(codes.InvalidArgument, "empty request")
- }
- ctx := sdk.UnwrapSDKContext(goCtx)
- iter := q.DevGasStore.Indexes.Deployer.ExactMatch(ctx, req.Deployer)
- return &types.QueryFeeSharesResponse{
- Feeshare: q.DevGasStore.Collect(ctx, iter),
- }, nil
-}
-
-// FeeShare returns the FeeShare that has been registered for fee distribution for a given
-// contract
-func (q Querier) FeeShare(
- goCtx context.Context,
- req *types.QueryFeeShareRequest,
-) (*types.QueryFeeShareResponse, error) {
- if req == nil {
- return nil, status.Error(codes.InvalidArgument, "empty request")
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- // check if the contract is a non-zero hex address
- contract, err := sdk.AccAddressFromBech32(req.ContractAddress)
- if err != nil {
- return nil, status.Errorf(
- codes.InvalidArgument,
- "invalid format for contract %s, should be bech32 ('nibi...')", req.ContractAddress,
- )
- }
-
- feeshare, found := q.GetFeeShare(ctx, contract)
- if !found {
- return nil, status.Errorf(
- codes.NotFound,
- "fees registered contract '%s'",
- req.ContractAddress,
- )
- }
-
- return &types.QueryFeeShareResponse{Feeshare: feeshare}, nil
-}
-
-// Params returns the fees module params
-func (q Querier) Params(
- c context.Context,
- _ *types.QueryParamsRequest,
-) (*types.QueryParamsResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
- params := q.GetParams(ctx)
- return &types.QueryParamsResponse{Params: params}, nil
-}
-
-// FeeSharesByWithdrawer returns all fees for a given withdraw address
-func (q Querier) FeeSharesByWithdrawer( // nolint: dupl
- goCtx context.Context,
- req *types.QueryFeeSharesByWithdrawerRequest,
-) (*types.QueryFeeSharesByWithdrawerResponse, error) {
- if req == nil {
- return nil, status.Error(codes.InvalidArgument, "empty request")
- }
- ctx := sdk.UnwrapSDKContext(goCtx)
- iter := q.DevGasStore.Indexes.Withdrawer.ExactMatch(ctx, req.WithdrawerAddress)
- return &types.QueryFeeSharesByWithdrawerResponse{
- Feeshare: q.DevGasStore.Collect(ctx, iter),
- }, nil
-}
diff --git a/x/devgas/v1/keeper/grpc_query_test.go b/x/devgas/v1/keeper/grpc_query_test.go
deleted file mode 100644
index e8eaef55f..000000000
--- a/x/devgas/v1/keeper/grpc_query_test.go
+++ /dev/null
@@ -1,167 +0,0 @@
-package keeper_test
-
-import (
- "github.com/cosmos/cosmos-sdk/testutil/testdata"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "cosmossdk.io/math"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
- devgaskeeper "github.com/NibiruChain/nibiru/x/devgas/v1/keeper"
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-func (s *KeeperTestSuite) TestQueryFeeShares() {
- s.SetupTest()
- _, _, sender := testdata.KeyTestPubAddr()
- _ = s.FundAccount(
- s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1_000_000))),
- )
-
- _, _, withdrawer := testdata.KeyTestPubAddr()
-
- var contractAddressList []string
- var index uint64
- for index < 5 {
- contractAddress := s.InstantiateContract(sender.String(), "")
- contractAddressList = append(contractAddressList, contractAddress)
- index++
- }
-
- // Register FeeShares
- var feeShares []devgastypes.FeeShare
- for _, contractAddress := range contractAddressList {
- goCtx := sdk.WrapSDKContext(s.ctx)
- msg := &devgastypes.MsgRegisterFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: withdrawer.String(),
- }
-
- feeShare := devgastypes.FeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: withdrawer.String(),
- }
-
- feeShares = append(feeShares, feeShare)
-
- _, err := s.devgasMsgServer.RegisterFeeShare(goCtx, msg)
- s.Require().NoError(err)
- }
-
- s.Run("from deployer", func() {
- deployer := sender.String()
- req := &devgastypes.QueryFeeSharesRequest{
- Deployer: deployer,
- }
- goCtx := sdk.WrapSDKContext(s.ctx)
- resp, err := s.queryClient.FeeShares(goCtx, req)
- s.NoError(err)
- s.Len(resp.Feeshare, len(feeShares))
- })
- s.Run("from random", func() {
- deployer := testutil.AccAddress().String()
- req := &devgastypes.QueryFeeSharesRequest{
- Deployer: deployer,
- }
- goCtx := sdk.WrapSDKContext(s.ctx)
- resp, err := s.queryClient.FeeShares(goCtx, req)
- s.NoError(err)
- s.Len(resp.Feeshare, 0)
- })
-}
-
-func (s *KeeperTestSuite) TestFeeShare() {
- s.SetupTest()
- _, _, sender := testdata.KeyTestPubAddr()
- _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1_000_000))))
-
- _, _, withdrawer := testdata.KeyTestPubAddr()
-
- contractAddress := s.InstantiateContract(sender.String(), "")
- goCtx := sdk.WrapSDKContext(s.ctx)
- msg := &devgastypes.MsgRegisterFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: withdrawer.String(),
- }
-
- feeShare := devgastypes.FeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: withdrawer.String(),
- }
- _, err := s.devgasMsgServer.RegisterFeeShare(goCtx, msg)
- s.Require().NoError(err)
-
- req := &devgastypes.QueryFeeShareRequest{
- ContractAddress: contractAddress,
- }
- goCtx = sdk.WrapSDKContext(s.ctx)
- resp, err := s.queryClient.FeeShare(goCtx, req)
- s.Require().NoError(err)
- s.Require().Equal(resp.Feeshare, feeShare)
-}
-
-func (s *KeeperTestSuite) TestFeeSharesByWithdrawer() {
- s.SetupTest()
- _, _, sender := testdata.KeyTestPubAddr()
- _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1_000_000))))
-
- _, _, withdrawer := testdata.KeyTestPubAddr()
-
- var contractAddressList []string
- var index uint64
- for index < 5 {
- contractAddress := s.InstantiateContract(sender.String(), "")
- contractAddressList = append(contractAddressList, contractAddress)
- index++
- }
-
- // RegsisFeeShare
- for _, contractAddress := range contractAddressList {
- goCtx := sdk.WrapSDKContext(s.ctx)
- msg := &devgastypes.MsgRegisterFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: withdrawer.String(),
- }
-
- _, err := s.devgasMsgServer.RegisterFeeShare(goCtx, msg)
- s.Require().NoError(err)
- }
-
- s.Run("Total", func() {
- goCtx := sdk.WrapSDKContext(s.ctx)
- resp, err := s.queryClient.FeeSharesByWithdrawer(goCtx,
- &devgastypes.QueryFeeSharesByWithdrawerRequest{
- WithdrawerAddress: withdrawer.String(),
- })
- s.Require().NoError(err)
- s.Require().Equal(len(contractAddressList), len(resp.Feeshare))
- })
-}
-
-func (s *KeeperTestSuite) TestQueryParams() {
- s.SetupTest()
- goCtx := sdk.WrapSDKContext(s.ctx)
- resp, err := s.queryClient.Params(goCtx, nil)
- s.NoError(err)
- s.NotNil(resp)
-}
-
-func (s *KeeperTestSuite) TestNilRequests() {
- s.SetupTest()
- goCtx := sdk.WrapSDKContext(s.ctx)
- querier := devgaskeeper.NewQuerier(s.app.DevGasKeeper)
-
- _, err := querier.FeeShare(goCtx, nil)
- s.Error(err)
-
- _, err = querier.FeeShares(goCtx, nil)
- s.Error(err)
-
- _, err = querier.FeeSharesByWithdrawer(goCtx, nil)
- s.Error(err)
-}
diff --git a/x/devgas/v1/keeper/keeper.go b/x/devgas/v1/keeper/keeper.go
deleted file mode 100644
index 97081ccd2..000000000
--- a/x/devgas/v1/keeper/keeper.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package keeper
-
-import (
- "fmt"
-
- wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
-
- "github.com/cometbft/cometbft/libs/log"
-
- "github.com/cosmos/cosmos-sdk/codec"
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/collections"
-
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-// Keeper of this module maintains collections of feeshares for contracts
-// registered to receive Nibiru Chain gas fees.
-type Keeper struct {
- storeKey storetypes.StoreKey
- cdc codec.BinaryCodec
-
- bankKeeper devgastypes.BankKeeper
- wasmKeeper wasmkeeper.Keeper
- accountKeeper devgastypes.AccountKeeper
-
- // feeCollectorName is the name of of x/auth module's fee collector module
- // account, "fee_collector", which collects transaction fees for distribution
- // to all stakers.
- //
- // See the `[AllocateTokens]` function from x/distribution to learn more.
- // [AllocateTokens]: https://github.com/cosmos/cosmos-sdk/blob/v0.50.3/x/distribution/keeper/allocation.go
- feeCollectorName string
-
- // DevGasStore: IndexedMap
- // - primary key (PK): Contract address. The contract is the primary key
- // because there's exactly one deployer and withdrawer.
- // - value (V): FeeShare value saved into state.
- // - indexers (I): Indexed by deployer and withdrawer
- DevGasStore collections.IndexedMap[string, devgastypes.FeeShare, DevGasIndexes]
-
- ModuleParams collections.Item[devgastypes.ModuleParams]
-
- // the address capable of executing a MsgUpdateParams message. Typically,
- // this should be the x/gov module account.
- authority string
-}
-
-// NewKeeper creates new instances of the fees Keeper
-func NewKeeper(
- storeKey storetypes.StoreKey,
- cdc codec.BinaryCodec,
- bk devgastypes.BankKeeper,
- wk wasmkeeper.Keeper,
- ak devgastypes.AccountKeeper,
- feeCollector string,
- authority string,
-) Keeper {
- return Keeper{
- storeKey: storeKey,
- cdc: cdc,
- bankKeeper: bk,
- wasmKeeper: wk,
- accountKeeper: ak,
- feeCollectorName: feeCollector,
- authority: authority,
- DevGasStore: NewDevGasStore(storeKey, cdc),
- ModuleParams: collections.NewItem(
- storeKey, devgastypes.KeyPrefixParams,
- collections.ProtoValueEncoder[devgastypes.ModuleParams](cdc),
- ),
- }
-}
-
-// GetAuthority returns the x/feeshare module's authority.
-func (k Keeper) GetAuthority() string {
- return k.authority
-}
-
-// Logger returns a module-specific logger.
-func (k Keeper) Logger(ctx sdk.Context) log.Logger {
- return ctx.Logger().With("module", fmt.Sprintf("x/%s", devgastypes.ModuleName))
-}
diff --git a/x/devgas/v1/keeper/keeper_test.go b/x/devgas/v1/keeper/keeper_test.go
deleted file mode 100644
index 9be7553eb..000000000
--- a/x/devgas/v1/keeper/keeper_test.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package keeper_test
-
-import (
- "testing"
-
- wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
- wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
- "github.com/stretchr/testify/suite"
-
- "github.com/cosmos/cosmos-sdk/baseapp"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- devgaskeeper "github.com/NibiruChain/nibiru/x/devgas/v1/keeper"
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-// BankKeeper defines the expected interface needed to retrieve account balances.
-type BankKeeper interface {
- MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
- SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
- SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
- SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
- SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
-}
-
-type KeeperTestSuite struct {
- suite.Suite
-
- ctx sdk.Context
- app *app.NibiruApp
- queryClient devgastypes.QueryClient
- devgasMsgServer devgastypes.MsgServer
- wasmMsgServer wasmtypes.MsgServer
-}
-
-func (s *KeeperTestSuite) SetupTest() {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
- s.app = nibiruApp
- s.ctx = ctx
-
- queryHelper := baseapp.NewQueryServerTestHelper(
- s.ctx, s.app.InterfaceRegistry(),
- )
- devgastypes.RegisterQueryServer(
- queryHelper, devgaskeeper.NewQuerier(s.app.DevGasKeeper),
- )
-
- s.queryClient = devgastypes.NewQueryClient(queryHelper)
- s.devgasMsgServer = s.app.DevGasKeeper
- s.wasmMsgServer = wasmkeeper.NewMsgServerImpl(&s.app.WasmKeeper)
-}
-
-func (s *KeeperTestSuite) SetupSuite() {
- s.SetupTest()
-}
-
-func (s *KeeperTestSuite) FundAccount(
- ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins,
-) error {
- return testapp.FundAccount(s.app.BankKeeper, ctx, addr, amounts)
-}
-
-func TestKeeperTestSuite(t *testing.T) {
- suite.Run(t, new(KeeperTestSuite))
-}
diff --git a/x/devgas/v1/keeper/msg_server.go b/x/devgas/v1/keeper/msg_server.go
deleted file mode 100644
index 0976557e4..000000000
--- a/x/devgas/v1/keeper/msg_server.go
+++ /dev/null
@@ -1,311 +0,0 @@
-package keeper
-
-import (
- "context"
-
- wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
-
- "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-var _ types.MsgServer = &Keeper{}
-
-// isContractCreatedFromFactory: Checks the smart contract info to see if it
-// was created by the "factory". This condition is true if:
-// (1) the info.Admin is the gov module
-// (2) the info.Creator is another smart contract
-// (3) the info.Admin is another contract
-func (k Keeper) isContractCreatedFromFactory(
- ctx sdk.Context, info *wasmTypes.ContractInfo, msgSender sdk.AccAddress,
-) bool {
- govMod := k.accountKeeper.GetModuleAddress(govtypes.ModuleName).String()
- switch {
- case info.Admin == govMod:
- // case 1: True if info.Admin is the gov module
- return true
- case len(info.Admin) == 0:
- // case 2: True if info.Creator is another smart contract
- creator, err := sdk.AccAddressFromBech32(info.Creator)
- if err != nil {
- return false
- }
- return k.wasmKeeper.HasContractInfo(ctx, creator)
- case info.Admin != msgSender.String():
- // case 3: True if info.Admin is another contract
- //
- // Note that if info.Admin == msgSender, then it's not a smart contract
- // because the signer for the TxMsg is always a non-contract account.
- admin, err := sdk.AccAddressFromBech32(info.Admin)
- if err != nil {
- return false
- }
- return k.wasmKeeper.HasContractInfo(ctx, admin)
- default:
- return false
- }
-}
-
-// GetContractAdminOrCreatorAddress ensures the deployer is the contract's
-// admin OR creator if no admin is set for all msg_server feeshare functions.
-func (k Keeper) GetContractAdminOrCreatorAddress(
- ctx sdk.Context, contract sdk.AccAddress, deployer string,
-) (sdk.AccAddress, error) {
- // Ensure the deployer address is valid
- _, err := sdk.AccAddressFromBech32(deployer)
- if err != nil {
- return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid deployer address %s", deployer)
- }
-
- // Retrieve contract info
- info := k.wasmKeeper.GetContractInfo(ctx, contract)
- if info == nil {
- return nil, sdkerrors.ErrUnauthorized.Wrapf(
- "contract with address %s not found in state", contract,
- )
- }
-
- // Check if the contract has an admin
- if len(info.Admin) == 0 {
- // No admin, so check if the deployer is the creator of the contract
- if info.Creator != deployer {
- return nil,
- sdkerrors.ErrUnauthorized.Wrapf("you are not the creator of this contract %s",
- info.Creator,
- )
- }
-
- contractCreator, err := sdk.AccAddressFromBech32(info.Creator)
- if err != nil {
- return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid creator address %s", info.Creator)
- }
-
- // Deployer is the creator, return the controlling account as the creator's address
- return contractCreator, err
- }
-
- // Admin is set, so check if the deployer is the admin of the contract
- if info.Admin != deployer {
- return nil, sdkerrors.ErrUnauthorized.Wrapf(
- "you are not an admin of this contract %s", deployer,
- )
- }
-
- // Verify the admin address is valid
- contractAdmin, err := sdk.AccAddressFromBech32(info.Admin)
- if err != nil {
- return nil, sdkerrors.ErrInvalidAddress.Wrapf(
- "%s: invalid admin address %s", err.Error(), info.Admin,
- )
- }
-
- return contractAdmin, err
-}
-
-// RegisterFeeShare registers a contract to receive transaction fees
-func (k Keeper) RegisterFeeShare(
- goCtx context.Context,
- msg *types.MsgRegisterFeeShare,
-) (*types.MsgRegisterFeeShareResponse, error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- params := k.GetParams(ctx)
- if !params.EnableFeeShare {
- return nil, types.ErrFeeShareDisabled
- }
-
- // Get Contract
- contract, err := sdk.AccAddressFromBech32(msg.ContractAddress)
- if err != nil {
- return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid contract address (%s)", err)
- }
-
- // Check if contract is already registered
- if k.IsFeeShareRegistered(ctx, contract) {
- return nil, types.ErrFeeShareAlreadyRegistered.Wrapf("contract is already registered %s", contract)
- }
-
- // Get the withdraw address of the contract
- withdrawer, err := sdk.AccAddressFromBech32(msg.WithdrawerAddress)
- if err != nil {
- return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid withdrawer address %s", msg.WithdrawerAddress)
- }
-
- // ensure msg.DeployerAddress is valid
- msgSender, err := sdk.AccAddressFromBech32(msg.DeployerAddress)
- if err != nil {
- return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid deployer address %s", msg.DeployerAddress)
- }
-
- var deployer sdk.AccAddress
-
- if k.isContractCreatedFromFactory(ctx, k.wasmKeeper.GetContractInfo(ctx, contract), msgSender) {
- // Anyone is allowed to register the dev gas withdrawer for a smart
- // contract to be the contract itself, so long as the contract was
- // created from the "factory" (gov module or if contract admin or creator is another contract)
- if msg.WithdrawerAddress != msg.ContractAddress {
- return nil, types.ErrFeeShareInvalidWithdrawer.Wrapf(
- "withdrawer address must be the same as the contract address if it is from a "+
- "factory contract withdrawer: %s contract: %s",
- msg.WithdrawerAddress, msg.ContractAddress,
- )
- }
-
- // set the deployer address to the contract address so it can self register
- msg.DeployerAddress = msg.ContractAddress
- deployer, err = sdk.AccAddressFromBech32(msg.DeployerAddress)
- if err != nil {
- return nil, err
- }
- } else {
- // Check that the person who signed the message is the wasm contract
- // admin or creator (if no admin)
- deployer, err = k.GetContractAdminOrCreatorAddress(ctx, contract, msg.DeployerAddress)
- if err != nil {
- return nil, err
- }
- }
-
- // prevent storing the same address for deployer and withdrawer
- feeshare := types.NewFeeShare(contract, deployer, withdrawer)
- k.SetFeeShare(ctx, feeshare)
-
- k.Logger(ctx).Debug(
- "registering contract for transaction fees",
- "contract", msg.ContractAddress,
- "deployer", msg.DeployerAddress,
- "withdraw", msg.WithdrawerAddress,
- )
-
- return &types.MsgRegisterFeeShareResponse{}, ctx.EventManager().EmitTypedEvent(
- &types.EventRegisterDevGas{
- Deployer: msg.DeployerAddress,
- Contract: msg.ContractAddress,
- Withdrawer: msg.WithdrawerAddress,
- },
- )
-}
-
-// UpdateFeeShare updates the withdraw address of a given FeeShare. If the given
-// withdraw address is empty or the same as the deployer address, the withdraw
-// address is removed.
-func (k Keeper) UpdateFeeShare(
- goCtx context.Context,
- msg *types.MsgUpdateFeeShare,
-) (*types.MsgUpdateFeeShareResponse, error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
- params := k.GetParams(ctx)
- if !params.EnableFeeShare {
- return nil, types.ErrFeeShareDisabled
- }
-
- contract, err := sdk.AccAddressFromBech32(msg.ContractAddress)
- if err != nil {
- return nil,
- sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid contract address (%s)", err,
- )
- }
-
- feeshare, found := k.GetFeeShare(ctx, contract)
- if !found {
- return nil,
- types.ErrFeeShareContractNotRegistered.Wrapf(
- "contract %s is not registered", msg.ContractAddress,
- )
- }
-
- // feeshare with the given withdraw address is already registered
- if msg.WithdrawerAddress == feeshare.WithdrawerAddress {
- return nil, types.ErrFeeShareAlreadyRegistered.Wrapf(
- "feeshare with withdraw address %s is already registered", msg.WithdrawerAddress,
- )
- }
-
- // Check that the person who signed the message is the wasm contract admin, if so return the deployer address
- _, err = k.GetContractAdminOrCreatorAddress(ctx, contract, msg.DeployerAddress)
- if err != nil {
- return nil, err
- }
-
- newWithdrawAddr, err := sdk.AccAddressFromBech32(msg.WithdrawerAddress)
- if err != nil {
- return nil, sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid WithdrawerAddress %s", msg.WithdrawerAddress,
- )
- }
-
- // update feeshare with new withdrawer
- feeshare.WithdrawerAddress = newWithdrawAddr.String()
- k.SetFeeShare(ctx, feeshare)
-
- return &types.MsgUpdateFeeShareResponse{}, ctx.EventManager().EmitTypedEvent(
- &types.EventUpdateDevGas{
- Deployer: msg.DeployerAddress,
- Contract: msg.ContractAddress,
- Withdrawer: msg.WithdrawerAddress,
- },
- )
-}
-
-// CancelFeeShare deletes the FeeShare for a given contract
-func (k Keeper) CancelFeeShare(
- goCtx context.Context,
- msg *types.MsgCancelFeeShare,
-) (*types.MsgCancelFeeShareResponse, error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- params := k.GetParams(ctx)
- if !params.EnableFeeShare {
- return nil, types.ErrFeeShareDisabled
- }
-
- contract, err := sdk.AccAddressFromBech32(msg.ContractAddress)
- if err != nil {
- return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid contract address (%s)", err)
- }
-
- fee, found := k.GetFeeShare(ctx, contract)
- if !found {
- return nil, types.ErrFeeShareContractNotRegistered.Wrapf(
- "contract %s is not registered", msg.ContractAddress,
- )
- }
-
- // Check that the person who signed the message is the wasm contract admin, if so return the deployer address
- _, err = k.GetContractAdminOrCreatorAddress(ctx, contract, msg.DeployerAddress)
- if err != nil {
- return nil, err
- }
-
- err = k.DevGasStore.Delete(ctx, fee.GetContractAddress())
- if err != nil {
- return nil, err
- }
-
- return &types.MsgCancelFeeShareResponse{}, ctx.EventManager().EmitTypedEvent(
- &types.EventCancelDevGas{
- Deployer: msg.DeployerAddress,
- Contract: msg.ContractAddress,
- },
- )
-}
-
-func (k Keeper) UpdateParams(
- goCtx context.Context, req *types.MsgUpdateParams,
-) (resp *types.MsgUpdateParamsResponse, err error) {
- if k.authority != req.Authority {
- return nil, govtypes.ErrInvalidSigner.Wrapf("invalid authority; expected %s, got %s", k.authority, req.Authority)
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
- if err := req.Params.Validate(); err != nil {
- return resp, err
- }
- k.ModuleParams.Set(ctx, req.Params)
-
- return &types.MsgUpdateParamsResponse{}, err
-}
diff --git a/x/devgas/v1/keeper/msg_server_test.go b/x/devgas/v1/keeper/msg_server_test.go
deleted file mode 100644
index d0add9498..000000000
--- a/x/devgas/v1/keeper/msg_server_test.go
+++ /dev/null
@@ -1,465 +0,0 @@
-package keeper_test
-
-import (
- "crypto/sha256"
- "fmt"
-
- "cosmossdk.io/math"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
-
- wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
-
- _ "embed"
-
- "github.com/cosmos/cosmos-sdk/testutil/testdata"
- sdk "github.com/cosmos/cosmos-sdk/types"
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
-
- "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-//go:embed testdata/reflect.wasm
-var wasmContract []byte
-
-func (s *KeeperTestSuite) StoreCode() {
- _, _, sender := testdata.KeyTestPubAddr()
- msg := wasmtypes.MsgStoreCodeFixture(func(m *wasmtypes.MsgStoreCode) {
- m.WASMByteCode = wasmContract
- m.Sender = sender.String()
- })
- rsp, err := s.app.MsgServiceRouter().Handler(msg)(s.ctx, msg)
- s.Require().NoError(err)
- var result wasmtypes.MsgStoreCodeResponse
- s.Require().NoError(s.app.AppCodec().Unmarshal(rsp.Data, &result))
- s.Require().Equal(uint64(1), result.CodeID)
- expHash := sha256.Sum256(wasmContract)
- s.Require().Equal(expHash[:], result.Checksum)
- // and
- info := s.app.WasmKeeper.GetCodeInfo(s.ctx, 1)
- s.Require().NotNil(info)
- s.Require().Equal(expHash[:], info.CodeHash)
- s.Require().Equal(sender.String(), info.Creator)
- s.Require().Equal(wasmtypes.DefaultParams().InstantiateDefaultPermission.With(sender), info.InstantiateConfig)
-}
-
-func (s *KeeperTestSuite) InstantiateContract(sender string, admin string) string {
- msgStoreCode := wasmtypes.MsgStoreCodeFixture(func(m *wasmtypes.MsgStoreCode) {
- m.WASMByteCode = wasmContract
- m.Sender = sender
- })
- _, err := s.app.MsgServiceRouter().Handler(msgStoreCode)(s.ctx, msgStoreCode)
- s.Require().NoError(err)
-
- msgInstantiate := wasmtypes.MsgInstantiateContractFixture(func(m *wasmtypes.MsgInstantiateContract) {
- m.Sender = sender
- m.Admin = admin
- m.Msg = []byte(`{}`)
- })
- resp, err := s.app.MsgServiceRouter().Handler(msgInstantiate)(s.ctx, msgInstantiate)
- s.Require().NoError(err)
- var result wasmtypes.MsgInstantiateContractResponse
- s.Require().NoError(s.app.AppCodec().Unmarshal(resp.Data, &result))
- contractInfo := s.app.WasmKeeper.GetContractInfo(s.ctx, sdk.MustAccAddressFromBech32(result.Address))
- s.Require().Equal(contractInfo.CodeID, uint64(1))
- s.Require().Equal(contractInfo.Admin, admin)
- s.Require().Equal(contractInfo.Creator, sender)
-
- return result.Address
-}
-
-func (s *KeeperTestSuite) TestGetContractAdminOrCreatorAddress() {
- _, _, sender := testdata.KeyTestPubAddr()
- _, _, admin := testdata.KeyTestPubAddr()
- _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1_000_000))))
- _ = s.FundAccount(s.ctx, admin, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1_000_000))))
-
- noAdminContractAddress := s.InstantiateContract(sender.String(), "")
- withAdminContractAddress := s.InstantiateContract(sender.String(), admin.String())
-
- for _, tc := range []struct {
- desc string
- contractAddress string
- deployerAddress string
- shouldErr bool
- }{
- {
- desc: "Success - Creator",
- contractAddress: noAdminContractAddress,
- deployerAddress: sender.String(),
- shouldErr: false,
- },
- {
- desc: "Success - Admin",
- contractAddress: withAdminContractAddress,
- deployerAddress: admin.String(),
- shouldErr: false,
- },
- {
- desc: "Error - Invalid deployer",
- contractAddress: noAdminContractAddress,
- deployerAddress: "Invalid",
- shouldErr: true,
- },
- } {
- tc := tc
- s.Run(tc.desc, func() {
- if !tc.shouldErr {
- _, err := s.app.DevGasKeeper.GetContractAdminOrCreatorAddress(
- s.ctx, sdk.MustAccAddressFromBech32(tc.contractAddress), tc.deployerAddress,
- )
- s.NoError(err)
- return
- }
- _, err := s.app.DevGasKeeper.GetContractAdminOrCreatorAddress(
- s.ctx, sdk.MustAccAddressFromBech32(tc.contractAddress), tc.deployerAddress,
- )
- s.Error(err)
- })
- }
-}
-
-func (s *KeeperTestSuite) TestRegisterFeeShare() {
- _, _, sender := testdata.KeyTestPubAddr()
- _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1_000_000))))
-
- gov := s.app.AccountKeeper.GetModuleAddress(govtypes.ModuleName).String()
- govContract := s.InstantiateContract(sender.String(), gov)
-
- contractAddress := s.InstantiateContract(sender.String(), "")
- contractAddress2 := s.InstantiateContract(contractAddress, contractAddress)
-
- deployer := s.InstantiateContract(sender.String(), "")
- subContract := s.InstantiateContract(deployer, deployer)
-
- _, _, withdrawer := testdata.KeyTestPubAddr()
-
- for _, tc := range []struct {
- desc string
- msg *types.MsgRegisterFeeShare
- resp *types.MsgRegisterFeeShareResponse
- shouldErr bool
- }{
- {
- desc: "Invalid contract address",
- msg: &types.MsgRegisterFeeShare{
- ContractAddress: "Invalid",
- DeployerAddress: sender.String(),
- WithdrawerAddress: withdrawer.String(),
- },
- resp: &types.MsgRegisterFeeShareResponse{},
- shouldErr: true,
- },
- {
- desc: "Invalid deployer address",
- msg: &types.MsgRegisterFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: "Invalid",
- WithdrawerAddress: withdrawer.String(),
- },
- resp: &types.MsgRegisterFeeShareResponse{},
- shouldErr: true,
- },
- {
- desc: "Invalid withdrawer address",
- msg: &types.MsgRegisterFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: "Invalid",
- },
- resp: &types.MsgRegisterFeeShareResponse{},
- shouldErr: true,
- },
- {
- desc: "Success",
- msg: &types.MsgRegisterFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: withdrawer.String(),
- },
- resp: &types.MsgRegisterFeeShareResponse{},
- shouldErr: false,
- },
- {
- desc: "Invalid withdraw address for factory contract",
- msg: &types.MsgRegisterFeeShare{
- ContractAddress: contractAddress2,
- DeployerAddress: sender.String(),
- WithdrawerAddress: sender.String(),
- },
- resp: &types.MsgRegisterFeeShareResponse{},
- shouldErr: true,
- },
- {
- desc: "Success register factory contract to itself",
- msg: &types.MsgRegisterFeeShare{
- ContractAddress: contractAddress2,
- DeployerAddress: sender.String(),
- WithdrawerAddress: contractAddress2,
- },
- resp: &types.MsgRegisterFeeShareResponse{},
- shouldErr: false,
- },
- {
- desc: "Invalid register gov contract withdraw address",
- msg: &types.MsgRegisterFeeShare{
- ContractAddress: govContract,
- DeployerAddress: sender.String(),
- WithdrawerAddress: sender.String(),
- },
- resp: &types.MsgRegisterFeeShareResponse{},
- shouldErr: true,
- },
- {
- desc: "Success register gov contract withdraw address to self",
- msg: &types.MsgRegisterFeeShare{
- ContractAddress: govContract,
- DeployerAddress: sender.String(),
- WithdrawerAddress: govContract,
- },
- resp: &types.MsgRegisterFeeShareResponse{},
- shouldErr: false,
- },
- {
- desc: "Success register contract from contract as admin",
- msg: &types.MsgRegisterFeeShare{
- ContractAddress: subContract,
- DeployerAddress: deployer,
- WithdrawerAddress: deployer,
- },
- resp: &types.MsgRegisterFeeShareResponse{},
- shouldErr: false,
- },
- } {
- tc := tc
- s.Run(tc.desc, func() {
- goCtx := sdk.WrapSDKContext(s.ctx)
- if !tc.shouldErr {
- resp, err := s.devgasMsgServer.RegisterFeeShare(goCtx, tc.msg)
- s.Require().NoError(err)
- s.Require().Equal(resp, tc.resp)
- } else {
- resp, err := s.devgasMsgServer.RegisterFeeShare(goCtx, tc.msg)
- s.Require().Error(err)
- s.Require().Nil(resp)
- }
- })
- }
-}
-
-func (s *KeeperTestSuite) TestUpdateFeeShare() {
- _, _, sender := testdata.KeyTestPubAddr()
- _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1_000_000))))
-
- fmt.Printf("s.ctx: %v\n", s.ctx)
- fmt.Printf("s.ctx.BlockTime(): %v\n", s.ctx.BlockTime())
- fmt.Printf("s.ctx.BlockHeight(): %v\n", s.ctx.BlockHeight())
- contractAddress := s.InstantiateContract(sender.String(), "")
- _, _, withdrawer := testdata.KeyTestPubAddr()
-
- contractAddressNoRegisFeeShare := s.InstantiateContract(sender.String(), "")
- s.Require().NotEqual(contractAddress, contractAddressNoRegisFeeShare)
-
- // RegsisFeeShare
- goCtx := sdk.WrapSDKContext(s.ctx)
- msg := &types.MsgRegisterFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: withdrawer.String(),
- }
- _, err := s.devgasMsgServer.RegisterFeeShare(goCtx, msg)
- s.Require().NoError(err)
- _, _, newWithdrawer := testdata.KeyTestPubAddr()
- s.Require().NotEqual(withdrawer, newWithdrawer)
-
- for _, tc := range []struct {
- desc string
- msg *types.MsgUpdateFeeShare
- resp *types.MsgCancelFeeShareResponse
- shouldErr bool
- }{
- {
- desc: "Invalid - contract not regis",
- msg: &types.MsgUpdateFeeShare{
- ContractAddress: contractAddressNoRegisFeeShare,
- DeployerAddress: sender.String(),
- WithdrawerAddress: newWithdrawer.String(),
- },
- resp: nil,
- shouldErr: true,
- },
- {
- desc: "Invalid - Invalid DeployerAddress",
- msg: &types.MsgUpdateFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: "Invalid",
- WithdrawerAddress: newWithdrawer.String(),
- },
- resp: nil,
- shouldErr: true,
- },
- {
- desc: "Invalid - Invalid WithdrawerAddress",
- msg: &types.MsgUpdateFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: "Invalid",
- },
- resp: nil,
- shouldErr: true,
- },
- {
- desc: "Invalid - Invalid WithdrawerAddress not change",
- msg: &types.MsgUpdateFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: withdrawer.String(),
- },
- resp: nil,
- shouldErr: true,
- },
- {
- desc: "Success",
- msg: &types.MsgUpdateFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: newWithdrawer.String(),
- },
- resp: &types.MsgCancelFeeShareResponse{},
- shouldErr: false,
- },
- } {
- tc := tc
- s.Run(tc.desc, func() {
- goCtx := sdk.WrapSDKContext(s.ctx)
- if !tc.shouldErr {
- _, err := s.devgasMsgServer.UpdateFeeShare(goCtx, tc.msg)
- s.Require().NoError(err)
- } else {
- resp, err := s.devgasMsgServer.UpdateFeeShare(goCtx, tc.msg)
- s.Require().Error(err)
- s.Require().Nil(resp)
- }
- })
- }
-}
-
-func (s *KeeperTestSuite) TestCancelFeeShare() {
- _, _, sender := testdata.KeyTestPubAddr()
- _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1_000_000))))
-
- contractAddress := s.InstantiateContract(sender.String(), "")
- _, _, withdrawer := testdata.KeyTestPubAddr()
-
- // RegsisFeeShare
- goCtx := sdk.WrapSDKContext(s.ctx)
- msg := &types.MsgRegisterFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- WithdrawerAddress: withdrawer.String(),
- }
- _, err := s.devgasMsgServer.RegisterFeeShare(goCtx, msg)
- s.Require().NoError(err)
-
- for _, tc := range []struct {
- desc string
- msg *types.MsgCancelFeeShare
- resp *types.MsgCancelFeeShareResponse
- shouldErr bool
- }{
- {
- desc: "Invalid - contract Address",
- msg: &types.MsgCancelFeeShare{
- ContractAddress: "Invalid",
- DeployerAddress: sender.String(),
- },
- resp: nil,
- shouldErr: true,
- },
- {
- desc: "Invalid - deployer Address",
- msg: &types.MsgCancelFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: "Invalid",
- },
- resp: nil,
- shouldErr: true,
- },
- {
- desc: "Success",
- msg: &types.MsgCancelFeeShare{
- ContractAddress: contractAddress,
- DeployerAddress: sender.String(),
- },
- resp: &types.MsgCancelFeeShareResponse{},
- shouldErr: false,
- },
- } {
- tc := tc
- s.Run(tc.desc, func() {
- goCtx := sdk.WrapSDKContext(s.ctx)
- if !tc.shouldErr {
- resp, err := s.devgasMsgServer.CancelFeeShare(goCtx, tc.msg)
- s.Require().NoError(err)
- s.Require().Equal(resp, tc.resp)
- } else {
- resp, err := s.devgasMsgServer.CancelFeeShare(goCtx, tc.msg)
- s.Require().Error(err)
- s.Require().Equal(resp, tc.resp)
- }
- })
- }
-}
-
-func (s *KeeperTestSuite) TestUpdateParams() {
- govModuleAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
- goCtx := sdk.WrapSDKContext(s.ctx)
-
- for _, tc := range []struct {
- desc string
- msg *types.MsgUpdateParams
- shouldErr bool
- }{
- {
- desc: "happy",
- msg: &types.MsgUpdateParams{
- Authority: govModuleAddr,
- Params: types.DefaultParams().Sanitize(),
- },
- shouldErr: false,
- },
- {
- desc: "err - empty params",
- msg: &types.MsgUpdateParams{
- Authority: govModuleAddr,
- Params: types.ModuleParams{},
- },
- shouldErr: true,
- },
- {
- desc: "err - nil params",
- msg: &types.MsgUpdateParams{
- Authority: govModuleAddr,
- },
- shouldErr: true,
- },
- {
- desc: "err - nil params",
- msg: &types.MsgUpdateParams{
- Authority: "not-an-authority",
- Params: types.DefaultParams(),
- },
- shouldErr: true,
- },
- } {
- tc := tc
- s.Run(tc.desc, func() {
- if !tc.shouldErr {
- _, err := s.devgasMsgServer.UpdateParams(goCtx, tc.msg)
- s.NoError(err)
- } else {
- _, err := s.devgasMsgServer.UpdateParams(goCtx, tc.msg)
- s.Error(err)
- }
- })
- }
-}
diff --git a/x/devgas/v1/keeper/params.go b/x/devgas/v1/keeper/params.go
deleted file mode 100644
index 3760136e5..000000000
--- a/x/devgas/v1/keeper/params.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package keeper
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-// GetParams returns the total set of fees parameters.
-func (k Keeper) GetParams(ctx sdk.Context) (params types.ModuleParams) {
- params, _ = k.ModuleParams.Get(ctx)
- return params.Sanitize()
-}
diff --git a/x/devgas/v1/keeper/store.go b/x/devgas/v1/keeper/store.go
deleted file mode 100644
index 93a2ff2db..000000000
--- a/x/devgas/v1/keeper/store.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package keeper
-
-import (
- "github.com/NibiruChain/collections"
- sdkcodec "github.com/cosmos/cosmos-sdk/codec"
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
-
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-type DevGasIndexes struct {
- // Deployer MultiIndex:
- // - indexing key (IK): deployer address
- // - primary key (PK): contract address
- // - value (V): Dev gas struct
- Deployer collections.MultiIndex[string, string, devgastypes.FeeShare]
-
- // Withdrawer MultiIndex:
- // - indexing key (IK): withdrawer address
- // - primary key (PK): contract address
- // - value (V): Dev gas struct
- Withdrawer collections.MultiIndex[string, string, devgastypes.FeeShare]
-}
-
-func (idxs DevGasIndexes) IndexerList() []collections.Indexer[string, devgastypes.FeeShare] {
- return []collections.Indexer[string, devgastypes.FeeShare]{
- idxs.Deployer, idxs.Withdrawer,
- }
-}
-
-func NewDevGasStore(
- storeKey storetypes.StoreKey, cdc sdkcodec.BinaryCodec,
-) collections.IndexedMap[string, devgastypes.FeeShare, DevGasIndexes] {
- primaryKeyEncoder := collections.StringKeyEncoder
- valueEncoder := collections.ProtoValueEncoder[devgastypes.FeeShare](cdc)
-
- var namespace collections.Namespace = devgastypes.KeyPrefixFeeShare
- var namespaceDeployerIdx collections.Namespace = devgastypes.KeyPrefixDeployer
- var namespaceWithdrawerIdx collections.Namespace = devgastypes.KeyPrefixWithdrawer
-
- return collections.NewIndexedMap[string, devgastypes.FeeShare](
- storeKey, namespace, primaryKeyEncoder, valueEncoder,
- DevGasIndexes{
- Deployer: collections.NewMultiIndex[string, string, devgastypes.FeeShare](
- storeKey, namespaceDeployerIdx,
- collections.StringKeyEncoder, // index key (IK)
- collections.StringKeyEncoder, // primary key (PK)
- func(v devgastypes.FeeShare) string { return v.DeployerAddress },
- ),
- Withdrawer: collections.NewMultiIndex[string, string, devgastypes.FeeShare](
- storeKey, namespaceWithdrawerIdx,
- collections.StringKeyEncoder, // index key (IK)
- collections.StringKeyEncoder, // primary key (PK)
- func(v devgastypes.FeeShare) string { return v.WithdrawerAddress },
- ),
- },
- )
-}
diff --git a/x/devgas/v1/keeper/testdata/reflect.wasm b/x/devgas/v1/keeper/testdata/reflect.wasm
deleted file mode 100644
index 412241177..000000000
Binary files a/x/devgas/v1/keeper/testdata/reflect.wasm and /dev/null differ
diff --git a/x/devgas/v1/module.go b/x/devgas/v1/module.go
deleted file mode 100644
index b76044225..000000000
--- a/x/devgas/v1/module.go
+++ /dev/null
@@ -1,191 +0,0 @@
-package devgas
-
-import (
- "context"
- "encoding/json"
- "fmt"
-
- abci "github.com/cometbft/cometbft/abci/types"
- sdkclient "github.com/cosmos/cosmos-sdk/client"
- sdkcodec "github.com/cosmos/cosmos-sdk/codec"
- sdkcodectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
- simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
- authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/devgas/v1/client/cli"
- "github.com/NibiruChain/nibiru/x/devgas/v1/exported"
- "github.com/NibiruChain/nibiru/x/devgas/v1/keeper"
- "github.com/NibiruChain/nibiru/x/devgas/v1/simulation"
- "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-// type check to ensure the interface is properly implemented
-var (
- _ module.AppModule = AppModule{}
- _ module.AppModuleBasic = AppModuleBasic{}
- _ module.AppModuleSimulation = AppModule{}
-)
-
-// ConsensusVersion defines the current module consensus version.
-const ConsensusVersion = 2
-
-// AppModuleBasic type for the fees module
-type AppModuleBasic struct{}
-
-// Name returns the fees module's name.
-func (AppModuleBasic) Name() string {
- return types.ModuleName
-}
-
-// RegisterLegacyAminoCodec performs a no-op as the fees do not support Amino
-// encoding.
-func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *sdkcodec.LegacyAmino) {
- types.RegisterLegacyAminoCodec(cdc)
-}
-
-// ConsensusVersion returns the consensus state-breaking version for the module.
-func (AppModuleBasic) ConsensusVersion() uint64 {
- return ConsensusVersion
-}
-
-// RegisterInterfaces registers interfaces and implementations of the fees
-// module.
-func (AppModuleBasic) RegisterInterfaces(
- interfaceRegistry sdkcodectypes.InterfaceRegistry,
-) {
- types.RegisterInterfaces(interfaceRegistry)
-}
-
-// DefaultGenesis returns default genesis state as raw bytes for the fees
-// module.
-func (AppModuleBasic) DefaultGenesis(cdc sdkcodec.JSONCodec) json.RawMessage {
- return cdc.MustMarshalJSON(types.DefaultGenesisState())
-}
-
-// ValidateGenesis performs genesis state validation for the fees module.
-func (b AppModuleBasic) ValidateGenesis(
- cdc sdkcodec.JSONCodec, _ sdkclient.TxEncodingConfig, bz json.RawMessage,
-) error {
- var genesisState types.GenesisState
- if err := cdc.UnmarshalJSON(bz, &genesisState); err != nil {
- return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
- }
-
- return genesisState.Validate()
-}
-
-// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the fees
-// module.
-func (b AppModuleBasic) RegisterGRPCGatewayRoutes(
- c sdkclient.Context, serveMux *runtime.ServeMux,
-) {
- if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil {
- panic(err)
- }
-}
-
-// GetTxCmd returns the root tx command for the fees module.
-func (AppModuleBasic) GetTxCmd() *cobra.Command {
- return cli.NewTxCmd()
-}
-
-// GetQueryCmd returns the fees module's root query command.
-func (AppModuleBasic) GetQueryCmd() *cobra.Command {
- return cli.GetQueryCmd()
-}
-
-// ___________________________________________________________________________
-
-// AppModule implements the AppModule interface for the fees module.
-type AppModule struct {
- AppModuleBasic
- keeper keeper.Keeper
- ak authkeeper.AccountKeeper
-
- // legacySubspace is used solely for migration of x/params managed parameters
- legacySubspace exported.Subspace
-}
-
-// NewAppModule creates a new AppModule Object
-func NewAppModule(
- k keeper.Keeper,
- ak authkeeper.AccountKeeper,
- ss exported.Subspace,
-) AppModule {
- return AppModule{
- AppModuleBasic: AppModuleBasic{},
- keeper: k,
- ak: ak,
- legacySubspace: ss,
- }
-}
-
-// Name returns the fees module's name.
-func (AppModule) Name() string {
- return types.ModuleName
-}
-
-// RegisterInvariants registers the fees module's invariants.
-func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
-
-// QuerierRoute returns the module's query routing key.
-func (am AppModule) QuerierRoute() string {
- return types.RouterKey
-}
-
-// RegisterServices registers a GRPC query service to respond to the
-// module-specific GRPC queries.
-func (am AppModule) RegisterServices(cfg module.Configurator) {
- types.RegisterMsgServer(cfg.MsgServer(), am.keeper)
- types.RegisterQueryServer(
- cfg.QueryServer(), keeper.NewQuerier(am.keeper),
- )
-}
-
-// BeginBlock executes all ABCI BeginBlock logic respective to the fees module.
-func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {
-}
-
-// EndBlock executes all ABCI EndBlock logic respective to the fee-share module. It
-// returns no validator updates.
-func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
- return []abci.ValidatorUpdate{}
-}
-
-// InitGenesis performs the fees module's genesis initialization. It returns
-// no validator updates.
-func (am AppModule) InitGenesis(ctx sdk.Context, cdc sdkcodec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
- var genesisState types.GenesisState
-
- cdc.MustUnmarshalJSON(data, &genesisState)
- InitGenesis(ctx, am.keeper, genesisState)
- return []abci.ValidatorUpdate{}
-}
-
-// ExportGenesis returns the fees module's exported genesis state as raw JSON bytes.
-func (am AppModule) ExportGenesis(ctx sdk.Context, cdc sdkcodec.JSONCodec) json.RawMessage {
- gs := ExportGenesis(ctx, am.keeper)
- return cdc.MustMarshalJSON(gs)
-}
-
-//----------------------------------------------------------------------------
-// AppModuleSimulation functions
-//----------------------------------------------------------------------------
-
-// GenerateGenesisState implements module.AppModuleSimulation.
-func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
- simulation.RandomizedGenState(simState)
-}
-
-// RegisterStoreDecoder implements module.AppModuleSimulation.
-func (AppModule) RegisterStoreDecoder(sdk.StoreDecoderRegistry) {
-}
-
-// WeightedOperations implements module.AppModuleSimulation.
-func (AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
- return nil
-}
diff --git a/x/devgas/v1/module_test.go b/x/devgas/v1/module_test.go
deleted file mode 100644
index 4ab9d8929..000000000
--- a/x/devgas/v1/module_test.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package devgas_test
-
-import (
- abci "github.com/cometbft/cometbft/abci/types"
-
- "github.com/NibiruChain/nibiru/app/codec"
- devgas "github.com/NibiruChain/nibiru/x/devgas/v1"
- devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-func (s *GenesisTestSuite) TestAppModule() {
- s.SetupTest()
- appModule := devgas.NewAppModule(
- s.app.DevGasKeeper,
- s.app.AccountKeeper,
- s.app.GetSubspace(devgastypes.ModuleName),
- )
-
- s.NotPanics(func() {
- s.T().Log("begin and end block")
- appModule.BeginBlock(s.ctx, abci.RequestBeginBlock{})
- appModule.EndBlock(s.ctx, abci.RequestEndBlock{})
-
- s.T().Log("AppModule.ExportGenesis")
- cdc := s.app.AppCodec()
- jsonBz := appModule.ExportGenesis(s.ctx, cdc)
-
- genState := new(devgastypes.GenesisState)
- err := cdc.UnmarshalJSON(jsonBz, genState)
- s.NoError(err)
- s.EqualValues(s.genesis, *genState)
-
- s.T().Log("AppModuleBasic.ValidateGenesis")
- encCfg := codec.MakeEncodingConfig()
- err = appModule.AppModuleBasic.ValidateGenesis(cdc, encCfg.TxConfig, jsonBz)
- s.NoError(err)
-
- s.T().Log("CLI commands")
- s.NotNil(appModule.AppModuleBasic.GetTxCmd())
- s.NotNil(appModule.AppModuleBasic.GetQueryCmd())
- s.NotEmpty(appModule.QuerierRoute())
- })
-}
diff --git a/x/devgas/v1/simulation/genesis.go b/x/devgas/v1/simulation/genesis.go
deleted file mode 100644
index 24f2c7ba2..000000000
--- a/x/devgas/v1/simulation/genesis.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package simulation
-
-// DONTCOVER
-
-import (
- "encoding/json"
- "fmt"
- "math/rand"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
-
- "github.com/NibiruChain/nibiru/x/devgas/v1/types"
-)
-
-const (
- DeveloperFeeShare = "developer_fee_share"
-)
-
-func GenDeveloperFeeShare(r *rand.Rand) sdk.Dec {
- return math.LegacyNewDecWithPrec(int64(r.Intn(100)), 2)
-}
-
-func RandomizedGenState(simState *module.SimulationState) {
- var developerFeeShare sdk.Dec
- simState.AppParams.GetOrGenerate(
- simState.Cdc, DeveloperFeeShare, &developerFeeShare, simState.Rand,
- func(r *rand.Rand) { developerFeeShare = GenDeveloperFeeShare(r) },
- )
-
- devgasGenesis := types.GenesisState{
- Params: types.ModuleParams{
- EnableFeeShare: true,
- DeveloperShares: developerFeeShare,
- AllowedDenoms: []string{},
- },
- FeeShare: []types.FeeShare{},
- }
-
- bz, err := json.MarshalIndent(&devgasGenesis, "", " ")
- if err != nil {
- panic(err)
- }
- fmt.Printf("Selected randomly generated x/devgas parameters:\n%s\n", bz)
- simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&devgasGenesis)
-}
diff --git a/x/devgas/v1/types/codec.go b/x/devgas/v1/types/codec.go
deleted file mode 100644
index ecedea2e1..000000000
--- a/x/devgas/v1/types/codec.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package types
-
-import (
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/msgservice"
- authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
-)
-
-var (
- amino = codec.NewLegacyAmino()
-
- // ModuleCdc references the global erc20 module codec. Note, the codec
- // should ONLY be used in certain instances of tests and for JSON encoding.
- //
- // The actual codec used for serialization should be provided to
- // modules/erc20 and defined at the application level.
- ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
-
- // AminoCdc is a amino codec created to support amino JSON compatible msgs.
- AminoCdc = codec.NewAminoCodec(amino)
-)
-
-const (
- // Amino names
- cancelFeeShareName = "nibiru/MsgCancelFeeShare"
- registerFeeShareName = "nibiru/MsgRegisterFeeShare"
- updateFeeShareName = "nibiru/MsgUpdateFeeShare"
- updateFeeShareParams = "nibiru/MsgUpdateParams"
-)
-
-// NOTE: This is required for the GetSignBytes function
-func init() {
- RegisterLegacyAminoCodec(amino)
-
- sdk.RegisterLegacyAminoCodec(amino)
-
- // Register all Amino interfaces and concrete types on the authz Amino codec
- // so that this can later be used to properly serialize MsgGrant and MsgExec
- // instances.
- RegisterLegacyAminoCodec(authzcodec.Amino)
-}
-
-// RegisterInterfaces register implementations
-func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- registry.RegisterImplementations(
- (*sdk.Msg)(nil),
- &MsgRegisterFeeShare{},
- &MsgCancelFeeShare{},
- &MsgUpdateFeeShare{},
- &MsgUpdateParams{},
- )
-
- msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
-}
-
-// RegisterLegacyAminoCodec registers the necessary x/FeeShare interfaces and
-// concrete types on the provided LegacyAmino codec. These types are used for
-// Amino JSON serialization and EIP-712 compatibility.
-func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- cdc.RegisterConcrete(&MsgCancelFeeShare{}, cancelFeeShareName, nil)
- cdc.RegisterConcrete(&MsgRegisterFeeShare{}, registerFeeShareName, nil)
- cdc.RegisterConcrete(&MsgUpdateFeeShare{}, updateFeeShareName, nil)
- cdc.RegisterConcrete(&MsgUpdateParams{}, updateFeeShareParams, nil)
-}
diff --git a/x/devgas/v1/types/codec_test.go b/x/devgas/v1/types/codec_test.go
deleted file mode 100644
index 3759d4fd8..000000000
--- a/x/devgas/v1/types/codec_test.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package types
-
-import (
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-type CodecTestSuite struct {
- suite.Suite
-}
-
-func TestCodecSuite(t *testing.T) {
- suite.Run(t, new(CodecTestSuite))
-}
-
-func (suite *CodecTestSuite) TestRegisterInterfaces() {
- registry := codectypes.NewInterfaceRegistry()
- registry.RegisterInterface(sdk.MsgInterfaceProtoName, (*sdk.Msg)(nil))
- RegisterInterfaces(registry)
-
- impls := registry.ListImplementations(sdk.MsgInterfaceProtoName)
- suite.Require().Equal(4, len(impls))
- suite.Require().ElementsMatch([]string{
- "/nibiru.devgas.v1.MsgRegisterFeeShare",
- "/nibiru.devgas.v1.MsgCancelFeeShare",
- "/nibiru.devgas.v1.MsgUpdateFeeShare",
- "/nibiru.devgas.v1.MsgUpdateParams",
- }, impls)
-}
diff --git a/x/devgas/v1/types/devgas.go b/x/devgas/v1/types/devgas.go
deleted file mode 100644
index 97e6a1ed5..000000000
--- a/x/devgas/v1/types/devgas.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package types
-
-import (
- errorsmod "cosmossdk.io/errors"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- sdkerror "github.com/cosmos/cosmos-sdk/types/errors"
-)
-
-// NewFeeShare returns an instance of FeeShare.
-func NewFeeShare(contract sdk.Address, deployer, withdrawer sdk.AccAddress) FeeShare {
- return FeeShare{
- ContractAddress: contract.String(),
- DeployerAddress: deployer.String(),
- WithdrawerAddress: withdrawer.String(),
- }
-}
-
-// GetContractAddr returns the contract address
-func (fs FeeShare) GetContractAddr() sdk.Address {
- contract, err := sdk.AccAddressFromBech32(fs.ContractAddress)
- if err != nil {
- return nil
- }
- return contract
-}
-
-// GetDeployerAddr returns the contract deployer address
-func (fs FeeShare) GetDeployerAddr() sdk.AccAddress {
- contract, err := sdk.AccAddressFromBech32(fs.DeployerAddress)
- if err != nil {
- return nil
- }
- return contract
-}
-
-// GetWithdrawerAddr returns the account address to where the funds proceeding
-// from the fees will be received.
-func (fs FeeShare) GetWithdrawerAddr() sdk.AccAddress {
- contract, err := sdk.AccAddressFromBech32(fs.WithdrawerAddress)
- if err != nil {
- return nil
- }
- return contract
-}
-
-// Validate performs a stateless validation of a FeeShare
-func (fs FeeShare) Validate() error {
- if _, err := sdk.AccAddressFromBech32(fs.ContractAddress); err != nil {
- return err
- }
-
- if _, err := sdk.AccAddressFromBech32(fs.DeployerAddress); err != nil {
- return err
- }
-
- if fs.WithdrawerAddress == "" {
- return errorsmod.Wrap(sdkerror.ErrInvalidAddress, "withdrawer address cannot be empty")
- }
-
- if _, err := sdk.AccAddressFromBech32(fs.WithdrawerAddress); err != nil {
- return err
- }
-
- return nil
-}
diff --git a/x/devgas/v1/types/devgas.pb.go b/x/devgas/v1/types/devgas.pb.go
deleted file mode 100644
index 8d007c067..000000000
--- a/x/devgas/v1/types/devgas.pb.go
+++ /dev/null
@@ -1,428 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/devgas/v1/devgas.proto
-
-package types
-
-import (
- fmt "fmt"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// FeeShare defines an instance that organizes fee distribution conditions for
-// the owner of a given smart contract
-type FeeShare struct {
- // contract_address is the bech32 address of a registered contract in string
- // form
- ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
- // deployer_address is the bech32 address of message sender. It must be the
- // same as the contracts admin address.
- DeployerAddress string `protobuf:"bytes,2,opt,name=deployer_address,json=deployerAddress,proto3" json:"deployer_address,omitempty"`
- // withdrawer_address is the bech32 address of account receiving the
- // transaction fees.
- WithdrawerAddress string `protobuf:"bytes,3,opt,name=withdrawer_address,json=withdrawerAddress,proto3" json:"withdrawer_address,omitempty"`
-}
-
-func (m *FeeShare) Reset() { *m = FeeShare{} }
-func (m *FeeShare) String() string { return proto.CompactTextString(m) }
-func (*FeeShare) ProtoMessage() {}
-func (*FeeShare) Descriptor() ([]byte, []int) {
- return fileDescriptor_f71dc4524d1e4ffb, []int{0}
-}
-func (m *FeeShare) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *FeeShare) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_FeeShare.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *FeeShare) XXX_Merge(src proto.Message) {
- xxx_messageInfo_FeeShare.Merge(m, src)
-}
-func (m *FeeShare) XXX_Size() int {
- return m.Size()
-}
-func (m *FeeShare) XXX_DiscardUnknown() {
- xxx_messageInfo_FeeShare.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_FeeShare proto.InternalMessageInfo
-
-func (m *FeeShare) GetContractAddress() string {
- if m != nil {
- return m.ContractAddress
- }
- return ""
-}
-
-func (m *FeeShare) GetDeployerAddress() string {
- if m != nil {
- return m.DeployerAddress
- }
- return ""
-}
-
-func (m *FeeShare) GetWithdrawerAddress() string {
- if m != nil {
- return m.WithdrawerAddress
- }
- return ""
-}
-
-func init() {
- proto.RegisterType((*FeeShare)(nil), "nibiru.devgas.v1.FeeShare")
-}
-
-func init() { proto.RegisterFile("nibiru/devgas/v1/devgas.proto", fileDescriptor_f71dc4524d1e4ffb) }
-
-var fileDescriptor_f71dc4524d1e4ffb = []byte{
- // 210 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0xcb, 0x4c, 0xca,
- 0x2c, 0x2a, 0xd5, 0x4f, 0x49, 0x2d, 0x4b, 0x4f, 0x2c, 0xd6, 0x2f, 0x33, 0x84, 0xb2, 0xf4, 0x0a,
- 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0x20, 0xd2, 0x7a, 0x50, 0xc1, 0x32, 0x43, 0xa5, 0x7e, 0x46,
- 0x2e, 0x0e, 0xb7, 0xd4, 0xd4, 0xe0, 0x8c, 0xc4, 0xa2, 0x54, 0x21, 0x4d, 0x2e, 0x81, 0xe4, 0xfc,
- 0xbc, 0x92, 0xa2, 0xc4, 0xe4, 0x92, 0xf8, 0xc4, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0x62, 0x09, 0x46,
- 0x05, 0x46, 0x0d, 0xce, 0x20, 0x7e, 0x98, 0xb8, 0x23, 0x44, 0x18, 0xa4, 0x34, 0x25, 0xb5, 0x20,
- 0x27, 0xbf, 0x32, 0xb5, 0x08, 0xae, 0x94, 0x09, 0xa2, 0x14, 0x26, 0x0e, 0x53, 0xaa, 0xcb, 0x25,
- 0x54, 0x9e, 0x59, 0x92, 0x91, 0x52, 0x94, 0x58, 0x8e, 0xa4, 0x98, 0x19, 0xac, 0x58, 0x10, 0x21,
- 0x03, 0x55, 0xee, 0xe4, 0x79, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9,
- 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xfa,
- 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x7e, 0x60, 0x8f, 0x38, 0x67,
- 0x24, 0x66, 0xe6, 0xe9, 0x43, 0xfd, 0x5c, 0x81, 0xe4, 0xeb, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24,
- 0x36, 0xb0, 0xaf, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2b, 0xbb, 0x00, 0xe8, 0x16, 0x01,
- 0x00, 0x00,
-}
-
-func (m *FeeShare) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *FeeShare) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *FeeShare) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.WithdrawerAddress) > 0 {
- i -= len(m.WithdrawerAddress)
- copy(dAtA[i:], m.WithdrawerAddress)
- i = encodeVarintDevgas(dAtA, i, uint64(len(m.WithdrawerAddress)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.DeployerAddress) > 0 {
- i -= len(m.DeployerAddress)
- copy(dAtA[i:], m.DeployerAddress)
- i = encodeVarintDevgas(dAtA, i, uint64(len(m.DeployerAddress)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.ContractAddress) > 0 {
- i -= len(m.ContractAddress)
- copy(dAtA[i:], m.ContractAddress)
- i = encodeVarintDevgas(dAtA, i, uint64(len(m.ContractAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintDevgas(dAtA []byte, offset int, v uint64) int {
- offset -= sovDevgas(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *FeeShare) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ContractAddress)
- if l > 0 {
- n += 1 + l + sovDevgas(uint64(l))
- }
- l = len(m.DeployerAddress)
- if l > 0 {
- n += 1 + l + sovDevgas(uint64(l))
- }
- l = len(m.WithdrawerAddress)
- if l > 0 {
- n += 1 + l + sovDevgas(uint64(l))
- }
- return n
-}
-
-func sovDevgas(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozDevgas(x uint64) (n int) {
- return sovDevgas(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *FeeShare) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowDevgas
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: FeeShare: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: FeeShare: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowDevgas
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthDevgas
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthDevgas
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ContractAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field DeployerAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowDevgas
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthDevgas
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthDevgas
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.DeployerAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field WithdrawerAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowDevgas
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthDevgas
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthDevgas
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.WithdrawerAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipDevgas(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthDevgas
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipDevgas(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowDevgas
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowDevgas
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowDevgas
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthDevgas
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupDevgas
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthDevgas
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthDevgas = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowDevgas = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupDevgas = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/devgas/v1/types/devgas_test.go b/x/devgas/v1/types/devgas_test.go
deleted file mode 100644
index 72add1d0e..000000000
--- a/x/devgas/v1/types/devgas_test.go
+++ /dev/null
@@ -1,146 +0,0 @@
-package types
-
-import (
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-type FeeShareTestSuite struct {
- suite.Suite
- address1 sdk.AccAddress
- address2 sdk.AccAddress
- contract sdk.AccAddress
-}
-
-func TestFeeShareSuite(t *testing.T) {
- suite.Run(t, new(FeeShareTestSuite))
-}
-
-func (suite *FeeShareTestSuite) SetupTest() {
- suite.address1 = sdk.AccAddress([]byte("cosmos1"))
- suite.address2 = sdk.AccAddress([]byte("cosmos2"))
-
- suite.contract = sdk.AccAddress([]byte("cosmos1contract"))
-}
-
-func (suite *FeeShareTestSuite) TestFeeNew() {
- testCases := []struct {
- name string
- contract sdk.Address
- deployer sdk.AccAddress
- withdraw sdk.AccAddress
- expectPass bool
- }{
- {
- "Create feeshare- pass",
- suite.contract,
- suite.address1,
- suite.address2,
- true,
- },
- {
- "Create feeshare- invalid contract address",
- sdk.AccAddress{},
- suite.address1,
- suite.address2,
- false,
- },
- {
- "Create feeshare- invalid deployer address",
- suite.contract,
- sdk.AccAddress{},
- suite.address2,
- false,
- },
- }
-
- for _, tc := range testCases {
- i := NewFeeShare(tc.contract, tc.deployer, tc.withdraw)
- err := i.Validate()
-
- if tc.expectPass {
- suite.Require().NoError(err, tc.name)
- } else {
- suite.Require().Error(err, tc.name)
- }
- }
-}
-
-func (suite *FeeShareTestSuite) TestFee() {
- testCases := []struct {
- msg string
- feeshare FeeShare
- expectPass bool
- }{
- {
- "Create feeshare- pass",
- FeeShare{
- suite.contract.String(),
- suite.address1.String(),
- suite.address2.String(),
- },
- true,
- },
- {
- "Create feeshare- invalid contract address (invalid length 2)",
- FeeShare{
- "nibi15u3dt79t6sxxa3x3kpkhzsy56edaa5a66kxmukqjz2sx0hes5sn38g",
- suite.address1.String(),
- suite.address2.String(),
- },
- false,
- },
- {
- "Create feeshare- invalid deployer address",
- FeeShare{
- suite.contract.String(),
- "nibi1hj5fveer5cjtn4wd6wstzugjfdxzl0xps73ftl",
- suite.address2.String(),
- },
- false,
- },
- {
- "Create feeshare- invalid withdraw address",
- FeeShare{
- suite.contract.String(),
- suite.address1.String(),
- "nibi1hj5fveer5cjtn4wd6wstzugjfdxzl0xps73ftl",
- },
- false,
- },
- }
-
- for _, tc := range testCases {
- err := tc.feeshare.Validate()
-
- if tc.expectPass {
- suite.Require().NoError(err, tc.msg)
- } else {
- suite.Require().Error(err, tc.msg)
- }
- }
-}
-
-func (suite *FeeShareTestSuite) TestFeeShareGetters() {
- contract := sdk.AccAddress([]byte("cosmos1contract"))
- fs := FeeShare{
- contract.String(),
- suite.address1.String(),
- suite.address2.String(),
- }
- suite.Equal(fs.GetContractAddr(), contract)
- suite.Equal(fs.GetDeployerAddr(), suite.address1)
- suite.Equal(fs.GetWithdrawerAddr(), suite.address2)
-
- fs = FeeShare{
- contract.String(),
- suite.address1.String(),
- "",
- }
- suite.Equal(fs.GetContractAddr(), contract)
- suite.Equal(fs.GetDeployerAddr(), suite.address1)
- suite.Equal(len(fs.GetWithdrawerAddr()), 0)
-}
diff --git a/x/devgas/v1/types/errors.go b/x/devgas/v1/types/errors.go
deleted file mode 100644
index 231c8557e..000000000
--- a/x/devgas/v1/types/errors.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package types
-
-import (
- errorsmod "cosmossdk.io/errors"
-)
-
-// errors
-var (
- ErrFeeShareDisabled = errorsmod.Register(ModuleName, 1, "feeshare module is disabled by governance")
- ErrFeeShareAlreadyRegistered = errorsmod.Register(ModuleName, 2, "feeshare already exists for given contract")
- ErrFeeShareNoContractDeployed = errorsmod.Register(ModuleName, 3, "no contract deployed")
- ErrFeeShareContractNotRegistered = errorsmod.Register(ModuleName, 4, "no feeshare registered for contract")
- ErrFeeSharePayment = errorsmod.Register(ModuleName, 5, "feeshare payment error")
- ErrFeeShareInvalidWithdrawer = errorsmod.Register(ModuleName, 6, "invalid withdrawer address")
-)
diff --git a/x/devgas/v1/types/event.pb.go b/x/devgas/v1/types/event.pb.go
deleted file mode 100644
index 6bc5c33c4..000000000
--- a/x/devgas/v1/types/event.pb.go
+++ /dev/null
@@ -1,1111 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/devgas/v1/event.proto
-
-package types
-
-import (
- fmt "fmt"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// ABCI event emitted when a deployer registers a contract to receive fee
-// sharing payouts, specifying the deployer, contract, and withdrawer addresses.
-type EventRegisterDevGas struct {
- // deployer is the addess of the account that registered the smart contract to
- // receive dev gas royalties.
- Deployer string `protobuf:"bytes,1,opt,name=deployer,proto3" json:"deployer,omitempty"`
- // Address of the smart contract. This identifies the specific contract
- // that will receive fee sharing payouts.
- Contract string `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"`
- // The address that will receive the fee sharing payouts for the registered
- // contract. This could be the deployer address or a separate withdrawer
- // address specified.
- Withdrawer string `protobuf:"bytes,3,opt,name=withdrawer,proto3" json:"withdrawer,omitempty"`
-}
-
-func (m *EventRegisterDevGas) Reset() { *m = EventRegisterDevGas{} }
-func (m *EventRegisterDevGas) String() string { return proto.CompactTextString(m) }
-func (*EventRegisterDevGas) ProtoMessage() {}
-func (*EventRegisterDevGas) Descriptor() ([]byte, []int) {
- return fileDescriptor_dd3ce94d3a226edf, []int{0}
-}
-func (m *EventRegisterDevGas) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventRegisterDevGas) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventRegisterDevGas.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventRegisterDevGas) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventRegisterDevGas.Merge(m, src)
-}
-func (m *EventRegisterDevGas) XXX_Size() int {
- return m.Size()
-}
-func (m *EventRegisterDevGas) XXX_DiscardUnknown() {
- xxx_messageInfo_EventRegisterDevGas.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventRegisterDevGas proto.InternalMessageInfo
-
-func (m *EventRegisterDevGas) GetDeployer() string {
- if m != nil {
- return m.Deployer
- }
- return ""
-}
-
-func (m *EventRegisterDevGas) GetContract() string {
- if m != nil {
- return m.Contract
- }
- return ""
-}
-
-func (m *EventRegisterDevGas) GetWithdrawer() string {
- if m != nil {
- return m.Withdrawer
- }
- return ""
-}
-
-// ABCI event emitted when a deployer cancels fee sharing for a contract,
-// specifying the deployer and contract addresses.
-type EventCancelDevGas struct {
- // deployer is the addess of the account that registered the smart contract to
- // receive dev gas royalties.
- Deployer string `protobuf:"bytes,1,opt,name=deployer,proto3" json:"deployer,omitempty"`
- // Address of the smart contract. This identifies the specific contract
- // that will receive fee sharing payouts.
- Contract string `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"`
-}
-
-func (m *EventCancelDevGas) Reset() { *m = EventCancelDevGas{} }
-func (m *EventCancelDevGas) String() string { return proto.CompactTextString(m) }
-func (*EventCancelDevGas) ProtoMessage() {}
-func (*EventCancelDevGas) Descriptor() ([]byte, []int) {
- return fileDescriptor_dd3ce94d3a226edf, []int{1}
-}
-func (m *EventCancelDevGas) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventCancelDevGas) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventCancelDevGas.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventCancelDevGas) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventCancelDevGas.Merge(m, src)
-}
-func (m *EventCancelDevGas) XXX_Size() int {
- return m.Size()
-}
-func (m *EventCancelDevGas) XXX_DiscardUnknown() {
- xxx_messageInfo_EventCancelDevGas.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventCancelDevGas proto.InternalMessageInfo
-
-func (m *EventCancelDevGas) GetDeployer() string {
- if m != nil {
- return m.Deployer
- }
- return ""
-}
-
-func (m *EventCancelDevGas) GetContract() string {
- if m != nil {
- return m.Contract
- }
- return ""
-}
-
-// ABCI event emitted when a deployer updates the fee sharing registration for a
-// contract, specifying updated deployer, contract, and/or withdrawer addresses.
-type EventUpdateDevGas struct {
- // deployer is the addess of the account that registered the smart contract to
- // receive dev gas royalties.
- Deployer string `protobuf:"bytes,1,opt,name=deployer,proto3" json:"deployer,omitempty"`
- // Address of the smart contract. This identifies the specific contract
- // that will receive fee sharing payouts.
- Contract string `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"`
- // The address that will receive the fee sharing payouts for the registered
- // contract. This could be the deployer address or a separate withdrawer
- // address specified.
- Withdrawer string `protobuf:"bytes,3,opt,name=withdrawer,proto3" json:"withdrawer,omitempty"`
-}
-
-func (m *EventUpdateDevGas) Reset() { *m = EventUpdateDevGas{} }
-func (m *EventUpdateDevGas) String() string { return proto.CompactTextString(m) }
-func (*EventUpdateDevGas) ProtoMessage() {}
-func (*EventUpdateDevGas) Descriptor() ([]byte, []int) {
- return fileDescriptor_dd3ce94d3a226edf, []int{2}
-}
-func (m *EventUpdateDevGas) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventUpdateDevGas) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventUpdateDevGas.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventUpdateDevGas) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventUpdateDevGas.Merge(m, src)
-}
-func (m *EventUpdateDevGas) XXX_Size() int {
- return m.Size()
-}
-func (m *EventUpdateDevGas) XXX_DiscardUnknown() {
- xxx_messageInfo_EventUpdateDevGas.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventUpdateDevGas proto.InternalMessageInfo
-
-func (m *EventUpdateDevGas) GetDeployer() string {
- if m != nil {
- return m.Deployer
- }
- return ""
-}
-
-func (m *EventUpdateDevGas) GetContract() string {
- if m != nil {
- return m.Contract
- }
- return ""
-}
-
-func (m *EventUpdateDevGas) GetWithdrawer() string {
- if m != nil {
- return m.Withdrawer
- }
- return ""
-}
-
-// ABCI event emitted when fee sharing payouts are made, containing details on
-// the payouts in JSON format.
-type EventPayoutDevGas struct {
- Payouts string `protobuf:"bytes,1,opt,name=payouts,proto3" json:"payouts,omitempty"`
-}
-
-func (m *EventPayoutDevGas) Reset() { *m = EventPayoutDevGas{} }
-func (m *EventPayoutDevGas) String() string { return proto.CompactTextString(m) }
-func (*EventPayoutDevGas) ProtoMessage() {}
-func (*EventPayoutDevGas) Descriptor() ([]byte, []int) {
- return fileDescriptor_dd3ce94d3a226edf, []int{3}
-}
-func (m *EventPayoutDevGas) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventPayoutDevGas) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventPayoutDevGas.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventPayoutDevGas) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventPayoutDevGas.Merge(m, src)
-}
-func (m *EventPayoutDevGas) XXX_Size() int {
- return m.Size()
-}
-func (m *EventPayoutDevGas) XXX_DiscardUnknown() {
- xxx_messageInfo_EventPayoutDevGas.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventPayoutDevGas proto.InternalMessageInfo
-
-func (m *EventPayoutDevGas) GetPayouts() string {
- if m != nil {
- return m.Payouts
- }
- return ""
-}
-
-func init() {
- proto.RegisterType((*EventRegisterDevGas)(nil), "nibiru.devgas.v1.EventRegisterDevGas")
- proto.RegisterType((*EventCancelDevGas)(nil), "nibiru.devgas.v1.EventCancelDevGas")
- proto.RegisterType((*EventUpdateDevGas)(nil), "nibiru.devgas.v1.EventUpdateDevGas")
- proto.RegisterType((*EventPayoutDevGas)(nil), "nibiru.devgas.v1.EventPayoutDevGas")
-}
-
-func init() { proto.RegisterFile("nibiru/devgas/v1/event.proto", fileDescriptor_dd3ce94d3a226edf) }
-
-var fileDescriptor_dd3ce94d3a226edf = []byte{
- // 256 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0xcb, 0x4c, 0xca,
- 0x2c, 0x2a, 0xd5, 0x4f, 0x49, 0x2d, 0x4b, 0x4f, 0x2c, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b,
- 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0xc8, 0xea, 0x41, 0x64, 0xf5,
- 0xca, 0x0c, 0x95, 0x72, 0xb9, 0x84, 0x5d, 0x41, 0x0a, 0x82, 0x52, 0xd3, 0x33, 0x8b, 0x4b, 0x52,
- 0x8b, 0x5c, 0x52, 0xcb, 0xdc, 0x13, 0x8b, 0x85, 0xa4, 0xb8, 0x38, 0x52, 0x52, 0x0b, 0x72, 0xf2,
- 0x2b, 0x53, 0x8b, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xe0, 0x7c, 0x90, 0x5c, 0x72, 0x7e,
- 0x5e, 0x49, 0x51, 0x62, 0x72, 0x89, 0x04, 0x13, 0x44, 0x0e, 0xc6, 0x17, 0x92, 0xe3, 0xe2, 0x2a,
- 0xcf, 0x2c, 0xc9, 0x48, 0x29, 0x4a, 0x2c, 0x4f, 0x2d, 0x92, 0x60, 0x06, 0xcb, 0x22, 0x89, 0x28,
- 0x79, 0x73, 0x09, 0x82, 0xad, 0x73, 0x4e, 0xcc, 0x4b, 0x4e, 0xcd, 0xa1, 0xcc, 0x32, 0xa5, 0x6c,
- 0xa8, 0x61, 0xa1, 0x05, 0x29, 0x89, 0x25, 0xa9, 0x34, 0x76, 0xb9, 0x2e, 0xd4, 0xb2, 0x80, 0xc4,
- 0xca, 0xfc, 0xd2, 0x12, 0xa8, 0x65, 0x12, 0x5c, 0xec, 0x05, 0x60, 0x7e, 0x31, 0xd4, 0x2e, 0x18,
- 0xd7, 0xc9, 0xf3, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c,
- 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xf4, 0xd3, 0x33,
- 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xfd, 0xc0, 0xd1, 0xe1, 0x9c, 0x91, 0x98,
- 0x99, 0xa7, 0x0f, 0x8d, 0xb8, 0x0a, 0xa4, 0xa8, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03,
- 0xc7, 0x9d, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x32, 0xd6, 0x7e, 0xdb, 0x01, 0x00, 0x00,
-}
-
-func (m *EventRegisterDevGas) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventRegisterDevGas) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventRegisterDevGas) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Withdrawer) > 0 {
- i -= len(m.Withdrawer)
- copy(dAtA[i:], m.Withdrawer)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Withdrawer)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.Contract) > 0 {
- i -= len(m.Contract)
- copy(dAtA[i:], m.Contract)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Contract)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Deployer) > 0 {
- i -= len(m.Deployer)
- copy(dAtA[i:], m.Deployer)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Deployer)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventCancelDevGas) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventCancelDevGas) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventCancelDevGas) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Contract) > 0 {
- i -= len(m.Contract)
- copy(dAtA[i:], m.Contract)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Contract)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Deployer) > 0 {
- i -= len(m.Deployer)
- copy(dAtA[i:], m.Deployer)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Deployer)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventUpdateDevGas) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventUpdateDevGas) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventUpdateDevGas) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Withdrawer) > 0 {
- i -= len(m.Withdrawer)
- copy(dAtA[i:], m.Withdrawer)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Withdrawer)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.Contract) > 0 {
- i -= len(m.Contract)
- copy(dAtA[i:], m.Contract)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Contract)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Deployer) > 0 {
- i -= len(m.Deployer)
- copy(dAtA[i:], m.Deployer)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Deployer)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventPayoutDevGas) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventPayoutDevGas) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventPayoutDevGas) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Payouts) > 0 {
- i -= len(m.Payouts)
- copy(dAtA[i:], m.Payouts)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Payouts)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintEvent(dAtA []byte, offset int, v uint64) int {
- offset -= sovEvent(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *EventRegisterDevGas) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Deployer)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Contract)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Withdrawer)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func (m *EventCancelDevGas) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Deployer)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Contract)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func (m *EventUpdateDevGas) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Deployer)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Contract)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Withdrawer)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func (m *EventPayoutDevGas) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Payouts)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func sovEvent(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozEvent(x uint64) (n int) {
- return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *EventRegisterDevGas) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventRegisterDevGas: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventRegisterDevGas: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Deployer", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Deployer = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Contract = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Withdrawer", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Withdrawer = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventCancelDevGas) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventCancelDevGas: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventCancelDevGas: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Deployer", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Deployer = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Contract = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventUpdateDevGas) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventUpdateDevGas: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventUpdateDevGas: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Deployer", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Deployer = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Contract = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Withdrawer", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Withdrawer = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventPayoutDevGas) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventPayoutDevGas: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventPayoutDevGas: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Payouts", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Payouts = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipEvent(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthEvent
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupEvent
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthEvent
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/devgas/v1/types/expected_keepers.go b/x/devgas/v1/types/expected_keepers.go
deleted file mode 100644
index 1592cf2bf..000000000
--- a/x/devgas/v1/types/expected_keepers.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package types
-
-import (
- wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
-
- // "github.com/cosmos/cosmos-sdk/client"
- sdk "github.com/cosmos/cosmos-sdk/types"
- acctypes "github.com/cosmos/cosmos-sdk/x/auth/types"
-)
-
-// AccountKeeper defines the expected interface needed to retrieve account info.
-type AccountKeeper interface {
- GetModuleAddress(moduleName string) sdk.AccAddress
- GetModuleAccount(ctx sdk.Context, name string) acctypes.ModuleAccountI
-
- HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool
- GetAccount(ctx sdk.Context, addr sdk.AccAddress) (account acctypes.AccountI)
-}
-
-// BankKeeper defines the expected interface needed to retrieve account balances.
-type BankKeeper interface {
- SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
- SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
- BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
- GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
- GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
-}
-
-// WasmKeeper defines the expected interface needed to retrieve cosmwasm contracts.
-type WasmKeeper interface {
- GetContractInfo(ctx sdk.Context, contractAddr sdk.AccAddress) (wasmtypes.ContractInfo, error)
-}
diff --git a/x/devgas/v1/types/export.go b/x/devgas/v1/types/export.go
deleted file mode 100644
index fb4b6e3b6..000000000
--- a/x/devgas/v1/types/export.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package types
-
-import (
- grpc "google.golang.org/grpc"
-)
-
-// GrpcQueryServiceDesc represents the query server's RPC service specification.
-// This gives access to the service name and method names needed for stargate
-// queries.
-func GrpcQueryServiceDesc() grpc.ServiceDesc {
- return _Query_serviceDesc
-}
diff --git a/x/devgas/v1/types/genesis.go b/x/devgas/v1/types/genesis.go
deleted file mode 100644
index 1b0600dc9..000000000
--- a/x/devgas/v1/types/genesis.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package types
-
-import "fmt"
-
-// NewGenesisState creates a new genesis state.
-func NewGenesisState(params ModuleParams, feeshare []FeeShare) GenesisState {
- return GenesisState{
- Params: params,
- FeeShare: feeshare,
- }
-}
-
-// DefaultGenesisState sets default evm genesis state with empty accounts and
-// default params and chain config values.
-func DefaultGenesisState() *GenesisState {
- return &GenesisState{
- Params: DefaultParams(),
- FeeShare: []FeeShare{},
- }
-}
-
-// Validate performs basic genesis state validation returning an error upon any
-// failure.
-func (gs GenesisState) Validate() error {
- seenContract := make(map[string]bool)
- for _, fs := range gs.FeeShare {
- // only one fee per contract
- if seenContract[fs.ContractAddress] {
- return fmt.Errorf("contract duplicated on genesis '%s'", fs.ContractAddress)
- }
-
- if err := fs.Validate(); err != nil {
- return err
- }
-
- seenContract[fs.ContractAddress] = true
- }
-
- return gs.Params.Validate()
-}
diff --git a/x/devgas/v1/types/genesis.pb.go b/x/devgas/v1/types/genesis.pb.go
deleted file mode 100644
index d31dd8b53..000000000
--- a/x/devgas/v1/types/genesis.pb.go
+++ /dev/null
@@ -1,666 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/devgas/v1/genesis.proto
-
-package types
-
-import (
- fmt "fmt"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// GenesisState defines the module's genesis state.
-type GenesisState struct {
- // params are the feeshare module parameters
- Params ModuleParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
- // FeeShare is a slice of active registered contracts for fee distribution
- FeeShare []FeeShare `protobuf:"bytes,2,rep,name=fee_share,json=feeShare,proto3" json:"fee_share"`
-}
-
-func (m *GenesisState) Reset() { *m = GenesisState{} }
-func (m *GenesisState) String() string { return proto.CompactTextString(m) }
-func (*GenesisState) ProtoMessage() {}
-func (*GenesisState) Descriptor() ([]byte, []int) {
- return fileDescriptor_86a5066ce5bd7311, []int{0}
-}
-func (m *GenesisState) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *GenesisState) XXX_Merge(src proto.Message) {
- xxx_messageInfo_GenesisState.Merge(m, src)
-}
-func (m *GenesisState) XXX_Size() int {
- return m.Size()
-}
-func (m *GenesisState) XXX_DiscardUnknown() {
- xxx_messageInfo_GenesisState.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_GenesisState proto.InternalMessageInfo
-
-func (m *GenesisState) GetParams() ModuleParams {
- if m != nil {
- return m.Params
- }
- return ModuleParams{}
-}
-
-func (m *GenesisState) GetFeeShare() []FeeShare {
- if m != nil {
- return m.FeeShare
- }
- return nil
-}
-
-// ModuleParams defines the params for the devgas module
-type ModuleParams struct {
- // enable_feeshare defines a parameter to enable the feeshare module
- EnableFeeShare bool `protobuf:"varint,1,opt,name=enable_fee_share,json=enableFeeShare,proto3" json:"enable_fee_share,omitempty"`
- // developer_shares defines the proportion of the transaction fees to be
- // distributed to the registered contract owner
- DeveloperShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=developer_shares,json=developerShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"developer_shares"`
- // allowed_denoms defines the list of denoms that are allowed to be paid to
- // the contract withdraw addresses. If said denom is not in the list, the fees
- // will ONLY be sent to the community pool.
- // If this list is empty, all denoms are allowed.
- AllowedDenoms []string `protobuf:"bytes,3,rep,name=allowed_denoms,json=allowedDenoms,proto3" json:"allowed_denoms,omitempty"`
-}
-
-func (m *ModuleParams) Reset() { *m = ModuleParams{} }
-func (m *ModuleParams) String() string { return proto.CompactTextString(m) }
-func (*ModuleParams) ProtoMessage() {}
-func (*ModuleParams) Descriptor() ([]byte, []int) {
- return fileDescriptor_86a5066ce5bd7311, []int{1}
-}
-func (m *ModuleParams) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *ModuleParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_ModuleParams.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *ModuleParams) XXX_Merge(src proto.Message) {
- xxx_messageInfo_ModuleParams.Merge(m, src)
-}
-func (m *ModuleParams) XXX_Size() int {
- return m.Size()
-}
-func (m *ModuleParams) XXX_DiscardUnknown() {
- xxx_messageInfo_ModuleParams.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ModuleParams proto.InternalMessageInfo
-
-func (m *ModuleParams) GetEnableFeeShare() bool {
- if m != nil {
- return m.EnableFeeShare
- }
- return false
-}
-
-func (m *ModuleParams) GetAllowedDenoms() []string {
- if m != nil {
- return m.AllowedDenoms
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*GenesisState)(nil), "nibiru.devgas.v1.GenesisState")
- proto.RegisterType((*ModuleParams)(nil), "nibiru.devgas.v1.ModuleParams")
-}
-
-func init() { proto.RegisterFile("nibiru/devgas/v1/genesis.proto", fileDescriptor_86a5066ce5bd7311) }
-
-var fileDescriptor_86a5066ce5bd7311 = []byte{
- // 358 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x91, 0xb1, 0x6e, 0xe2, 0x40,
- 0x10, 0x86, 0xbd, 0x70, 0x42, 0xb0, 0x70, 0x1c, 0xb2, 0xae, 0xb0, 0x90, 0x6e, 0xb1, 0x90, 0xee,
- 0xe4, 0xe6, 0x76, 0x05, 0xd7, 0x5e, 0x1a, 0x82, 0x12, 0xa5, 0x48, 0x14, 0x99, 0x2a, 0x69, 0xd0,
- 0x1a, 0x0f, 0xc6, 0x8a, 0xed, 0xb5, 0xbc, 0xc6, 0x49, 0x9e, 0x21, 0x4d, 0x9e, 0x27, 0x4f, 0x40,
- 0x49, 0x19, 0xa5, 0x40, 0x11, 0xbc, 0x48, 0xe4, 0xb5, 0x93, 0xa0, 0x50, 0x79, 0xfc, 0xcf, 0xfc,
- 0xdf, 0x8c, 0xf6, 0xc7, 0x24, 0xf2, 0x1d, 0x3f, 0x59, 0x32, 0x17, 0x32, 0x8f, 0x4b, 0x96, 0x0d,
- 0x98, 0x07, 0x11, 0x48, 0x5f, 0xd2, 0x38, 0x11, 0xa9, 0xd0, 0x3b, 0x45, 0x9f, 0x16, 0x7d, 0x9a,
- 0x0d, 0xba, 0xbf, 0x0e, 0x1c, 0x65, 0x4f, 0x19, 0xba, 0x3f, 0x3d, 0xe1, 0x09, 0x55, 0xb2, 0xbc,
- 0x2a, 0xd4, 0xfe, 0x03, 0xc2, 0xad, 0xd3, 0x02, 0x3c, 0x49, 0x79, 0x0a, 0xfa, 0x7f, 0x5c, 0x8b,
- 0x79, 0xc2, 0x43, 0x69, 0x20, 0x13, 0x59, 0xcd, 0x21, 0xa1, 0x5f, 0x17, 0xd1, 0x73, 0xe1, 0x2e,
- 0x03, 0xb8, 0x54, 0x53, 0xa3, 0x6f, 0xab, 0x4d, 0x4f, 0xb3, 0x4b, 0x8f, 0x7e, 0x84, 0x1b, 0x73,
- 0x80, 0xa9, 0x5c, 0xf0, 0x04, 0x8c, 0x8a, 0x59, 0xb5, 0x9a, 0xc3, 0xee, 0x21, 0xe0, 0x04, 0x60,
- 0x92, 0x4f, 0x94, 0xe6, 0xfa, 0xbc, 0xfc, 0xef, 0x3f, 0x21, 0xdc, 0xda, 0xa7, 0xeb, 0x16, 0xee,
- 0x40, 0xc4, 0x9d, 0x00, 0xa6, 0x9f, 0xd8, 0xfc, 0xae, 0xba, 0xdd, 0x2e, 0xf4, 0x77, 0x94, 0x7e,
- 0x85, 0x3b, 0x2e, 0x64, 0x10, 0x88, 0x18, 0x92, 0x62, 0x50, 0x1a, 0x15, 0x13, 0x59, 0x8d, 0x11,
- 0xcd, 0x97, 0xbc, 0x6c, 0x7a, 0x7f, 0x3c, 0x3f, 0x5d, 0x2c, 0x1d, 0x3a, 0x13, 0x21, 0x9b, 0x09,
- 0x19, 0x0a, 0x59, 0x7e, 0xfe, 0x4a, 0xf7, 0x86, 0xa5, 0xf7, 0x31, 0x48, 0x3a, 0x86, 0x99, 0xfd,
- 0xe3, 0x83, 0xa3, 0xc8, 0x52, 0xff, 0x8d, 0xdb, 0x3c, 0x08, 0xc4, 0x2d, 0xb8, 0x53, 0x17, 0x22,
- 0x11, 0x4a, 0xa3, 0x6a, 0x56, 0xad, 0x86, 0xfd, 0xbd, 0x54, 0xc7, 0x4a, 0x1c, 0x9d, 0xad, 0xb6,
- 0x04, 0xad, 0xb7, 0x04, 0xbd, 0x6e, 0x09, 0x7a, 0xdc, 0x11, 0x6d, 0xbd, 0x23, 0xda, 0xf3, 0x8e,
- 0x68, 0xd7, 0x6c, 0x6f, 0xf3, 0x85, 0x7a, 0x8c, 0xe3, 0x05, 0xf7, 0x23, 0x56, 0x06, 0x76, 0xb7,
- 0x17, 0x99, 0x3a, 0xc3, 0xa9, 0xa9, 0x70, 0xfe, 0xbd, 0x05, 0x00, 0x00, 0xff, 0xff, 0x24, 0xf2,
- 0x7e, 0x8d, 0x05, 0x02, 0x00, 0x00,
-}
-
-func (m *GenesisState) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.FeeShare) > 0 {
- for iNdEx := len(m.FeeShare) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.FeeShare[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- }
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *ModuleParams) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ModuleParams) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *ModuleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.AllowedDenoms) > 0 {
- for iNdEx := len(m.AllowedDenoms) - 1; iNdEx >= 0; iNdEx-- {
- i -= len(m.AllowedDenoms[iNdEx])
- copy(dAtA[i:], m.AllowedDenoms[iNdEx])
- i = encodeVarintGenesis(dAtA, i, uint64(len(m.AllowedDenoms[iNdEx])))
- i--
- dAtA[i] = 0x1a
- }
- }
- {
- size := m.DeveloperShares.Size()
- i -= size
- if _, err := m.DeveloperShares.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if m.EnableFeeShare {
- i--
- if m.EnableFeeShare {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
- offset -= sovGenesis(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *GenesisState) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Params.Size()
- n += 1 + l + sovGenesis(uint64(l))
- if len(m.FeeShare) > 0 {
- for _, e := range m.FeeShare {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- return n
-}
-
-func (m *ModuleParams) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.EnableFeeShare {
- n += 2
- }
- l = m.DeveloperShares.Size()
- n += 1 + l + sovGenesis(uint64(l))
- if len(m.AllowedDenoms) > 0 {
- for _, s := range m.AllowedDenoms {
- l = len(s)
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- return n
-}
-
-func sovGenesis(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozGenesis(x uint64) (n int) {
- return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *GenesisState) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field FeeShare", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.FeeShare = append(m.FeeShare, FeeShare{})
- if err := m.FeeShare[len(m.FeeShare)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipGenesis(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenesis
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *ModuleParams) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ModuleParams: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ModuleParams: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EnableFeeShare", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.EnableFeeShare = bool(v != 0)
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field DeveloperShares", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.DeveloperShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AllowedDenoms", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.AllowedDenoms = append(m.AllowedDenoms, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipGenesis(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenesis
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipGenesis(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthGenesis
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupGenesis
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenesis
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/devgas/v1/types/genesis_test.go b/x/devgas/v1/types/genesis_test.go
deleted file mode 100644
index a6297b1b1..000000000
--- a/x/devgas/v1/types/genesis_test.go
+++ /dev/null
@@ -1,138 +0,0 @@
-package types
-
-import (
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-type GenesisTestSuite struct {
- suite.Suite
- address1 string
- address2 string
- contractA string
- contractB string
-}
-
-func TestGenesisTestSuite(t *testing.T) {
- suite.Run(t, new(GenesisTestSuite))
-}
-
-func (suite *GenesisTestSuite) SetupTest() {
- suite.address1 = sdk.AccAddress([]byte("cosmos1")).String()
- suite.address2 = sdk.AccAddress([]byte("cosmos2")).String()
-
- suite.contractA = "cosmos15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hesh45zsv"
- suite.contractB = "cosmos168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8skhnwe8"
-}
-
-func (suite *GenesisTestSuite) TestValidateGenesis() {
- newGen := NewGenesisState(DefaultParams(), []FeeShare{})
- testCases := []struct {
- name string
- genState *GenesisState
- expPass bool
- }{
- {
- name: "valid genesis constructor",
- genState: &newGen,
- expPass: true,
- },
- {
- name: "default",
- genState: DefaultGenesisState(),
- expPass: true,
- },
- {
- name: "valid genesis",
- genState: &GenesisState{
- Params: DefaultParams(),
- FeeShare: []FeeShare{},
- },
- expPass: true,
- },
- {
- name: "valid genesis - with fee",
- genState: &GenesisState{
- Params: DefaultParams(),
- FeeShare: []FeeShare{
- {
- ContractAddress: suite.contractA,
- DeployerAddress: suite.address1,
- WithdrawerAddress: suite.address1,
- },
- {
- ContractAddress: suite.contractB,
- DeployerAddress: suite.address2,
- WithdrawerAddress: suite.address2,
- },
- },
- },
- expPass: true,
- },
- {
- name: "empty genesis",
- genState: &GenesisState{},
- expPass: false,
- },
- {
- name: "invalid genesis - duplicated fee",
- genState: &GenesisState{
- Params: DefaultParams(),
- FeeShare: []FeeShare{
- {
- ContractAddress: suite.contractA,
- DeployerAddress: suite.address1,
- },
- {
- ContractAddress: suite.contractA,
- DeployerAddress: suite.address1,
- },
- },
- },
- expPass: false,
- },
- {
- name: "invalid genesis - duplicated fee with different deployer address",
- genState: &GenesisState{
- Params: DefaultParams(),
- FeeShare: []FeeShare{
- {
- ContractAddress: suite.contractA,
- DeployerAddress: suite.address1,
- },
- {
- ContractAddress: suite.contractA,
- DeployerAddress: suite.address2,
- },
- },
- },
- expPass: false,
- },
- {
- name: "invalid genesis - invalid withdrawer address",
- genState: &GenesisState{
- Params: DefaultParams(),
- FeeShare: []FeeShare{
- {
- ContractAddress: suite.contractA,
- DeployerAddress: suite.address1,
- WithdrawerAddress: "withdraw",
- },
- },
- },
- expPass: false,
- },
- }
-
- for _, tc := range testCases {
- err := tc.genState.Validate()
- if tc.expPass {
- suite.Require().NoError(err, tc.name)
- } else {
- suite.Require().Error(err, tc.name)
- }
- }
-}
diff --git a/x/devgas/v1/types/keys.go b/x/devgas/v1/types/keys.go
deleted file mode 100644
index 43ee7ee70..000000000
--- a/x/devgas/v1/types/keys.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package types
-
-import (
- "github.com/NibiruChain/collections"
-)
-
-// constants
-const (
- // module name
- ModuleName = "devgas"
-
- // StoreKey to be used when creating the KVStore
- StoreKey = ModuleName
-
- // RouterKey to be used for message routing
- RouterKey = ModuleName
-)
-
-// KVStore key and mutli-index prefixes
-// prefix bytes for the fees persistent store
-const (
- KeyPrefixFeeShare collections.Namespace = iota + 1
- KeyPrefixDeployer
- KeyPrefixWithdrawer
- KeyPrefixParams
-)
diff --git a/x/devgas/v1/types/msg.go b/x/devgas/v1/types/msg.go
deleted file mode 100644
index ab2da1005..000000000
--- a/x/devgas/v1/types/msg.go
+++ /dev/null
@@ -1,183 +0,0 @@
-package types
-
-import (
- errorsmod "cosmossdk.io/errors"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-var (
- _ sdk.Msg = &MsgRegisterFeeShare{}
- _ sdk.Msg = &MsgCancelFeeShare{}
- _ sdk.Msg = &MsgUpdateFeeShare{}
-)
-
-const (
- TypeMsgRegisterFeeShare = "register_feeshare"
- TypeMsgCancelFeeShare = "cancel_feeshare"
- TypeMsgUpdateFeeShare = "update_feeshare"
-)
-
-// NewMsgRegisterFeeShare creates new instance of MsgRegisterFeeShare
-func NewMsgRegisterFeeShare(
- contract sdk.Address,
- deployer,
- withdrawer sdk.AccAddress,
-) *MsgRegisterFeeShare {
- withdrawerAddress := ""
- if withdrawer != nil {
- withdrawerAddress = withdrawer.String()
- }
-
- return &MsgRegisterFeeShare{
- ContractAddress: contract.String(),
- DeployerAddress: deployer.String(),
- WithdrawerAddress: withdrawerAddress,
- }
-}
-
-// Route returns the name of the module
-func (msg MsgRegisterFeeShare) Route() string { return RouterKey }
-
-// Type returns the the action
-func (msg MsgRegisterFeeShare) Type() string { return TypeMsgRegisterFeeShare }
-
-// ValidateBasic runs stateless checks on the message
-func (msg MsgRegisterFeeShare) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(msg.DeployerAddress); err != nil {
- return errorsmod.Wrapf(err, "invalid deployer address %s", msg.DeployerAddress)
- }
-
- if _, err := sdk.AccAddressFromBech32(msg.ContractAddress); err != nil {
- return errorsmod.Wrapf(err, "invalid contract address %s", msg.ContractAddress)
- }
-
- if msg.WithdrawerAddress != "" {
- if _, err := sdk.AccAddressFromBech32(msg.WithdrawerAddress); err != nil {
- return errorsmod.Wrapf(err, "invalid withdraw address %s", msg.WithdrawerAddress)
- }
- }
-
- return nil
-}
-
-// GetSignBytes encodes the message for signing
-func (msg *MsgRegisterFeeShare) GetSignBytes() []byte {
- return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(msg))
-}
-
-// GetSigners defines whose signature is required
-func (msg MsgRegisterFeeShare) GetSigners() []sdk.AccAddress {
- from, _ := sdk.AccAddressFromBech32(msg.DeployerAddress)
- return []sdk.AccAddress{from}
-}
-
-// NewMsgCancelFeeShare creates new instance of MsgCancelFeeShare.
-func NewMsgCancelFeeShare(
- contract sdk.Address,
- deployer sdk.AccAddress,
-) *MsgCancelFeeShare {
- return &MsgCancelFeeShare{
- ContractAddress: contract.String(),
- DeployerAddress: deployer.String(),
- }
-}
-
-// Route returns the message route for a MsgCancelFeeShare.
-func (msg MsgCancelFeeShare) Route() string { return RouterKey }
-
-// Type returns the message type for a MsgCancelFeeShare.
-func (msg MsgCancelFeeShare) Type() string { return TypeMsgCancelFeeShare }
-
-// ValidateBasic runs stateless checks on the message
-func (msg MsgCancelFeeShare) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(msg.DeployerAddress); err != nil {
- return errorsmod.Wrapf(err, "invalid deployer address %s", msg.DeployerAddress)
- }
-
- if _, err := sdk.AccAddressFromBech32(msg.ContractAddress); err != nil {
- return errorsmod.Wrapf(err, "invalid deployer address %s", msg.DeployerAddress)
- }
-
- return nil
-}
-
-// GetSignBytes encodes the message for signing
-func (msg *MsgCancelFeeShare) GetSignBytes() []byte {
- return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(msg))
-}
-
-// GetSigners defines whose signature is required
-func (msg MsgCancelFeeShare) GetSigners() []sdk.AccAddress {
- funder, _ := sdk.AccAddressFromBech32(msg.DeployerAddress)
- return []sdk.AccAddress{funder}
-}
-
-// NewMsgUpdateFeeShare creates new instance of MsgUpdateFeeShare
-func NewMsgUpdateFeeShare(
- contract sdk.Address,
- deployer,
- withdraw sdk.AccAddress,
-) *MsgUpdateFeeShare {
- return &MsgUpdateFeeShare{
- ContractAddress: contract.String(),
- DeployerAddress: deployer.String(),
- WithdrawerAddress: withdraw.String(),
- }
-}
-
-// Route returns the name of the module
-func (msg MsgUpdateFeeShare) Route() string { return RouterKey }
-
-// Type returns the the action
-func (msg MsgUpdateFeeShare) Type() string { return TypeMsgUpdateFeeShare }
-
-// ValidateBasic runs stateless checks on the message
-func (msg MsgUpdateFeeShare) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(msg.DeployerAddress); err != nil {
- return errorsmod.Wrapf(err, "invalid deployer address %s", msg.DeployerAddress)
- }
-
- if _, err := sdk.AccAddressFromBech32(msg.ContractAddress); err != nil {
- return errorsmod.Wrapf(err, "invalid contract address %s", msg.ContractAddress)
- }
-
- if _, err := sdk.AccAddressFromBech32(msg.WithdrawerAddress); err != nil {
- return errorsmod.Wrapf(err, "invalid withdraw address %s", msg.WithdrawerAddress)
- }
-
- return nil
-}
-
-// GetSignBytes encodes the message for signing
-func (msg *MsgUpdateFeeShare) GetSignBytes() []byte {
- return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(msg))
-}
-
-// GetSigners defines whose signature is required
-func (msg MsgUpdateFeeShare) GetSigners() []sdk.AccAddress {
- from, _ := sdk.AccAddressFromBech32(msg.DeployerAddress)
- return []sdk.AccAddress{from}
-}
-
-var _ sdk.Msg = &MsgUpdateParams{}
-
-// GetSignBytes implements the LegacyMsg interface.
-func (m MsgUpdateParams) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
-
-// GetSigners returns the expected signers for a MsgUpdateParams message.
-func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress {
- addr, _ := sdk.AccAddressFromBech32(m.Authority)
- return []sdk.AccAddress{addr}
-}
-
-// ValidateBasic does a sanity check on the provided data.
-func (m *MsgUpdateParams) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
- return errorsmod.Wrap(err, "invalid authority address")
- }
-
- return m.Params.Validate()
-}
diff --git a/x/devgas/v1/types/msg_test.go b/x/devgas/v1/types/msg_test.go
deleted file mode 100644
index fb41cba0f..000000000
--- a/x/devgas/v1/types/msg_test.go
+++ /dev/null
@@ -1,283 +0,0 @@
-package types
-
-import (
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-type MsgsTestSuite struct {
- suite.Suite
- contract sdk.AccAddress
- deployer sdk.AccAddress
- deployerStr string
- withdrawerStr string
-}
-
-func TestMsgsTestSuite(t *testing.T) {
- suite.Run(t, new(MsgsTestSuite))
-}
-
-func (suite *MsgsTestSuite) SetupTest() {
- deployer := "cosmos1"
- withdraw := "cosmos2"
- suite.contract = sdk.AccAddress([]byte("nibi15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g"))
- suite.deployer = sdk.AccAddress([]byte(deployer))
- suite.deployerStr = suite.deployer.String()
- suite.withdrawerStr = sdk.AccAddress([]byte(withdraw)).String()
-}
-
-func (suite *MsgsTestSuite) TestMsgRegisterFeeShareGetters() {
- msgInvalid := MsgRegisterFeeShare{}
- msg := NewMsgRegisterFeeShare(
- suite.contract,
- suite.deployer,
- suite.deployer,
- )
- suite.Require().Equal(RouterKey, msg.Route())
- suite.Require().Equal(TypeMsgRegisterFeeShare, msg.Type())
- suite.Require().NotNil(msgInvalid.GetSignBytes())
- suite.Require().NotNil(msg.GetSigners())
-}
-
-func (suite *MsgsTestSuite) TestMsgRegisterFeeShareNew() {
- testCases := []struct {
- msg string
- contract string
- deployer string
- withdraw string
- expectPass bool
- }{
- {
- "pass",
- suite.contract.String(),
- suite.deployerStr,
- suite.withdrawerStr,
- true,
- },
- {
- "pass - empty withdrawer address",
- suite.contract.String(),
- suite.deployerStr,
- "",
- true,
- },
- {
- "pass - same withdrawer and deployer address",
- suite.contract.String(),
- suite.deployerStr,
- suite.deployerStr,
- true,
- },
- {
- "invalid contract address",
- "",
- suite.deployerStr,
- suite.withdrawerStr,
- false,
- },
- {
- "invalid deployer address",
- suite.contract.String(),
- "",
- suite.withdrawerStr,
- false,
- },
- {
- "invalid withdraw address",
- suite.contract.String(),
- suite.deployerStr,
- "withdraw",
- false,
- },
- }
-
- for i, tc := range testCases {
- tx := MsgRegisterFeeShare{
- ContractAddress: tc.contract,
- DeployerAddress: tc.deployer,
- WithdrawerAddress: tc.withdraw,
- }
- err := tx.ValidateBasic()
-
- if tc.expectPass {
- suite.Require().NoError(err, "valid test %d failed: %s", i, tc.msg)
- } else {
- suite.Require().Error(err, "invalid test %d passed: %s", i, tc.msg)
- suite.Require().Contains(err.Error(), tc.msg)
- }
- }
-}
-
-func (suite *MsgsTestSuite) TestMsgCancelFeeShareGetters() {
- msgInvalid := MsgCancelFeeShare{}
- msg := NewMsgCancelFeeShare(
- suite.contract,
- sdk.AccAddress(suite.deployer.Bytes()),
- )
- suite.Require().Equal(RouterKey, msg.Route())
- suite.Require().Equal(TypeMsgCancelFeeShare, msg.Type())
- suite.Require().NotNil(msgInvalid.GetSignBytes())
- suite.Require().NotNil(msg.GetSigners())
-}
-
-func (suite *MsgsTestSuite) TestMsgCancelFeeShareNew() {
- testCases := []struct {
- errMsg string
- contract string
- deployer string
- expectPass bool
- }{
- {
- errMsg: "msg cancel contract fee - pass",
- contract: suite.contract.String(),
- deployer: suite.deployerStr,
- expectPass: true,
- },
- {
- errMsg: "decoding bech32 failed",
- contract: "contract",
- deployer: suite.deployerStr,
- expectPass: false,
- },
- {
- errMsg: "decoding bech32 failed",
- contract: suite.contract.String(),
- deployer: "deployer",
- expectPass: false,
- },
- }
-
- for i, tc := range testCases {
- tx := MsgCancelFeeShare{
- ContractAddress: tc.contract,
- DeployerAddress: tc.deployer,
- }
- err := tx.ValidateBasic()
-
- if tc.expectPass {
- suite.Require().NoError(err, "valid test %d failed: %s, %v", i, tc.errMsg)
- } else {
- suite.Require().Error(err, "invalid test %d passed: %s, %v", i, tc.errMsg)
- suite.Require().Contains(err.Error(), tc.errMsg)
- }
- }
-}
-
-func (suite *MsgsTestSuite) TestMsgUpdateFeeShareGetters() {
- msgInvalid := MsgUpdateFeeShare{}
- msg := NewMsgUpdateFeeShare(
- suite.contract,
- sdk.AccAddress(suite.deployer.Bytes()),
- sdk.AccAddress(suite.deployer.Bytes()),
- )
- suite.Require().Equal(RouterKey, msg.Route())
- suite.Require().Equal(TypeMsgUpdateFeeShare, msg.Type())
- suite.Require().NotNil(msgInvalid.GetSignBytes())
- suite.Require().NotNil(msg.GetSigners())
-}
-
-func (suite *MsgsTestSuite) TestMsgUpdateFeeShareNew() {
- testCases := []struct {
- msg string
- contract string
- deployer string
- withdraw string
- expectPass bool
- }{
- {
- "msg update fee - pass",
- suite.contract.String(),
- suite.deployerStr,
- suite.withdrawerStr,
- true,
- },
- {
- "invalid contract address",
- "",
- suite.deployerStr,
- suite.withdrawerStr,
- false,
- },
- {
- "invalid withdraw address",
- suite.contract.String(),
- suite.deployerStr,
- "withdraw",
- false,
- },
- {
- "change fee withdrawer to deployer - pass",
- suite.contract.String(),
- suite.deployerStr,
- suite.deployerStr,
- true,
- },
- }
-
- for i, tc := range testCases {
- tx := MsgUpdateFeeShare{
- ContractAddress: tc.contract,
- DeployerAddress: tc.deployer,
- WithdrawerAddress: tc.withdraw,
- }
- err := tx.ValidateBasic()
-
- if tc.expectPass {
- suite.Require().NoError(err, "valid test %d failed: %s, %v", i, tc.msg)
- } else {
- suite.Require().Error(err, "invalid test %d passed: %s, %v", i, tc.msg)
- suite.Require().Contains(err.Error(), tc.msg)
- }
- }
-}
-
-func (s *MsgsTestSuite) TestQuery_ValidateBasic() {
- validAddr := s.contract.String()
- invalidAddr := "invalid-addr"
-
- for _, tc := range []struct {
- name string
- test func()
- }{
- {
- name: "query fee share", test: func() {
- queryMsg := &QueryFeeShareRequest{
- ContractAddress: validAddr,
- }
- s.NoError(queryMsg.ValidateBasic())
-
- queryMsg.ContractAddress = invalidAddr
- s.Error(queryMsg.ValidateBasic())
- },
- },
- {
- name: "query fee shares", test: func() {
- queryMsg := &QueryFeeSharesRequest{
- Deployer: validAddr,
- }
- s.NoError(queryMsg.ValidateBasic())
-
- queryMsg.Deployer = invalidAddr
- s.Error(queryMsg.ValidateBasic())
- },
- },
- {
- name: "query fee shares by withdraw", test: func() {
- queryMsg := &QueryFeeSharesByWithdrawerRequest{
- WithdrawerAddress: validAddr,
- }
- s.NoError(queryMsg.ValidateBasic())
-
- queryMsg.WithdrawerAddress = invalidAddr
- s.Error(queryMsg.ValidateBasic())
- },
- },
- } {
- s.T().Run(tc.name, func(t *testing.T) {
- tc.test()
- })
- }
-}
diff --git a/x/devgas/v1/types/params.go b/x/devgas/v1/types/params.go
deleted file mode 100644
index 433aa4d43..000000000
--- a/x/devgas/v1/types/params.go
+++ /dev/null
@@ -1,95 +0,0 @@
-package types
-
-import (
- "fmt"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// NewParams creates a new Params object
-func NewParams(
- enableFeeShare bool,
- developerShares sdk.Dec,
- allowedDenoms []string,
-) ModuleParams {
- return ModuleParams{
- EnableFeeShare: enableFeeShare,
- DeveloperShares: developerShares,
- AllowedDenoms: allowedDenoms,
- }
-}
-
-func DefaultParams() ModuleParams {
- return ModuleParams{
- EnableFeeShare: DefaultEnableFeeShare,
- DeveloperShares: DefaultDeveloperShares,
- AllowedDenoms: DefaultAllowedDenoms,
- }
-}
-
-func validateBool(i interface{}) error {
- _, ok := i.(bool)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
-
- return nil
-}
-
-func validateShares(i interface{}) error {
- v, ok := i.(sdk.Dec)
-
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
-
- if v.IsNil() {
- return fmt.Errorf("invalid parameter: nil")
- }
-
- if v.IsNegative() {
- return fmt.Errorf("value cannot be negative: %T", i)
- }
-
- if v.GT(math.LegacyOneDec()) {
- return fmt.Errorf("value cannot be greater than 1: %T", i)
- }
-
- return nil
-}
-
-func validateArray(i interface{}) error {
- _, ok := i.([]string)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
-
- for _, denom := range i.([]string) {
- if denom == "" {
- return fmt.Errorf("denom cannot be blank")
- }
- }
-
- return nil
-}
-
-func (p ModuleParams) Validate() error {
- if err := validateBool(p.EnableFeeShare); err != nil {
- return err
- }
- if err := validateShares(p.DeveloperShares); err != nil {
- return err
- }
- err := validateArray(p.AllowedDenoms)
- return err
-}
-
-func (p ModuleParams) Sanitize() ModuleParams {
- newP := new(ModuleParams)
- *newP = p
- if len(newP.AllowedDenoms) == 0 {
- newP.AllowedDenoms = DefaultAllowedDenoms
- }
- return *newP
-}
diff --git a/x/devgas/v1/types/params_legacy.go b/x/devgas/v1/types/params_legacy.go
deleted file mode 100644
index 259708e8a..000000000
--- a/x/devgas/v1/types/params_legacy.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package types
-
-// TODO: Remove this and params_legacy_test.go after v0.47.x (v16) upgrade
-
-import (
- "cosmossdk.io/math"
- paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
-)
-
-// Parameter store key
-var (
- DefaultEnableFeeShare = true
- DefaultDeveloperShares = math.LegacyNewDecWithPrec(50, 2) // 50%
- // DefaultAllowedDenoms = []string(nil) // all allowed
- DefaultAllowedDenoms = []string{} // all allowed
-
- ParamStoreKeyEnableFeeShare = []byte("EnableFeeShare")
- ParamStoreKeyDeveloperShares = []byte("DeveloperShares")
- ParamStoreKeyAllowedDenoms = []byte("AllowedDenoms")
-)
-
-// ParamKeyTable returns the parameter key table.
-func ParamKeyTable() paramtypes.KeyTable {
- return paramtypes.NewKeyTable().RegisterParamSet(&ModuleParams{})
-}
-
-// ParamSetPairs returns the parameter set pairs.
-func (p *ModuleParams) ParamSetPairs() paramtypes.ParamSetPairs {
- return paramtypes.ParamSetPairs{
- paramtypes.NewParamSetPair(ParamStoreKeyEnableFeeShare, &p.EnableFeeShare, validateBool),
- paramtypes.NewParamSetPair(ParamStoreKeyDeveloperShares, &p.DeveloperShares, validateShares),
- paramtypes.NewParamSetPair(ParamStoreKeyAllowedDenoms, &p.AllowedDenoms, validateArray),
- }
-}
diff --git a/x/devgas/v1/types/params_legacy_test.go b/x/devgas/v1/types/params_legacy_test.go
deleted file mode 100644
index 6a86405cf..000000000
--- a/x/devgas/v1/types/params_legacy_test.go
+++ /dev/null
@@ -1,117 +0,0 @@
-package types
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- "github.com/stretchr/testify/require"
-
- paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
-)
-
-func TestLegacyParamKeyTable(t *testing.T) {
- require.IsType(t, paramtypes.KeyTable{}, ParamKeyTable())
- require.NotEmpty(t, ParamKeyTable())
-}
-
-func TestLegacyParamSetPairs(t *testing.T) {
- params := DefaultParams()
- require.NotEmpty(t, params.ParamSetPairs())
-}
-
-func TestLegacyParamsValidate(t *testing.T) {
- devShares := math.LegacyNewDecWithPrec(60, 2)
- acceptedDenoms := []string{"unibi"}
-
- testCases := []struct {
- name string
- params ModuleParams
- expError bool
- }{
- {"default", DefaultParams(), false},
- {
- "valid: enabled",
- NewParams(true, devShares, acceptedDenoms),
- false,
- },
- {
- "valid: disabled",
- NewParams(false, devShares, acceptedDenoms),
- false,
- },
- {
- "valid: 100% devs",
- ModuleParams{true, math.LegacyNewDecFromInt(math.NewInt(1)), acceptedDenoms},
- false,
- },
- {
- "empty",
- ModuleParams{},
- true,
- },
- {
- "invalid: share > 1",
- ModuleParams{true, math.LegacyNewDecFromInt(math.NewInt(2)), acceptedDenoms},
- true,
- },
- {
- "invalid: share < 0",
- ModuleParams{true, math.LegacyNewDecFromInt(math.NewInt(-1)), acceptedDenoms},
- true,
- },
- {
- "valid: all denoms allowed",
- ModuleParams{true, math.LegacyNewDecFromInt(math.NewInt(-1)), []string{}},
- true,
- },
- }
- for _, tc := range testCases {
- err := tc.params.Validate()
-
- if tc.expError {
- require.Error(t, err, tc.name)
- } else {
- require.NoError(t, err, tc.name)
- }
- }
-}
-
-func TestLegacyParamsValidateShares(t *testing.T) {
- testCases := []struct {
- name string
- value interface{}
- expError bool
- }{
- {"default", DefaultDeveloperShares, false},
- {"valid", math.LegacyNewDecFromInt(math.NewInt(1)), false},
- {"invalid - wrong type - bool", false, true},
- {"invalid - wrong type - string", "", true},
- {"invalid - wrong type - int64", int64(123), true},
- {"invalid - wrong type - math.Int", math.NewInt(1), true},
- {"invalid - is nil", nil, true},
- {"invalid - is negative", math.LegacyNewDecFromInt(math.NewInt(-1)), true},
- {"invalid - is > 1", math.LegacyNewDecFromInt(math.NewInt(2)), true},
- }
- for _, tc := range testCases {
- err := validateShares(tc.value)
-
- if tc.expError {
- require.Error(t, err, tc.name)
- } else {
- require.NoError(t, err, tc.name)
- }
- }
-}
-
-func TestLegacyParamsValidateBool(t *testing.T) {
- err := validateBool(DefaultEnableFeeShare)
- require.NoError(t, err)
- err = validateBool(true)
- require.NoError(t, err)
- err = validateBool(false)
- require.NoError(t, err)
- err = validateBool("")
- require.Error(t, err)
- err = validateBool(int64(123))
- require.Error(t, err)
-}
diff --git a/x/devgas/v1/types/params_test.go b/x/devgas/v1/types/params_test.go
deleted file mode 100644
index 422eeac98..000000000
--- a/x/devgas/v1/types/params_test.go
+++ /dev/null
@@ -1,116 +0,0 @@
-package types
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- "github.com/stretchr/testify/require"
-)
-
-// func TestParamKeyTable(t *testing.T) {
-// require.IsType(t, paramtypes.KeyTable{}, ParamKeyTable())
-// require.NotEmpty(t, ParamKeyTable())
-// }
-
-func TestDefaultParams(t *testing.T) {
- params := DefaultParams()
- require.NotEmpty(t, params)
-}
-
-func TestParamsValidate(t *testing.T) {
- devShares := math.LegacyNewDecWithPrec(60, 2)
- acceptedDenoms := []string{"unibi"}
-
- testCases := []struct {
- name string
- params ModuleParams
- expError bool
- }{
- {name: "default", params: DefaultParams(), expError: false},
- {name: "default sanitize", params: DefaultParams().Sanitize(), expError: false},
- {
- "valid: enabled",
- NewParams(true, devShares, acceptedDenoms),
- false,
- },
- {
- "valid: disabled",
- NewParams(false, devShares, acceptedDenoms),
- false,
- },
- {
- "valid: 100% devs",
- ModuleParams{true, math.LegacyNewDecFromInt(math.NewInt(1)), acceptedDenoms},
- false,
- },
- {
- "empty",
- ModuleParams{},
- true,
- },
- {
- "invalid: share > 1",
- ModuleParams{true, math.LegacyNewDecFromInt(math.NewInt(2)), acceptedDenoms},
- true,
- },
- {
- "invalid: share < 0",
- ModuleParams{true, math.LegacyNewDecFromInt(math.NewInt(-1)), acceptedDenoms},
- true,
- },
- {
- "valid: all denoms allowed",
- ModuleParams{true, math.LegacyNewDecFromInt(math.NewInt(-1)), []string{}},
- true,
- },
- }
- for _, tc := range testCases {
- err := tc.params.Validate()
-
- if tc.expError {
- require.Error(t, err, tc.name)
- } else {
- require.NoError(t, err, tc.name)
- }
- }
-}
-
-func TestParamsValidateShares(t *testing.T) {
- testCases := []struct {
- name string
- value interface{}
- expError bool
- }{
- {"default", DefaultDeveloperShares, false},
- {"valid", math.LegacyNewDecFromInt(math.NewInt(1)), false},
- {"invalid - wrong type - bool", false, true},
- {"invalid - wrong type - string", "", true},
- {"invalid - wrong type - int64", int64(123), true},
- {"invalid - wrong type - math.Int", math.NewInt(1), true},
- {"invalid - is nil", nil, true},
- {"invalid - is negative", math.LegacyNewDecFromInt(math.NewInt(-1)), true},
- {"invalid - is > 1", math.LegacyNewDecFromInt(math.NewInt(2)), true},
- }
- for _, tc := range testCases {
- err := validateShares(tc.value)
-
- if tc.expError {
- require.Error(t, err, tc.name)
- } else {
- require.NoError(t, err, tc.name)
- }
- }
-}
-
-func TestParamsValidateBool(t *testing.T) {
- err := validateBool(DefaultEnableFeeShare)
- require.NoError(t, err)
- err = validateBool(true)
- require.NoError(t, err)
- err = validateBool(false)
- require.NoError(t, err)
- err = validateBool("")
- require.Error(t, err)
- err = validateBool(int64(123))
- require.Error(t, err)
-}
diff --git a/x/devgas/v1/types/query.go b/x/devgas/v1/types/query.go
deleted file mode 100644
index 928059c53..000000000
--- a/x/devgas/v1/types/query.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package types
-
-import (
- errorsmod "cosmossdk.io/errors"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// ValidateBasic runs stateless checks on the query requests
-func (q QueryFeeShareRequest) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(q.ContractAddress); err != nil {
- return errorsmod.Wrapf(err, "invalid contract address %s", q.ContractAddress)
- }
- return nil
-}
-
-// ValidateBasic runs stateless checks on the query requests
-func (q QueryFeeSharesRequest) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(q.Deployer); err != nil {
- return errorsmod.Wrapf(err, "invalid deployer address %s", q.Deployer)
- }
- return nil
-}
-
-// ValidateBasic runs stateless checks on the query requests
-func (q QueryFeeSharesByWithdrawerRequest) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(q.WithdrawerAddress); err != nil {
- return errorsmod.Wrapf(err, "invalid withdraw address %s", q.WithdrawerAddress)
- }
- return nil
-}
diff --git a/x/devgas/v1/types/query.pb.go b/x/devgas/v1/types/query.pb.go
deleted file mode 100644
index fad0f6db7..000000000
--- a/x/devgas/v1/types/query.pb.go
+++ /dev/null
@@ -1,1731 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/devgas/v1/query.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- _ "github.com/cosmos/cosmos-sdk/types/query"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// QueryFeeSharesRequest is the request type for the Query/FeeShares RPC method.
-type QueryFeeSharesRequest struct {
- // TODO feat(devgas): re-implement the paginated version
- // TODO feat(colletions): add automatic pagination generation
- Deployer string `protobuf:"bytes,1,opt,name=deployer,proto3" json:"deployer,omitempty"`
-}
-
-func (m *QueryFeeSharesRequest) Reset() { *m = QueryFeeSharesRequest{} }
-func (m *QueryFeeSharesRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryFeeSharesRequest) ProtoMessage() {}
-func (*QueryFeeSharesRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_b68d3a02185e7c52, []int{0}
-}
-func (m *QueryFeeSharesRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryFeeSharesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryFeeSharesRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryFeeSharesRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryFeeSharesRequest.Merge(m, src)
-}
-func (m *QueryFeeSharesRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryFeeSharesRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryFeeSharesRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryFeeSharesRequest proto.InternalMessageInfo
-
-func (m *QueryFeeSharesRequest) GetDeployer() string {
- if m != nil {
- return m.Deployer
- }
- return ""
-}
-
-// QueryFeeSharesResponse is the response type for the Query/FeeShares RPC
-// method.
-type QueryFeeSharesResponse struct {
- // FeeShare is the slice of all stored Reveneue for the deployer
- Feeshare []FeeShare `protobuf:"bytes,1,rep,name=feeshare,proto3" json:"feeshare"`
-}
-
-func (m *QueryFeeSharesResponse) Reset() { *m = QueryFeeSharesResponse{} }
-func (m *QueryFeeSharesResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryFeeSharesResponse) ProtoMessage() {}
-func (*QueryFeeSharesResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_b68d3a02185e7c52, []int{1}
-}
-func (m *QueryFeeSharesResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryFeeSharesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryFeeSharesResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryFeeSharesResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryFeeSharesResponse.Merge(m, src)
-}
-func (m *QueryFeeSharesResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryFeeSharesResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryFeeSharesResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryFeeSharesResponse proto.InternalMessageInfo
-
-func (m *QueryFeeSharesResponse) GetFeeshare() []FeeShare {
- if m != nil {
- return m.Feeshare
- }
- return nil
-}
-
-// QueryFeeShareRequest is the request type for the Query/FeeShare RPC method.
-type QueryFeeShareRequest struct {
- // contract_address of a registered contract in bech32 format
- ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
-}
-
-func (m *QueryFeeShareRequest) Reset() { *m = QueryFeeShareRequest{} }
-func (m *QueryFeeShareRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryFeeShareRequest) ProtoMessage() {}
-func (*QueryFeeShareRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_b68d3a02185e7c52, []int{2}
-}
-func (m *QueryFeeShareRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryFeeShareRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryFeeShareRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryFeeShareRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryFeeShareRequest.Merge(m, src)
-}
-func (m *QueryFeeShareRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryFeeShareRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryFeeShareRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryFeeShareRequest proto.InternalMessageInfo
-
-func (m *QueryFeeShareRequest) GetContractAddress() string {
- if m != nil {
- return m.ContractAddress
- }
- return ""
-}
-
-// QueryFeeShareResponse is the response type for the Query/FeeShare RPC method.
-type QueryFeeShareResponse struct {
- // FeeShare is a stored Reveneue for the queried contract
- Feeshare FeeShare `protobuf:"bytes,1,opt,name=feeshare,proto3" json:"feeshare"`
-}
-
-func (m *QueryFeeShareResponse) Reset() { *m = QueryFeeShareResponse{} }
-func (m *QueryFeeShareResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryFeeShareResponse) ProtoMessage() {}
-func (*QueryFeeShareResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_b68d3a02185e7c52, []int{3}
-}
-func (m *QueryFeeShareResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryFeeShareResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryFeeShareResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryFeeShareResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryFeeShareResponse.Merge(m, src)
-}
-func (m *QueryFeeShareResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryFeeShareResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryFeeShareResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryFeeShareResponse proto.InternalMessageInfo
-
-func (m *QueryFeeShareResponse) GetFeeshare() FeeShare {
- if m != nil {
- return m.Feeshare
- }
- return FeeShare{}
-}
-
-// QueryParamsRequest is the request type for the Query/Params RPC method.
-type QueryParamsRequest struct {
-}
-
-func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} }
-func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryParamsRequest) ProtoMessage() {}
-func (*QueryParamsRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_b68d3a02185e7c52, []int{4}
-}
-func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryParamsRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryParamsRequest.Merge(m, src)
-}
-func (m *QueryParamsRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryParamsRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo
-
-// QueryParamsResponse is the response type for the Query/Params RPC method.
-type QueryParamsResponse struct {
- // params is the returned FeeShare parameter
- Params ModuleParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
-}
-
-func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} }
-func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryParamsResponse) ProtoMessage() {}
-func (*QueryParamsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_b68d3a02185e7c52, []int{5}
-}
-func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryParamsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryParamsResponse.Merge(m, src)
-}
-func (m *QueryParamsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryParamsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo
-
-func (m *QueryParamsResponse) GetParams() ModuleParams {
- if m != nil {
- return m.Params
- }
- return ModuleParams{}
-}
-
-// QueryFeeSharesByWithdrawerRequest is the request type for the
-// Query/FeeSharesByWithdrawer RPC method.
-type QueryFeeSharesByWithdrawerRequest struct {
- // withdrawer_address in bech32 format
- WithdrawerAddress string `protobuf:"bytes,1,opt,name=withdrawer_address,json=withdrawerAddress,proto3" json:"withdrawer_address,omitempty"`
-}
-
-func (m *QueryFeeSharesByWithdrawerRequest) Reset() { *m = QueryFeeSharesByWithdrawerRequest{} }
-func (m *QueryFeeSharesByWithdrawerRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryFeeSharesByWithdrawerRequest) ProtoMessage() {}
-func (*QueryFeeSharesByWithdrawerRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_b68d3a02185e7c52, []int{6}
-}
-func (m *QueryFeeSharesByWithdrawerRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryFeeSharesByWithdrawerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryFeeSharesByWithdrawerRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryFeeSharesByWithdrawerRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryFeeSharesByWithdrawerRequest.Merge(m, src)
-}
-func (m *QueryFeeSharesByWithdrawerRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryFeeSharesByWithdrawerRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryFeeSharesByWithdrawerRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryFeeSharesByWithdrawerRequest proto.InternalMessageInfo
-
-func (m *QueryFeeSharesByWithdrawerRequest) GetWithdrawerAddress() string {
- if m != nil {
- return m.WithdrawerAddress
- }
- return ""
-}
-
-// QueryFeeSharesByWithdrawerResponse is the response type for the
-// Query/FeeSharesByWithdrawer RPC method.
-type QueryFeeSharesByWithdrawerResponse struct {
- Feeshare []FeeShare `protobuf:"bytes,1,rep,name=feeshare,proto3" json:"feeshare"`
-}
-
-func (m *QueryFeeSharesByWithdrawerResponse) Reset() { *m = QueryFeeSharesByWithdrawerResponse{} }
-func (m *QueryFeeSharesByWithdrawerResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryFeeSharesByWithdrawerResponse) ProtoMessage() {}
-func (*QueryFeeSharesByWithdrawerResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_b68d3a02185e7c52, []int{7}
-}
-func (m *QueryFeeSharesByWithdrawerResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryFeeSharesByWithdrawerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryFeeSharesByWithdrawerResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryFeeSharesByWithdrawerResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryFeeSharesByWithdrawerResponse.Merge(m, src)
-}
-func (m *QueryFeeSharesByWithdrawerResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryFeeSharesByWithdrawerResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryFeeSharesByWithdrawerResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryFeeSharesByWithdrawerResponse proto.InternalMessageInfo
-
-func (m *QueryFeeSharesByWithdrawerResponse) GetFeeshare() []FeeShare {
- if m != nil {
- return m.Feeshare
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*QueryFeeSharesRequest)(nil), "nibiru.devgas.v1.QueryFeeSharesRequest")
- proto.RegisterType((*QueryFeeSharesResponse)(nil), "nibiru.devgas.v1.QueryFeeSharesResponse")
- proto.RegisterType((*QueryFeeShareRequest)(nil), "nibiru.devgas.v1.QueryFeeShareRequest")
- proto.RegisterType((*QueryFeeShareResponse)(nil), "nibiru.devgas.v1.QueryFeeShareResponse")
- proto.RegisterType((*QueryParamsRequest)(nil), "nibiru.devgas.v1.QueryParamsRequest")
- proto.RegisterType((*QueryParamsResponse)(nil), "nibiru.devgas.v1.QueryParamsResponse")
- proto.RegisterType((*QueryFeeSharesByWithdrawerRequest)(nil), "nibiru.devgas.v1.QueryFeeSharesByWithdrawerRequest")
- proto.RegisterType((*QueryFeeSharesByWithdrawerResponse)(nil), "nibiru.devgas.v1.QueryFeeSharesByWithdrawerResponse")
-}
-
-func init() { proto.RegisterFile("nibiru/devgas/v1/query.proto", fileDescriptor_b68d3a02185e7c52) }
-
-var fileDescriptor_b68d3a02185e7c52 = []byte{
- // 567 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x4f, 0x8b, 0xd3, 0x5c,
- 0x14, 0xc6, 0x9b, 0xf7, 0x1d, 0x4b, 0xe7, 0xba, 0x70, 0xbc, 0x76, 0xa4, 0x84, 0x31, 0xd6, 0xa0,
- 0xb6, 0x23, 0x98, 0x4b, 0xa6, 0x82, 0x08, 0x6e, 0xa6, 0x82, 0xe0, 0x42, 0xd1, 0x0e, 0x2a, 0xb8,
- 0x19, 0x6e, 0x9a, 0x33, 0x69, 0xa0, 0xcd, 0xcd, 0xe4, 0xa6, 0xad, 0x45, 0xba, 0xf1, 0x0b, 0x28,
- 0xe8, 0xd7, 0x71, 0x3f, 0xcb, 0x01, 0x37, 0xae, 0x44, 0x5a, 0x37, 0x7e, 0x0b, 0xe9, 0xfd, 0x53,
- 0x6d, 0xd3, 0x69, 0x18, 0x70, 0x97, 0x9e, 0x73, 0x9e, 0xf3, 0xfc, 0x7a, 0xf2, 0xb4, 0x68, 0x27,
- 0x0a, 0xbd, 0x30, 0xe9, 0x13, 0x1f, 0x06, 0x01, 0xe5, 0x64, 0xe0, 0x92, 0xe3, 0x3e, 0x24, 0x23,
- 0x27, 0x4e, 0x58, 0xca, 0xf0, 0x96, 0xec, 0x3a, 0xb2, 0xeb, 0x0c, 0x5c, 0xf3, 0x4e, 0x9b, 0xf1,
- 0x1e, 0xe3, 0xc4, 0xa3, 0x1c, 0xe4, 0x28, 0x19, 0xb8, 0x1e, 0xa4, 0xd4, 0x25, 0x31, 0x0d, 0xc2,
- 0x88, 0xa6, 0x21, 0x8b, 0xa4, 0xda, 0xb4, 0x32, 0xbb, 0x03, 0x88, 0x80, 0x87, 0x5c, 0xf5, 0xaf,
- 0x65, 0xfa, 0xca, 0x47, 0xb6, 0xcb, 0x01, 0x0b, 0x98, 0x78, 0x24, 0xb3, 0x27, 0x55, 0xdd, 0x09,
- 0x18, 0x0b, 0xba, 0x40, 0x68, 0x1c, 0x12, 0x1a, 0x45, 0x2c, 0x15, 0x8e, 0x4a, 0x63, 0x37, 0xd0,
- 0xf6, 0x8b, 0x19, 0xd4, 0x63, 0x80, 0x83, 0x0e, 0x4d, 0x80, 0xb7, 0xe0, 0xb8, 0x0f, 0x3c, 0xc5,
- 0x26, 0x2a, 0xf9, 0x10, 0x77, 0xd9, 0x08, 0x92, 0x8a, 0x51, 0x35, 0xea, 0x9b, 0xad, 0xf9, 0x67,
- 0xfb, 0x15, 0xba, 0xba, 0x2c, 0xe2, 0x31, 0x8b, 0x38, 0xe0, 0x87, 0xa8, 0x74, 0x04, 0xc0, 0x67,
- 0xc5, 0x8a, 0x51, 0xfd, 0xbf, 0x7e, 0x71, 0xcf, 0x74, 0x96, 0x4f, 0xe2, 0x68, 0x59, 0x73, 0xe3,
- 0xe4, 0xfb, 0xf5, 0x42, 0x6b, 0xae, 0xb0, 0xf7, 0x51, 0x79, 0x61, 0xaf, 0x66, 0xd9, 0x45, 0x5b,
- 0x6d, 0x16, 0xa5, 0x09, 0x6d, 0xa7, 0x87, 0xd4, 0xf7, 0x13, 0xe0, 0x5c, 0x31, 0x5d, 0xd2, 0xf5,
- 0x7d, 0x59, 0xb6, 0x5f, 0x2e, 0x7d, 0x9f, 0x33, 0xc8, 0x8c, 0x73, 0x92, 0x95, 0x11, 0x16, 0x6b,
- 0x9f, 0xd3, 0x84, 0xf6, 0xf4, 0x8d, 0xec, 0x03, 0x74, 0x65, 0xa1, 0x3a, 0xb7, 0x2a, 0xc6, 0xa2,
- 0xa2, 0x8c, 0xac, 0xac, 0xd1, 0x53, 0xe6, 0xf7, 0xbb, 0x20, 0x75, 0xca, 0x4c, 0x69, 0xec, 0x16,
- 0xba, 0xb1, 0x78, 0xdc, 0xe6, 0xe8, 0x75, 0x98, 0x76, 0xfc, 0x84, 0x0e, 0x21, 0xd1, 0x17, 0xb9,
- 0x8b, 0xf0, 0x70, 0x5e, 0x5c, 0xba, 0xc9, 0xe5, 0x3f, 0x1d, 0x7d, 0x15, 0x0f, 0xd9, 0xeb, 0x76,
- 0xfe, 0x8b, 0x97, 0xb7, 0xf7, 0x6b, 0x03, 0x5d, 0x10, 0x26, 0xf8, 0x83, 0x81, 0x36, 0xe7, 0x4e,
- 0xb8, 0x96, 0xdd, 0xb1, 0x32, 0x71, 0x66, 0x3d, 0x7f, 0x50, 0x82, 0xda, 0xe4, 0xfd, 0xd7, 0x9f,
- 0x9f, 0xfe, 0xdb, 0xc5, 0x35, 0x92, 0xf9, 0x41, 0x1c, 0x01, 0x1c, 0x0a, 0x1e, 0x4e, 0xde, 0xe9,
- 0xbc, 0x8e, 0xf1, 0x67, 0x03, 0x95, 0xf4, 0x1a, 0x7c, 0x3b, 0xc7, 0x47, 0xf3, 0xd4, 0x72, 0xe7,
- 0x14, 0xce, 0x7d, 0x81, 0xe3, 0x62, 0xb2, 0x1e, 0x67, 0x39, 0xc2, 0x63, 0x3c, 0x44, 0x45, 0x19,
- 0x01, 0x7c, 0xf3, 0x0c, 0xaf, 0x85, 0xbc, 0x99, 0xb7, 0x72, 0xa6, 0x14, 0x4f, 0x55, 0xf0, 0x98,
- 0xb8, 0x92, 0xe5, 0x91, 0x19, 0xc3, 0x5f, 0x0c, 0xb4, 0xbd, 0x32, 0x0b, 0xb8, 0x91, 0xf7, 0x12,
- 0x56, 0xa4, 0xd1, 0xbc, 0x77, 0x3e, 0x91, 0xc2, 0x7c, 0x20, 0x30, 0x1b, 0xd8, 0x5d, 0x7f, 0xb6,
- 0x6c, 0xce, 0xc7, 0xcd, 0x27, 0x27, 0x13, 0xcb, 0x38, 0x9d, 0x58, 0xc6, 0x8f, 0x89, 0x65, 0x7c,
- 0x9c, 0x5a, 0x85, 0xd3, 0xa9, 0x55, 0xf8, 0x36, 0xb5, 0x0a, 0x6f, 0x48, 0x10, 0xa6, 0x9d, 0xbe,
- 0xe7, 0xb4, 0x59, 0x8f, 0x3c, 0x13, 0x6b, 0x1f, 0x75, 0x68, 0x18, 0x69, 0x8b, 0xb7, 0x7f, 0x99,
- 0xa4, 0xa3, 0x18, 0xb8, 0x57, 0x14, 0xff, 0x83, 0x8d, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x72,
- 0x1e, 0xa0, 0x89, 0xd8, 0x05, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// QueryClient is the client API for Query service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type QueryClient interface {
- // FeeShares retrieves all FeeShares that a deployer has
- // registered
- FeeShares(ctx context.Context, in *QueryFeeSharesRequest, opts ...grpc.CallOption) (*QueryFeeSharesResponse, error)
- // FeeShare retrieves a registered FeeShare for a given contract address
- FeeShare(ctx context.Context, in *QueryFeeShareRequest, opts ...grpc.CallOption) (*QueryFeeShareResponse, error)
- // Params retrieves the module params
- Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
- // FeeSharesByWithdrawer retrieves all FeeShares with a given withdrawer
- // address
- FeeSharesByWithdrawer(ctx context.Context, in *QueryFeeSharesByWithdrawerRequest, opts ...grpc.CallOption) (*QueryFeeSharesByWithdrawerResponse, error)
-}
-
-type queryClient struct {
- cc grpc1.ClientConn
-}
-
-func NewQueryClient(cc grpc1.ClientConn) QueryClient {
- return &queryClient{cc}
-}
-
-func (c *queryClient) FeeShares(ctx context.Context, in *QueryFeeSharesRequest, opts ...grpc.CallOption) (*QueryFeeSharesResponse, error) {
- out := new(QueryFeeSharesResponse)
- err := c.cc.Invoke(ctx, "/nibiru.devgas.v1.Query/FeeShares", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) FeeShare(ctx context.Context, in *QueryFeeShareRequest, opts ...grpc.CallOption) (*QueryFeeShareResponse, error) {
- out := new(QueryFeeShareResponse)
- err := c.cc.Invoke(ctx, "/nibiru.devgas.v1.Query/FeeShare", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) {
- out := new(QueryParamsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.devgas.v1.Query/Params", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) FeeSharesByWithdrawer(ctx context.Context, in *QueryFeeSharesByWithdrawerRequest, opts ...grpc.CallOption) (*QueryFeeSharesByWithdrawerResponse, error) {
- out := new(QueryFeeSharesByWithdrawerResponse)
- err := c.cc.Invoke(ctx, "/nibiru.devgas.v1.Query/FeeSharesByWithdrawer", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// QueryServer is the server API for Query service.
-type QueryServer interface {
- // FeeShares retrieves all FeeShares that a deployer has
- // registered
- FeeShares(context.Context, *QueryFeeSharesRequest) (*QueryFeeSharesResponse, error)
- // FeeShare retrieves a registered FeeShare for a given contract address
- FeeShare(context.Context, *QueryFeeShareRequest) (*QueryFeeShareResponse, error)
- // Params retrieves the module params
- Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
- // FeeSharesByWithdrawer retrieves all FeeShares with a given withdrawer
- // address
- FeeSharesByWithdrawer(context.Context, *QueryFeeSharesByWithdrawerRequest) (*QueryFeeSharesByWithdrawerResponse, error)
-}
-
-// UnimplementedQueryServer can be embedded to have forward compatible implementations.
-type UnimplementedQueryServer struct {
-}
-
-func (*UnimplementedQueryServer) FeeShares(ctx context.Context, req *QueryFeeSharesRequest) (*QueryFeeSharesResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method FeeShares not implemented")
-}
-func (*UnimplementedQueryServer) FeeShare(ctx context.Context, req *QueryFeeShareRequest) (*QueryFeeShareResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method FeeShare not implemented")
-}
-func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
-}
-func (*UnimplementedQueryServer) FeeSharesByWithdrawer(ctx context.Context, req *QueryFeeSharesByWithdrawerRequest) (*QueryFeeSharesByWithdrawerResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method FeeSharesByWithdrawer not implemented")
-}
-
-func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
- s.RegisterService(&_Query_serviceDesc, srv)
-}
-
-func _Query_FeeShares_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryFeeSharesRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).FeeShares(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.devgas.v1.Query/FeeShares",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).FeeShares(ctx, req.(*QueryFeeSharesRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_FeeShare_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryFeeShareRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).FeeShare(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.devgas.v1.Query/FeeShare",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).FeeShare(ctx, req.(*QueryFeeShareRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryParamsRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Params(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.devgas.v1.Query/Params",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_FeeSharesByWithdrawer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryFeeSharesByWithdrawerRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).FeeSharesByWithdrawer(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.devgas.v1.Query/FeeSharesByWithdrawer",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).FeeSharesByWithdrawer(ctx, req.(*QueryFeeSharesByWithdrawerRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Query_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.devgas.v1.Query",
- HandlerType: (*QueryServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "FeeShares",
- Handler: _Query_FeeShares_Handler,
- },
- {
- MethodName: "FeeShare",
- Handler: _Query_FeeShare_Handler,
- },
- {
- MethodName: "Params",
- Handler: _Query_Params_Handler,
- },
- {
- MethodName: "FeeSharesByWithdrawer",
- Handler: _Query_FeeSharesByWithdrawer_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/devgas/v1/query.proto",
-}
-
-func (m *QueryFeeSharesRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryFeeSharesRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryFeeSharesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Deployer) > 0 {
- i -= len(m.Deployer)
- copy(dAtA[i:], m.Deployer)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Deployer)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryFeeSharesResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryFeeSharesResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryFeeSharesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Feeshare) > 0 {
- for iNdEx := len(m.Feeshare) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Feeshare[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryFeeShareRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryFeeShareRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryFeeShareRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.ContractAddress) > 0 {
- i -= len(m.ContractAddress)
- copy(dAtA[i:], m.ContractAddress)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.ContractAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryFeeShareResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryFeeShareResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryFeeShareResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Feeshare.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *QueryFeeSharesByWithdrawerRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryFeeSharesByWithdrawerRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryFeeSharesByWithdrawerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.WithdrawerAddress) > 0 {
- i -= len(m.WithdrawerAddress)
- copy(dAtA[i:], m.WithdrawerAddress)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.WithdrawerAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryFeeSharesByWithdrawerResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryFeeSharesByWithdrawerResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryFeeSharesByWithdrawerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Feeshare) > 0 {
- for iNdEx := len(m.Feeshare) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Feeshare[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
- offset -= sovQuery(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *QueryFeeSharesRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Deployer)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryFeeSharesResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Feeshare) > 0 {
- for _, e := range m.Feeshare {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- return n
-}
-
-func (m *QueryFeeShareRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ContractAddress)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryFeeShareResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Feeshare.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *QueryParamsRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryParamsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Params.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *QueryFeeSharesByWithdrawerRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.WithdrawerAddress)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryFeeSharesByWithdrawerResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Feeshare) > 0 {
- for _, e := range m.Feeshare {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- return n
-}
-
-func sovQuery(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozQuery(x uint64) (n int) {
- return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *QueryFeeSharesRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryFeeSharesRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryFeeSharesRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Deployer", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Deployer = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryFeeSharesResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryFeeSharesResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryFeeSharesResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Feeshare", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Feeshare = append(m.Feeshare, FeeShare{})
- if err := m.Feeshare[len(m.Feeshare)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryFeeShareRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryFeeShareRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryFeeShareRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ContractAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryFeeShareResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryFeeShareResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryFeeShareResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Feeshare", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Feeshare.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryFeeSharesByWithdrawerRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryFeeSharesByWithdrawerRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryFeeSharesByWithdrawerRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field WithdrawerAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.WithdrawerAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryFeeSharesByWithdrawerResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryFeeSharesByWithdrawerResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryFeeSharesByWithdrawerResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Feeshare", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Feeshare = append(m.Feeshare, FeeShare{})
- if err := m.Feeshare[len(m.Feeshare)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipQuery(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthQuery
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupQuery
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthQuery
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/devgas/v1/types/query.pb.gw.go b/x/devgas/v1/types/query.pb.gw.go
deleted file mode 100644
index 0f2930e04..000000000
--- a/x/devgas/v1/types/query.pb.gw.go
+++ /dev/null
@@ -1,456 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: nibiru/devgas/v1/query.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-func request_Query_FeeShares_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryFeeSharesRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["deployer"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "deployer")
- }
-
- protoReq.Deployer, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "deployer", err)
- }
-
- msg, err := client.FeeShares(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_FeeShares_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryFeeSharesRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["deployer"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "deployer")
- }
-
- protoReq.Deployer, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "deployer", err)
- }
-
- msg, err := server.FeeShares(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_FeeShare_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryFeeShareRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["contract_address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "contract_address")
- }
-
- protoReq.ContractAddress, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "contract_address", err)
- }
-
- msg, err := client.FeeShare(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_FeeShare_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryFeeShareRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["contract_address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "contract_address")
- }
-
- protoReq.ContractAddress, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "contract_address", err)
- }
-
- msg, err := server.FeeShare(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryParamsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryParamsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.Params(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_FeeSharesByWithdrawer_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryFeeSharesByWithdrawerRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["withdrawer_address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "withdrawer_address")
- }
-
- protoReq.WithdrawerAddress, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "withdrawer_address", err)
- }
-
- msg, err := client.FeeSharesByWithdrawer(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_FeeSharesByWithdrawer_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryFeeSharesByWithdrawerRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["withdrawer_address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "withdrawer_address")
- }
-
- protoReq.WithdrawerAddress, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "withdrawer_address", err)
- }
-
- msg, err := server.FeeSharesByWithdrawer(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
-// UnaryRPC :call QueryServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
-func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
-
- mux.Handle("GET", pattern_Query_FeeShares_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_FeeShares_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_FeeShares_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_FeeShare_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_FeeShare_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_FeeShare_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_FeeSharesByWithdrawer_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_FeeSharesByWithdrawer_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_FeeSharesByWithdrawer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterQueryHandler(ctx, mux, conn)
-}
-
-// RegisterQueryHandler registers the http handlers for service Query to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
-}
-
-// RegisterQueryHandlerClient registers the http handlers for service Query
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "QueryClient" to call the correct interceptors.
-func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
-
- mux.Handle("GET", pattern_Query_FeeShares_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_FeeShares_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_FeeShares_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_FeeShare_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_FeeShare_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_FeeShare_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_FeeSharesByWithdrawer_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_FeeSharesByWithdrawer_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_FeeSharesByWithdrawer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Query_FeeShares_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "devgas", "v1", "fee_shares", "deployer"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_FeeShare_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "devgas", "v1", "fee_shares", "contract_address"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "devgas", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_FeeSharesByWithdrawer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "devgas", "v1", "fee_shares", "withdrawer_address"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Query_FeeShares_0 = runtime.ForwardResponseMessage
-
- forward_Query_FeeShare_0 = runtime.ForwardResponseMessage
-
- forward_Query_Params_0 = runtime.ForwardResponseMessage
-
- forward_Query_FeeSharesByWithdrawer_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/devgas/v1/types/tx.pb.go b/x/devgas/v1/types/tx.pb.go
deleted file mode 100644
index a034bea94..000000000
--- a/x/devgas/v1/types/tx.pb.go
+++ /dev/null
@@ -1,1873 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/devgas/v1/tx.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- _ "github.com/cosmos/cosmos-proto"
- _ "github.com/cosmos/cosmos-sdk/types/msgservice"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// MsgRegisterFeeShare defines a message that registers a FeeShare
-type MsgRegisterFeeShare struct {
- // contract_address in bech32 format
- ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
- // deployer_address is the bech32 address of message sender. It must be the
- // same the contract's admin address
- DeployerAddress string `protobuf:"bytes,2,opt,name=deployer_address,json=deployerAddress,proto3" json:"deployer_address,omitempty"`
- // withdrawer_address is the bech32 address of account receiving the
- // transaction fees
- WithdrawerAddress string `protobuf:"bytes,3,opt,name=withdrawer_address,json=withdrawerAddress,proto3" json:"withdrawer_address,omitempty"`
-}
-
-func (m *MsgRegisterFeeShare) Reset() { *m = MsgRegisterFeeShare{} }
-func (m *MsgRegisterFeeShare) String() string { return proto.CompactTextString(m) }
-func (*MsgRegisterFeeShare) ProtoMessage() {}
-func (*MsgRegisterFeeShare) Descriptor() ([]byte, []int) {
- return fileDescriptor_72949c99a02cd615, []int{0}
-}
-func (m *MsgRegisterFeeShare) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgRegisterFeeShare) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgRegisterFeeShare.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgRegisterFeeShare) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgRegisterFeeShare.Merge(m, src)
-}
-func (m *MsgRegisterFeeShare) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgRegisterFeeShare) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgRegisterFeeShare.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgRegisterFeeShare proto.InternalMessageInfo
-
-func (m *MsgRegisterFeeShare) GetContractAddress() string {
- if m != nil {
- return m.ContractAddress
- }
- return ""
-}
-
-func (m *MsgRegisterFeeShare) GetDeployerAddress() string {
- if m != nil {
- return m.DeployerAddress
- }
- return ""
-}
-
-func (m *MsgRegisterFeeShare) GetWithdrawerAddress() string {
- if m != nil {
- return m.WithdrawerAddress
- }
- return ""
-}
-
-// MsgRegisterFeeShareResponse defines the MsgRegisterFeeShare response type
-type MsgRegisterFeeShareResponse struct {
-}
-
-func (m *MsgRegisterFeeShareResponse) Reset() { *m = MsgRegisterFeeShareResponse{} }
-func (m *MsgRegisterFeeShareResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgRegisterFeeShareResponse) ProtoMessage() {}
-func (*MsgRegisterFeeShareResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_72949c99a02cd615, []int{1}
-}
-func (m *MsgRegisterFeeShareResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgRegisterFeeShareResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgRegisterFeeShareResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgRegisterFeeShareResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgRegisterFeeShareResponse.Merge(m, src)
-}
-func (m *MsgRegisterFeeShareResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgRegisterFeeShareResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgRegisterFeeShareResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgRegisterFeeShareResponse proto.InternalMessageInfo
-
-// MsgUpdateFeeShare defines a message that updates the withdrawer address for a
-// registered FeeShare
-type MsgUpdateFeeShare struct {
- // contract_address in bech32 format
- ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
- // deployer_address is the bech32 address of message sender. It must be the
- // same the contract's admin address
- DeployerAddress string `protobuf:"bytes,2,opt,name=deployer_address,json=deployerAddress,proto3" json:"deployer_address,omitempty"`
- // withdrawer_address is the bech32 address of account receiving the
- // transaction fees
- WithdrawerAddress string `protobuf:"bytes,3,opt,name=withdrawer_address,json=withdrawerAddress,proto3" json:"withdrawer_address,omitempty"`
-}
-
-func (m *MsgUpdateFeeShare) Reset() { *m = MsgUpdateFeeShare{} }
-func (m *MsgUpdateFeeShare) String() string { return proto.CompactTextString(m) }
-func (*MsgUpdateFeeShare) ProtoMessage() {}
-func (*MsgUpdateFeeShare) Descriptor() ([]byte, []int) {
- return fileDescriptor_72949c99a02cd615, []int{2}
-}
-func (m *MsgUpdateFeeShare) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgUpdateFeeShare) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgUpdateFeeShare.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgUpdateFeeShare) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgUpdateFeeShare.Merge(m, src)
-}
-func (m *MsgUpdateFeeShare) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgUpdateFeeShare) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgUpdateFeeShare.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgUpdateFeeShare proto.InternalMessageInfo
-
-func (m *MsgUpdateFeeShare) GetContractAddress() string {
- if m != nil {
- return m.ContractAddress
- }
- return ""
-}
-
-func (m *MsgUpdateFeeShare) GetDeployerAddress() string {
- if m != nil {
- return m.DeployerAddress
- }
- return ""
-}
-
-func (m *MsgUpdateFeeShare) GetWithdrawerAddress() string {
- if m != nil {
- return m.WithdrawerAddress
- }
- return ""
-}
-
-// MsgUpdateFeeShareResponse defines the MsgUpdateFeeShare response type
-type MsgUpdateFeeShareResponse struct {
-}
-
-func (m *MsgUpdateFeeShareResponse) Reset() { *m = MsgUpdateFeeShareResponse{} }
-func (m *MsgUpdateFeeShareResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgUpdateFeeShareResponse) ProtoMessage() {}
-func (*MsgUpdateFeeShareResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_72949c99a02cd615, []int{3}
-}
-func (m *MsgUpdateFeeShareResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgUpdateFeeShareResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgUpdateFeeShareResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgUpdateFeeShareResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgUpdateFeeShareResponse.Merge(m, src)
-}
-func (m *MsgUpdateFeeShareResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgUpdateFeeShareResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgUpdateFeeShareResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgUpdateFeeShareResponse proto.InternalMessageInfo
-
-// MsgCancelFeeShare defines a message that cancels a registered FeeShare
-type MsgCancelFeeShare struct {
- // contract_address in bech32 format
- ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
- // deployer_address is the bech32 address of message sender. It must be the
- // same the contract's admin address
- DeployerAddress string `protobuf:"bytes,2,opt,name=deployer_address,json=deployerAddress,proto3" json:"deployer_address,omitempty"`
-}
-
-func (m *MsgCancelFeeShare) Reset() { *m = MsgCancelFeeShare{} }
-func (m *MsgCancelFeeShare) String() string { return proto.CompactTextString(m) }
-func (*MsgCancelFeeShare) ProtoMessage() {}
-func (*MsgCancelFeeShare) Descriptor() ([]byte, []int) {
- return fileDescriptor_72949c99a02cd615, []int{4}
-}
-func (m *MsgCancelFeeShare) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgCancelFeeShare) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgCancelFeeShare.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgCancelFeeShare) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgCancelFeeShare.Merge(m, src)
-}
-func (m *MsgCancelFeeShare) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgCancelFeeShare) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgCancelFeeShare.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgCancelFeeShare proto.InternalMessageInfo
-
-func (m *MsgCancelFeeShare) GetContractAddress() string {
- if m != nil {
- return m.ContractAddress
- }
- return ""
-}
-
-func (m *MsgCancelFeeShare) GetDeployerAddress() string {
- if m != nil {
- return m.DeployerAddress
- }
- return ""
-}
-
-// MsgCancelFeeShareResponse defines the MsgCancelFeeShare response type
-type MsgCancelFeeShareResponse struct {
-}
-
-func (m *MsgCancelFeeShareResponse) Reset() { *m = MsgCancelFeeShareResponse{} }
-func (m *MsgCancelFeeShareResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgCancelFeeShareResponse) ProtoMessage() {}
-func (*MsgCancelFeeShareResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_72949c99a02cd615, []int{5}
-}
-func (m *MsgCancelFeeShareResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgCancelFeeShareResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgCancelFeeShareResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgCancelFeeShareResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgCancelFeeShareResponse.Merge(m, src)
-}
-func (m *MsgCancelFeeShareResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgCancelFeeShareResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgCancelFeeShareResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgCancelFeeShareResponse proto.InternalMessageInfo
-
-// MsgUpdateParams is the Msg/UpdateParams request type.
-//
-// Since: cosmos-sdk 0.47
-type MsgUpdateParams struct {
- // authority is the address that controls the module (defaults to x/gov unless
- // overwritten).
- Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"`
- // params defines the x/feeshare parameters to update.
- //
- // NOTE: All parameters must be supplied.
- Params ModuleParams `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
-}
-
-func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} }
-func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) }
-func (*MsgUpdateParams) ProtoMessage() {}
-func (*MsgUpdateParams) Descriptor() ([]byte, []int) {
- return fileDescriptor_72949c99a02cd615, []int{6}
-}
-func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgUpdateParams) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgUpdateParams.Merge(m, src)
-}
-func (m *MsgUpdateParams) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgUpdateParams) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo
-
-func (m *MsgUpdateParams) GetAuthority() string {
- if m != nil {
- return m.Authority
- }
- return ""
-}
-
-func (m *MsgUpdateParams) GetParams() ModuleParams {
- if m != nil {
- return m.Params
- }
- return ModuleParams{}
-}
-
-// MsgUpdateParamsResponse defines the response structure for executing a
-// MsgUpdateParams message.
-//
-// Since: cosmos-sdk 0.47
-type MsgUpdateParamsResponse struct {
-}
-
-func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} }
-func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgUpdateParamsResponse) ProtoMessage() {}
-func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_72949c99a02cd615, []int{7}
-}
-func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src)
-}
-func (m *MsgUpdateParamsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*MsgRegisterFeeShare)(nil), "nibiru.devgas.v1.MsgRegisterFeeShare")
- proto.RegisterType((*MsgRegisterFeeShareResponse)(nil), "nibiru.devgas.v1.MsgRegisterFeeShareResponse")
- proto.RegisterType((*MsgUpdateFeeShare)(nil), "nibiru.devgas.v1.MsgUpdateFeeShare")
- proto.RegisterType((*MsgUpdateFeeShareResponse)(nil), "nibiru.devgas.v1.MsgUpdateFeeShareResponse")
- proto.RegisterType((*MsgCancelFeeShare)(nil), "nibiru.devgas.v1.MsgCancelFeeShare")
- proto.RegisterType((*MsgCancelFeeShareResponse)(nil), "nibiru.devgas.v1.MsgCancelFeeShareResponse")
- proto.RegisterType((*MsgUpdateParams)(nil), "nibiru.devgas.v1.MsgUpdateParams")
- proto.RegisterType((*MsgUpdateParamsResponse)(nil), "nibiru.devgas.v1.MsgUpdateParamsResponse")
-}
-
-func init() { proto.RegisterFile("nibiru/devgas/v1/tx.proto", fileDescriptor_72949c99a02cd615) }
-
-var fileDescriptor_72949c99a02cd615 = []byte{
- // 565 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x94, 0x41, 0x6b, 0x13, 0x4d,
- 0x18, 0xc7, 0xb3, 0x6d, 0x28, 0x74, 0xde, 0x97, 0x36, 0x5d, 0x0b, 0x6d, 0x52, 0xdd, 0xea, 0xaa,
- 0xa5, 0x55, 0xb3, 0x43, 0x2b, 0x78, 0x28, 0x5e, 0x4c, 0x41, 0xf0, 0x10, 0x91, 0x14, 0x2f, 0x22,
- 0x84, 0xc9, 0xee, 0x30, 0x19, 0x48, 0x76, 0x96, 0x99, 0xd9, 0xb4, 0xb9, 0xf6, 0x13, 0x14, 0x3c,
- 0xe8, 0x49, 0x7a, 0xf0, 0x03, 0x78, 0xf0, 0x43, 0xf4, 0x58, 0xf4, 0xe2, 0x49, 0x24, 0x11, 0xf4,
- 0x63, 0x48, 0x66, 0x66, 0x37, 0xdd, 0x64, 0x5b, 0x7b, 0x11, 0xbc, 0x25, 0xf3, 0xff, 0x3d, 0xcf,
- 0xf3, 0xdb, 0xe5, 0x99, 0x05, 0xe5, 0x90, 0xb6, 0x28, 0x8f, 0x61, 0x80, 0x7b, 0x04, 0x09, 0xd8,
- 0xdb, 0x86, 0xf2, 0xd0, 0x8b, 0x38, 0x93, 0xcc, 0x2e, 0xe9, 0xc8, 0xd3, 0x91, 0xd7, 0xdb, 0xae,
- 0x2c, 0x13, 0x46, 0x98, 0x0a, 0xe1, 0xe8, 0x97, 0xe6, 0x2a, 0xd7, 0x09, 0x63, 0xa4, 0x83, 0x21,
- 0x8a, 0x28, 0x44, 0x61, 0xc8, 0x24, 0x92, 0x94, 0x85, 0xc2, 0xa4, 0x2b, 0x3e, 0x13, 0x5d, 0x26,
- 0x60, 0x57, 0x90, 0x51, 0xf7, 0xae, 0x20, 0x26, 0x28, 0xeb, 0xa0, 0xa9, 0xfb, 0xe9, 0x3f, 0x26,
- 0x72, 0xa6, 0xa4, 0x08, 0x0e, 0xb1, 0xa0, 0x26, 0x77, 0x4f, 0x2c, 0x70, 0xad, 0x2e, 0x48, 0x03,
- 0x13, 0x2a, 0x24, 0xe6, 0x4f, 0x31, 0xde, 0x6f, 0x23, 0x8e, 0xed, 0x2d, 0x50, 0xf2, 0x59, 0x28,
- 0x39, 0xf2, 0x65, 0x13, 0x05, 0x01, 0xc7, 0x42, 0xac, 0x5a, 0x37, 0xad, 0xcd, 0xf9, 0xc6, 0x62,
- 0x72, 0xfe, 0x44, 0x1f, 0x8f, 0xd0, 0x00, 0x47, 0x1d, 0xd6, 0xc7, 0x3c, 0x45, 0x67, 0x34, 0x9a,
- 0x9c, 0x27, 0x68, 0x15, 0xd8, 0x07, 0x54, 0xb6, 0x03, 0x8e, 0x0e, 0xce, 0xc1, 0xb3, 0x0a, 0x5e,
- 0x1a, 0x27, 0x06, 0xdf, 0x2d, 0xfe, 0x3a, 0x59, 0x2f, 0xb8, 0x37, 0xc0, 0x5a, 0x8e, 0x61, 0x03,
- 0x8b, 0x88, 0x85, 0x02, 0xbb, 0xef, 0x2d, 0xb0, 0x54, 0x17, 0xe4, 0x65, 0x14, 0x20, 0x89, 0xff,
- 0x45, 0xff, 0x35, 0x50, 0x9e, 0xf2, 0x4b, 0xed, 0x99, 0x92, 0xdf, 0x43, 0xa1, 0x8f, 0x3b, 0x7f,
- 0x57, 0x3e, 0x63, 0x93, 0x1d, 0x98, 0xda, 0xbc, 0xb5, 0xc0, 0x62, 0xea, 0xfa, 0x02, 0x71, 0xd4,
- 0x15, 0xf6, 0x23, 0x30, 0x8f, 0x62, 0xd9, 0x66, 0x9c, 0xca, 0xbe, 0xb6, 0xa8, 0xad, 0x7e, 0xfe,
- 0x54, 0x5d, 0x36, 0x6b, 0x66, 0xba, 0xef, 0x4b, 0x4e, 0x43, 0xd2, 0x18, 0xa3, 0xf6, 0x63, 0x30,
- 0x17, 0xa9, 0x0e, 0xca, 0xe7, 0xbf, 0x1d, 0xc7, 0x9b, 0xbc, 0x04, 0x5e, 0x9d, 0x05, 0x71, 0xc7,
- 0xcc, 0xa9, 0x15, 0x4f, 0xbf, 0xad, 0x17, 0x1a, 0xa6, 0x66, 0x77, 0xe1, 0xe8, 0xe7, 0xc7, 0x7b,
- 0xe3, 0x6e, 0x6e, 0x19, 0xac, 0x4c, 0x88, 0x25, 0xd2, 0x3b, 0x1f, 0x8a, 0x60, 0xb6, 0x2e, 0x88,
- 0xfd, 0xce, 0x02, 0xa5, 0xa9, 0x3d, 0xbe, 0x9b, 0x33, 0x75, 0x7a, 0x99, 0x2a, 0xd5, 0x2b, 0x61,
- 0xe9, 0x7b, 0xf2, 0x8e, 0xbe, 0xfc, 0x78, 0x33, 0xb3, 0xe9, 0x6e, 0xc0, 0x9c, 0x3b, 0x0f, 0xb9,
- 0x29, 0x6b, 0xa6, 0x16, 0xc7, 0x16, 0x58, 0x98, 0x58, 0xd0, 0xdb, 0xb9, 0x13, 0xb3, 0x50, 0xe5,
- 0xfe, 0x15, 0xa0, 0x54, 0xea, 0x81, 0x92, 0xda, 0x70, 0xef, 0xe4, 0x4a, 0xc5, 0xaa, 0x28, 0xab,
- 0x34, 0xb1, 0x76, 0xf9, 0x4a, 0x59, 0xe8, 0x02, 0xa5, 0x0b, 0xf6, 0xe9, 0x72, 0x25, 0x5f, 0x15,
- 0x8d, 0x95, 0x5e, 0x83, 0xff, 0x33, 0x9b, 0x77, 0xeb, 0x92, 0xa7, 0xd7, 0x48, 0x65, 0xeb, 0x8f,
- 0x48, 0xe2, 0x52, 0x7b, 0x76, 0x3a, 0x70, 0xac, 0xb3, 0x81, 0x63, 0x7d, 0x1f, 0x38, 0xd6, 0xf1,
- 0xd0, 0x29, 0x9c, 0x0d, 0x9d, 0xc2, 0xd7, 0xa1, 0x53, 0x78, 0x05, 0x09, 0x95, 0xed, 0xb8, 0xe5,
- 0xf9, 0xac, 0x0b, 0x9f, 0xab, 0x76, 0x7b, 0x6d, 0x44, 0xc3, 0xc4, 0xf9, 0xf0, 0xbc, 0x75, 0x3f,
- 0xc2, 0xa2, 0x35, 0xa7, 0xbe, 0x9d, 0x0f, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x2c, 0x24, 0xc1,
- 0x45, 0xf2, 0x05, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// MsgClient is the client API for Msg service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type MsgClient interface {
- // RegisterFeeShare registers a new contract for receiving transaction fees
- RegisterFeeShare(ctx context.Context, in *MsgRegisterFeeShare, opts ...grpc.CallOption) (*MsgRegisterFeeShareResponse, error)
- // UpdateFeeShare updates the withdrawer address of a FeeShare
- UpdateFeeShare(ctx context.Context, in *MsgUpdateFeeShare, opts ...grpc.CallOption) (*MsgUpdateFeeShareResponse, error)
- // CancelFeeShare cancels a contract's fee registration and further receival
- // of transaction fees
- CancelFeeShare(ctx context.Context, in *MsgCancelFeeShare, opts ...grpc.CallOption) (*MsgCancelFeeShareResponse, error)
- // Update the params of the module through gov v1 type.
- UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
-}
-
-type msgClient struct {
- cc grpc1.ClientConn
-}
-
-func NewMsgClient(cc grpc1.ClientConn) MsgClient {
- return &msgClient{cc}
-}
-
-func (c *msgClient) RegisterFeeShare(ctx context.Context, in *MsgRegisterFeeShare, opts ...grpc.CallOption) (*MsgRegisterFeeShareResponse, error) {
- out := new(MsgRegisterFeeShareResponse)
- err := c.cc.Invoke(ctx, "/nibiru.devgas.v1.Msg/RegisterFeeShare", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) UpdateFeeShare(ctx context.Context, in *MsgUpdateFeeShare, opts ...grpc.CallOption) (*MsgUpdateFeeShareResponse, error) {
- out := new(MsgUpdateFeeShareResponse)
- err := c.cc.Invoke(ctx, "/nibiru.devgas.v1.Msg/UpdateFeeShare", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) CancelFeeShare(ctx context.Context, in *MsgCancelFeeShare, opts ...grpc.CallOption) (*MsgCancelFeeShareResponse, error) {
- out := new(MsgCancelFeeShareResponse)
- err := c.cc.Invoke(ctx, "/nibiru.devgas.v1.Msg/CancelFeeShare", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) {
- out := new(MsgUpdateParamsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.devgas.v1.Msg/UpdateParams", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// MsgServer is the server API for Msg service.
-type MsgServer interface {
- // RegisterFeeShare registers a new contract for receiving transaction fees
- RegisterFeeShare(context.Context, *MsgRegisterFeeShare) (*MsgRegisterFeeShareResponse, error)
- // UpdateFeeShare updates the withdrawer address of a FeeShare
- UpdateFeeShare(context.Context, *MsgUpdateFeeShare) (*MsgUpdateFeeShareResponse, error)
- // CancelFeeShare cancels a contract's fee registration and further receival
- // of transaction fees
- CancelFeeShare(context.Context, *MsgCancelFeeShare) (*MsgCancelFeeShareResponse, error)
- // Update the params of the module through gov v1 type.
- UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
-}
-
-// UnimplementedMsgServer can be embedded to have forward compatible implementations.
-type UnimplementedMsgServer struct {
-}
-
-func (*UnimplementedMsgServer) RegisterFeeShare(ctx context.Context, req *MsgRegisterFeeShare) (*MsgRegisterFeeShareResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method RegisterFeeShare not implemented")
-}
-func (*UnimplementedMsgServer) UpdateFeeShare(ctx context.Context, req *MsgUpdateFeeShare) (*MsgUpdateFeeShareResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method UpdateFeeShare not implemented")
-}
-func (*UnimplementedMsgServer) CancelFeeShare(ctx context.Context, req *MsgCancelFeeShare) (*MsgCancelFeeShareResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method CancelFeeShare not implemented")
-}
-func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
-}
-
-func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
- s.RegisterService(&_Msg_serviceDesc, srv)
-}
-
-func _Msg_RegisterFeeShare_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgRegisterFeeShare)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).RegisterFeeShare(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.devgas.v1.Msg/RegisterFeeShare",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).RegisterFeeShare(ctx, req.(*MsgRegisterFeeShare))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_UpdateFeeShare_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgUpdateFeeShare)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).UpdateFeeShare(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.devgas.v1.Msg/UpdateFeeShare",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).UpdateFeeShare(ctx, req.(*MsgUpdateFeeShare))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_CancelFeeShare_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgCancelFeeShare)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).CancelFeeShare(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.devgas.v1.Msg/CancelFeeShare",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).CancelFeeShare(ctx, req.(*MsgCancelFeeShare))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgUpdateParams)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).UpdateParams(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.devgas.v1.Msg/UpdateParams",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Msg_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.devgas.v1.Msg",
- HandlerType: (*MsgServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "RegisterFeeShare",
- Handler: _Msg_RegisterFeeShare_Handler,
- },
- {
- MethodName: "UpdateFeeShare",
- Handler: _Msg_UpdateFeeShare_Handler,
- },
- {
- MethodName: "CancelFeeShare",
- Handler: _Msg_CancelFeeShare_Handler,
- },
- {
- MethodName: "UpdateParams",
- Handler: _Msg_UpdateParams_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/devgas/v1/tx.proto",
-}
-
-func (m *MsgRegisterFeeShare) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgRegisterFeeShare) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgRegisterFeeShare) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.WithdrawerAddress) > 0 {
- i -= len(m.WithdrawerAddress)
- copy(dAtA[i:], m.WithdrawerAddress)
- i = encodeVarintTx(dAtA, i, uint64(len(m.WithdrawerAddress)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.DeployerAddress) > 0 {
- i -= len(m.DeployerAddress)
- copy(dAtA[i:], m.DeployerAddress)
- i = encodeVarintTx(dAtA, i, uint64(len(m.DeployerAddress)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.ContractAddress) > 0 {
- i -= len(m.ContractAddress)
- copy(dAtA[i:], m.ContractAddress)
- i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgRegisterFeeShareResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgRegisterFeeShareResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgRegisterFeeShareResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgUpdateFeeShare) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgUpdateFeeShare) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgUpdateFeeShare) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.WithdrawerAddress) > 0 {
- i -= len(m.WithdrawerAddress)
- copy(dAtA[i:], m.WithdrawerAddress)
- i = encodeVarintTx(dAtA, i, uint64(len(m.WithdrawerAddress)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.DeployerAddress) > 0 {
- i -= len(m.DeployerAddress)
- copy(dAtA[i:], m.DeployerAddress)
- i = encodeVarintTx(dAtA, i, uint64(len(m.DeployerAddress)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.ContractAddress) > 0 {
- i -= len(m.ContractAddress)
- copy(dAtA[i:], m.ContractAddress)
- i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgUpdateFeeShareResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgUpdateFeeShareResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgUpdateFeeShareResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgCancelFeeShare) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgCancelFeeShare) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgCancelFeeShare) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.DeployerAddress) > 0 {
- i -= len(m.DeployerAddress)
- copy(dAtA[i:], m.DeployerAddress)
- i = encodeVarintTx(dAtA, i, uint64(len(m.DeployerAddress)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.ContractAddress) > 0 {
- i -= len(m.ContractAddress)
- copy(dAtA[i:], m.ContractAddress)
- i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgCancelFeeShareResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgCancelFeeShareResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgCancelFeeShareResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Authority) > 0 {
- i -= len(m.Authority)
- copy(dAtA[i:], m.Authority)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Authority)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
- offset -= sovTx(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *MsgRegisterFeeShare) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ContractAddress)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.DeployerAddress)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.WithdrawerAddress)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgRegisterFeeShareResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgUpdateFeeShare) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ContractAddress)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.DeployerAddress)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.WithdrawerAddress)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgUpdateFeeShareResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgCancelFeeShare) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ContractAddress)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.DeployerAddress)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgCancelFeeShareResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgUpdateParams) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Authority)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = m.Params.Size()
- n += 1 + l + sovTx(uint64(l))
- return n
-}
-
-func (m *MsgUpdateParamsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func sovTx(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozTx(x uint64) (n int) {
- return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *MsgRegisterFeeShare) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgRegisterFeeShare: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgRegisterFeeShare: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ContractAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field DeployerAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.DeployerAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field WithdrawerAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.WithdrawerAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgRegisterFeeShareResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgRegisterFeeShareResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgRegisterFeeShareResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgUpdateFeeShare) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgUpdateFeeShare: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgUpdateFeeShare: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ContractAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field DeployerAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.DeployerAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field WithdrawerAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.WithdrawerAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgUpdateFeeShareResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgUpdateFeeShareResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgUpdateFeeShareResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgCancelFeeShare) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgCancelFeeShare: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgCancelFeeShare: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ContractAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field DeployerAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.DeployerAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgCancelFeeShareResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgCancelFeeShareResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgCancelFeeShareResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Authority = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipTx(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthTx
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupTx
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthTx
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowTx = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/devgas/v1/types/tx.pb.gw.go b/x/devgas/v1/types/tx.pb.gw.go
deleted file mode 100644
index 20372e277..000000000
--- a/x/devgas/v1/types/tx.pb.gw.go
+++ /dev/null
@@ -1,337 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: nibiru/devgas/v1/tx.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-var (
- filter_Msg_RegisterFeeShare_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_RegisterFeeShare_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgRegisterFeeShare
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_RegisterFeeShare_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.RegisterFeeShare(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_RegisterFeeShare_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgRegisterFeeShare
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_RegisterFeeShare_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.RegisterFeeShare(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Msg_UpdateFeeShare_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_UpdateFeeShare_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgUpdateFeeShare
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_UpdateFeeShare_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.UpdateFeeShare(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_UpdateFeeShare_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgUpdateFeeShare
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_UpdateFeeShare_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.UpdateFeeShare(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Msg_CancelFeeShare_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_CancelFeeShare_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgCancelFeeShare
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CancelFeeShare_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.CancelFeeShare(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_CancelFeeShare_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgCancelFeeShare
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CancelFeeShare_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.CancelFeeShare(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux".
-// UnaryRPC :call MsgServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead.
-func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error {
-
- mux.Handle("POST", pattern_Msg_RegisterFeeShare_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_RegisterFeeShare_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_RegisterFeeShare_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_UpdateFeeShare_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_UpdateFeeShare_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_UpdateFeeShare_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_CancelFeeShare_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_CancelFeeShare_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_CancelFeeShare_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterMsgHandler(ctx, mux, conn)
-}
-
-// RegisterMsgHandler registers the http handlers for service Msg to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn))
-}
-
-// RegisterMsgHandlerClient registers the http handlers for service Msg
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "MsgClient" to call the correct interceptors.
-func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error {
-
- mux.Handle("POST", pattern_Msg_RegisterFeeShare_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_RegisterFeeShare_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_RegisterFeeShare_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_UpdateFeeShare_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_UpdateFeeShare_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_UpdateFeeShare_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_CancelFeeShare_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_CancelFeeShare_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_CancelFeeShare_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Msg_RegisterFeeShare_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"nibiru", "devgas", "v1", "tx", "register_FeeShare"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Msg_UpdateFeeShare_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"nibiru", "devgas", "v1", "tx", "update_FeeShare"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Msg_CancelFeeShare_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"nibiru", "devgas", "v1", "tx", "cancel_FeeShare"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Msg_RegisterFeeShare_0 = runtime.ForwardResponseMessage
-
- forward_Msg_UpdateFeeShare_0 = runtime.ForwardResponseMessage
-
- forward_Msg_CancelFeeShare_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/epochs/README.md b/x/epochs/README.md
deleted file mode 100644
index dbdf04b80..000000000
--- a/x/epochs/README.md
+++ /dev/null
@@ -1,158 +0,0 @@
-# `epochs`
-
-Often in the SDK, we would like to run certain code every-so often. The purpose of `epochs` module is to allow other modules to set that they would like to be signaled once every period. So another module can specify it wants to execute code once a week, starting at UTC-time = x. `epochs` creates a generalized epoch interface to other modules so that they can easily be signalled upon such events.
-
-#### Contents
-
-- [`epochs`](#epochs)
-- [Concepts](#concepts)
-- [State](#state)
- - [Epoch information type](#epoch-information-type)
-- [Events](#events)
- - [BeginBlocker](#beginblocker)
- - [EndBlocker](#endblocker)
-- [Keepers](#keepers)
- - [Keeper functions](#keeper-functions)
-- [Hooks](#hooks)
- - [Hooks](#hooks-1)
- - [How modules receive hooks](#how-modules-receive-hooks)
-- [Queries](#queries)
-- [Future Improvements](#future-improvements)
- - [Lack point using this module](#lack-point-using-this-module)
- - [Block-time drifts problem](#block-time-drifts-problem)
-
-# Concepts
-
-The purpose of `epochs` module is to provide generalized epoch interface to other modules so that they can easily implement epochs without keeping own code for epochs.
-
-# State
-
-Epochs module keeps `EpochInfo` objects and modify the information as epochs info changes.
-Epochs are initialized as part of genesis initialization, and modified on begin blockers or end blockers.
-
-### Epoch information type
-
-```protobuf
-message EpochInfo {
- string identifier = 1;
- google.protobuf.Timestamp start_time = 2 [
- (gogoproto.stdtime) = true,
- (gogoproto.nullable) = false,
- (gogoproto.moretags) = "yaml:\"start_time\""
- ];
- google.protobuf.Duration duration = 3 [
- (gogoproto.nullable) = false,
- (gogoproto.stdduration) = true,
- (gogoproto.jsontag) = "duration,omitempty",
- (gogoproto.moretags) = "yaml:\"duration\""
- ];
- int64 current_epoch = 4;
- google.protobuf.Timestamp current_epoch_start_time = 5 [
- (gogoproto.stdtime) = true,
- (gogoproto.nullable) = false,
- (gogoproto.moretags) = "yaml:\"current_epoch_start_time\""
- ];
- bool epoch_counting_started = 6;
- reserved 7;
- int64 current_epoch_start_height = 8;
-}
-```
-
-EpochInfo keeps `identifier`, `start_time`,`duration`, `current_epoch`, `current_epoch_start_time`, `epoch_counting_started`, `current_epoch_start_height`.
-
-1. `identifier` keeps epoch identification string.
-2. `start_time` keeps epoch counting start time, if block time passes `start_time`, `epoch_counting_started` is set.
-3. `duration` keeps target epoch duration.
-4. `current_epoch` keeps current active epoch number.
-5. `current_epoch_start_time` keeps the start time of current epoch.
-6. `epoch_number` is counted only when `epoch_counting_started` flag is set.
-7. `current_epoch_start_height` keeps the start block height of current epoch.
-
-# Events
-
-The `epochs` module emits the following events:
-
-## BeginBlocker
-
-| Type | Attribute Key | Attribute Value |
-|-------------|---------------|-----------------|
-| epoch_start | epoch_number | {epoch_number} |
-| epoch_start | start_time | {start_time} |
-
-## EndBlocker
-
-| Type | Attribute Key | Attribute Value |
-|-----------|---------------|-----------------|
-| epoch_end | epoch_number | {epoch_number} |
-
-# Keepers
-
-## Keeper functions
-
-Epochs keeper module provides utility functions to manage epochs.
-
-```go
-// Keeper is the interface for epoch module keeper
-type Keeper interface {
- // GetEpochInfo returns epoch info by identifier
- GetEpochInfo(ctx sdk.Context, identifier string) types.EpochInfo
- // SetEpochInfo set epoch info
- SetEpochInfo(ctx sdk.Context, epoch types.EpochInfo)
- // DeleteEpochInfo delete epoch info
- DeleteEpochInfo(ctx sdk.Context, identifier string)
- // IterateEpochInfo iterate through epochs
- IterateEpochInfo(ctx sdk.Context, fn func(index int64, epochInfo types.EpochInfo) (stop bool))
- // Get all epoch infos
- AllEpochInfos(ctx sdk.Context) []types.EpochInfo
-}
-```
-
-# Hooks
-
-## Hooks
-```go
- // the first block whose timestamp is after the duration is counted as the end of the epoch
- AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64)
- // new epoch is next block of epoch end block
- BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64)
-```
-
-## How modules receive hooks
-
-On hook receiver function of other modules, they need to filter `epochIdentifier` and only do executions for only specific epochIdentifier.
-Filtering epochIdentifier could be in `Params` of other modules so that they can be modified by governance.
-Governance can change epoch from `week` to `day` as their need.
-
-# Queries
-
-Epochs module is providing below queries to check the module's state.
-
-```protobuf
-service Query {
- // EpochInfos provide running epochInfos
- rpc EpochInfos(QueryEpochInfosRequest) returns (QueryEpochInfosResponse) {}
- // CurrentEpoch provide current epoch of specified identifier
- rpc CurrentEpoch(QueryCurrentEpochRequest) returns (QueryCurrentEpochResponse) {}
-}
-```
-
-# Future Improvements
-
-## Lack point using this module
-
-In current design each epoch should be at least 2 blocks as start block should be different from endblock.
-Because of this, each epoch time will be `max(blocks_time x 2, epoch_duration)`.
-If epoch_duration is set to `1s`, and `block_time` is `5s`, actual epoch time should be `10s`.
-We definitely recommend configure epoch_duration as more than 2x block_time, to use this module correctly.
-If you enforce to set it to 1s, it's same as 10s - could make module logic invalid.
-
-TODO for postlaunch: We should see if we can architect things such that the receiver doesn't have to do this filtering, and the epochs module would pre-filter for them.
-
-## Block-time drifts problem
-
-This implementation has block time drift based on block time.
-For instance, we have an epoch of 100 units that ends at t=100, if we have a block at t=97 and a block at t=104 and t=110, this epoch ends at t=104.
-And new epoch start at t=110. There are time drifts here, for around 1-2 blocks time.
-It will slow down epochs.
-
-It's going to slow down epoch by 10-20s per week when epoch duration is 1 week. This should be resolved after launch.
diff --git a/x/epochs/abci.go b/x/epochs/abci.go
deleted file mode 100644
index 319999944..000000000
--- a/x/epochs/abci.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package epochs
-
-import (
- "time"
-
- "github.com/cosmos/cosmos-sdk/telemetry"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/epochs/keeper"
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-// BeginBlocker of epochs module.
-func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
- defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
- k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) {
- if ctx.BlockTime().Before(epochInfo.StartTime) {
- return false
- }
-
- if !shouldEpochStart(epochInfo, ctx) {
- return false
- }
-
- epochInfo.CurrentEpochStartHeight = ctx.BlockHeight()
- epochInfo.CurrentEpochStartTime = ctx.BlockTime()
-
- if !epochInfo.EpochCountingStarted {
- epochInfo.EpochCountingStarted = true
- epochInfo.CurrentEpoch = 1
- } else {
- _ = ctx.EventManager().EmitTypedEvent(&types.EventEpochEnd{EpochNumber: epochInfo.CurrentEpoch})
- k.AfterEpochEnd(ctx, epochInfo.Identifier, epochInfo.CurrentEpoch)
- epochInfo.CurrentEpoch += 1
- }
-
- // emit new epoch start event, set epoch info, and run BeforeEpochStart hook
- _ = ctx.EventManager().EmitTypedEvent(&types.EventEpochStart{
- EpochNumber: epochInfo.CurrentEpoch,
- EpochStartTime: epochInfo.CurrentEpochStartTime,
- })
-
- k.Epochs.Insert(ctx, epochInfo.Identifier, epochInfo)
- k.BeforeEpochStart(ctx, epochInfo.Identifier, epochInfo.CurrentEpoch)
-
- return false
- })
-}
-
-// shouldEpochStart checks if the epoch should start.
-// an epoch is ready to start if:
-// - it has not yet been initialized.
-// - the current epoch end time is before the current block time
-func shouldEpochStart(epochInfo types.EpochInfo, ctx sdk.Context) bool {
- // Epoch has not started yet
- if !epochInfo.EpochCountingStarted {
- return true
- }
-
- epochEndTime := epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration)
-
- return ctx.BlockTime().After(epochEndTime) || ctx.BlockTime().Equal(epochEndTime)
-}
diff --git a/x/epochs/abci_test.go b/x/epochs/abci_test.go
deleted file mode 100644
index 483e56ee4..000000000
--- a/x/epochs/abci_test.go
+++ /dev/null
@@ -1,295 +0,0 @@
-package epochs_test
-
-import (
- "testing"
- "time"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/epochs"
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-func TestEpochInfoChangesBeginBlockerAndInitGenesis(t *testing.T) {
- var app *app.NibiruApp
- var ctx sdk.Context
-
- now := time.Now().UTC()
-
- tests := []struct {
- name string
- when func()
- expectedEpochInfo types.EpochInfo
- }{
- {
- name: "no increment",
- when: func() {
- ctx = ctx.WithBlockHeight(2).WithBlockTime(now.Add(time.Second))
- epochs.BeginBlocker(ctx, app.EpochsKeeper)
- },
- expectedEpochInfo: types.EpochInfo{
- Identifier: "monthly",
- StartTime: now,
- Duration: time.Hour * 24 * 31,
- CurrentEpoch: 1,
- CurrentEpochStartHeight: 1,
- CurrentEpochStartTime: now,
- EpochCountingStarted: true,
- },
- },
- {
- name: "increment",
- when: func() {
- ctx = ctx.WithBlockHeight(2).WithBlockTime(now.Add(time.Second))
- epochs.BeginBlocker(ctx, app.EpochsKeeper)
- ctx = ctx.WithBlockHeight(3).WithBlockTime(now.Add(time.Hour * 24 * 32))
- epochs.BeginBlocker(ctx, app.EpochsKeeper)
- },
- expectedEpochInfo: types.EpochInfo{
- Identifier: "monthly",
- StartTime: now,
- Duration: time.Hour * 24 * 31,
- CurrentEpoch: 2,
- CurrentEpochStartHeight: 3,
- CurrentEpochStartTime: now.Add(time.Hour * 24 * 32),
- EpochCountingStarted: true,
- },
- },
- // Test that incrementing _exactly_ 1 month increments the epoch count.
- {
- name: "exact increment",
- when: func() {
- ctx = ctx.WithBlockHeight(2).WithBlockTime(now.Add(time.Hour * 24 * 31))
- epochs.BeginBlocker(ctx, app.EpochsKeeper)
- },
- expectedEpochInfo: types.EpochInfo{
- Identifier: "monthly",
- StartTime: now,
- Duration: time.Hour * 24 * 31,
- CurrentEpoch: 2,
- CurrentEpochStartHeight: 2,
- CurrentEpochStartTime: now.Add(time.Hour * 24 * 31),
- EpochCountingStarted: true,
- },
- },
- {
- name: "increment twice",
- when: func() {
- ctx = ctx.WithBlockHeight(2).WithBlockTime(now.Add(time.Hour * 24 * 31))
- epochs.BeginBlocker(ctx, app.EpochsKeeper)
- ctx = ctx.WithBlockHeight(3).WithBlockTime(now.Add(time.Hour * 24 * 31 * 2))
- epochs.BeginBlocker(ctx, app.EpochsKeeper)
- },
- expectedEpochInfo: types.EpochInfo{
- Identifier: "monthly",
- StartTime: now,
- Duration: time.Hour * 24 * 31,
- CurrentEpoch: 3,
- CurrentEpochStartHeight: 3,
- CurrentEpochStartTime: now.Add(time.Hour * 24 * 31 * 2),
- EpochCountingStarted: true,
- },
- },
- }
-
- for _, tc := range tests {
- tc := tc
- t.Run(tc.name, func(t *testing.T) {
- app, ctx = testapp.NewNibiruTestAppAndContext()
-
- // On init genesis, default epochs information is set
- // To check init genesis again, should make it fresh status
- epochInfos := app.EpochsKeeper.AllEpochInfos(ctx)
- for _, epochInfo := range epochInfos {
- err := app.EpochsKeeper.DeleteEpochInfo(ctx, epochInfo.Identifier)
- require.NoError(t, err)
- }
-
- // erorr beceause empty identifier
- err := app.EpochsKeeper.AddEpochInfo(ctx, types.EpochInfo{
- Identifier: "",
- StartTime: now,
- Duration: time.Hour * 24 * 31,
- CurrentEpoch: 1,
- CurrentEpochStartHeight: 1,
- CurrentEpochStartTime: now,
- EpochCountingStarted: true,
- })
- assert.Error(t, err)
-
- // insert epoch info that's already begun
- ctx = ctx.WithBlockHeight(1).WithBlockTime(now)
- err = app.EpochsKeeper.AddEpochInfo(ctx, types.EpochInfo{
- Identifier: "monthly",
- StartTime: now,
- Duration: time.Hour * 24 * 31,
- CurrentEpoch: 1,
- CurrentEpochStartHeight: 1,
- CurrentEpochStartTime: now,
- EpochCountingStarted: true,
- })
- assert.NoError(t, err)
-
- err = app.EpochsKeeper.AddEpochInfo(ctx, types.EpochInfo{
- Identifier: "monthly",
- StartTime: now,
- Duration: time.Hour * 24 * 31,
- CurrentEpoch: 1,
- CurrentEpochStartHeight: 1,
- CurrentEpochStartTime: now,
- EpochCountingStarted: true,
- })
- assert.Error(t, err)
-
- tc.when()
-
- epochInfo, err := app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- assert.NoError(t, err)
- assert.Equal(t, tc.expectedEpochInfo.CurrentEpoch, epochInfo.CurrentEpoch)
- assert.Equal(t, tc.expectedEpochInfo.CurrentEpochStartTime, epochInfo.CurrentEpochStartTime)
- assert.Equal(t, tc.expectedEpochInfo.CurrentEpochStartHeight, epochInfo.CurrentEpochStartHeight)
-
- // insert epoch info that's already begun
- err = app.EpochsKeeper.DeleteEpochInfo(ctx, "monthly")
- assert.NoError(t, err)
-
- err = app.EpochsKeeper.DeleteEpochInfo(ctx, "monthly")
- assert.Error(t, err)
-
- tc.when()
-
- epochInfo, err = app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- assert.Error(t, err)
- })
- }
-}
-
-func TestEpochStartingOneMonthAfterInitGenesis(t *testing.T) {
- app, ctx := testapp.NewNibiruTestAppAndContext()
-
- // On init genesis, default epochs information is set
- // To check init genesis again, should make it fresh status
- epochInfos := app.EpochsKeeper.AllEpochInfos(ctx)
- for _, epochInfo := range epochInfos {
- err := app.EpochsKeeper.DeleteEpochInfo(ctx, epochInfo.Identifier)
- require.NoError(t, err)
- }
-
- now := time.Now()
- week := time.Hour * 24 * 7
- month := time.Hour * 24 * 30
- initialBlockHeight := int64(1)
- ctx = ctx.WithBlockHeight(initialBlockHeight).WithBlockTime(now)
-
- err := epochs.InitGenesis(ctx, app.EpochsKeeper, types.GenesisState{
- Epochs: []types.EpochInfo{
- {
- Identifier: "daily",
- StartTime: now.Add(month),
- Duration: time.Hour * 24 * 30,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: ctx.BlockHeight(),
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- {
- Identifier: "monthly",
- StartTime: now.Add(month),
- Duration: time.Hour * 24 * 30,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: ctx.BlockHeight(),
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- {
- Identifier: "weekly",
- StartTime: now.Add(month),
- Duration: time.Hour * 24 * 30,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: ctx.BlockHeight(),
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- },
- })
- require.NoError(t, err)
-
- // epoch not started yet
- epochInfo, err := app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- assert.NoError(t, err)
- require.Equal(t, epochInfo.CurrentEpoch, uint64(0))
- require.Equal(t, epochInfo.CurrentEpochStartHeight, initialBlockHeight)
- require.Equal(t, epochInfo.CurrentEpochStartTime, time.Time{})
- require.Equal(t, epochInfo.EpochCountingStarted, false)
-
- // after 1 week
- ctx = ctx.WithBlockHeight(2).WithBlockTime(now.Add(week))
- epochs.BeginBlocker(ctx, app.EpochsKeeper)
-
- // epoch not started yet
- epochInfo, err = app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- assert.NoError(t, err)
- require.Equal(t, epochInfo.CurrentEpoch, uint64(0))
- require.Equal(t, epochInfo.CurrentEpochStartHeight, initialBlockHeight)
- require.Equal(t, epochInfo.CurrentEpochStartTime, time.Time{})
- require.Equal(t, epochInfo.EpochCountingStarted, false)
-
- // after 1 month
- ctx = ctx.WithBlockHeight(3).WithBlockTime(now.Add(month))
- epochs.BeginBlocker(ctx, app.EpochsKeeper)
-
- // epoch started
- epochInfo, err = app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- assert.NoError(t, err)
- require.Equal(t, epochInfo.CurrentEpoch, uint64(1))
- require.Equal(t, epochInfo.CurrentEpochStartHeight, ctx.BlockHeight())
- require.Equal(t, epochInfo.CurrentEpochStartTime.UTC().String(), now.Add(month).UTC().String())
- require.Equal(t, epochInfo.EpochCountingStarted, true)
-}
-
-// This test ensures legacy EpochInfo messages will not throw errors via InitGenesis and BeginBlocker
-func TestLegacyEpochSerialization(t *testing.T) {
- // Legacy Epoch Info message - without CurrentEpochStartHeight property
- legacyEpochInfo := types.EpochInfo{
- Identifier: "monthly",
- StartTime: time.Time{},
- Duration: time.Hour * 24 * 31,
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- }
-
- now := time.Now()
- app, ctx := testapp.NewNibiruTestAppAndContext()
- // On init genesis, default epochs information is set
- // To check init genesis again, should make it fresh status
- epochInfos := app.EpochsKeeper.AllEpochInfos(ctx)
- for _, epochInfo := range epochInfos {
- err := app.EpochsKeeper.DeleteEpochInfo(ctx, epochInfo.Identifier)
- require.NoError(t, err)
- }
-
- ctx = ctx.WithBlockHeight(1).WithBlockTime(now)
-
- // check init genesis
- err := epochs.InitGenesis(ctx, app.EpochsKeeper, types.GenesisState{
- Epochs: []types.EpochInfo{legacyEpochInfo},
- })
- require.NoError(t, err)
-
- // Do not increment epoch
- ctx = ctx.WithBlockHeight(2).WithBlockTime(now.Add(time.Second))
- epochs.BeginBlocker(ctx, app.EpochsKeeper)
-
- // Increment epoch
- ctx = ctx.WithBlockHeight(3).WithBlockTime(now.Add(time.Hour * 24 * 32))
- epochs.BeginBlocker(ctx, app.EpochsKeeper)
- epochInfo, err := app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- assert.NoError(t, err)
-
- require.NotEqual(t, epochInfo.CurrentEpochStartHeight, int64(0))
-}
diff --git a/x/epochs/client/cli/query.go b/x/epochs/client/cli/query.go
deleted file mode 100644
index 4cf75f50e..000000000
--- a/x/epochs/client/cli/query.go
+++ /dev/null
@@ -1,106 +0,0 @@
-package cli
-
-import (
- "fmt"
- "strings"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/version"
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-// GetQueryCmd returns the cli query commands for this module.
-func GetQueryCmd() *cobra.Command {
- // Group epochs queries under a subcommand
- cmd := &cobra.Command{
- Use: types.ModuleName,
- Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- cmd.AddCommand(
- GetCmdEpochInfos(),
- GetCmdCurrentEpoch(),
- )
-
- return cmd
-}
-
-// GetCmdEpochInfos provide running epochInfos.
-func GetCmdEpochInfos() *cobra.Command {
- cmd := &cobra.Command{
- Use: "epoch-infos",
- Short: "Query running epochInfos",
- Long: strings.TrimSpace(
- fmt.Sprintf(`Query running epoch infos.
-
-Example:
-$ %s query epochs epoch-infos
-`,
- version.AppName,
- ),
- ),
- Args: cobra.ExactArgs(0),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- res, err := queryClient.EpochInfos(cmd.Context(), &types.QueryEpochInfosRequest{})
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
-
-// GetCmdCurrentEpoch provides current epoch by specified identifier.
-func GetCmdCurrentEpoch() *cobra.Command {
- cmd := &cobra.Command{
- Use: "current-epoch",
- Short: "Query current epoch by specified identifier",
- Long: strings.TrimSpace(
- fmt.Sprintf(`Query current epoch by specified identifier.
-
-Example:
-$ %s query epochs current-epoch day
-`,
- version.AppName,
- ),
- ),
- Args: cobra.ExactArgs(1),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- res, err := queryClient.CurrentEpoch(cmd.Context(), &types.QueryCurrentEpochRequest{
- Identifier: args[0],
- })
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
diff --git a/x/epochs/client/cli/tx.go b/x/epochs/client/cli/tx.go
deleted file mode 100644
index c00148ecc..000000000
--- a/x/epochs/client/cli/tx.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package cli
-
-import (
- "fmt"
-
- "github.com/spf13/cobra"
-
- "github.com/cosmos/cosmos-sdk/client"
-
- // "github.com/cosmos/cosmos-sdk/client/flags".
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-// GetTxCmd returns the transaction commands for this module.
-func GetTxCmd() *cobra.Command {
- cmd := &cobra.Command{
- Use: types.ModuleName,
- Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- return cmd
-}
diff --git a/x/epochs/client/rest/rest.go b/x/epochs/client/rest/rest.go
deleted file mode 100644
index 6e66e1a78..000000000
--- a/x/epochs/client/rest/rest.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package rest
-
-import (
- "github.com/gorilla/mux"
-
- "github.com/cosmos/cosmos-sdk/client"
-)
-
-const (
- MethodGet = "GET"
-)
-
-// RegisterRoutes registers epochs-related REST handlers to a router.
-func RegisterRoutes(clientCtx client.Context, r *mux.Router) {
-}
diff --git a/x/epochs/genesis.go b/x/epochs/genesis.go
deleted file mode 100644
index bffe0dfa7..000000000
--- a/x/epochs/genesis.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package epochs
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/epochs/keeper"
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-// InitGenesis sets epoch info from genesis
-func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) (err error) {
- err = genState.Validate()
- if err != nil {
- return
- }
- for _, epoch := range genState.Epochs {
- if err = k.AddEpochInfo(ctx, epoch); err != nil {
- return err
- }
- }
- return
-}
-
-// ExportGenesis returns the capability module's exported genesis.
-func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
- genesis := types.DefaultGenesisFromTime(ctx.BlockTime())
- genesis.Epochs = k.AllEpochInfos(ctx)
-
- return genesis
-}
diff --git a/x/epochs/genesis_test.go b/x/epochs/genesis_test.go
deleted file mode 100644
index 88eda5256..000000000
--- a/x/epochs/genesis_test.go
+++ /dev/null
@@ -1,124 +0,0 @@
-package epochs_test
-
-import (
- "fmt"
- "testing"
- "time"
-
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil/genesis"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/epochs"
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-func TestEpochsExportGenesis(t *testing.T) {
- chainStartTime := time.Now().UTC()
- moduleGenesisIn := types.DefaultGenesisFromTime(chainStartTime)
-
- encCfg := app.MakeEncodingConfig()
- appGenesis := genesis.NewTestGenesisState(encCfg)
- appGenesis[types.ModuleName] = encCfg.Codec.MustMarshalJSON(moduleGenesisIn)
-
- app := testapp.NewNibiruTestApp(appGenesis)
- ctx := testapp.NewContext(app).WithBlockTime(chainStartTime)
-
- genesis := epochs.ExportGenesis(ctx, app.EpochsKeeper)
- require.Len(t, genesis.Epochs, 3)
-
- errMsg := fmt.Sprintf("app.EpochsKeeper.AllEpochInfos(ctx): %v\n", app.EpochsKeeper.AllEpochInfos(ctx))
- require.Equal(t, genesis.Epochs[0].Identifier, "30 min")
- require.Equal(t, genesis.Epochs[0].StartTime, chainStartTime, errMsg)
- require.Equal(t, genesis.Epochs[0].Duration, time.Minute*30, errMsg)
- require.Equal(t, genesis.Epochs[0].CurrentEpoch, uint64(0))
- require.Equal(t, genesis.Epochs[0].CurrentEpochStartHeight, int64(0))
- require.Equal(t, genesis.Epochs[0].CurrentEpochStartTime, chainStartTime)
- require.Equal(t, genesis.Epochs[0].EpochCountingStarted, false)
-
- require.Equal(t, genesis.Epochs[1].Identifier, "day")
- require.Equal(t, genesis.Epochs[1].StartTime, chainStartTime, errMsg)
- require.Equal(t, genesis.Epochs[1].Duration, time.Hour*24)
- require.Equal(t, genesis.Epochs[1].CurrentEpoch, uint64(0))
- require.Equal(t, genesis.Epochs[1].CurrentEpochStartHeight, int64(0))
- require.Equal(t, genesis.Epochs[1].CurrentEpochStartTime, chainStartTime, errMsg)
- require.Equal(t, genesis.Epochs[1].EpochCountingStarted, false)
-
- require.Equal(t, genesis.Epochs[2].Identifier, "week")
- require.Equal(t, genesis.Epochs[2].StartTime, chainStartTime, errMsg)
- require.Equal(t, genesis.Epochs[2].Duration, time.Hour*24*7)
- require.Equal(t, genesis.Epochs[2].CurrentEpoch, uint64(0))
- require.Equal(t, genesis.Epochs[2].CurrentEpochStartHeight, int64(0))
- require.Equal(t, genesis.Epochs[2].CurrentEpochStartTime, chainStartTime, errMsg)
- require.Equal(t, genesis.Epochs[2].EpochCountingStarted, false)
-}
-
-func TestEpochsInitGenesis(t *testing.T) {
- app, ctx := testapp.NewNibiruTestAppAndContext()
- // On init genesis, default epochs information is set
- // To check init genesis again, should make it fresh status
- epochInfos := app.EpochsKeeper.AllEpochInfos(ctx)
- for _, epochInfo := range epochInfos {
- err := app.EpochsKeeper.DeleteEpochInfo(ctx, epochInfo.Identifier)
- require.NoError(t, err)
- }
-
- now := time.Now()
- ctx = ctx.WithBlockHeight(1)
- ctx = ctx.WithBlockTime(now)
-
- // test genesisState validation
- genesisState := types.GenesisState{
- Epochs: []types.EpochInfo{
- {
- Identifier: "monthly",
- StartTime: time.Time{},
- Duration: time.Hour * 24,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: ctx.BlockHeight(),
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: true,
- },
- {
- Identifier: "monthly",
- StartTime: time.Time{},
- Duration: time.Hour * 24,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: ctx.BlockHeight(),
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: true,
- },
- },
- }
- err := epochs.InitGenesis(ctx, app.EpochsKeeper, genesisState)
- require.Error(t, err)
-
- require.EqualError(t, genesisState.Validate(), "epoch identifier should be unique")
-
- genesisState = types.GenesisState{
- Epochs: []types.EpochInfo{
- {
- Identifier: "monthly",
- StartTime: time.Time{},
- Duration: time.Hour * 24,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: ctx.BlockHeight(),
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: true,
- },
- },
- }
-
- err = epochs.InitGenesis(ctx, app.EpochsKeeper, genesisState)
- require.NoError(t, err)
- epochInfo, err := app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- require.NoError(t, err)
- require.Equal(t, epochInfo.Identifier, "monthly")
- require.Equal(t, epochInfo.StartTime.UTC().String(), now.UTC().String())
- require.Equal(t, epochInfo.Duration, time.Hour*24)
- require.Equal(t, epochInfo.CurrentEpoch, uint64(0))
- require.Equal(t, epochInfo.CurrentEpochStartHeight, ctx.BlockHeight())
- require.Equal(t, epochInfo.CurrentEpochStartTime.UTC().String(), time.Time{}.String())
- require.Equal(t, epochInfo.EpochCountingStarted, true)
-}
diff --git a/x/epochs/integration/action/epoch.go b/x/epochs/integration/action/epoch.go
deleted file mode 100644
index daacf217c..000000000
--- a/x/epochs/integration/action/epoch.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package action
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil/action"
-)
-
-type startEpoch struct {
- epochIdentifier string
-}
-
-func (s startEpoch) IsNotMandatory() {}
-
-func (s startEpoch) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- epochInfo, err := app.EpochsKeeper.GetEpochInfo(ctx, s.epochIdentifier)
- if err != nil {
- return ctx, err
- }
- epochInfo.EpochCountingStarted = true
- epochInfo.CurrentEpoch = 1
- epochInfo.CurrentEpochStartHeight = ctx.BlockHeight()
- epochInfo.CurrentEpochStartTime = ctx.BlockTime()
- epochInfo.StartTime = ctx.BlockTime()
-
- app.EpochsKeeper.Epochs.Insert(ctx, epochInfo.Identifier, epochInfo)
-
- return ctx, nil
-}
-
-func StartEpoch(epochIdentifier string) action.Action {
- return startEpoch{epochIdentifier: epochIdentifier}
-}
diff --git a/x/epochs/keeper/epoch.go b/x/epochs/keeper/epoch.go
deleted file mode 100644
index 48510df30..000000000
--- a/x/epochs/keeper/epoch.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package keeper
-
-import (
- "fmt"
- "time"
-
- "github.com/NibiruChain/collections"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-// GetEpochInfo returns epoch info by identifier.
-func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) (epoch types.EpochInfo, err error) {
- epoch, err = k.Epochs.Get(ctx, identifier)
- if err != nil {
- err = fmt.Errorf("epoch with identifier %s not found", identifier)
- return
- }
-
- return
-}
-
-// EpochExists checks if the epoch exists
-func (k Keeper) EpochExists(ctx sdk.Context, identifier string) bool {
- _, err := k.Epochs.Get(ctx, identifier)
- return err == nil
-}
-
-// AddEpochInfo adds a new epoch info. Will return an error if the epoch fails validation,
-// or re-uses an existing identifier.
-// This method also sets the start time if left unset, and sets the epoch start height.
-func (k Keeper) AddEpochInfo(ctx sdk.Context, epoch types.EpochInfo) error {
- if err := epoch.Validate(); err != nil {
- return err
- }
-
- if k.EpochExists(ctx, epoch.Identifier) {
- return fmt.Errorf("epoch with identifier %s already exists", epoch.Identifier)
- }
-
- // Initialize empty and default epoch values
- if epoch.StartTime.Equal(time.Time{}) {
- epoch.StartTime = ctx.BlockTime()
- }
-
- epoch.CurrentEpochStartHeight = ctx.BlockHeight()
-
- k.Epochs.Insert(ctx, epoch.Identifier, epoch)
-
- return nil
-}
-
-// DeleteEpochInfo delete epoch info.
-func (k Keeper) DeleteEpochInfo(ctx sdk.Context, identifier string) (err error) {
- err = k.Epochs.Delete(ctx, identifier)
- return
-}
-
-// IterateEpochInfo iterate through epochs.
-func (k Keeper) IterateEpochInfo(
- ctx sdk.Context,
- fn func(index int64, epochInfo types.EpochInfo) (stop bool),
-) {
- iterate := k.Epochs.Iterate(ctx, &collections.Range[string]{})
- i := int64(0)
-
- for ; iterate.Valid(); iterate.Next() {
- epoch := iterate.Value()
- stop := fn(i, epoch)
-
- if stop {
- break
- }
- i++
- }
-}
-
-// AllEpochInfos iterate through epochs to return all epochs info.
-func (k Keeper) AllEpochInfos(ctx sdk.Context) []types.EpochInfo {
- var epochs []types.EpochInfo
- k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) {
- epochs = append(epochs, epochInfo)
- return false
- })
- return epochs
-}
diff --git a/x/epochs/keeper/grpc_query.go b/x/epochs/keeper/grpc_query.go
deleted file mode 100644
index 3ecf1833a..000000000
--- a/x/epochs/keeper/grpc_query.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package keeper
-
-import (
- "context"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-var _ types.QueryServer = Querier{}
-
-// Querier defines a wrapper around the x/epochs keeper providing gRPC method
-// handlers.
-type Querier struct {
- Keeper
-}
-
-func NewQuerier(k Keeper) Querier {
- return Querier{Keeper: k}
-}
-
-// EpochInfos provide running epochInfos.
-func (q Querier) EpochInfos(c context.Context, _ *types.QueryEpochInfosRequest) (*types.QueryEpochInfosResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
-
- return &types.QueryEpochInfosResponse{
- Epochs: q.Keeper.AllEpochInfos(ctx),
- }, nil
-}
-
-// CurrentEpoch provides current epoch of specified identifier.
-func (q Querier) CurrentEpoch(c context.Context, req *types.QueryCurrentEpochRequest) (resp *types.QueryCurrentEpochResponse, err error) {
- ctx := sdk.UnwrapSDKContext(c)
-
- info, err := q.Keeper.GetEpochInfo(ctx, req.Identifier)
- if err != nil {
- return
- }
-
- return &types.QueryCurrentEpochResponse{
- CurrentEpoch: info.CurrentEpoch,
- }, nil
-}
diff --git a/x/epochs/keeper/grpc_query_test.go b/x/epochs/keeper/grpc_query_test.go
deleted file mode 100644
index d8d820757..000000000
--- a/x/epochs/keeper/grpc_query_test.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package keeper_test
-
-import (
- gocontext "context"
- "fmt"
- "testing"
- "time"
-
- "github.com/cosmos/cosmos-sdk/baseapp"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/epochs/keeper"
-
- epochstypes "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-func TestQueryEpochInfos(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
-
- queryHelper := baseapp.NewQueryServerTestHelper(ctx, nibiruApp.InterfaceRegistry())
- epochstypes.RegisterQueryServer(queryHelper, keeper.NewQuerier(nibiruApp.EpochsKeeper))
- queryClient := epochstypes.NewQueryClient(queryHelper)
-
- epochInfos := nibiruApp.EpochsKeeper.AllEpochInfos(ctx)
- chainStartTime := epochInfos[0].StartTime
- errMsg := fmt.Sprintf("epochInfos: %v\n", epochInfos)
-
- // Invalid param
- epochInfosResponse, err := queryClient.EpochInfos(
- gocontext.Background(), &epochstypes.QueryEpochInfosRequest{},
- )
- require.NoError(t, err, errMsg)
- require.Len(t, epochInfosResponse.Epochs, 3)
-
- // check if EpochInfos are correct
- require.Equal(t, epochInfosResponse.Epochs[0].StartTime, chainStartTime, errMsg)
- require.Equal(t, epochInfosResponse.Epochs[0].CurrentEpochStartTime, chainStartTime)
- require.Equal(t, epochInfosResponse.Epochs[0].Identifier, "30 min")
- require.Equal(t, epochInfosResponse.Epochs[0].Duration, time.Minute*30)
- require.Equal(t, epochInfosResponse.Epochs[0].CurrentEpoch, uint64(0))
- require.Equal(t, epochInfosResponse.Epochs[0].EpochCountingStarted, false)
-
- require.Equal(t, epochInfosResponse.Epochs[1].StartTime, chainStartTime)
- require.Equal(t, epochInfosResponse.Epochs[1].CurrentEpochStartTime, chainStartTime)
- require.Equal(t, epochInfosResponse.Epochs[1].Identifier, "day")
- require.Equal(t, epochInfosResponse.Epochs[1].Duration, time.Hour*24)
- require.Equal(t, epochInfosResponse.Epochs[1].CurrentEpoch, uint64(0))
- require.Equal(t, epochInfosResponse.Epochs[1].EpochCountingStarted, false)
-}
-
-func TestCurrentEpochQuery(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
-
- queryHelper := baseapp.NewQueryServerTestHelper(ctx, nibiruApp.InterfaceRegistry())
- epochstypes.RegisterQueryServer(queryHelper, keeper.NewQuerier(nibiruApp.EpochsKeeper))
- queryClient := epochstypes.NewQueryClient(queryHelper)
-
- // Valid epoch
- epochInfosResponse, err := queryClient.CurrentEpoch(gocontext.Background(), &epochstypes.QueryCurrentEpochRequest{Identifier: "30 min"})
- require.NoError(t, err)
- require.Equal(t, epochInfosResponse.CurrentEpoch, uint64(0))
-
- // Invalid epoch
- _, err = queryClient.CurrentEpoch(gocontext.Background(), &epochstypes.QueryCurrentEpochRequest{Identifier: "invalid epoch"})
- require.Error(t, err)
-}
diff --git a/x/epochs/keeper/hooks.go b/x/epochs/keeper/hooks.go
deleted file mode 100644
index 46b32b0b0..000000000
--- a/x/epochs/keeper/hooks.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package keeper
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// AfterEpochEnd epoch hook
-func (k Keeper) AfterEpochEnd(ctx sdk.Context, identifier string, epochNumber uint64) {
- k.hooks.AfterEpochEnd(ctx, identifier, epochNumber)
-}
-
-// BeforeEpochStart epoch hook
-func (k Keeper) BeforeEpochStart(ctx sdk.Context, identifier string, epochNumber uint64) {
- k.hooks.BeforeEpochStart(ctx, identifier, epochNumber)
-}
diff --git a/x/epochs/keeper/hooks_test.go b/x/epochs/keeper/hooks_test.go
deleted file mode 100644
index 5e4d1d477..000000000
--- a/x/epochs/keeper/hooks_test.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package keeper_test
-
-import (
- "testing"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/mock"
-
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
-)
-
-type MockHooks struct {
- mock.Mock
-}
-
-type Hooks interface {
- AfterEpochEnd(ctx sdk.Context, identifier string, epochNumber uint64)
- BeforeEpochStart(ctx sdk.Context, identifier string, epochNumber uint64)
-}
-
-func (h *MockHooks) AfterEpochEnd(ctx sdk.Context, identifier string, epochNumber uint64) {
- h.Called(ctx, identifier, epochNumber)
-}
-
-func (h *MockHooks) BeforeEpochStart(ctx sdk.Context, identifier string, epochNumber uint64) {
- h.Called(ctx, identifier, epochNumber)
-}
-
-func TestAfterEpochEnd(t *testing.T) {
- hooks := new(MockHooks)
-
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
- identifier := "testID"
- epochNumber := uint64(10)
-
- nibiruApp.EpochsKeeper.SetHooks(hooks)
- hooks.On("AfterEpochEnd", ctx, identifier, epochNumber)
- nibiruApp.EpochsKeeper.AfterEpochEnd(ctx, identifier, epochNumber)
- hooks.AssertExpectations(t)
-}
-
-func TestBeforeEpochStart(t *testing.T) {
- hooks := new(MockHooks)
-
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
- identifier := "testID"
- epochNumber := uint64(10)
-
- nibiruApp.EpochsKeeper.SetHooks(hooks)
- hooks.On("BeforeEpochStart", ctx, identifier, epochNumber)
- nibiruApp.EpochsKeeper.BeforeEpochStart(ctx, identifier, epochNumber)
-
- hooks.AssertExpectations(t)
-}
diff --git a/x/epochs/keeper/keeper.go b/x/epochs/keeper/keeper.go
deleted file mode 100644
index a1d997938..000000000
--- a/x/epochs/keeper/keeper.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package keeper
-
-import (
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
-
- "github.com/NibiruChain/collections"
-
- "github.com/cosmos/cosmos-sdk/codec"
-
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-type Keeper struct {
- cdc codec.Codec
- storeKey storetypes.StoreKey
- hooks types.EpochHooks
-
- Epochs collections.Map[string, types.EpochInfo]
-}
-
-func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey) Keeper {
- return Keeper{
- cdc: cdc,
- storeKey: storeKey,
-
- Epochs: collections.NewMap[string, types.EpochInfo](storeKey, 1, collections.StringKeyEncoder, collections.ProtoValueEncoder[types.EpochInfo](cdc)),
- }
-}
-
-// SetHooks Set the epoch hooks.
-func (k *Keeper) SetHooks(eh types.EpochHooks) *Keeper {
- k.hooks = eh
-
- return k
-}
diff --git a/x/epochs/keeper/keeper_test.go b/x/epochs/keeper/keeper_test.go
deleted file mode 100644
index 74e11e5dd..000000000
--- a/x/epochs/keeper/keeper_test.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package keeper_test
-
-import (
- "testing"
- "time"
-
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-func TestUpsertEpochInfo_HappyPath(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
-
- epochInfo := types.EpochInfo{
- Identifier: "monthly",
- StartTime: time.Time{},
- Duration: time.Hour * 24 * 30,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- }
-
- nibiruApp.EpochsKeeper.Epochs.Insert(ctx, epochInfo.Identifier, epochInfo)
-
- epochInfoSaved, err := nibiruApp.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- require.NoError(t, err)
- require.Equal(t, epochInfo, epochInfoSaved)
-
- allEpochs := nibiruApp.EpochsKeeper.AllEpochInfos(ctx)
-
- require.Len(t, allEpochs, 4)
- // Epochs are ordered in alphabetical order
- require.Equal(t, "30 min", allEpochs[0].Identifier)
- require.Equal(t, "day", allEpochs[1].Identifier)
- require.Equal(t, "monthly", allEpochs[2].Identifier)
- require.Equal(t, "week", allEpochs[3].Identifier)
-}
-
-func TestEpochExists(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
-
- epochInfo := types.EpochInfo{
- Identifier: "monthly",
- StartTime: time.Time{},
- Duration: time.Hour * 24 * 30,
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- }
- nibiruApp.EpochsKeeper.Epochs.Insert(ctx, epochInfo.Identifier, epochInfo)
-
- require.True(t, nibiruApp.EpochsKeeper.EpochExists(ctx, "monthly"))
- require.False(t, nibiruApp.EpochsKeeper.EpochExists(ctx, "unexisting-epoch"))
-}
-
-func TestItFailsAddingEpochThatExists(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
-
- epochInfo := types.EpochInfo{
- Identifier: "monthly",
- StartTime: time.Time{},
- Duration: time.Hour * 24 * 30,
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- }
-
- err := nibiruApp.EpochsKeeper.AddEpochInfo(ctx, epochInfo)
- require.NoError(t, err)
-
- // It fails if we try to add it again.
- err = nibiruApp.EpochsKeeper.AddEpochInfo(ctx, epochInfo)
- require.Error(t, err)
-}
diff --git a/x/epochs/module.go b/x/epochs/module.go
deleted file mode 100644
index 1bbd0a53b..000000000
--- a/x/epochs/module.go
+++ /dev/null
@@ -1,169 +0,0 @@
-package epochs
-
-import (
- "context"
- "encoding/json"
- "fmt"
-
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/codec"
- cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
- simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/epochs/client/cli"
- "github.com/NibiruChain/nibiru/x/epochs/keeper"
- "github.com/NibiruChain/nibiru/x/epochs/simulation"
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-var (
- _ module.AppModuleBasic = AppModuleBasic{}
- _ module.AppModule = AppModule{}
- _ module.AppModuleSimulation = AppModule{}
-)
-
-// ----------------------------------------------------------------------------
-// AppModuleBasic
-// ----------------------------------------------------------------------------
-
-// AppModuleBasic implements the AppModuleBasic interface for the capability module.
-type AppModuleBasic struct {
- cdc codec.Codec
-}
-
-func NewAppModuleBasic(cdc codec.Codec) AppModuleBasic {
- return AppModuleBasic{cdc: cdc}
-}
-
-// Name returns the capability module's name.
-func (AppModuleBasic) Name() string {
- return types.ModuleName
-}
-
-func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
-}
-
-// RegisterInterfaces registers the module's interface types.
-func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {
-}
-
-// DefaultGenesis returns the capability module's default genesis state.
-func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
- return cdc.MustMarshalJSON(types.DefaultGenesis())
-}
-
-// ValidateGenesis performs genesis state validation for the capability module.
-func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
- var genState types.GenesisState
- if err := cdc.UnmarshalJSON(bz, &genState); err != nil {
- return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
- }
- return genState.Validate()
-}
-
-// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
-func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
- types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck
-}
-
-// GetTxCmd returns the capability module's root tx command.
-func (a AppModuleBasic) GetTxCmd() *cobra.Command {
- return cli.GetTxCmd()
-}
-
-// GetQueryCmd returns the capability module's root query command.
-func (AppModuleBasic) GetQueryCmd() *cobra.Command {
- return cli.GetQueryCmd()
-}
-
-// ----------------------------------------------------------------------------
-// AppModule
-// ----------------------------------------------------------------------------
-
-// AppModule implements the AppModule interface for the capability module.
-type AppModule struct {
- AppModuleBasic
-
- keeper keeper.Keeper
-}
-
-func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule {
- return AppModule{
- AppModuleBasic: NewAppModuleBasic(cdc),
- keeper: keeper,
- }
-}
-
-// Name returns the capability module's name.
-func (am AppModule) Name() string {
- return am.AppModuleBasic.Name()
-}
-
-// RegisterServices registers a GRPC query service to respond to the
-// module-specific GRPC queries.
-func (am AppModule) RegisterServices(cfg module.Configurator) {
- types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper))
-}
-
-// RegisterInvariants registers the capability module's invariants.
-func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
-
-// InitGenesis performs the capability module's genesis initialization It returns
-// no validator updates.
-func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate {
- var genState types.GenesisState
- // Initialize global index to index in genesis state
- cdc.MustUnmarshalJSON(gs, &genState)
-
- _ = InitGenesis(ctx, am.keeper, genState)
-
- return []abci.ValidatorUpdate{}
-}
-
-// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes.
-func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
- genState := ExportGenesis(ctx, am.keeper)
- return cdc.MustMarshalJSON(genState)
-}
-
-// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
-func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
- BeginBlocker(ctx, am.keeper)
-}
-
-// EndBlock executes all ABCI EndBlock logic respective to the capability module. It
-// returns no validator updates.
-func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
- return []abci.ValidatorUpdate{}
-}
-
-// ___________________________________________________________________________
-
-// AppModuleSimulation functions
-
-// GenerateGenesisState creates a randomized GenState of the epochs module.
-func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
- simulation.RandomizedGenState(simState)
-}
-
-// ProposalContents doesn't return any content functions for governance proposals.
-func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalMsg {
- return nil
-}
-
-// RegisterStoreDecoder registers a decoder for supply module's types.
-func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
-}
-
-// WeightedOperations returns the all the gov module operations with their respective weights.
-func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
- return nil
-}
-
-// ConsensusVersion implements AppModule/ConsensusVersion.
-func (AppModule) ConsensusVersion() uint64 { return 1 }
diff --git a/x/epochs/simulation/genesis.go b/x/epochs/simulation/genesis.go
deleted file mode 100644
index 8a8da4ef1..000000000
--- a/x/epochs/simulation/genesis.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package simulation
-
-// DONTCOVER
-
-import (
- "encoding/json"
- "fmt"
- "time"
-
- "github.com/cosmos/cosmos-sdk/types/module"
-
- "github.com/NibiruChain/nibiru/x/epochs/types"
-)
-
-// RandomizedGenState generates a random GenesisState for mint.
-func RandomizedGenState(simState *module.SimulationState) {
- epochs := []types.EpochInfo{
- {
- Identifier: "day",
- StartTime: time.Time{},
- Duration: time.Hour * 24,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- {
- Identifier: "hour",
- StartTime: time.Time{},
- Duration: time.Hour,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- {
- Identifier: "second",
- StartTime: time.Time{},
- Duration: time.Second,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- }
- epochGenesis := types.NewGenesisState(epochs)
-
- bz, err := json.MarshalIndent(&epochGenesis, "", " ")
- if err != nil {
- panic(err)
- }
-
- // TODO: Do some randomization later
- fmt.Printf("Selected deterministically generated epoch parameters:\n%s\n", bz)
- simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(epochGenesis)
-}
diff --git a/x/epochs/types/epochinfo.go b/x/epochs/types/epochinfo.go
deleted file mode 100644
index efbf7f318..000000000
--- a/x/epochs/types/epochinfo.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package types
-
-import (
- "errors"
-)
-
-// Validate also validates epoch info.
-func (e *EpochInfo) Validate() error {
- if e.Identifier == "" {
- return errors.New("epoch identifier should NOT be empty")
- }
-
- if e.Duration == 0 {
- return errors.New("epoch duration should NOT be 0")
- }
-
- if e.CurrentEpochStartHeight < 0 {
- return errors.New("epoch CurrentEpoch Start Height must be non-negative")
- }
-
- return nil
-}
diff --git a/x/epochs/types/epochinfo_test.go b/x/epochs/types/epochinfo_test.go
deleted file mode 100644
index f6e5d3d6f..000000000
--- a/x/epochs/types/epochinfo_test.go
+++ /dev/null
@@ -1,130 +0,0 @@
-package types
-
-import (
- "testing"
- "time"
-
- "github.com/stretchr/testify/require"
-)
-
-func TestDefaultGenesis(t *testing.T) {
- genState := DefaultGenesis()
-
- expectedEpochs := []EpochInfo{
- {
- Identifier: ThirtyMinuteEpochID,
- StartTime: time.Time{},
- Duration: 30 * time.Minute,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- {
- Identifier: DayEpochID,
- StartTime: time.Time{},
- Duration: 24 * time.Hour,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- {
- Identifier: WeekEpochID,
- StartTime: time.Time{},
- Duration: 7 * 24 * time.Hour,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- }
-
- // Ensure that genState and expectedEpochs are the same
- require.Equal(t, expectedEpochs, genState.Epochs)
-}
-
-func TestEpochInfo_Validate(t *testing.T) {
- tests := []struct {
- name string
- epochInfo EpochInfo
- errString string
- }{
- {
- name: "empty identifier",
- epochInfo: EpochInfo{
- Identifier: "",
- StartTime: time.Now(),
- Duration: 10 * time.Minute,
- CurrentEpoch: 1,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- errString: "epoch identifier should NOT be empty",
- },
- {
- name: "epoch duration 0",
- epochInfo: EpochInfo{
- Identifier: "monthly",
- StartTime: time.Now(),
- Duration: 0,
- CurrentEpoch: 1,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- errString: "epoch duration should NOT be 0",
- },
- {
- name: "current epoch start height negative",
- epochInfo: EpochInfo{
- Identifier: "monthly",
- StartTime: time.Now(),
- Duration: 10 * time.Minute,
- CurrentEpoch: 10,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: -1,
- },
- errString: "epoch CurrentEpoch Start Height must be non-negative",
- },
- }
-
- for _, tc := range tests {
- tc := tc
- t.Run(tc.name, func(t *testing.T) {
- err := tc.epochInfo.Validate()
- require.Error(t, err)
- require.ErrorContains(t, err, tc.errString)
- })
- }
-}
-
-func TestEpochInfo_HappyPath(t *testing.T) {
- tests := []struct {
- name string
- epochInfo EpochInfo
- }{
- {
- name: "empty identifier",
- epochInfo: EpochInfo{
- Identifier: "myEpoch",
- StartTime: time.Now(),
- Duration: 10 * time.Minute,
- CurrentEpoch: 1,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- },
- }
-
- for _, tc := range tests {
- tc := tc
- t.Run(tc.name, func(t *testing.T) {
- err := tc.epochInfo.Validate()
- require.NoError(t, err)
- })
- }
-}
diff --git a/x/epochs/types/errors.go b/x/epochs/types/errors.go
deleted file mode 100644
index 0b103f6b0..000000000
--- a/x/epochs/types/errors.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package types
-
-// DONTCOVER
-
-import (
- sdkerrors "cosmossdk.io/errors"
-)
-
-// x/epochs module sentinel errors.
-var (
- ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error")
-)
diff --git a/x/epochs/types/event.pb.go b/x/epochs/types/event.pb.go
deleted file mode 100644
index b05dc493b..000000000
--- a/x/epochs/types/event.pb.go
+++ /dev/null
@@ -1,518 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/epochs/v1/event.proto
-
-package types
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types"
- _ "google.golang.org/protobuf/types/known/timestamppb"
- io "io"
- math "math"
- math_bits "math/bits"
- time "time"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-var _ = time.Kitchen
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-type EventEpochStart struct {
- // Epoch number, starting from 1.
- EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"`
- // The start timestamp of the epoch.
- EpochStartTime time.Time `protobuf:"bytes,2,opt,name=epoch_start_time,json=epochStartTime,proto3,stdtime" json:"epoch_start_time"`
-}
-
-func (m *EventEpochStart) Reset() { *m = EventEpochStart{} }
-func (m *EventEpochStart) String() string { return proto.CompactTextString(m) }
-func (*EventEpochStart) ProtoMessage() {}
-func (*EventEpochStart) Descriptor() ([]byte, []int) {
- return fileDescriptor_7af14d87a2487e5d, []int{0}
-}
-func (m *EventEpochStart) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventEpochStart) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventEpochStart.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventEpochStart) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventEpochStart.Merge(m, src)
-}
-func (m *EventEpochStart) XXX_Size() int {
- return m.Size()
-}
-func (m *EventEpochStart) XXX_DiscardUnknown() {
- xxx_messageInfo_EventEpochStart.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventEpochStart proto.InternalMessageInfo
-
-func (m *EventEpochStart) GetEpochNumber() uint64 {
- if m != nil {
- return m.EpochNumber
- }
- return 0
-}
-
-func (m *EventEpochStart) GetEpochStartTime() time.Time {
- if m != nil {
- return m.EpochStartTime
- }
- return time.Time{}
-}
-
-type EventEpochEnd struct {
- // Epoch number, starting from 1.
- EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"`
-}
-
-func (m *EventEpochEnd) Reset() { *m = EventEpochEnd{} }
-func (m *EventEpochEnd) String() string { return proto.CompactTextString(m) }
-func (*EventEpochEnd) ProtoMessage() {}
-func (*EventEpochEnd) Descriptor() ([]byte, []int) {
- return fileDescriptor_7af14d87a2487e5d, []int{1}
-}
-func (m *EventEpochEnd) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventEpochEnd) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventEpochEnd.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventEpochEnd) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventEpochEnd.Merge(m, src)
-}
-func (m *EventEpochEnd) XXX_Size() int {
- return m.Size()
-}
-func (m *EventEpochEnd) XXX_DiscardUnknown() {
- xxx_messageInfo_EventEpochEnd.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventEpochEnd proto.InternalMessageInfo
-
-func (m *EventEpochEnd) GetEpochNumber() uint64 {
- if m != nil {
- return m.EpochNumber
- }
- return 0
-}
-
-func init() {
- proto.RegisterType((*EventEpochStart)(nil), "nibiru.epochs.v1.EventEpochStart")
- proto.RegisterType((*EventEpochEnd)(nil), "nibiru.epochs.v1.EventEpochEnd")
-}
-
-func init() { proto.RegisterFile("nibiru/epochs/v1/event.proto", fileDescriptor_7af14d87a2487e5d) }
-
-var fileDescriptor_7af14d87a2487e5d = []byte{
- // 270 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0xcb, 0x4c, 0xca,
- 0x2c, 0x2a, 0xd5, 0x4f, 0x2d, 0xc8, 0x4f, 0xce, 0x28, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b,
- 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0xc8, 0xea, 0x41, 0x64, 0xf5,
- 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x94,
- 0x7c, 0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x3e, 0x98, 0x97, 0x54, 0x9a, 0xa6, 0x5f, 0x92, 0x99,
- 0x9b, 0x5a, 0x5c, 0x92, 0x98, 0x5b, 0x00, 0x51, 0xa0, 0xd4, 0xc2, 0xc8, 0xc5, 0xef, 0x0a, 0x32,
- 0xd8, 0x15, 0x64, 0x52, 0x70, 0x49, 0x62, 0x51, 0x89, 0x90, 0x22, 0x17, 0x0f, 0xd8, 0xdc, 0xf8,
- 0xbc, 0xd2, 0xdc, 0xa4, 0xd4, 0x22, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x96, 0x20, 0x6e, 0xb0, 0x98,
- 0x1f, 0x58, 0x48, 0xc8, 0x8f, 0x4b, 0x00, 0xa2, 0xa4, 0x18, 0xa4, 0x23, 0x1e, 0x64, 0xaa, 0x04,
- 0x93, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x94, 0x1e, 0xc4, 0x4a, 0x3d, 0x98, 0x95, 0x7a, 0x21, 0x30,
- 0x2b, 0x9d, 0x38, 0x4e, 0xdc, 0x93, 0x67, 0x98, 0x70, 0x5f, 0x9e, 0x31, 0x88, 0x2f, 0x15, 0x6e,
- 0x1d, 0x48, 0x5a, 0xc9, 0x88, 0x8b, 0x17, 0xe1, 0x0a, 0xd7, 0xbc, 0x14, 0x22, 0xdc, 0xe0, 0xe4,
- 0x76, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c,
- 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x3a, 0xe9, 0x99, 0x25, 0x19,
- 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x7e, 0xe0, 0x80, 0x72, 0xce, 0x48, 0xcc, 0xcc, 0xd3,
- 0x87, 0x06, 0x69, 0x05, 0x2c, 0x50, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x2e, 0x35,
- 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x58, 0xd4, 0xcd, 0xf7, 0x72, 0x01, 0x00, 0x00,
-}
-
-func (m *EventEpochStart) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventEpochStart) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventEpochStart) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.EpochStartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EpochStartTime):])
- if err1 != nil {
- return 0, err1
- }
- i -= n1
- i = encodeVarintEvent(dAtA, i, uint64(n1))
- i--
- dAtA[i] = 0x12
- if m.EpochNumber != 0 {
- i = encodeVarintEvent(dAtA, i, uint64(m.EpochNumber))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventEpochEnd) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventEpochEnd) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventEpochEnd) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.EpochNumber != 0 {
- i = encodeVarintEvent(dAtA, i, uint64(m.EpochNumber))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintEvent(dAtA []byte, offset int, v uint64) int {
- offset -= sovEvent(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *EventEpochStart) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.EpochNumber != 0 {
- n += 1 + sovEvent(uint64(m.EpochNumber))
- }
- l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EpochStartTime)
- n += 1 + l + sovEvent(uint64(l))
- return n
-}
-
-func (m *EventEpochEnd) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.EpochNumber != 0 {
- n += 1 + sovEvent(uint64(m.EpochNumber))
- }
- return n
-}
-
-func sovEvent(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozEvent(x uint64) (n int) {
- return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *EventEpochStart) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventEpochStart: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventEpochStart: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EpochNumber", wireType)
- }
- m.EpochNumber = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.EpochNumber |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EpochStartTime", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.EpochStartTime, dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventEpochEnd) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventEpochEnd: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventEpochEnd: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EpochNumber", wireType)
- }
- m.EpochNumber = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.EpochNumber |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipEvent(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthEvent
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupEvent
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthEvent
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/epochs/types/export.go b/x/epochs/types/export.go
deleted file mode 100644
index fb4b6e3b6..000000000
--- a/x/epochs/types/export.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package types
-
-import (
- grpc "google.golang.org/grpc"
-)
-
-// GrpcQueryServiceDesc represents the query server's RPC service specification.
-// This gives access to the service name and method names needed for stargate
-// queries.
-func GrpcQueryServiceDesc() grpc.ServiceDesc {
- return _Query_serviceDesc
-}
diff --git a/x/epochs/types/genesis.go b/x/epochs/types/genesis.go
deleted file mode 100644
index 2c1aea11d..000000000
--- a/x/epochs/types/genesis.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package types
-
-import (
- "errors"
- "time"
-)
-
-func NewGenesisState(epochs []EpochInfo) *GenesisState {
- return &GenesisState{Epochs: epochs}
-}
-
-// DefaultGenesis returns the default Capability genesis state.
-func DefaultGenesis() *GenesisState {
- startTime := time.Time{}
- return DefaultGenesisFromTime(startTime)
-}
-
-func DefaultGenesisFromTime(startTime time.Time) *GenesisState {
- epochs := []EpochInfo{
- {
- Identifier: ThirtyMinuteEpochID,
- StartTime: startTime,
- Duration: 30 * time.Minute,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: startTime,
- EpochCountingStarted: false,
- },
- {
- Identifier: DayEpochID,
- StartTime: startTime,
- Duration: 24 * time.Hour,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: startTime,
- EpochCountingStarted: false,
- },
- {
- Identifier: WeekEpochID,
- StartTime: startTime,
- Duration: 7 * 24 * time.Hour,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: startTime,
- EpochCountingStarted: false,
- },
- }
-
- return NewGenesisState(epochs)
-}
-
-// Validate performs basic genesis state validation returning an error upon any
-// failure.
-func (gs GenesisState) Validate() error {
- epochIdentifiers := map[string]bool{}
- for _, epoch := range gs.Epochs {
- if epochIdentifiers[epoch.Identifier] {
- return errors.New("epoch identifier should be unique")
- }
-
- if err := epoch.Validate(); err != nil {
- return err
- }
-
- epochIdentifiers[epoch.Identifier] = true
- }
-
- return nil
-}
diff --git a/x/epochs/types/genesis.pb.go b/x/epochs/types/genesis.pb.go
deleted file mode 100644
index 84b413ce0..000000000
--- a/x/epochs/types/genesis.pb.go
+++ /dev/null
@@ -1,334 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/epochs/v1/genesis.proto
-
-package types
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/protobuf/types/known/durationpb"
- _ "google.golang.org/protobuf/types/known/timestamppb"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// GenesisState defines the epochs module's genesis state.
-type GenesisState struct {
- Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"`
-}
-
-func (m *GenesisState) Reset() { *m = GenesisState{} }
-func (m *GenesisState) String() string { return proto.CompactTextString(m) }
-func (*GenesisState) ProtoMessage() {}
-func (*GenesisState) Descriptor() ([]byte, []int) {
- return fileDescriptor_0e52385b95ea69b9, []int{0}
-}
-func (m *GenesisState) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *GenesisState) XXX_Merge(src proto.Message) {
- xxx_messageInfo_GenesisState.Merge(m, src)
-}
-func (m *GenesisState) XXX_Size() int {
- return m.Size()
-}
-func (m *GenesisState) XXX_DiscardUnknown() {
- xxx_messageInfo_GenesisState.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_GenesisState proto.InternalMessageInfo
-
-func (m *GenesisState) GetEpochs() []EpochInfo {
- if m != nil {
- return m.Epochs
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*GenesisState)(nil), "nibiru.epochs.v1.GenesisState")
-}
-
-func init() { proto.RegisterFile("nibiru/epochs/v1/genesis.proto", fileDescriptor_0e52385b95ea69b9) }
-
-var fileDescriptor_0e52385b95ea69b9 = []byte{
- // 237 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcb, 0xcb, 0x4c, 0xca,
- 0x2c, 0x2a, 0xd5, 0x4f, 0x2d, 0xc8, 0x4f, 0xce, 0x28, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd,
- 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0xc8, 0xeb, 0x41,
- 0xe4, 0xf5, 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44,
- 0x9d, 0x94, 0x5c, 0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x3e, 0x98, 0x97, 0x54, 0x9a, 0xa6, 0x9f,
- 0x52, 0x5a, 0x94, 0x58, 0x92, 0x99, 0x9f, 0x07, 0x95, 0x97, 0x47, 0x97, 0x2f, 0xc9, 0xcc, 0x4d,
- 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0x80, 0x2a, 0x90, 0xc1, 0x70, 0x48, 0x71, 0x49, 0x62, 0x49, 0x2a,
- 0x44, 0x56, 0xc9, 0x93, 0x8b, 0xc7, 0x1d, 0xe2, 0xae, 0x60, 0x90, 0xa8, 0x90, 0x25, 0x17, 0x1b,
- 0x44, 0xa1, 0x04, 0xa3, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0xb4, 0x1e, 0xba, 0x3b, 0xf5, 0x5c, 0x41,
- 0x2c, 0xcf, 0xbc, 0xb4, 0x7c, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x1a, 0x9c, 0xdc,
- 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5,
- 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x27, 0x3d, 0xb3, 0x24, 0xa3,
- 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xdf, 0x0f, 0x6c, 0x9c, 0x73, 0x46, 0x62, 0x66, 0x9e, 0x3e,
- 0xd4, 0x65, 0x15, 0x30, 0xb7, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x5d, 0x66, 0x0c,
- 0x08, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x99, 0x59, 0x11, 0x42, 0x01, 0x00, 0x00,
-}
-
-func (m *GenesisState) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Epochs) > 0 {
- for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Epochs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
- offset -= sovGenesis(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *GenesisState) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Epochs) > 0 {
- for _, e := range m.Epochs {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- return n
-}
-
-func sovGenesis(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozGenesis(x uint64) (n int) {
- return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *GenesisState) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Epochs", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Epochs = append(m.Epochs, EpochInfo{})
- if err := m.Epochs[len(m.Epochs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipGenesis(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenesis
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipGenesis(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthGenesis
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupGenesis
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenesis
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/epochs/types/genesis_test.go b/x/epochs/types/genesis_test.go
deleted file mode 100644
index 62e7dcdf6..000000000
--- a/x/epochs/types/genesis_test.go
+++ /dev/null
@@ -1,136 +0,0 @@
-package types
-
-import (
- "testing"
- "time"
-
- "github.com/stretchr/testify/require"
-)
-
-func TestGenesisState_Validate(t *testing.T) {
- tests := []struct {
- name string
- genState GenesisState
- errString string
- }{
- {
- name: "duplicate epochinfo",
- genState: GenesisState{
- Epochs: []EpochInfo{
- {
- Identifier: "repeated",
- StartTime: time.Now(),
- Duration: 10,
- CurrentEpoch: 2,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- {
- Identifier: "someOther",
- StartTime: time.Now(),
- Duration: 10,
- CurrentEpoch: 2,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- {
- Identifier: "repeated",
- StartTime: time.Now(),
- Duration: 10,
- CurrentEpoch: 2,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- },
- },
- errString: "epoch identifier should be unique",
- },
- {
- name: "at least one invalid epochinfo",
- genState: GenesisState{
- Epochs: []EpochInfo{
- {
- Identifier: "repeated",
- StartTime: time.Now(),
- Duration: 10,
- CurrentEpoch: 2,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- {
- Identifier: "someOther",
- StartTime: time.Now(),
- Duration: 10,
- CurrentEpoch: 2,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- {
- Identifier: "the invalid",
- StartTime: time.Now(),
- Duration: 0,
- CurrentEpoch: 2,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- },
- },
- errString: "epoch duration should NOT be 0",
- },
- }
-
- for _, tc := range tests {
- tc := tc
- t.Run(tc.name, func(t *testing.T) {
- err := tc.genState.Validate()
- require.ErrorContains(t, err, tc.errString)
- })
- }
-}
-
-func TestGenesisState_HappyPath(t *testing.T) {
- tests := []struct {
- name string
- genState GenesisState
- }{
- {
- name: "duplicate epochinfo",
- genState: GenesisState{
- Epochs: []EpochInfo{
- {
- Identifier: "firstOne",
- StartTime: time.Now(),
- Duration: 10,
- CurrentEpoch: 2,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- {
- Identifier: "someOther",
- StartTime: time.Now(),
- Duration: 10,
- CurrentEpoch: 2,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 1,
- },
- },
- },
- },
- }
-
- for _, tc := range tests {
- tc := tc
- t.Run(tc.name, func(t *testing.T) {
- err := tc.genState.Validate()
- require.NoError(t, err)
- })
- }
-}
diff --git a/x/epochs/types/hooks.go b/x/epochs/types/hooks.go
deleted file mode 100644
index ee32a2d81..000000000
--- a/x/epochs/types/hooks.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package types
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// EpochHooks defines a set of lifecycle hooks to occur in the ABCI BeginBlock
-// hooks based on temporal epochs.
-type EpochHooks interface {
- // AfterEpochEnd the first block whose timestamp is after the duration is
- // counted as the end of the epoch
- AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber uint64)
- // BeforeEpochStart new epoch is next block of epoch end block
- BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber uint64)
-}
-
-var _ EpochHooks = MultiEpochHooks{}
-
-// MultiEpochHooks combines multiple [EpochHooks]. All hook functions are
-// executed sequentially in the order of the slice.
-type MultiEpochHooks []EpochHooks
-
-func NewMultiEpochHooks(hooks ...EpochHooks) MultiEpochHooks {
- return hooks
-}
-
-// AfterEpochEnd runs logic at the end of an epoch.
-//
-// - epochIdentifier: The unique identifier of specific epoch. Ex: "30 min", "1 min".
-// - epochNumber: Counter for the specific epoch type identified.
-func (h MultiEpochHooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber uint64) {
- for i := range h {
- h[i].AfterEpochEnd(ctx, epochIdentifier, epochNumber)
- }
-}
-
-// BeforeEpochStart runs logic in the ABCI BeginBlocker right before an epoch
-// starts.
-//
-// - epochIdentifier: The unique identifier of specific epoch. Ex: "30 min", "1 min".
-// - epochNumber: Counter for the specific epoch type identified.
-func (h MultiEpochHooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber uint64) {
- for i := range h {
- h[i].BeforeEpochStart(ctx, epochIdentifier, epochNumber)
- }
-}
diff --git a/x/epochs/types/hooks_test.go b/x/epochs/types/hooks_test.go
deleted file mode 100644
index 063843533..000000000
--- a/x/epochs/types/hooks_test.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package types_test
-
-import (
- "testing"
-
- "github.com/stretchr/testify/mock"
-
- "github.com/NibiruChain/nibiru/x/epochs/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// Define a MockEpochHooks type
-type MockEpochHooks struct {
- mock.Mock
-}
-
-func (h *MockEpochHooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber uint64) {
- h.Called(ctx, epochIdentifier, epochNumber)
-}
-
-func (h *MockEpochHooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber uint64) {
- h.Called(ctx, epochIdentifier, epochNumber)
-}
-
-func TestAfterEpochEnd(t *testing.T) {
- hook1 := new(MockEpochHooks)
- hook2 := new(MockEpochHooks)
- hooks := types.NewMultiEpochHooks(hook1, hook2)
-
- ctx := sdk.Context{}
- epochIdentifier := "testID"
- epochNumber := uint64(10)
-
- hook1.On("AfterEpochEnd", ctx, epochIdentifier, epochNumber)
- hook2.On("AfterEpochEnd", ctx, epochIdentifier, epochNumber)
-
- hooks.AfterEpochEnd(ctx, epochIdentifier, epochNumber)
-
- hook1.AssertExpectations(t)
- hook2.AssertExpectations(t)
-}
-
-func TestBeforeEpochStart(t *testing.T) {
- hook1 := new(MockEpochHooks)
- hook2 := new(MockEpochHooks)
- hooks := types.NewMultiEpochHooks(hook1, hook2)
-
- ctx := sdk.Context{}
- epochIdentifier := "testID"
- epochNumber := uint64(10)
-
- hook1.On("BeforeEpochStart", ctx, epochIdentifier, epochNumber)
- hook2.On("BeforeEpochStart", ctx, epochIdentifier, epochNumber)
-
- hooks.BeforeEpochStart(ctx, epochIdentifier, epochNumber)
-
- hook1.AssertExpectations(t)
- hook2.AssertExpectations(t)
-}
diff --git a/x/epochs/types/identifier.go b/x/epochs/types/identifier.go
deleted file mode 100644
index 3dd3012cb..000000000
--- a/x/epochs/types/identifier.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package types
-
-import (
- "fmt"
- "strings"
-)
-
-const (
- // WeekEpochID defines the identifier for weekly epochs
- WeekEpochID = "week"
- // DayEpochID defines the identifier for daily epochs
- DayEpochID = "day"
- // HourEpochID defines the identifier for hourly epochs
- HourEpochID = "hour"
- // FifteenMinuteEpochID defines the identifier for 15 minute epochs
- FifteenMinuteEpochID = "15 min"
- // ThirtyMinuteEpochID defines the identifier for 30 minute epochs
- ThirtyMinuteEpochID = "30 min"
-)
-
-// ValidateEpochIdentifierInterface performs a stateless
-// validation of the epoch ID interface.
-func ValidateEpochIdentifierInterface(i interface{}) error {
- v, ok := i.(string)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
-
- return ValidateEpochIdentifierString(v)
-}
-
-// ValidateEpochIdentifierString performs a stateless
-// validation of the epoch ID.
-func ValidateEpochIdentifierString(s string) error {
- s = strings.TrimSpace(s)
- if s == "" {
- return fmt.Errorf("blank epoch identifier: %s", s)
- }
- return nil
-}
diff --git a/x/epochs/types/identifier_test.go b/x/epochs/types/identifier_test.go
deleted file mode 100644
index 5eb375acd..000000000
--- a/x/epochs/types/identifier_test.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package types
-
-import (
- "testing"
-
- "github.com/stretchr/testify/require"
-)
-
-func TestValidateEpochIdentifierInterface(t *testing.T) {
- testCases := []struct {
- name string
- id interface{}
- expectPass bool
- }{
- {
- "invalid - blank identifier",
- "",
- false,
- },
- {
- "invalid - blank identifier with spaces",
- " ",
- false,
- },
- {
- "invalid - non-string",
- 3,
- false,
- },
- {
- "pass",
- WeekEpochID,
- true,
- },
- }
-
- for _, tc := range testCases {
- err := ValidateEpochIdentifierInterface(tc.id)
-
- if tc.expectPass {
- require.NoError(t, err)
- } else {
- require.Error(t, err)
- }
- }
-}
diff --git a/x/epochs/types/keys.go b/x/epochs/types/keys.go
deleted file mode 100644
index 4c6186fe5..000000000
--- a/x/epochs/types/keys.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package types
-
-const (
- // ModuleName defines the module name.
- ModuleName = "epochs"
-
- // StoreKey defines the primary module store key.
- StoreKey = ModuleName
-
- // RouterKey is the message route for slashing.
- RouterKey = ModuleName
-
- // QuerierRoute defines the module's query routing key.
- QuerierRoute = ModuleName
-)
-
-// KeyPrefixEpoch defines prefix key for storing epochs.
-var KeyPrefixEpoch = []byte{0x01}
diff --git a/x/epochs/types/query.pb.go b/x/epochs/types/query.pb.go
deleted file mode 100644
index bab7018fb..000000000
--- a/x/epochs/types/query.pb.go
+++ /dev/null
@@ -1,912 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/epochs/v1/query.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- _ "github.com/cosmos/cosmos-sdk/types/query"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-type QueryEpochInfosRequest struct {
-}
-
-func (m *QueryEpochInfosRequest) Reset() { *m = QueryEpochInfosRequest{} }
-func (m *QueryEpochInfosRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryEpochInfosRequest) ProtoMessage() {}
-func (*QueryEpochInfosRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_2d273c3d69b40555, []int{0}
-}
-func (m *QueryEpochInfosRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryEpochInfosRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryEpochInfosRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryEpochInfosRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryEpochInfosRequest.Merge(m, src)
-}
-func (m *QueryEpochInfosRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryEpochInfosRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryEpochInfosRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryEpochInfosRequest proto.InternalMessageInfo
-
-type QueryEpochInfosResponse struct {
- Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"`
-}
-
-func (m *QueryEpochInfosResponse) Reset() { *m = QueryEpochInfosResponse{} }
-func (m *QueryEpochInfosResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryEpochInfosResponse) ProtoMessage() {}
-func (*QueryEpochInfosResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_2d273c3d69b40555, []int{1}
-}
-func (m *QueryEpochInfosResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryEpochInfosResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryEpochInfosResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryEpochInfosResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryEpochInfosResponse.Merge(m, src)
-}
-func (m *QueryEpochInfosResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryEpochInfosResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryEpochInfosResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryEpochInfosResponse proto.InternalMessageInfo
-
-func (m *QueryEpochInfosResponse) GetEpochs() []EpochInfo {
- if m != nil {
- return m.Epochs
- }
- return nil
-}
-
-type QueryCurrentEpochRequest struct {
- Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
-}
-
-func (m *QueryCurrentEpochRequest) Reset() { *m = QueryCurrentEpochRequest{} }
-func (m *QueryCurrentEpochRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryCurrentEpochRequest) ProtoMessage() {}
-func (*QueryCurrentEpochRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_2d273c3d69b40555, []int{2}
-}
-func (m *QueryCurrentEpochRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryCurrentEpochRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryCurrentEpochRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryCurrentEpochRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryCurrentEpochRequest.Merge(m, src)
-}
-func (m *QueryCurrentEpochRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryCurrentEpochRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryCurrentEpochRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryCurrentEpochRequest proto.InternalMessageInfo
-
-func (m *QueryCurrentEpochRequest) GetIdentifier() string {
- if m != nil {
- return m.Identifier
- }
- return ""
-}
-
-type QueryCurrentEpochResponse struct {
- CurrentEpoch uint64 `protobuf:"varint,1,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"`
-}
-
-func (m *QueryCurrentEpochResponse) Reset() { *m = QueryCurrentEpochResponse{} }
-func (m *QueryCurrentEpochResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryCurrentEpochResponse) ProtoMessage() {}
-func (*QueryCurrentEpochResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_2d273c3d69b40555, []int{3}
-}
-func (m *QueryCurrentEpochResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryCurrentEpochResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryCurrentEpochResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryCurrentEpochResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryCurrentEpochResponse.Merge(m, src)
-}
-func (m *QueryCurrentEpochResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryCurrentEpochResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryCurrentEpochResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryCurrentEpochResponse proto.InternalMessageInfo
-
-func (m *QueryCurrentEpochResponse) GetCurrentEpoch() uint64 {
- if m != nil {
- return m.CurrentEpoch
- }
- return 0
-}
-
-func init() {
- proto.RegisterType((*QueryEpochInfosRequest)(nil), "nibiru.epochs.v1.QueryEpochInfosRequest")
- proto.RegisterType((*QueryEpochInfosResponse)(nil), "nibiru.epochs.v1.QueryEpochInfosResponse")
- proto.RegisterType((*QueryCurrentEpochRequest)(nil), "nibiru.epochs.v1.QueryCurrentEpochRequest")
- proto.RegisterType((*QueryCurrentEpochResponse)(nil), "nibiru.epochs.v1.QueryCurrentEpochResponse")
-}
-
-func init() { proto.RegisterFile("nibiru/epochs/v1/query.proto", fileDescriptor_2d273c3d69b40555) }
-
-var fileDescriptor_2d273c3d69b40555 = []byte{
- // 412 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x4d, 0x8b, 0xd3, 0x40,
- 0x18, 0xce, 0xd4, 0x5a, 0x70, 0xac, 0x20, 0x83, 0x68, 0x8c, 0x35, 0x2d, 0xf1, 0x83, 0x5a, 0x4b,
- 0x86, 0xd4, 0x93, 0x9e, 0xa4, 0x45, 0xc1, 0x8b, 0x60, 0xf0, 0xe4, 0x45, 0x26, 0x71, 0x9a, 0x0e,
- 0xd8, 0x99, 0x34, 0x33, 0x29, 0xf6, 0xea, 0xc9, 0xa3, 0xb0, 0xec, 0x9f, 0xd8, 0x5f, 0xd2, 0x63,
- 0x61, 0x2f, 0x7b, 0x5a, 0x96, 0x76, 0x7f, 0xc8, 0xd2, 0x99, 0x74, 0xb7, 0xdb, 0x0f, 0xe8, 0x2d,
- 0x99, 0xe7, 0xe3, 0x7d, 0x9e, 0x77, 0x06, 0xd6, 0x38, 0x8b, 0x58, 0x96, 0x63, 0x9a, 0x8a, 0x78,
- 0x20, 0xf1, 0x38, 0xc0, 0xa3, 0x9c, 0x66, 0x13, 0x3f, 0xcd, 0x84, 0x12, 0xe8, 0xa1, 0x41, 0x7d,
- 0x83, 0xfa, 0xe3, 0xc0, 0x79, 0x94, 0x88, 0x44, 0x68, 0x10, 0x2f, 0xbf, 0x0c, 0xcf, 0xa9, 0x25,
- 0x42, 0x24, 0xbf, 0x29, 0x26, 0x29, 0xc3, 0x84, 0x73, 0xa1, 0x88, 0x62, 0x82, 0xcb, 0x02, 0x6d,
- 0xc5, 0x42, 0x0e, 0x85, 0xc4, 0x11, 0x91, 0xd4, 0xd8, 0xe3, 0x71, 0x10, 0x51, 0x45, 0x02, 0x9c,
- 0x92, 0x84, 0x71, 0x4d, 0x5e, 0x39, 0x6d, 0xe5, 0x91, 0x8a, 0x28, 0x6a, 0x50, 0xcf, 0x86, 0x8f,
- 0xbf, 0x2d, 0xf5, 0x9f, 0x96, 0xe8, 0x17, 0xde, 0x17, 0x32, 0xa4, 0xa3, 0x9c, 0x4a, 0xe5, 0x7d,
- 0x87, 0x4f, 0xb6, 0x10, 0x99, 0x0a, 0x2e, 0x29, 0x7a, 0x0f, 0x2b, 0xc6, 0xcd, 0x06, 0x8d, 0x3b,
- 0xcd, 0xfb, 0x9d, 0x67, 0xfe, 0x66, 0x2b, 0xff, 0x5a, 0xd5, 0x2d, 0x4f, 0xcf, 0xeb, 0x56, 0x58,
- 0x08, 0xbc, 0x0f, 0xd0, 0xd6, 0xae, 0xbd, 0x3c, 0xcb, 0x28, 0x57, 0x9a, 0x56, 0x4c, 0x44, 0x2e,
- 0x84, 0xec, 0x17, 0xe5, 0x8a, 0xf5, 0x19, 0xcd, 0x6c, 0xd0, 0x00, 0xcd, 0x7b, 0xe1, 0xda, 0x89,
- 0xf7, 0x11, 0x3e, 0xdd, 0xa1, 0x2d, 0x32, 0xbd, 0x80, 0x0f, 0x62, 0x73, 0xfe, 0x53, 0x8f, 0xd2,
- 0xfa, 0x72, 0x58, 0x8d, 0xd7, 0xc8, 0x9d, 0x93, 0x12, 0xbc, 0xab, 0x2d, 0xd0, 0x3f, 0x00, 0xe1,
- 0x4d, 0x33, 0xd4, 0xdc, 0x6e, 0xb0, 0x7b, 0x2d, 0xce, 0x9b, 0x03, 0x98, 0x26, 0x92, 0xf7, 0xea,
- 0xef, 0xe9, 0xe5, 0x51, 0xa9, 0x8e, 0x9e, 0xe3, 0xcd, 0x2b, 0x30, 0x57, 0x65, 0x7e, 0xd1, 0x31,
- 0x80, 0xd5, 0xf5, 0x4a, 0xa8, 0xb5, 0x67, 0xc4, 0x8e, 0x9d, 0x39, 0x6f, 0x0f, 0xe2, 0x16, 0x81,
- 0xda, 0x3a, 0xd0, 0x6b, 0xf4, 0x72, 0x4f, 0xa0, 0x5b, 0x0b, 0xec, 0x7e, 0x9e, 0xce, 0x5d, 0x30,
- 0x9b, 0xbb, 0xe0, 0x62, 0xee, 0x82, 0xff, 0x0b, 0xd7, 0x9a, 0x2d, 0x5c, 0xeb, 0x6c, 0xe1, 0x5a,
- 0x3f, 0xda, 0x09, 0x53, 0x83, 0x3c, 0xf2, 0x63, 0x31, 0xc4, 0x5f, 0xb5, 0x53, 0x6f, 0x40, 0x18,
- 0x5f, 0xb9, 0xfe, 0x59, 0xf9, 0xaa, 0x49, 0x4a, 0x65, 0x54, 0xd1, 0x2f, 0xed, 0xdd, 0x55, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0xe7, 0x96, 0x70, 0xa3, 0x19, 0x03, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// QueryClient is the client API for Query service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type QueryClient interface {
- // EpochInfos provide running epochInfos
- EpochInfos(ctx context.Context, in *QueryEpochInfosRequest, opts ...grpc.CallOption) (*QueryEpochInfosResponse, error)
- // CurrentEpoch provide current epoch of specified identifier
- CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error)
-}
-
-type queryClient struct {
- cc grpc1.ClientConn
-}
-
-func NewQueryClient(cc grpc1.ClientConn) QueryClient {
- return &queryClient{cc}
-}
-
-func (c *queryClient) EpochInfos(ctx context.Context, in *QueryEpochInfosRequest, opts ...grpc.CallOption) (*QueryEpochInfosResponse, error) {
- out := new(QueryEpochInfosResponse)
- err := c.cc.Invoke(ctx, "/nibiru.epochs.v1.Query/EpochInfos", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error) {
- out := new(QueryCurrentEpochResponse)
- err := c.cc.Invoke(ctx, "/nibiru.epochs.v1.Query/CurrentEpoch", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// QueryServer is the server API for Query service.
-type QueryServer interface {
- // EpochInfos provide running epochInfos
- EpochInfos(context.Context, *QueryEpochInfosRequest) (*QueryEpochInfosResponse, error)
- // CurrentEpoch provide current epoch of specified identifier
- CurrentEpoch(context.Context, *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error)
-}
-
-// UnimplementedQueryServer can be embedded to have forward compatible implementations.
-type UnimplementedQueryServer struct {
-}
-
-func (*UnimplementedQueryServer) EpochInfos(ctx context.Context, req *QueryEpochInfosRequest) (*QueryEpochInfosResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EpochInfos not implemented")
-}
-func (*UnimplementedQueryServer) CurrentEpoch(ctx context.Context, req *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method CurrentEpoch not implemented")
-}
-
-func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
- s.RegisterService(&_Query_serviceDesc, srv)
-}
-
-func _Query_EpochInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryEpochInfosRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).EpochInfos(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.epochs.v1.Query/EpochInfos",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).EpochInfos(ctx, req.(*QueryEpochInfosRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_CurrentEpoch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryCurrentEpochRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).CurrentEpoch(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.epochs.v1.Query/CurrentEpoch",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).CurrentEpoch(ctx, req.(*QueryCurrentEpochRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Query_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.epochs.v1.Query",
- HandlerType: (*QueryServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "EpochInfos",
- Handler: _Query_EpochInfos_Handler,
- },
- {
- MethodName: "CurrentEpoch",
- Handler: _Query_CurrentEpoch_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/epochs/v1/query.proto",
-}
-
-func (m *QueryEpochInfosRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryEpochInfosRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryEpochInfosRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryEpochInfosResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryEpochInfosResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryEpochInfosResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Epochs) > 0 {
- for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Epochs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryCurrentEpochRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryCurrentEpochRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryCurrentEpochRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Identifier) > 0 {
- i -= len(m.Identifier)
- copy(dAtA[i:], m.Identifier)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Identifier)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryCurrentEpochResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryCurrentEpochResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryCurrentEpochResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.CurrentEpoch != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.CurrentEpoch))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
- offset -= sovQuery(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *QueryEpochInfosRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryEpochInfosResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Epochs) > 0 {
- for _, e := range m.Epochs {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- return n
-}
-
-func (m *QueryCurrentEpochRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Identifier)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryCurrentEpochResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.CurrentEpoch != 0 {
- n += 1 + sovQuery(uint64(m.CurrentEpoch))
- }
- return n
-}
-
-func sovQuery(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozQuery(x uint64) (n int) {
- return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *QueryEpochInfosRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryEpochInfosRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryEpochInfosRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryEpochInfosResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryEpochInfosResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryEpochInfosResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Epochs", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Epochs = append(m.Epochs, EpochInfo{})
- if err := m.Epochs[len(m.Epochs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryCurrentEpochRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryCurrentEpochRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryCurrentEpochRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Identifier = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryCurrentEpochResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryCurrentEpochResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryCurrentEpochResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType)
- }
- m.CurrentEpoch = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.CurrentEpoch |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipQuery(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthQuery
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupQuery
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthQuery
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/epochs/types/query.pb.gw.go b/x/epochs/types/query.pb.gw.go
deleted file mode 100644
index 3286ae0bc..000000000
--- a/x/epochs/types/query.pb.gw.go
+++ /dev/null
@@ -1,236 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: nibiru/epochs/v1/query.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-func request_Query_EpochInfos_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryEpochInfosRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.EpochInfos(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_EpochInfos_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryEpochInfosRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.EpochInfos(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Query_CurrentEpoch_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Query_CurrentEpoch_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryCurrentEpochRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CurrentEpoch_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.CurrentEpoch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_CurrentEpoch_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryCurrentEpochRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CurrentEpoch_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.CurrentEpoch(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
-// UnaryRPC :call QueryServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
-func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
-
- mux.Handle("GET", pattern_Query_EpochInfos_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_EpochInfos_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EpochInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_CurrentEpoch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_CurrentEpoch_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_CurrentEpoch_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterQueryHandler(ctx, mux, conn)
-}
-
-// RegisterQueryHandler registers the http handlers for service Query to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
-}
-
-// RegisterQueryHandlerClient registers the http handlers for service Query
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "QueryClient" to call the correct interceptors.
-func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
-
- mux.Handle("GET", pattern_Query_EpochInfos_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_EpochInfos_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EpochInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_CurrentEpoch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_CurrentEpoch_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_CurrentEpoch_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Query_EpochInfos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"nibiru", "epochs", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_CurrentEpoch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "epochs", "v1beta1", "current_epoch"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Query_EpochInfos_0 = runtime.ForwardResponseMessage
-
- forward_Query_CurrentEpoch_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/epochs/types/state.pb.go b/x/epochs/types/state.pb.go
deleted file mode 100644
index d4a2c07ac..000000000
--- a/x/epochs/types/state.pb.go
+++ /dev/null
@@ -1,610 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/epochs/v1/state.proto
-
-package types
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types"
- _ "google.golang.org/protobuf/types/known/durationpb"
- _ "google.golang.org/protobuf/types/known/timestamppb"
- io "io"
- math "math"
- math_bits "math/bits"
- time "time"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-var _ = time.Kitchen
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-type EpochInfo struct {
- // A string identifier for the epoch. e.g. "15min" or "1hour"
- Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
- // When the epoch repetitino should start.
- StartTime time.Time `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"`
- // How long each epoch lasts for.
- Duration time.Duration `protobuf:"bytes,3,opt,name=duration,proto3,stdduration" json:"duration,omitempty" yaml:"duration"`
- // The current epoch number, starting from 1.
- CurrentEpoch uint64 `protobuf:"varint,4,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"`
- // The start timestamp of the current epoch.
- CurrentEpochStartTime time.Time `protobuf:"bytes,5,opt,name=current_epoch_start_time,json=currentEpochStartTime,proto3,stdtime" json:"current_epoch_start_time" yaml:"current_epoch_start_time"`
- // Whether or not this epoch has started. Set to true if current blocktime >=
- // start_time.
- EpochCountingStarted bool `protobuf:"varint,6,opt,name=epoch_counting_started,json=epochCountingStarted,proto3" json:"epoch_counting_started,omitempty"`
- // The block height at which the current epoch started at.
- CurrentEpochStartHeight int64 `protobuf:"varint,7,opt,name=current_epoch_start_height,json=currentEpochStartHeight,proto3" json:"current_epoch_start_height,omitempty"`
-}
-
-func (m *EpochInfo) Reset() { *m = EpochInfo{} }
-func (m *EpochInfo) String() string { return proto.CompactTextString(m) }
-func (*EpochInfo) ProtoMessage() {}
-func (*EpochInfo) Descriptor() ([]byte, []int) {
- return fileDescriptor_8bd50db1722dd5e6, []int{0}
-}
-func (m *EpochInfo) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EpochInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EpochInfo.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EpochInfo) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EpochInfo.Merge(m, src)
-}
-func (m *EpochInfo) XXX_Size() int {
- return m.Size()
-}
-func (m *EpochInfo) XXX_DiscardUnknown() {
- xxx_messageInfo_EpochInfo.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EpochInfo proto.InternalMessageInfo
-
-func (m *EpochInfo) GetIdentifier() string {
- if m != nil {
- return m.Identifier
- }
- return ""
-}
-
-func (m *EpochInfo) GetStartTime() time.Time {
- if m != nil {
- return m.StartTime
- }
- return time.Time{}
-}
-
-func (m *EpochInfo) GetDuration() time.Duration {
- if m != nil {
- return m.Duration
- }
- return 0
-}
-
-func (m *EpochInfo) GetCurrentEpoch() uint64 {
- if m != nil {
- return m.CurrentEpoch
- }
- return 0
-}
-
-func (m *EpochInfo) GetCurrentEpochStartTime() time.Time {
- if m != nil {
- return m.CurrentEpochStartTime
- }
- return time.Time{}
-}
-
-func (m *EpochInfo) GetEpochCountingStarted() bool {
- if m != nil {
- return m.EpochCountingStarted
- }
- return false
-}
-
-func (m *EpochInfo) GetCurrentEpochStartHeight() int64 {
- if m != nil {
- return m.CurrentEpochStartHeight
- }
- return 0
-}
-
-func init() {
- proto.RegisterType((*EpochInfo)(nil), "nibiru.epochs.v1.EpochInfo")
-}
-
-func init() { proto.RegisterFile("nibiru/epochs/v1/state.proto", fileDescriptor_8bd50db1722dd5e6) }
-
-var fileDescriptor_8bd50db1722dd5e6 = []byte{
- // 433 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xb1, 0x6f, 0xd4, 0x30,
- 0x14, 0xc6, 0x63, 0x7a, 0x94, 0x9e, 0x01, 0x01, 0x56, 0x81, 0x10, 0x81, 0x13, 0x85, 0x25, 0x12,
- 0x55, 0xac, 0x03, 0x26, 0xd8, 0xae, 0x80, 0x60, 0x61, 0x48, 0x19, 0x10, 0xcb, 0x29, 0xc9, 0xf9,
- 0x12, 0x4b, 0x8d, 0x1d, 0x25, 0x2f, 0x15, 0xb7, 0x31, 0x33, 0x75, 0xe4, 0x4f, 0xea, 0xd8, 0x91,
- 0x29, 0xa0, 0xbb, 0x8d, 0xb1, 0x7f, 0x01, 0x8a, 0x9d, 0x94, 0x83, 0x82, 0xd8, 0x92, 0xf7, 0xfb,
- 0xde, 0xf7, 0xf9, 0x3d, 0x3d, 0x7c, 0x5f, 0x8a, 0x44, 0x54, 0x0d, 0xe3, 0xa5, 0x4a, 0xf3, 0x9a,
- 0x1d, 0x4d, 0x58, 0x0d, 0x31, 0xf0, 0xb0, 0xac, 0x14, 0x28, 0x72, 0xd3, 0xd0, 0xd0, 0xd0, 0xf0,
- 0x68, 0xe2, 0xec, 0x66, 0x2a, 0x53, 0x1a, 0xb2, 0xee, 0xcb, 0xe8, 0x1c, 0x9a, 0x29, 0x95, 0x1d,
- 0x72, 0xa6, 0xff, 0x92, 0x66, 0xc1, 0xe6, 0x4d, 0x15, 0x83, 0x50, 0xb2, 0xe7, 0xee, 0x9f, 0x1c,
- 0x44, 0xc1, 0x6b, 0x88, 0x8b, 0xd2, 0x08, 0xfc, 0xcf, 0x23, 0x3c, 0x7e, 0xd9, 0x85, 0xbc, 0x91,
- 0x0b, 0x45, 0x28, 0xc6, 0x62, 0xce, 0x25, 0x88, 0x85, 0xe0, 0x95, 0x8d, 0x3c, 0x14, 0x8c, 0xa3,
- 0x8d, 0x0a, 0x79, 0x8f, 0x71, 0x0d, 0x71, 0x05, 0xb3, 0xce, 0xc6, 0xbe, 0xe4, 0xa1, 0xe0, 0xea,
- 0x63, 0x27, 0x34, 0x19, 0xe1, 0x90, 0x11, 0xbe, 0x1b, 0x32, 0xa6, 0x0f, 0x4e, 0x5a, 0xd7, 0x3a,
- 0x6b, 0xdd, 0x5b, 0xcb, 0xb8, 0x38, 0x7c, 0xe6, 0xff, 0xea, 0xf5, 0x8f, 0xbf, 0xb9, 0x28, 0x1a,
- 0xeb, 0x42, 0x27, 0x27, 0x39, 0xde, 0x19, 0x9e, 0x6e, 0x6f, 0x69, 0xdf, 0x7b, 0x17, 0x7c, 0x5f,
- 0xf4, 0x82, 0xe9, 0xa4, 0xb3, 0xfd, 0xd1, 0xba, 0x64, 0x68, 0xd9, 0x53, 0x85, 0x00, 0x5e, 0x94,
- 0xb0, 0x3c, 0x6b, 0xdd, 0x1b, 0x26, 0x6c, 0x60, 0xfe, 0x97, 0x2e, 0xea, 0xdc, 0x9d, 0x3c, 0xc4,
- 0xd7, 0xd3, 0xa6, 0xaa, 0xb8, 0x84, 0x99, 0xde, 0xae, 0x3d, 0xf2, 0x50, 0x30, 0x8a, 0xae, 0xf5,
- 0x45, 0xbd, 0x0c, 0xf2, 0x09, 0x61, 0xfb, 0x37, 0xd5, 0x6c, 0x63, 0xee, 0xcb, 0xff, 0x9d, 0xfb,
- 0x51, 0x3f, 0xb7, 0x6b, 0x9e, 0xf2, 0x2f, 0x27, 0xb3, 0x85, 0xdb, 0x9b, 0xc9, 0x07, 0xe7, 0x1b,
- 0x79, 0x8a, 0xef, 0x18, 0x7d, 0xaa, 0x1a, 0x09, 0x42, 0x66, 0xa6, 0x91, 0xcf, 0xed, 0x6d, 0x0f,
- 0x05, 0x3b, 0xd1, 0xae, 0xa6, 0xfb, 0x3d, 0x3c, 0x30, 0x8c, 0x3c, 0xc7, 0xce, 0xdf, 0xd2, 0x72,
- 0x2e, 0xb2, 0x1c, 0xec, 0x2b, 0x1e, 0x0a, 0xb6, 0xa2, 0xbb, 0x17, 0x02, 0x5f, 0x6b, 0x3c, 0x7d,
- 0x75, 0xb2, 0xa2, 0xe8, 0x74, 0x45, 0xd1, 0xf7, 0x15, 0x45, 0xc7, 0x6b, 0x6a, 0x9d, 0xae, 0xa9,
- 0xf5, 0x75, 0x4d, 0xad, 0x0f, 0x7b, 0x99, 0x80, 0xbc, 0x49, 0xc2, 0x54, 0x15, 0xec, 0xad, 0x3e,
- 0xcd, 0xfd, 0x3c, 0x16, 0x92, 0xf5, 0x47, 0xfc, 0x71, 0x38, 0x63, 0x58, 0x96, 0xbc, 0x4e, 0xb6,
- 0xf5, 0x4a, 0x9e, 0xfc, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x02, 0xe6, 0x18, 0x2d, 0xe4, 0x02, 0x00,
- 0x00,
-}
-
-func (m *EpochInfo) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EpochInfo) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EpochInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.CurrentEpochStartHeight != 0 {
- i = encodeVarintState(dAtA, i, uint64(m.CurrentEpochStartHeight))
- i--
- dAtA[i] = 0x38
- }
- if m.EpochCountingStarted {
- i--
- if m.EpochCountingStarted {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x30
- }
- n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CurrentEpochStartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime):])
- if err1 != nil {
- return 0, err1
- }
- i -= n1
- i = encodeVarintState(dAtA, i, uint64(n1))
- i--
- dAtA[i] = 0x2a
- if m.CurrentEpoch != 0 {
- i = encodeVarintState(dAtA, i, uint64(m.CurrentEpoch))
- i--
- dAtA[i] = 0x20
- }
- n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.Duration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration):])
- if err2 != nil {
- return 0, err2
- }
- i -= n2
- i = encodeVarintState(dAtA, i, uint64(n2))
- i--
- dAtA[i] = 0x1a
- n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):])
- if err3 != nil {
- return 0, err3
- }
- i -= n3
- i = encodeVarintState(dAtA, i, uint64(n3))
- i--
- dAtA[i] = 0x12
- if len(m.Identifier) > 0 {
- i -= len(m.Identifier)
- copy(dAtA[i:], m.Identifier)
- i = encodeVarintState(dAtA, i, uint64(len(m.Identifier)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintState(dAtA []byte, offset int, v uint64) int {
- offset -= sovState(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *EpochInfo) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Identifier)
- if l > 0 {
- n += 1 + l + sovState(uint64(l))
- }
- l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime)
- n += 1 + l + sovState(uint64(l))
- l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration)
- n += 1 + l + sovState(uint64(l))
- if m.CurrentEpoch != 0 {
- n += 1 + sovState(uint64(m.CurrentEpoch))
- }
- l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime)
- n += 1 + l + sovState(uint64(l))
- if m.EpochCountingStarted {
- n += 2
- }
- if m.CurrentEpochStartHeight != 0 {
- n += 1 + sovState(uint64(m.CurrentEpochStartHeight))
- }
- return n
-}
-
-func sovState(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozState(x uint64) (n int) {
- return sovState(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *EpochInfo) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EpochInfo: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EpochInfo: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Identifier = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.Duration, dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType)
- }
- m.CurrentEpoch = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.CurrentEpoch |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartTime", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.CurrentEpochStartTime, dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EpochCountingStarted", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.EpochCountingStarted = bool(v != 0)
- case 7:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartHeight", wireType)
- }
- m.CurrentEpochStartHeight = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.CurrentEpochStartHeight |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipState(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthState
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipState(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthState
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupState
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthState
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthState = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowState = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupState = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/evm/README.md b/x/evm/README.md
deleted file mode 100644
index 12509d421..000000000
--- a/x/evm/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# evm
-
-To install dependencies:
-
-```bash
-bun install
-```
-
-To run:
-
-```bash
-bun run README.ts
-```
-
-This project was created using `bun init` in bun v1.0.28. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
diff --git a/x/evm/access_list.go b/x/evm/access_list.go
deleted file mode 100644
index 19be79d0d..000000000
--- a/x/evm/access_list.go
+++ /dev/null
@@ -1,302 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "math/big"
-
- errorsmod "cosmossdk.io/errors"
- sdkmath "cosmossdk.io/math"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-// AccessList is an EIP-2930 access list that represents the slice of
-// the protobuf AccessTuples.
-type AccessList []AccessTuple
-
-// NewAccessList creates a new protobuf-compatible AccessList from an ethereum
-// core AccessList type
-func NewAccessList(ethAccessList *gethcore.AccessList) AccessList {
- if ethAccessList == nil {
- return nil
- }
-
- al := AccessList{}
- for _, tuple := range *ethAccessList {
- storageKeys := make([]string, len(tuple.StorageKeys))
-
- for i := range tuple.StorageKeys {
- storageKeys[i] = tuple.StorageKeys[i].String()
- }
-
- al = append(al, AccessTuple{
- Address: tuple.Address.String(),
- StorageKeys: storageKeys,
- })
- }
-
- return al
-}
-
-// ToEthAccessList is an utility function to convert the protobuf compatible
-// AccessList to eth core AccessList from go-ethereum
-func (al AccessList) ToEthAccessList() *gethcore.AccessList {
- var ethAccessList gethcore.AccessList
-
- for _, tuple := range al {
- storageKeys := make([]common.Hash, len(tuple.StorageKeys))
-
- for i := range tuple.StorageKeys {
- storageKeys[i] = common.HexToHash(tuple.StorageKeys[i])
- }
-
- ethAccessList = append(ethAccessList, gethcore.AccessTuple{
- Address: common.HexToAddress(tuple.Address),
- StorageKeys: storageKeys,
- })
- }
-
- return ðAccessList
-}
-
-// AccessListTx
-
-func newAccessListTx(tx *gethcore.Transaction) (*AccessListTx, error) {
- txData := &AccessListTx{
- Nonce: tx.Nonce(),
- Data: tx.Data(),
- GasLimit: tx.Gas(),
- }
-
- v, r, s := tx.RawSignatureValues()
- if to := tx.To(); to != nil {
- txData.To = to.Hex()
- }
-
- if tx.Value() != nil {
- amountInt, err := eth.SafeNewIntFromBigInt(tx.Value())
- if err != nil {
- return nil, err
- }
- txData.Amount = &amountInt
- }
-
- if tx.GasPrice() != nil {
- gasPriceInt, err := eth.SafeNewIntFromBigInt(tx.GasPrice())
- if err != nil {
- return nil, err
- }
- txData.GasPrice = &gasPriceInt
- }
-
- if tx.AccessList() != nil {
- al := tx.AccessList()
- txData.Accesses = NewAccessList(&al)
- }
-
- txData.SetSignatureValues(tx.ChainId(), v, r, s)
- return txData, nil
-}
-
-// TxType returns the tx type
-func (tx *AccessListTx) TxType() uint8 {
- return gethcore.AccessListTxType
-}
-
-// Copy returns an instance with the same field values
-func (tx *AccessListTx) Copy() TxData {
- return &AccessListTx{
- ChainID: tx.ChainID,
- Nonce: tx.Nonce,
- GasPrice: tx.GasPrice,
- GasLimit: tx.GasLimit,
- To: tx.To,
- Amount: tx.Amount,
- Data: common.CopyBytes(tx.Data),
- Accesses: tx.Accesses,
- V: common.CopyBytes(tx.V),
- R: common.CopyBytes(tx.R),
- S: common.CopyBytes(tx.S),
- }
-}
-
-// GetChainID returns the chain id field from the AccessListTx
-func (tx *AccessListTx) GetChainID() *big.Int {
- if tx.ChainID == nil {
- return nil
- }
-
- return tx.ChainID.BigInt()
-}
-
-// GetAccessList returns the AccessList field.
-func (tx *AccessListTx) GetAccessList() gethcore.AccessList {
- if tx.Accesses == nil {
- return nil
- }
- return *tx.Accesses.ToEthAccessList()
-}
-
-// GetData returns the a copy of the input data bytes.
-func (tx *AccessListTx) GetData() []byte {
- return common.CopyBytes(tx.Data)
-}
-
-// GetGas returns the gas limit.
-func (tx *AccessListTx) GetGas() uint64 {
- return tx.GasLimit
-}
-
-// GetGasPrice returns the gas price field.
-func (tx *AccessListTx) GetGasPrice() *big.Int {
- if tx.GasPrice == nil {
- return nil
- }
- return tx.GasPrice.BigInt()
-}
-
-// GetGasTipCap returns the gas price field.
-func (tx *AccessListTx) GetGasTipCap() *big.Int {
- return tx.GetGasPrice()
-}
-
-// GetGasFeeCap returns the gas price field.
-func (tx *AccessListTx) GetGasFeeCap() *big.Int {
- return tx.GetGasPrice()
-}
-
-// GetValue returns the tx amount.
-func (tx *AccessListTx) GetValue() *big.Int {
- if tx.Amount == nil {
- return nil
- }
-
- return tx.Amount.BigInt()
-}
-
-// GetNonce returns the account sequence for the transaction.
-func (tx *AccessListTx) GetNonce() uint64 { return tx.Nonce }
-
-// GetTo returns the pointer to the recipient address.
-func (tx *AccessListTx) GetTo() *common.Address {
- if tx.To == "" {
- return nil
- }
- to := common.HexToAddress(tx.To)
- return &to
-}
-
-// AsEthereumData returns an AccessListTx transaction tx from the proto-formatted
-// TxData defined on the Cosmos EVM.
-func (tx *AccessListTx) AsEthereumData() gethcore.TxData {
- v, r, s := tx.GetRawSignatureValues()
- return &gethcore.AccessListTx{
- ChainID: tx.GetChainID(),
- Nonce: tx.GetNonce(),
- GasPrice: tx.GetGasPrice(),
- Gas: tx.GetGas(),
- To: tx.GetTo(),
- Value: tx.GetValue(),
- Data: tx.GetData(),
- AccessList: tx.GetAccessList(),
- V: v,
- R: r,
- S: s,
- }
-}
-
-// GetRawSignatureValues returns the V, R, S signature values of the transaction.
-// The return values should not be modified by the caller.
-func (tx *AccessListTx) GetRawSignatureValues() (v, r, s *big.Int) {
- return rawSignatureValues(tx.V, tx.R, tx.S)
-}
-
-// SetSignatureValues sets the signature values to the transaction.
-func (tx *AccessListTx) SetSignatureValues(chainID, v, r, s *big.Int) {
- if v != nil {
- tx.V = v.Bytes()
- }
- if r != nil {
- tx.R = r.Bytes()
- }
- if s != nil {
- tx.S = s.Bytes()
- }
- if chainID != nil {
- chainIDInt := sdkmath.NewIntFromBigInt(chainID)
- tx.ChainID = &chainIDInt
- }
-}
-
-// Validate performs a stateless validation of the tx fields.
-func (tx AccessListTx) Validate() error {
- gasPrice := tx.GetGasPrice()
- if gasPrice == nil {
- return errorsmod.Wrap(ErrInvalidGasPrice, "cannot be nil")
- }
- if !eth.IsValidInt256(gasPrice) {
- return errorsmod.Wrap(ErrInvalidGasPrice, "out of bound")
- }
-
- if gasPrice.Sign() == -1 {
- return errorsmod.Wrapf(ErrInvalidGasPrice, "gas price cannot be negative %s", gasPrice)
- }
-
- amount := tx.GetValue()
- // Amount can be 0
- if amount != nil && amount.Sign() == -1 {
- return errorsmod.Wrapf(ErrInvalidAmount, "amount cannot be negative %s", amount)
- }
- if !eth.IsValidInt256(amount) {
- return errorsmod.Wrap(ErrInvalidAmount, "out of bound")
- }
-
- if !eth.IsValidInt256(tx.Fee()) {
- return errorsmod.Wrap(ErrInvalidGasFee, "out of bound")
- }
-
- if tx.To != "" {
- if err := eth.ValidateAddress(tx.To); err != nil {
- return errorsmod.Wrap(err, "invalid to address")
- }
- }
-
- chainID := tx.GetChainID()
-
- if chainID == nil {
- return errorsmod.Wrap(
- errortypes.ErrInvalidChainID,
- "chain ID must be present on AccessList txs",
- )
- }
-
- return nil
-}
-
-// Fee returns gasprice * gaslimit.
-func (tx AccessListTx) Fee() *big.Int {
- return fee(tx.GetGasPrice(), tx.GetGas())
-}
-
-// Cost returns amount + gasprice * gaslimit.
-func (tx AccessListTx) Cost() *big.Int {
- return cost(tx.Fee(), tx.GetValue())
-}
-
-// EffectiveGasPrice is the same as GasPrice for AccessListTx
-func (tx AccessListTx) EffectiveGasPrice(_ *big.Int) *big.Int {
- return tx.GetGasPrice()
-}
-
-// EffectiveFee is the same as Fee for AccessListTx
-func (tx AccessListTx) EffectiveFee(_ *big.Int) *big.Int {
- return tx.Fee()
-}
-
-// EffectiveCost is the same as Cost for AccessListTx
-func (tx AccessListTx) EffectiveCost(_ *big.Int) *big.Int {
- return tx.Cost()
-}
diff --git a/x/evm/access_list_test.go b/x/evm/access_list_test.go
deleted file mode 100644
index c66de410b..000000000
--- a/x/evm/access_list_test.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package evm_test
-
-import (
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-func (suite *TxDataTestSuite) TestTestNewAccessList() {
- testCases := []struct {
- name string
- ethAccessList *gethcore.AccessList
- expAl evm.AccessList
- }{
- {
- "ethAccessList is nil",
- nil,
- nil,
- },
- {
- "non-empty ethAccessList",
- &gethcore.AccessList{{Address: suite.addr, StorageKeys: []common.Hash{{0}}}},
- evm.AccessList{{Address: suite.hexAddr, StorageKeys: []string{common.Hash{}.Hex()}}},
- },
- }
- for _, tc := range testCases {
- al := evm.NewAccessList(tc.ethAccessList)
-
- suite.Require().Equal(tc.expAl, al)
- }
-}
-
-func (suite *TxDataTestSuite) TestAccessListToEthAccessList() {
- ethAccessList := gethcore.AccessList{{Address: suite.addr, StorageKeys: []common.Hash{{0}}}}
- al := evm.NewAccessList(ðAccessList)
- actual := al.ToEthAccessList()
-
- suite.Require().Equal(ðAccessList, actual)
-}
diff --git a/x/evm/chain_config.go b/x/evm/chain_config.go
deleted file mode 100644
index 660770224..000000000
--- a/x/evm/chain_config.go
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "math/big"
- "strings"
-
- sdkmath "cosmossdk.io/math"
-
- errorsmod "cosmossdk.io/errors"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/params"
-)
-
-// EthereumConfig returns an Ethereum ChainConfig for EVM state transitions.
-// All the negative or nil values are converted to nil
-func (cc ChainConfig) EthereumConfig(chainID *big.Int) *params.ChainConfig {
- return ¶ms.ChainConfig{
- ChainID: chainID,
- HomesteadBlock: getBlockValue(cc.HomesteadBlock),
- DAOForkBlock: getBlockValue(cc.DAOForkBlock),
- DAOForkSupport: cc.DAOForkSupport,
- EIP150Block: getBlockValue(cc.EIP150Block),
- EIP150Hash: common.HexToHash(cc.EIP150Hash),
- EIP155Block: getBlockValue(cc.EIP155Block),
- EIP158Block: getBlockValue(cc.EIP158Block),
- ByzantiumBlock: getBlockValue(cc.ByzantiumBlock),
- ConstantinopleBlock: getBlockValue(cc.ConstantinopleBlock),
- PetersburgBlock: getBlockValue(cc.PetersburgBlock),
- IstanbulBlock: getBlockValue(cc.IstanbulBlock),
- MuirGlacierBlock: getBlockValue(cc.MuirGlacierBlock),
- BerlinBlock: getBlockValue(cc.BerlinBlock),
- LondonBlock: getBlockValue(cc.LondonBlock),
- ArrowGlacierBlock: getBlockValue(cc.ArrowGlacierBlock),
- GrayGlacierBlock: getBlockValue(cc.GrayGlacierBlock),
- MergeNetsplitBlock: getBlockValue(cc.MergeNetsplitBlock),
- ShanghaiBlock: getBlockValue(cc.ShanghaiBlock),
- CancunBlock: getBlockValue(cc.CancunBlock),
- TerminalTotalDifficulty: nil,
- Ethash: nil,
- Clique: nil,
- }
-}
-
-// DefaultChainConfig returns default evm parameters.
-func DefaultChainConfig() ChainConfig {
- homesteadBlock := sdkmath.ZeroInt()
- daoForkBlock := sdkmath.ZeroInt()
- eip150Block := sdkmath.ZeroInt()
- eip155Block := sdkmath.ZeroInt()
- eip158Block := sdkmath.ZeroInt()
- byzantiumBlock := sdkmath.ZeroInt()
- constantinopleBlock := sdkmath.ZeroInt()
- petersburgBlock := sdkmath.ZeroInt()
- istanbulBlock := sdkmath.ZeroInt()
- muirGlacierBlock := sdkmath.ZeroInt()
- berlinBlock := sdkmath.ZeroInt()
- londonBlock := sdkmath.ZeroInt()
- arrowGlacierBlock := sdkmath.ZeroInt()
- grayGlacierBlock := sdkmath.ZeroInt()
- mergeNetsplitBlock := sdkmath.ZeroInt()
- shanghaiBlock := sdkmath.ZeroInt()
- cancunBlock := sdkmath.ZeroInt()
-
- return ChainConfig{
- HomesteadBlock: &homesteadBlock,
- DAOForkBlock: &daoForkBlock,
- DAOForkSupport: true,
- EIP150Block: &eip150Block,
- EIP150Hash: common.Hash{}.String(),
- EIP155Block: &eip155Block,
- EIP158Block: &eip158Block,
- ByzantiumBlock: &byzantiumBlock,
- ConstantinopleBlock: &constantinopleBlock,
- PetersburgBlock: &petersburgBlock,
- IstanbulBlock: &istanbulBlock,
- MuirGlacierBlock: &muirGlacierBlock,
- BerlinBlock: &berlinBlock,
- LondonBlock: &londonBlock,
- ArrowGlacierBlock: &arrowGlacierBlock,
- GrayGlacierBlock: &grayGlacierBlock,
- MergeNetsplitBlock: &mergeNetsplitBlock,
- ShanghaiBlock: &shanghaiBlock,
- CancunBlock: &cancunBlock,
- }
-}
-
-func getBlockValue(block *sdkmath.Int) *big.Int {
- if block == nil || block.IsNegative() {
- return nil
- }
-
- return block.BigInt()
-}
-
-// Validate performs a basic validation of the ChainConfig params. The function will return an error
-// if any of the block values is uninitialized (i.e nil) or if the EIP150Hash is an invalid hash.
-func (cc ChainConfig) Validate() error {
- if err := validateBlock(cc.HomesteadBlock); err != nil {
- return errorsmod.Wrap(err, "homesteadBlock")
- }
- if err := validateBlock(cc.DAOForkBlock); err != nil {
- return errorsmod.Wrap(err, "daoForkBlock")
- }
- if err := validateBlock(cc.EIP150Block); err != nil {
- return errorsmod.Wrap(err, "eip150Block")
- }
- if err := validateHash(cc.EIP150Hash); err != nil {
- return err
- }
- if err := validateBlock(cc.EIP155Block); err != nil {
- return errorsmod.Wrap(err, "eip155Block")
- }
- if err := validateBlock(cc.EIP158Block); err != nil {
- return errorsmod.Wrap(err, "eip158Block")
- }
- if err := validateBlock(cc.ByzantiumBlock); err != nil {
- return errorsmod.Wrap(err, "byzantiumBlock")
- }
- if err := validateBlock(cc.ConstantinopleBlock); err != nil {
- return errorsmod.Wrap(err, "constantinopleBlock")
- }
- if err := validateBlock(cc.PetersburgBlock); err != nil {
- return errorsmod.Wrap(err, "petersburgBlock")
- }
- if err := validateBlock(cc.IstanbulBlock); err != nil {
- return errorsmod.Wrap(err, "istanbulBlock")
- }
- if err := validateBlock(cc.MuirGlacierBlock); err != nil {
- return errorsmod.Wrap(err, "muirGlacierBlock")
- }
- if err := validateBlock(cc.BerlinBlock); err != nil {
- return errorsmod.Wrap(err, "berlinBlock")
- }
- if err := validateBlock(cc.LondonBlock); err != nil {
- return errorsmod.Wrap(err, "londonBlock")
- }
- if err := validateBlock(cc.ArrowGlacierBlock); err != nil {
- return errorsmod.Wrap(err, "arrowGlacierBlock")
- }
- if err := validateBlock(cc.GrayGlacierBlock); err != nil {
- return errorsmod.Wrap(err, "GrayGlacierBlock")
- }
- if err := validateBlock(cc.MergeNetsplitBlock); err != nil {
- return errorsmod.Wrap(err, "MergeNetsplitBlock")
- }
- if err := validateBlock(cc.ShanghaiBlock); err != nil {
- return errorsmod.Wrap(err, "ShanghaiBlock")
- }
- if err := validateBlock(cc.CancunBlock); err != nil {
- return errorsmod.Wrap(err, "CancunBlock")
- }
- // NOTE: chain ID is not needed to check config order
- if err := cc.EthereumConfig(nil).CheckConfigForkOrder(); err != nil {
- return errorsmod.Wrap(err, "invalid config fork order")
- }
- return nil
-}
-
-func validateHash(hex string) error {
- if hex != "" && strings.TrimSpace(hex) == "" {
- return errorsmod.Wrap(ErrInvalidChainConfig, "hash cannot be blank")
- }
-
- return nil
-}
-
-func validateBlock(block *sdkmath.Int) error {
- // nil value means that the fork has not yet been applied
- if block == nil {
- return nil
- }
-
- if block.IsNegative() {
- return errorsmod.Wrapf(
- ErrInvalidChainConfig, "block value cannot be negative: %s", block,
- )
- }
-
- return nil
-}
diff --git a/x/evm/chain_config_test.go b/x/evm/chain_config_test.go
deleted file mode 100644
index 71d46d746..000000000
--- a/x/evm/chain_config_test.go
+++ /dev/null
@@ -1,381 +0,0 @@
-package evm
-
-import (
- "testing"
-
- sdkmath "cosmossdk.io/math"
- "github.com/stretchr/testify/require"
-
- "github.com/ethereum/go-ethereum/common"
-)
-
-var defaultEIP150Hash = common.Hash{}.String()
-
-func newIntPtr(i int64) *sdkmath.Int {
- v := sdkmath.NewInt(i)
- return &v
-}
-
-func TestChainConfigValidate(t *testing.T) {
- testCases := []struct {
- name string
- config ChainConfig
- expError bool
- }{
- {"default", DefaultChainConfig(), false},
- {
- "valid",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(0),
- MuirGlacierBlock: newIntPtr(0),
- BerlinBlock: newIntPtr(0),
- LondonBlock: newIntPtr(0),
- CancunBlock: newIntPtr(0),
- ShanghaiBlock: newIntPtr(0),
- },
- false,
- },
- {
- "valid with nil values",
- ChainConfig{
- HomesteadBlock: nil,
- DAOForkBlock: nil,
- EIP150Block: nil,
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: nil,
- EIP158Block: nil,
- ByzantiumBlock: nil,
- ConstantinopleBlock: nil,
- PetersburgBlock: nil,
- IstanbulBlock: nil,
- MuirGlacierBlock: nil,
- BerlinBlock: nil,
- LondonBlock: nil,
- CancunBlock: nil,
- ShanghaiBlock: nil,
- },
- false,
- },
- {
- "empty",
- ChainConfig{},
- false,
- },
- {
- "invalid HomesteadBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid DAOForkBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid EIP150Block",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid EIP150Hash",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: " ",
- },
- true,
- },
- {
- "invalid EIP155Block",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid EIP158Block",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid ByzantiumBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid ConstantinopleBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid PetersburgBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid IstanbulBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid MuirGlacierBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(0),
- MuirGlacierBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid BerlinBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(0),
- MuirGlacierBlock: newIntPtr(0),
- BerlinBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid LondonBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(0),
- MuirGlacierBlock: newIntPtr(0),
- BerlinBlock: newIntPtr(0),
- LondonBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid ArrowGlacierBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(0),
- MuirGlacierBlock: newIntPtr(0),
- BerlinBlock: newIntPtr(0),
- LondonBlock: newIntPtr(0),
- ArrowGlacierBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid GrayGlacierBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(0),
- MuirGlacierBlock: newIntPtr(0),
- BerlinBlock: newIntPtr(0),
- LondonBlock: newIntPtr(0),
- ArrowGlacierBlock: newIntPtr(0),
- GrayGlacierBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid MergeNetsplitBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(0),
- MuirGlacierBlock: newIntPtr(0),
- BerlinBlock: newIntPtr(0),
- LondonBlock: newIntPtr(0),
- ArrowGlacierBlock: newIntPtr(0),
- GrayGlacierBlock: newIntPtr(0),
- MergeNetsplitBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid fork order - skip HomesteadBlock",
- ChainConfig{
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(0),
- MuirGlacierBlock: newIntPtr(0),
- BerlinBlock: newIntPtr(0),
- LondonBlock: newIntPtr(0),
- },
- true,
- },
- {
- "invalid ShanghaiBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(0),
- MuirGlacierBlock: newIntPtr(0),
- BerlinBlock: newIntPtr(0),
- LondonBlock: newIntPtr(0),
- ArrowGlacierBlock: newIntPtr(0),
- GrayGlacierBlock: newIntPtr(0),
- MergeNetsplitBlock: newIntPtr(0),
- ShanghaiBlock: newIntPtr(-1),
- },
- true,
- },
- {
- "invalid CancunBlock",
- ChainConfig{
- HomesteadBlock: newIntPtr(0),
- DAOForkBlock: newIntPtr(0),
- EIP150Block: newIntPtr(0),
- EIP150Hash: defaultEIP150Hash,
- EIP155Block: newIntPtr(0),
- EIP158Block: newIntPtr(0),
- ByzantiumBlock: newIntPtr(0),
- ConstantinopleBlock: newIntPtr(0),
- PetersburgBlock: newIntPtr(0),
- IstanbulBlock: newIntPtr(0),
- MuirGlacierBlock: newIntPtr(0),
- BerlinBlock: newIntPtr(0),
- LondonBlock: newIntPtr(0),
- ArrowGlacierBlock: newIntPtr(0),
- GrayGlacierBlock: newIntPtr(0),
- MergeNetsplitBlock: newIntPtr(0),
- ShanghaiBlock: newIntPtr(0),
- CancunBlock: newIntPtr(-1),
- },
- true,
- },
- }
-
- for _, tc := range testCases {
- err := tc.config.Validate()
-
- if tc.expError {
- require.Error(t, err, tc.name)
- } else {
- require.NoError(t, err, tc.name)
- }
- }
-}
diff --git a/x/evm/cli/cli.go b/x/evm/cli/cli.go
deleted file mode 100644
index 2fe7b80b8..000000000
--- a/x/evm/cli/cli.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package cli
-
-import (
- "fmt"
-
- "github.com/NibiruChain/nibiru/x/evm"
- "github.com/NibiruChain/nibiru/x/sudo/types"
-
- "github.com/cosmos/cosmos-sdk/client"
-
- "github.com/spf13/cobra"
-)
-
-// GetTxCmd returns a cli command for this module's transactions
-func GetTxCmd() *cobra.Command {
- txCmd := &cobra.Command{
- Use: evm.ModuleName,
- Short: fmt.Sprintf("x/%s transaction subcommands", evm.ModuleName),
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- cmds := []*cobra.Command{}
- for _, cmd := range cmds {
- txCmd.AddCommand(cmd)
- }
-
- return txCmd
-}
-
-// GetQueryCmd returns a cli command for this module's queries
-func GetQueryCmd() *cobra.Command {
- moduleQueryCmd := &cobra.Command{
- Use: evm.ModuleName,
- Short: fmt.Sprintf(
- "Query commands for the x/%s module", types.ModuleName),
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- // Add subcommands
- cmds := []*cobra.Command{}
- for _, cmd := range cmds {
- moduleQueryCmd.AddCommand(cmd)
- }
-
- return moduleQueryCmd
-}
diff --git a/x/evm/codec.go b/x/evm/codec.go
deleted file mode 100644
index a382495ac..000000000
--- a/x/evm/codec.go
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- errorsmod "cosmossdk.io/errors"
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
- "github.com/cosmos/cosmos-sdk/types/msgservice"
- "github.com/cosmos/cosmos-sdk/types/tx"
- proto "github.com/cosmos/gogoproto/proto"
-)
-
-var (
- amino = codec.NewLegacyAmino()
- // ModuleCdc references the global evm module codec. Note, the codec should
- // ONLY be used in certain instances of tests and for JSON encoding.
- ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
-
- // AminoCdc is a amino codec created to support amino JSON compatible msgs.
- AminoCdc = codec.NewAminoCodec(amino)
-)
-
-const (
- // Protobuf type URL for a consensus tx holding Ethereum transaction msgs.
- // Corresponds with [ExtensionOptionsEthereumTx].
- TYPE_URL_ETHEREUM_TX = "/eth.evm.v1.ExtensionOptionsEthereumTx"
-)
-
-// NOTE: This is required for the GetSignBytes function
-func init() {
- RegisterLegacyAminoCodec(amino)
- amino.Seal()
-}
-
-// RegisterInterfaces registers the client interfaces to protobuf Any.
-func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- registry.RegisterImplementations(
- (*tx.TxExtensionOptionI)(nil),
- &ExtensionOptionsEthereumTx{},
- )
- registry.RegisterImplementations(
- (*sdk.Msg)(nil),
- &MsgEthereumTx{},
- &MsgUpdateParams{},
- )
- registry.RegisterInterface(
- "eth.evm.v1.TxData",
- (*TxData)(nil),
- &DynamicFeeTx{},
- &AccessListTx{},
- &LegacyTx{},
- )
-
- msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
-}
-
-// PackTxData constructs a new Any packed with the given tx data value. It returns
-// an error if the client state can't be casted to a protobuf message or if the concrete
-// implementation is not registered to the protobuf codec.
-func PackTxData(txData TxData) (*codectypes.Any, error) {
- msg, ok := txData.(proto.Message)
- if !ok {
- return nil, errorsmod.Wrapf(errortypes.ErrPackAny, "cannot proto marshal %T", txData)
- }
-
- anyTxData, err := codectypes.NewAnyWithValue(msg)
- if err != nil {
- return nil, errorsmod.Wrap(errortypes.ErrPackAny, err.Error())
- }
-
- return anyTxData, nil
-}
-
-// UnpackTxData unpacks an Any into a TxData. It returns an error if the
-// client state can't be unpacked into a TxData.
-func UnpackTxData(any *codectypes.Any) (TxData, error) {
- if any == nil {
- return nil, errorsmod.Wrap(errortypes.ErrUnpackAny, "protobuf Any message cannot be nil")
- }
-
- txData, ok := any.GetCachedValue().(TxData)
- if !ok {
- return nil, errorsmod.Wrapf(errortypes.ErrUnpackAny, "cannot unpack Any into TxData %T", any)
- }
-
- return txData, nil
-}
-
-// RegisterLegacyAminoCodec required for EIP-712
-func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- cdc.RegisterConcrete(&MsgUpdateParams{}, updateParamsName, nil)
-}
diff --git a/x/evm/const.go b/x/evm/const.go
deleted file mode 100644
index 7188b4209..000000000
--- a/x/evm/const.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "github.com/NibiruChain/collections"
- "github.com/ethereum/go-ethereum/common"
-)
-
-const (
- // ModuleName string name of module
- ModuleName = "evm"
-
- // StoreKey: Persistent storage key for ethereum storage data, account code
- // (StateDB) or block related data for the Eth Web3 API.
- StoreKey = ModuleName
-
- // TransientKey is the key to access the EVM transient store, that is reset
- // during the Commit phase.
- TransientKey = "transient_" + ModuleName
-
- // RouterKey uses module name for routing
- RouterKey = ModuleName
-)
-
-// prefix bytes for the EVM persistent store
-const (
- KeyPrefixAccCodes collections.Namespace = iota + 1
- KeyPrefixAccState
- KeyPrefixParams
- KeyPrefixEthAddrIndex
-)
-
-// KVStore transient prefix namespaces for the EVM Module. Transient stores only
-// remain for current block, and have more gas efficient read and write access.
-const (
- NamespaceBlockBloom collections.Namespace = iota + 1
- NamespaceBlockTxIndex
- NamespaceBlockLogSize
- NamespaceBlockGasUsed
-)
-
-var KeyPrefixBzAccState = KeyPrefixAccState.Prefix()
-
-// PrefixAccStateEthAddr returns a prefix to iterate over a given account storage.
-func PrefixAccStateEthAddr(address common.Address) []byte {
- return append(KeyPrefixBzAccState, address.Bytes()...)
-}
-
-// StateKey defines the full key under which an account state is stored.
-func StateKey(address common.Address, key []byte) []byte {
- return append(PrefixAccStateEthAddr(address), key...)
-}
-
-const (
- // Amino names
- updateParamsName = "evm/MsgUpdateParams"
-)
-
-type CallType int
-
-const (
- // CallTypeRPC call type is used on requests to eth_estimateGas rpc API endpoint
- CallTypeRPC CallType = iota + 1
- // CallTypeSmart call type is used in case of smart contract methods calls
- CallTypeSmart
-)
diff --git a/x/evm/deps.go b/x/evm/deps.go
deleted file mode 100644
index b76eb37ac..000000000
--- a/x/evm/deps.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
-)
-
-// AccountKeeper defines the expected account keeper interface
-type AccountKeeper interface {
- NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
- GetModuleAddress(moduleName string) sdk.AccAddress
- GetAllAccounts(ctx sdk.Context) (accounts []authtypes.AccountI)
- IterateAccounts(ctx sdk.Context, cb func(account authtypes.AccountI) bool)
- GetSequence(sdk.Context, sdk.AccAddress) (uint64, error)
- GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
- SetAccount(ctx sdk.Context, account authtypes.AccountI)
- RemoveAccount(ctx sdk.Context, account authtypes.AccountI)
- GetParams(ctx sdk.Context) (params authtypes.Params)
-}
-
-// BankKeeper defines the expected interface needed to retrieve account balances.
-type BankKeeper interface {
- authtypes.BankKeeper
- GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
- SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
- MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
- BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
-}
-
-// StakingKeeper returns the historical headers kept in store.
-type StakingKeeper interface {
- GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool)
- GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, found bool)
-}
diff --git a/x/evm/errors.go b/x/evm/errors.go
deleted file mode 100644
index 78ee2bda9..000000000
--- a/x/evm/errors.go
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "errors"
- "fmt"
-
- errorsmod "cosmossdk.io/errors"
- "github.com/ethereum/go-ethereum/common"
-
- "github.com/ethereum/go-ethereum/accounts/abi"
- "github.com/ethereum/go-ethereum/common/hexutil"
-)
-
-const (
- codeErrInvalidState = uint32(iota) + 2 // NOTE: code 1 is reserved for internal errors
- codeErrInvalidChainConfig
- codeErrZeroAddress
- codeErrCreateDisabled
- codeErrCallDisabled
- codeErrInvalidAmount
- codeErrInvalidGasPrice
- codeErrInvalidGasFee
- codeErrVMExecution
- codeErrInvalidRefund
- codeErrInvalidGasCap
- codeErrInvalidBaseFee
- codeErrGasOverflow
- codeErrInvalidAccount
- codeErrInvalidGasLimit
- codeErrInactivePrecompile
-)
-
-var ErrPostTxProcessing = errors.New("failed to execute post processing")
-
-var (
- // ErrInvalidState returns an error resulting from an invalid Storage State.
- ErrInvalidState = errorsmod.Register(ModuleName, codeErrInvalidState, "invalid storage state")
-
- // ErrInvalidChainConfig returns an error resulting from an invalid ChainConfig.
- ErrInvalidChainConfig = errorsmod.Register(ModuleName, codeErrInvalidChainConfig, "invalid chain configuration")
-
- // ErrZeroAddress returns an error resulting from an zero (empty) ethereum Address.
- ErrZeroAddress = errorsmod.Register(ModuleName, codeErrZeroAddress, "invalid zero address")
-
- // ErrCreateDisabled returns an error if the EnableCreate parameter is false.
- ErrCreateDisabled = errorsmod.Register(ModuleName, codeErrCreateDisabled, "EVM Create operation is disabled")
-
- // ErrCallDisabled returns an error if the EnableCall parameter is false.
- ErrCallDisabled = errorsmod.Register(ModuleName, codeErrCallDisabled, "EVM Call operation is disabled")
-
- // ErrInvalidAmount returns an error if a tx contains an invalid amount.
- ErrInvalidAmount = errorsmod.Register(ModuleName, codeErrInvalidAmount, "invalid transaction amount")
-
- // ErrInvalidGasPrice returns an error if an invalid gas price is provided to the tx.
- ErrInvalidGasPrice = errorsmod.Register(ModuleName, codeErrInvalidGasPrice, "invalid gas price")
-
- // ErrInvalidGasFee returns an error if the tx gas fee is out of bound.
- ErrInvalidGasFee = errorsmod.Register(ModuleName, codeErrInvalidGasFee, "invalid gas fee")
-
- // ErrVMExecution returns an error resulting from an error in EVM execution.
- ErrVMExecution = errorsmod.Register(ModuleName, codeErrVMExecution, "evm transaction execution failed")
-
- // ErrInvalidRefund returns an error if a the gas refund value is invalid.
- ErrInvalidRefund = errorsmod.Register(ModuleName, codeErrInvalidRefund, "invalid gas refund amount")
-
- // ErrInvalidGasCap returns an error if a the gas cap value is negative or invalid
- ErrInvalidGasCap = errorsmod.Register(ModuleName, codeErrInvalidGasCap, "invalid gas cap")
-
- // ErrInvalidBaseFee returns an error if a the base fee cap value is invalid
- ErrInvalidBaseFee = errorsmod.Register(ModuleName, codeErrInvalidBaseFee, "invalid base fee")
-
- // ErrGasOverflow returns an error if gas computation overlow/underflow
- ErrGasOverflow = errorsmod.Register(ModuleName, codeErrGasOverflow, "gas computation overflow/underflow")
-
- // ErrInvalidAccount returns an error if the account is not an EVM compatible account
- ErrInvalidAccount = errorsmod.Register(ModuleName, codeErrInvalidAccount, "account type is not a valid ethereum account")
-
- // ErrInvalidGasLimit returns an error if gas limit value is invalid
- ErrInvalidGasLimit = errorsmod.Register(ModuleName, codeErrInvalidGasLimit, "invalid gas limit")
-
- // ErrInactivePrecompile returns an error if a call is made to an inactive precompile
- ErrInactivePrecompile = errorsmod.Register(ModuleName, codeErrInactivePrecompile, "precompile not enabled")
-)
-
-// NewExecErrorWithReason unpacks the revert return bytes and returns a wrapped error
-// with the return reason.
-func NewExecErrorWithReason(revertReason []byte) *RevertError {
- result := common.CopyBytes(revertReason)
- reason, errUnpack := abi.UnpackRevert(result)
- err := errors.New("execution reverted")
- if errUnpack == nil {
- err = fmt.Errorf("execution reverted: %v", reason)
- }
- return &RevertError{
- error: err,
- reason: hexutil.Encode(result),
- }
-}
-
-// RevertError is an API error that encompass an EVM revert with JSON error
-// code and a binary data blob.
-type RevertError struct {
- error
- reason string // revert reason hex encoded
-}
-
-// ErrorCode returns the JSON error code for a revert.
-// See: https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal
-func (e *RevertError) ErrorCode() int {
- return 3
-}
-
-// ErrorData returns the hex encoded revert reason.
-func (e *RevertError) ErrorData() interface{} {
- return e.reason
-}
diff --git a/x/evm/events.go b/x/evm/events.go
deleted file mode 100644
index 3b89eac17..000000000
--- a/x/evm/events.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-// Evm module events
-const (
- EventTypeEthereumTx = TypeMsgEthereumTx
- EventTypeBlockBloom = "block_bloom"
- EventTypeTxLog = "tx_log"
-
- AttributeKeyContractAddress = "contract"
- AttributeKeyRecipient = "recipient"
- AttributeKeyTxHash = "txHash"
- AttributeKeyEthereumTxHash = "ethereumTxHash"
- AttributeKeyTxIndex = "txIndex"
- AttributeKeyTxGasUsed = "txGasUsed"
- AttributeKeyTxType = "txType"
- AttributeKeyTxLog = "txLog"
- // tx failed in eth vm execution
- AttributeKeyEthereumTxFailed = "ethereumTxFailed"
- AttributeValueCategory = ModuleName
- AttributeKeyEthereumBloom = "bloom"
-
- MetricKeyTransitionDB = "transition_db"
- MetricKeyStaticCall = "static_call"
-)
diff --git a/x/evm/events.pb.go b/x/evm/events.pb.go
deleted file mode 100644
index d7e35e49a..000000000
--- a/x/evm/events.pb.go
+++ /dev/null
@@ -1,1265 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: eth/evm/v1/events.proto
-
-package evm
-
-import (
- fmt "fmt"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// EventEthereumTx defines the event for an Ethereum transaction
-type EventEthereumTx struct {
- // amount
- Amount string `protobuf:"bytes,1,opt,name=amount,proto3" json:"amount,omitempty"`
- // eth_hash is the Ethereum hash of the transaction
- EthHash string `protobuf:"bytes,2,opt,name=eth_hash,json=ethHash,proto3" json:"eth_hash,omitempty"`
- // index of the transaction in the block
- Index string `protobuf:"bytes,3,opt,name=index,proto3" json:"index,omitempty"`
- // gas_used is the amount of gas used by the transaction
- GasUsed string `protobuf:"bytes,4,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"`
- // hash is the Tendermint hash of the transaction
- Hash string `protobuf:"bytes,5,opt,name=hash,proto3" json:"hash,omitempty"`
- // recipient of the transaction
- Recipient string `protobuf:"bytes,6,opt,name=recipient,proto3" json:"recipient,omitempty"`
- // eth_tx_failed contains a VM error should it occur
- EthTxFailed string `protobuf:"bytes,7,opt,name=eth_tx_failed,json=ethTxFailed,proto3" json:"eth_tx_failed,omitempty"`
-}
-
-func (m *EventEthereumTx) Reset() { *m = EventEthereumTx{} }
-func (m *EventEthereumTx) String() string { return proto.CompactTextString(m) }
-func (*EventEthereumTx) ProtoMessage() {}
-func (*EventEthereumTx) Descriptor() ([]byte, []int) {
- return fileDescriptor_f8bc26b53c788f17, []int{0}
-}
-func (m *EventEthereumTx) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventEthereumTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventEthereumTx.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventEthereumTx) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventEthereumTx.Merge(m, src)
-}
-func (m *EventEthereumTx) XXX_Size() int {
- return m.Size()
-}
-func (m *EventEthereumTx) XXX_DiscardUnknown() {
- xxx_messageInfo_EventEthereumTx.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventEthereumTx proto.InternalMessageInfo
-
-func (m *EventEthereumTx) GetAmount() string {
- if m != nil {
- return m.Amount
- }
- return ""
-}
-
-func (m *EventEthereumTx) GetEthHash() string {
- if m != nil {
- return m.EthHash
- }
- return ""
-}
-
-func (m *EventEthereumTx) GetIndex() string {
- if m != nil {
- return m.Index
- }
- return ""
-}
-
-func (m *EventEthereumTx) GetGasUsed() string {
- if m != nil {
- return m.GasUsed
- }
- return ""
-}
-
-func (m *EventEthereumTx) GetHash() string {
- if m != nil {
- return m.Hash
- }
- return ""
-}
-
-func (m *EventEthereumTx) GetRecipient() string {
- if m != nil {
- return m.Recipient
- }
- return ""
-}
-
-func (m *EventEthereumTx) GetEthTxFailed() string {
- if m != nil {
- return m.EthTxFailed
- }
- return ""
-}
-
-// EventTxLog defines the event for an Ethereum transaction log
-type EventTxLog struct {
- // tx_logs is an array of transaction logs
- TxLogs []string `protobuf:"bytes,1,rep,name=tx_logs,json=txLogs,proto3" json:"tx_logs,omitempty"`
-}
-
-func (m *EventTxLog) Reset() { *m = EventTxLog{} }
-func (m *EventTxLog) String() string { return proto.CompactTextString(m) }
-func (*EventTxLog) ProtoMessage() {}
-func (*EventTxLog) Descriptor() ([]byte, []int) {
- return fileDescriptor_f8bc26b53c788f17, []int{1}
-}
-func (m *EventTxLog) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventTxLog) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventTxLog.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventTxLog) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventTxLog.Merge(m, src)
-}
-func (m *EventTxLog) XXX_Size() int {
- return m.Size()
-}
-func (m *EventTxLog) XXX_DiscardUnknown() {
- xxx_messageInfo_EventTxLog.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventTxLog proto.InternalMessageInfo
-
-func (m *EventTxLog) GetTxLogs() []string {
- if m != nil {
- return m.TxLogs
- }
- return nil
-}
-
-// EventMessage
-type EventMessage struct {
- // module which emits the event
- Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"`
- // sender of the message
- Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"`
- // tx_type is the type of the message
- TxType string `protobuf:"bytes,3,opt,name=tx_type,json=txType,proto3" json:"tx_type,omitempty"`
-}
-
-func (m *EventMessage) Reset() { *m = EventMessage{} }
-func (m *EventMessage) String() string { return proto.CompactTextString(m) }
-func (*EventMessage) ProtoMessage() {}
-func (*EventMessage) Descriptor() ([]byte, []int) {
- return fileDescriptor_f8bc26b53c788f17, []int{2}
-}
-func (m *EventMessage) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventMessage.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventMessage) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventMessage.Merge(m, src)
-}
-func (m *EventMessage) XXX_Size() int {
- return m.Size()
-}
-func (m *EventMessage) XXX_DiscardUnknown() {
- xxx_messageInfo_EventMessage.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventMessage proto.InternalMessageInfo
-
-func (m *EventMessage) GetModule() string {
- if m != nil {
- return m.Module
- }
- return ""
-}
-
-func (m *EventMessage) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-func (m *EventMessage) GetTxType() string {
- if m != nil {
- return m.TxType
- }
- return ""
-}
-
-// EventBlockBloom defines an Ethereum block bloom filter event
-type EventBlockBloom struct {
- // bloom is the bloom filter of the block
- Bloom string `protobuf:"bytes,1,opt,name=bloom,proto3" json:"bloom,omitempty"`
-}
-
-func (m *EventBlockBloom) Reset() { *m = EventBlockBloom{} }
-func (m *EventBlockBloom) String() string { return proto.CompactTextString(m) }
-func (*EventBlockBloom) ProtoMessage() {}
-func (*EventBlockBloom) Descriptor() ([]byte, []int) {
- return fileDescriptor_f8bc26b53c788f17, []int{3}
-}
-func (m *EventBlockBloom) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventBlockBloom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventBlockBloom.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventBlockBloom) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventBlockBloom.Merge(m, src)
-}
-func (m *EventBlockBloom) XXX_Size() int {
- return m.Size()
-}
-func (m *EventBlockBloom) XXX_DiscardUnknown() {
- xxx_messageInfo_EventBlockBloom.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventBlockBloom proto.InternalMessageInfo
-
-func (m *EventBlockBloom) GetBloom() string {
- if m != nil {
- return m.Bloom
- }
- return ""
-}
-
-func init() {
- proto.RegisterType((*EventEthereumTx)(nil), "eth.evm.v1.EventEthereumTx")
- proto.RegisterType((*EventTxLog)(nil), "eth.evm.v1.EventTxLog")
- proto.RegisterType((*EventMessage)(nil), "eth.evm.v1.EventMessage")
- proto.RegisterType((*EventBlockBloom)(nil), "eth.evm.v1.EventBlockBloom")
-}
-
-func init() { proto.RegisterFile("eth/evm/v1/events.proto", fileDescriptor_f8bc26b53c788f17) }
-
-var fileDescriptor_f8bc26b53c788f17 = []byte{
- // 363 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x91, 0xc1, 0x6a, 0xdb, 0x40,
- 0x10, 0x86, 0xad, 0xda, 0x96, 0xeb, 0x6d, 0x4b, 0x61, 0x29, 0xb5, 0x0a, 0x45, 0x18, 0x95, 0xd2,
- 0x9e, 0x24, 0x4c, 0xcf, 0xbd, 0x38, 0x38, 0xe4, 0x90, 0xe4, 0x10, 0x14, 0x02, 0xb9, 0x88, 0x95,
- 0x35, 0xd1, 0x2e, 0x91, 0xb4, 0x42, 0x3b, 0x12, 0xeb, 0xb7, 0xc8, 0x63, 0x05, 0x72, 0xf1, 0x31,
- 0xc7, 0x60, 0xbf, 0x48, 0xd8, 0x95, 0x42, 0x6e, 0xf3, 0xff, 0xb3, 0xf3, 0x2f, 0xdf, 0x0c, 0x59,
- 0x00, 0xf2, 0x08, 0xba, 0x32, 0xea, 0x56, 0x11, 0x74, 0x50, 0xa1, 0x0a, 0xeb, 0x46, 0xa2, 0xa4,
- 0x04, 0x90, 0x87, 0xd0, 0x95, 0x61, 0xb7, 0x0a, 0x9e, 0x1c, 0xf2, 0x75, 0x63, 0x9a, 0x1b, 0xe4,
- 0xd0, 0x40, 0x5b, 0xc6, 0x9a, 0x7e, 0x27, 0x2e, 0x2b, 0x65, 0x5b, 0xa1, 0xe7, 0x2c, 0x9d, 0xbf,
- 0xf3, 0xab, 0x41, 0xd1, 0x1f, 0xe4, 0x23, 0x20, 0x4f, 0x38, 0x53, 0xdc, 0xfb, 0x60, 0x3b, 0x33,
- 0x40, 0x7e, 0xc6, 0x14, 0xa7, 0xdf, 0xc8, 0x54, 0x54, 0x19, 0x68, 0x6f, 0x6c, 0xfd, 0x5e, 0x98,
- 0x81, 0x9c, 0xa9, 0xa4, 0x55, 0x90, 0x79, 0x93, 0x7e, 0x20, 0x67, 0xea, 0x5a, 0x41, 0x46, 0x29,
- 0x99, 0xd8, 0x9c, 0xa9, 0xb5, 0x6d, 0x4d, 0x7f, 0x92, 0x79, 0x03, 0x5b, 0x51, 0x0b, 0xa8, 0xd0,
- 0x73, 0x6d, 0xe3, 0xdd, 0xa0, 0x01, 0xf9, 0x62, 0x7e, 0x47, 0x9d, 0xdc, 0x31, 0x51, 0x40, 0xe6,
- 0xcd, 0xec, 0x8b, 0x4f, 0x80, 0x3c, 0xd6, 0xa7, 0xd6, 0x0a, 0x7e, 0x13, 0x62, 0x61, 0x62, 0x7d,
- 0x2e, 0x73, 0xba, 0x20, 0x33, 0xd4, 0x49, 0x21, 0x73, 0xe5, 0x39, 0xcb, 0xb1, 0x01, 0x41, 0xe3,
- 0xab, 0xe0, 0x86, 0x7c, 0xb6, 0xcf, 0x2e, 0x40, 0x29, 0x96, 0x83, 0x01, 0x2e, 0x65, 0xd6, 0x16,
- 0xf0, 0x06, 0xdc, 0x2b, 0xe3, 0x2b, 0xa8, 0x32, 0x68, 0x06, 0xdc, 0x41, 0x0d, 0xc1, 0xb8, 0xab,
- 0x61, 0xe0, 0x75, 0x51, 0xc7, 0xbb, 0x1a, 0x82, 0x3f, 0xc3, 0x32, 0xd7, 0x85, 0xdc, 0xde, 0xaf,
- 0x0b, 0x29, 0x4b, 0xb3, 0x99, 0xd4, 0x14, 0x43, 0x74, 0x2f, 0xd6, 0xff, 0x1f, 0x0f, 0xbe, 0xb3,
- 0x3f, 0xf8, 0xce, 0xcb, 0xc1, 0x77, 0x1e, 0x8e, 0xfe, 0x68, 0x7f, 0xf4, 0x47, 0xcf, 0x47, 0x7f,
- 0x74, 0xfb, 0x2b, 0x17, 0xc8, 0xdb, 0x34, 0xdc, 0xca, 0x32, 0xba, 0x14, 0xa9, 0x68, 0xda, 0x13,
- 0xce, 0x44, 0x15, 0x55, 0xb6, 0x8e, 0xb4, 0xb9, 0x68, 0xea, 0xda, 0x43, 0xfe, 0x7b, 0x0d, 0x00,
- 0x00, 0xff, 0xff, 0xba, 0x7a, 0xfa, 0x28, 0xe3, 0x01, 0x00, 0x00,
-}
-
-func (m *EventEthereumTx) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventEthereumTx) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventEthereumTx) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.EthTxFailed) > 0 {
- i -= len(m.EthTxFailed)
- copy(dAtA[i:], m.EthTxFailed)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.EthTxFailed)))
- i--
- dAtA[i] = 0x3a
- }
- if len(m.Recipient) > 0 {
- i -= len(m.Recipient)
- copy(dAtA[i:], m.Recipient)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.Recipient)))
- i--
- dAtA[i] = 0x32
- }
- if len(m.Hash) > 0 {
- i -= len(m.Hash)
- copy(dAtA[i:], m.Hash)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.Hash)))
- i--
- dAtA[i] = 0x2a
- }
- if len(m.GasUsed) > 0 {
- i -= len(m.GasUsed)
- copy(dAtA[i:], m.GasUsed)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.GasUsed)))
- i--
- dAtA[i] = 0x22
- }
- if len(m.Index) > 0 {
- i -= len(m.Index)
- copy(dAtA[i:], m.Index)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.Index)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.EthHash) > 0 {
- i -= len(m.EthHash)
- copy(dAtA[i:], m.EthHash)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.EthHash)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Amount) > 0 {
- i -= len(m.Amount)
- copy(dAtA[i:], m.Amount)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.Amount)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventTxLog) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventTxLog) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventTxLog) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.TxLogs) > 0 {
- for iNdEx := len(m.TxLogs) - 1; iNdEx >= 0; iNdEx-- {
- i -= len(m.TxLogs[iNdEx])
- copy(dAtA[i:], m.TxLogs[iNdEx])
- i = encodeVarintEvents(dAtA, i, uint64(len(m.TxLogs[iNdEx])))
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventMessage) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventMessage) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.TxType) > 0 {
- i -= len(m.TxType)
- copy(dAtA[i:], m.TxType)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.TxType)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Module) > 0 {
- i -= len(m.Module)
- copy(dAtA[i:], m.Module)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.Module)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventBlockBloom) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventBlockBloom) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventBlockBloom) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Bloom) > 0 {
- i -= len(m.Bloom)
- copy(dAtA[i:], m.Bloom)
- i = encodeVarintEvents(dAtA, i, uint64(len(m.Bloom)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintEvents(dAtA []byte, offset int, v uint64) int {
- offset -= sovEvents(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *EventEthereumTx) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Amount)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- l = len(m.EthHash)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- l = len(m.Index)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- l = len(m.GasUsed)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- l = len(m.Hash)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- l = len(m.Recipient)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- l = len(m.EthTxFailed)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- return n
-}
-
-func (m *EventTxLog) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.TxLogs) > 0 {
- for _, s := range m.TxLogs {
- l = len(s)
- n += 1 + l + sovEvents(uint64(l))
- }
- }
- return n
-}
-
-func (m *EventMessage) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Module)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- l = len(m.TxType)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- return n
-}
-
-func (m *EventBlockBloom) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Bloom)
- if l > 0 {
- n += 1 + l + sovEvents(uint64(l))
- }
- return n
-}
-
-func sovEvents(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozEvents(x uint64) (n int) {
- return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *EventEthereumTx) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventEthereumTx: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventEthereumTx: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Amount = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EthHash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.EthHash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Index = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasUsed", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.GasUsed = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Hash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Recipient = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EthTxFailed", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.EthTxFailed = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvents(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvents
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventTxLog) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventTxLog: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventTxLog: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field TxLogs", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.TxLogs = append(m.TxLogs, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvents(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvents
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventMessage) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventMessage: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventMessage: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Module", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Module = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field TxType", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.TxType = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvents(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvents
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventBlockBloom) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventBlockBloom: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventBlockBloom: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Bloom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvents
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvents
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Bloom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvents(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvents
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipEvents(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvents
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthEvents
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupEvents
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthEvents
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/evm/evm.pb.go b/x/evm/evm.pb.go
deleted file mode 100644
index dcb320fab..000000000
--- a/x/evm/evm.pb.go
+++ /dev/null
@@ -1,4175 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: eth/evm/v1/evm.proto
-
-package evm
-
-import (
- cosmossdk_io_math "cosmossdk.io/math"
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// Params defines the EVM module parameters
-type Params struct {
- // evm_denom represents the token denomination used to run the EVM state
- // transitions.
- EvmDenom string `protobuf:"bytes,1,opt,name=evm_denom,json=evmDenom,proto3" json:"evm_denom,omitempty" yaml:"evm_denom"`
- // enable_create toggles state transitions that use the vm.Create function
- EnableCreate bool `protobuf:"varint,2,opt,name=enable_create,json=enableCreate,proto3" json:"enable_create,omitempty" yaml:"enable_create"`
- // enable_call toggles state transitions that use the vm.Call function
- EnableCall bool `protobuf:"varint,3,opt,name=enable_call,json=enableCall,proto3" json:"enable_call,omitempty" yaml:"enable_call"`
- // extra_eips defines the additional EIPs for the vm.Config
- ExtraEIPs []int64 `protobuf:"varint,4,rep,packed,name=extra_eips,json=extraEips,proto3" json:"extra_eips,omitempty" yaml:"extra_eips"`
- // chain_config defines the EVM chain configuration parameters
- ChainConfig ChainConfig `protobuf:"bytes,5,opt,name=chain_config,json=chainConfig,proto3" json:"chain_config" yaml:"chain_config"`
- // allow_unprotected_txs defines if replay-protected (i.e non EIP155
- // signed) transactions can be executed on the state machine.
- AllowUnprotectedTxs bool `protobuf:"varint,6,opt,name=allow_unprotected_txs,json=allowUnprotectedTxs,proto3" json:"allow_unprotected_txs,omitempty"`
- // active_precompiles defines the slice of hex addresses of the precompiled
- // contracts that are active
- ActivePrecompiles []string `protobuf:"bytes,7,rep,name=active_precompiles,json=activePrecompiles,proto3" json:"active_precompiles,omitempty"`
- // evm_channels is the list of channel identifiers from EVM compatible chains
- EVMChannels []string `protobuf:"bytes,8,rep,name=evm_channels,json=evmChannels,proto3" json:"evm_channels,omitempty"`
-}
-
-func (m *Params) Reset() { *m = Params{} }
-func (m *Params) String() string { return proto.CompactTextString(m) }
-func (*Params) ProtoMessage() {}
-func (*Params) Descriptor() ([]byte, []int) {
- return fileDescriptor_98abbdadb327b7d0, []int{0}
-}
-func (m *Params) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_Params.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *Params) XXX_Merge(src proto.Message) {
- xxx_messageInfo_Params.Merge(m, src)
-}
-func (m *Params) XXX_Size() int {
- return m.Size()
-}
-func (m *Params) XXX_DiscardUnknown() {
- xxx_messageInfo_Params.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_Params proto.InternalMessageInfo
-
-func (m *Params) GetEvmDenom() string {
- if m != nil {
- return m.EvmDenom
- }
- return ""
-}
-
-func (m *Params) GetEnableCreate() bool {
- if m != nil {
- return m.EnableCreate
- }
- return false
-}
-
-func (m *Params) GetEnableCall() bool {
- if m != nil {
- return m.EnableCall
- }
- return false
-}
-
-func (m *Params) GetExtraEIPs() []int64 {
- if m != nil {
- return m.ExtraEIPs
- }
- return nil
-}
-
-func (m *Params) GetChainConfig() ChainConfig {
- if m != nil {
- return m.ChainConfig
- }
- return ChainConfig{}
-}
-
-func (m *Params) GetAllowUnprotectedTxs() bool {
- if m != nil {
- return m.AllowUnprotectedTxs
- }
- return false
-}
-
-func (m *Params) GetActivePrecompiles() []string {
- if m != nil {
- return m.ActivePrecompiles
- }
- return nil
-}
-
-func (m *Params) GetEVMChannels() []string {
- if m != nil {
- return m.EVMChannels
- }
- return nil
-}
-
-// ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values
-// instead of *big.Int.
-type ChainConfig struct {
- // homestead_block switch (nil no fork, 0 = already homestead)
- HomesteadBlock *cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=homestead_block,json=homesteadBlock,proto3,customtype=cosmossdk.io/math.Int" json:"homestead_block,omitempty" yaml:"homestead_block"`
- // dao_fork_block corresponds to TheDAO hard-fork switch block (nil no fork)
- DAOForkBlock *cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=dao_fork_block,json=daoForkBlock,proto3,customtype=cosmossdk.io/math.Int" json:"dao_fork_block,omitempty" yaml:"dao_fork_block"`
- // dao_fork_support defines whether the nodes supports or opposes the DAO hard-fork
- DAOForkSupport bool `protobuf:"varint,3,opt,name=dao_fork_support,json=daoForkSupport,proto3" json:"dao_fork_support,omitempty" yaml:"dao_fork_support"`
- // eip150_block: EIP150 implements the Gas price changes
- // (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (nil no fork)
- EIP150Block *cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=eip150_block,json=eip150Block,proto3,customtype=cosmossdk.io/math.Int" json:"eip150_block,omitempty" yaml:"eip150_block"`
- // eip150_hash: EIP150 HF hash (needed for header only clients as only gas pricing changed)
- EIP150Hash string `protobuf:"bytes,5,opt,name=eip150_hash,json=eip150Hash,proto3" json:"eip150_hash,omitempty" yaml:"byzantium_block"`
- // eip155_block: EIP155Block HF block
- EIP155Block *cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=eip155_block,json=eip155Block,proto3,customtype=cosmossdk.io/math.Int" json:"eip155_block,omitempty" yaml:"eip155_block"`
- // eip158_block: EIP158 HF block
- EIP158Block *cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=eip158_block,json=eip158Block,proto3,customtype=cosmossdk.io/math.Int" json:"eip158_block,omitempty" yaml:"eip158_block"`
- // byzantium_block: Byzantium switch block (nil no fork, 0 = already on byzantium)
- ByzantiumBlock *cosmossdk_io_math.Int `protobuf:"bytes,8,opt,name=byzantium_block,json=byzantiumBlock,proto3,customtype=cosmossdk.io/math.Int" json:"byzantium_block,omitempty" yaml:"byzantium_block"`
- // constantinople_block: Constantinople switch block (nil no fork, 0 = already activated)
- ConstantinopleBlock *cosmossdk_io_math.Int `protobuf:"bytes,9,opt,name=constantinople_block,json=constantinopleBlock,proto3,customtype=cosmossdk.io/math.Int" json:"constantinople_block,omitempty" yaml:"constantinople_block"`
- // petersburg_block: Petersburg switch block (nil same as Constantinople)
- PetersburgBlock *cosmossdk_io_math.Int `protobuf:"bytes,10,opt,name=petersburg_block,json=petersburgBlock,proto3,customtype=cosmossdk.io/math.Int" json:"petersburg_block,omitempty" yaml:"petersburg_block"`
- // istanbul_block: Istanbul switch block (nil no fork, 0 = already on istanbul)
- IstanbulBlock *cosmossdk_io_math.Int `protobuf:"bytes,11,opt,name=istanbul_block,json=istanbulBlock,proto3,customtype=cosmossdk.io/math.Int" json:"istanbul_block,omitempty" yaml:"istanbul_block"`
- // muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no fork, 0 = already activated)
- MuirGlacierBlock *cosmossdk_io_math.Int `protobuf:"bytes,12,opt,name=muir_glacier_block,json=muirGlacierBlock,proto3,customtype=cosmossdk.io/math.Int" json:"muir_glacier_block,omitempty" yaml:"muir_glacier_block"`
- // berlin_block: Berlin switch block (nil = no fork, 0 = already on berlin)
- BerlinBlock *cosmossdk_io_math.Int `protobuf:"bytes,13,opt,name=berlin_block,json=berlinBlock,proto3,customtype=cosmossdk.io/math.Int" json:"berlin_block,omitempty" yaml:"berlin_block"`
- // london_block: London switch block (nil = no fork, 0 = already on london)
- LondonBlock *cosmossdk_io_math.Int `protobuf:"bytes,17,opt,name=london_block,json=londonBlock,proto3,customtype=cosmossdk.io/math.Int" json:"london_block,omitempty" yaml:"london_block"`
- // arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
- ArrowGlacierBlock *cosmossdk_io_math.Int `protobuf:"bytes,18,opt,name=arrow_glacier_block,json=arrowGlacierBlock,proto3,customtype=cosmossdk.io/math.Int" json:"arrow_glacier_block,omitempty" yaml:"arrow_glacier_block"`
- // gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
- GrayGlacierBlock *cosmossdk_io_math.Int `protobuf:"bytes,20,opt,name=gray_glacier_block,json=grayGlacierBlock,proto3,customtype=cosmossdk.io/math.Int" json:"gray_glacier_block,omitempty" yaml:"gray_glacier_block"`
- // merge_netsplit_block: Virtual fork after The Merge to use as a network splitter
- MergeNetsplitBlock *cosmossdk_io_math.Int `protobuf:"bytes,21,opt,name=merge_netsplit_block,json=mergeNetsplitBlock,proto3,customtype=cosmossdk.io/math.Int" json:"merge_netsplit_block,omitempty" yaml:"merge_netsplit_block"`
- // shanghai_block switch block (nil = no fork, 0 = already on shanghai)
- ShanghaiBlock *cosmossdk_io_math.Int `protobuf:"bytes,22,opt,name=shanghai_block,json=shanghaiBlock,proto3,customtype=cosmossdk.io/math.Int" json:"shanghai_block,omitempty" yaml:"shanghai_block"`
- // cancun_block switch block (nil = no fork, 0 = already on cancun)
- CancunBlock *cosmossdk_io_math.Int `protobuf:"bytes,23,opt,name=cancun_block,json=cancunBlock,proto3,customtype=cosmossdk.io/math.Int" json:"cancun_block,omitempty" yaml:"cancun_block"`
-}
-
-func (m *ChainConfig) Reset() { *m = ChainConfig{} }
-func (m *ChainConfig) String() string { return proto.CompactTextString(m) }
-func (*ChainConfig) ProtoMessage() {}
-func (*ChainConfig) Descriptor() ([]byte, []int) {
- return fileDescriptor_98abbdadb327b7d0, []int{1}
-}
-func (m *ChainConfig) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *ChainConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_ChainConfig.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *ChainConfig) XXX_Merge(src proto.Message) {
- xxx_messageInfo_ChainConfig.Merge(m, src)
-}
-func (m *ChainConfig) XXX_Size() int {
- return m.Size()
-}
-func (m *ChainConfig) XXX_DiscardUnknown() {
- xxx_messageInfo_ChainConfig.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ChainConfig proto.InternalMessageInfo
-
-func (m *ChainConfig) GetDAOForkSupport() bool {
- if m != nil {
- return m.DAOForkSupport
- }
- return false
-}
-
-func (m *ChainConfig) GetEIP150Hash() string {
- if m != nil {
- return m.EIP150Hash
- }
- return ""
-}
-
-// State represents a single Storage key value pair item.
-type State struct {
- // key is the stored key
- Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
- // value is the stored value for the given key
- Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
-}
-
-func (m *State) Reset() { *m = State{} }
-func (m *State) String() string { return proto.CompactTextString(m) }
-func (*State) ProtoMessage() {}
-func (*State) Descriptor() ([]byte, []int) {
- return fileDescriptor_98abbdadb327b7d0, []int{2}
-}
-func (m *State) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *State) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_State.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *State) XXX_Merge(src proto.Message) {
- xxx_messageInfo_State.Merge(m, src)
-}
-func (m *State) XXX_Size() int {
- return m.Size()
-}
-func (m *State) XXX_DiscardUnknown() {
- xxx_messageInfo_State.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_State proto.InternalMessageInfo
-
-func (m *State) GetKey() string {
- if m != nil {
- return m.Key
- }
- return ""
-}
-
-func (m *State) GetValue() string {
- if m != nil {
- return m.Value
- }
- return ""
-}
-
-// TransactionLogs define the logs generated from a transaction execution
-// with a given hash. It it used for import/export data as transactions are not
-// persisted on blockchain state after an upgrade.
-type TransactionLogs struct {
- // hash of the transaction
- Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
- // logs is an array of Logs for the given transaction hash
- Logs []*Log `protobuf:"bytes,2,rep,name=logs,proto3" json:"logs,omitempty"`
-}
-
-func (m *TransactionLogs) Reset() { *m = TransactionLogs{} }
-func (m *TransactionLogs) String() string { return proto.CompactTextString(m) }
-func (*TransactionLogs) ProtoMessage() {}
-func (*TransactionLogs) Descriptor() ([]byte, []int) {
- return fileDescriptor_98abbdadb327b7d0, []int{3}
-}
-func (m *TransactionLogs) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *TransactionLogs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_TransactionLogs.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *TransactionLogs) XXX_Merge(src proto.Message) {
- xxx_messageInfo_TransactionLogs.Merge(m, src)
-}
-func (m *TransactionLogs) XXX_Size() int {
- return m.Size()
-}
-func (m *TransactionLogs) XXX_DiscardUnknown() {
- xxx_messageInfo_TransactionLogs.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_TransactionLogs proto.InternalMessageInfo
-
-func (m *TransactionLogs) GetHash() string {
- if m != nil {
- return m.Hash
- }
- return ""
-}
-
-func (m *TransactionLogs) GetLogs() []*Log {
- if m != nil {
- return m.Logs
- }
- return nil
-}
-
-// Log represents an protobuf compatible Ethereum Log that defines a contract
-// log event. These events are generated by the LOG opcode and stored/indexed by
-// the node.
-//
-// NOTE: address, topics and data are consensus fields. The rest of the fields
-// are derived, i.e. filled in by the nodes, but not secured by consensus.
-type Log struct {
- // address of the contract that generated the event
- Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
- // topics is a list of topics provided by the contract.
- Topics []string `protobuf:"bytes,2,rep,name=topics,proto3" json:"topics,omitempty"`
- // data which is supplied by the contract, usually ABI-encoded
- Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
- // block_number of the block in which the transaction was included
- BlockNumber uint64 `protobuf:"varint,4,opt,name=block_number,json=blockNumber,proto3" json:"blockNumber"`
- // tx_hash is the transaction hash
- TxHash string `protobuf:"bytes,5,opt,name=tx_hash,json=txHash,proto3" json:"transactionHash"`
- // tx_index of the transaction in the block
- TxIndex uint64 `protobuf:"varint,6,opt,name=tx_index,json=txIndex,proto3" json:"transactionIndex"`
- // block_hash of the block in which the transaction was included
- BlockHash string `protobuf:"bytes,7,opt,name=block_hash,json=blockHash,proto3" json:"blockHash"`
- // index of the log in the block
- Index uint64 `protobuf:"varint,8,opt,name=index,proto3" json:"logIndex"`
- // removed is true if this log was reverted due to a chain
- // reorganisation. You must pay attention to this field if you receive logs
- // through a filter query.
- Removed bool `protobuf:"varint,9,opt,name=removed,proto3" json:"removed,omitempty"`
-}
-
-func (m *Log) Reset() { *m = Log{} }
-func (m *Log) String() string { return proto.CompactTextString(m) }
-func (*Log) ProtoMessage() {}
-func (*Log) Descriptor() ([]byte, []int) {
- return fileDescriptor_98abbdadb327b7d0, []int{4}
-}
-func (m *Log) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *Log) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_Log.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *Log) XXX_Merge(src proto.Message) {
- xxx_messageInfo_Log.Merge(m, src)
-}
-func (m *Log) XXX_Size() int {
- return m.Size()
-}
-func (m *Log) XXX_DiscardUnknown() {
- xxx_messageInfo_Log.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_Log proto.InternalMessageInfo
-
-func (m *Log) GetAddress() string {
- if m != nil {
- return m.Address
- }
- return ""
-}
-
-func (m *Log) GetTopics() []string {
- if m != nil {
- return m.Topics
- }
- return nil
-}
-
-func (m *Log) GetData() []byte {
- if m != nil {
- return m.Data
- }
- return nil
-}
-
-func (m *Log) GetBlockNumber() uint64 {
- if m != nil {
- return m.BlockNumber
- }
- return 0
-}
-
-func (m *Log) GetTxHash() string {
- if m != nil {
- return m.TxHash
- }
- return ""
-}
-
-func (m *Log) GetTxIndex() uint64 {
- if m != nil {
- return m.TxIndex
- }
- return 0
-}
-
-func (m *Log) GetBlockHash() string {
- if m != nil {
- return m.BlockHash
- }
- return ""
-}
-
-func (m *Log) GetIndex() uint64 {
- if m != nil {
- return m.Index
- }
- return 0
-}
-
-func (m *Log) GetRemoved() bool {
- if m != nil {
- return m.Removed
- }
- return false
-}
-
-// TxResult stores results of Tx execution.
-type TxResult struct {
- // contract_address contains the ethereum address of the created contract (if
- // any). If the state transition is an evm.Call, the contract address will be
- // empty.
- ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty" yaml:"contract_address"`
- // bloom represents the bloom filter bytes
- Bloom []byte `protobuf:"bytes,2,opt,name=bloom,proto3" json:"bloom,omitempty"`
- // tx_logs contains the transaction hash and the proto-compatible ethereum
- // logs.
- TxLogs TransactionLogs `protobuf:"bytes,3,opt,name=tx_logs,json=txLogs,proto3" json:"tx_logs" yaml:"tx_logs"`
- // ret defines the bytes from the execution.
- Ret []byte `protobuf:"bytes,4,opt,name=ret,proto3" json:"ret,omitempty"`
- // reverted flag is set to true when the call has been reverted
- Reverted bool `protobuf:"varint,5,opt,name=reverted,proto3" json:"reverted,omitempty"`
- // gas_used notes the amount of gas consumed while execution
- GasUsed uint64 `protobuf:"varint,6,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"`
-}
-
-func (m *TxResult) Reset() { *m = TxResult{} }
-func (m *TxResult) String() string { return proto.CompactTextString(m) }
-func (*TxResult) ProtoMessage() {}
-func (*TxResult) Descriptor() ([]byte, []int) {
- return fileDescriptor_98abbdadb327b7d0, []int{5}
-}
-func (m *TxResult) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *TxResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_TxResult.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *TxResult) XXX_Merge(src proto.Message) {
- xxx_messageInfo_TxResult.Merge(m, src)
-}
-func (m *TxResult) XXX_Size() int {
- return m.Size()
-}
-func (m *TxResult) XXX_DiscardUnknown() {
- xxx_messageInfo_TxResult.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_TxResult proto.InternalMessageInfo
-
-// AccessTuple is the element type of an access list.
-type AccessTuple struct {
- // address is a hex formatted ethereum address
- Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
- // storage_keys are hex formatted hashes of the storage keys
- StorageKeys []string `protobuf:"bytes,2,rep,name=storage_keys,json=storageKeys,proto3" json:"storageKeys"`
-}
-
-func (m *AccessTuple) Reset() { *m = AccessTuple{} }
-func (m *AccessTuple) String() string { return proto.CompactTextString(m) }
-func (*AccessTuple) ProtoMessage() {}
-func (*AccessTuple) Descriptor() ([]byte, []int) {
- return fileDescriptor_98abbdadb327b7d0, []int{6}
-}
-func (m *AccessTuple) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *AccessTuple) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_AccessTuple.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *AccessTuple) XXX_Merge(src proto.Message) {
- xxx_messageInfo_AccessTuple.Merge(m, src)
-}
-func (m *AccessTuple) XXX_Size() int {
- return m.Size()
-}
-func (m *AccessTuple) XXX_DiscardUnknown() {
- xxx_messageInfo_AccessTuple.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_AccessTuple proto.InternalMessageInfo
-
-// TraceConfig holds extra parameters to trace functions.
-type TraceConfig struct {
- // tracer is a custom javascript tracer
- Tracer string `protobuf:"bytes,1,opt,name=tracer,proto3" json:"tracer,omitempty"`
- // timeout overrides the default timeout of 5 seconds for JavaScript-based tracing
- // calls
- Timeout string `protobuf:"bytes,2,opt,name=timeout,proto3" json:"timeout,omitempty"`
- // reexec defines the number of blocks the tracer is willing to go back
- Reexec uint64 `protobuf:"varint,3,opt,name=reexec,proto3" json:"reexec,omitempty"`
- // disable_stack switches stack capture
- DisableStack bool `protobuf:"varint,5,opt,name=disable_stack,json=disableStack,proto3" json:"disableStack"`
- // disable_storage switches storage capture
- DisableStorage bool `protobuf:"varint,6,opt,name=disable_storage,json=disableStorage,proto3" json:"disableStorage"`
- // debug can be used to print output during capture end
- Debug bool `protobuf:"varint,8,opt,name=debug,proto3" json:"debug,omitempty"`
- // limit defines the maximum length of output, but zero means unlimited
- Limit int32 `protobuf:"varint,9,opt,name=limit,proto3" json:"limit,omitempty"`
- // overrides can be used to execute a trace using future fork rules
- Overrides *ChainConfig `protobuf:"bytes,10,opt,name=overrides,proto3" json:"overrides,omitempty"`
- // enable_memory switches memory capture
- EnableMemory bool `protobuf:"varint,11,opt,name=enable_memory,json=enableMemory,proto3" json:"enableMemory"`
- // enable_return_data switches the capture of return data
- EnableReturnData bool `protobuf:"varint,12,opt,name=enable_return_data,json=enableReturnData,proto3" json:"enableReturnData"`
- // tracer_json_config configures the tracer using a JSON string
- TracerJsonConfig string `protobuf:"bytes,13,opt,name=tracer_json_config,json=tracerJsonConfig,proto3" json:"tracerConfig"`
-}
-
-func (m *TraceConfig) Reset() { *m = TraceConfig{} }
-func (m *TraceConfig) String() string { return proto.CompactTextString(m) }
-func (*TraceConfig) ProtoMessage() {}
-func (*TraceConfig) Descriptor() ([]byte, []int) {
- return fileDescriptor_98abbdadb327b7d0, []int{7}
-}
-func (m *TraceConfig) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *TraceConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_TraceConfig.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *TraceConfig) XXX_Merge(src proto.Message) {
- xxx_messageInfo_TraceConfig.Merge(m, src)
-}
-func (m *TraceConfig) XXX_Size() int {
- return m.Size()
-}
-func (m *TraceConfig) XXX_DiscardUnknown() {
- xxx_messageInfo_TraceConfig.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_TraceConfig proto.InternalMessageInfo
-
-func (m *TraceConfig) GetTracer() string {
- if m != nil {
- return m.Tracer
- }
- return ""
-}
-
-func (m *TraceConfig) GetTimeout() string {
- if m != nil {
- return m.Timeout
- }
- return ""
-}
-
-func (m *TraceConfig) GetReexec() uint64 {
- if m != nil {
- return m.Reexec
- }
- return 0
-}
-
-func (m *TraceConfig) GetDisableStack() bool {
- if m != nil {
- return m.DisableStack
- }
- return false
-}
-
-func (m *TraceConfig) GetDisableStorage() bool {
- if m != nil {
- return m.DisableStorage
- }
- return false
-}
-
-func (m *TraceConfig) GetDebug() bool {
- if m != nil {
- return m.Debug
- }
- return false
-}
-
-func (m *TraceConfig) GetLimit() int32 {
- if m != nil {
- return m.Limit
- }
- return 0
-}
-
-func (m *TraceConfig) GetOverrides() *ChainConfig {
- if m != nil {
- return m.Overrides
- }
- return nil
-}
-
-func (m *TraceConfig) GetEnableMemory() bool {
- if m != nil {
- return m.EnableMemory
- }
- return false
-}
-
-func (m *TraceConfig) GetEnableReturnData() bool {
- if m != nil {
- return m.EnableReturnData
- }
- return false
-}
-
-func (m *TraceConfig) GetTracerJsonConfig() string {
- if m != nil {
- return m.TracerJsonConfig
- }
- return ""
-}
-
-func init() {
- proto.RegisterType((*Params)(nil), "eth.evm.v1.Params")
- proto.RegisterType((*ChainConfig)(nil), "eth.evm.v1.ChainConfig")
- proto.RegisterType((*State)(nil), "eth.evm.v1.State")
- proto.RegisterType((*TransactionLogs)(nil), "eth.evm.v1.TransactionLogs")
- proto.RegisterType((*Log)(nil), "eth.evm.v1.Log")
- proto.RegisterType((*TxResult)(nil), "eth.evm.v1.TxResult")
- proto.RegisterType((*AccessTuple)(nil), "eth.evm.v1.AccessTuple")
- proto.RegisterType((*TraceConfig)(nil), "eth.evm.v1.TraceConfig")
-}
-
-func init() { proto.RegisterFile("eth/evm/v1/evm.proto", fileDescriptor_98abbdadb327b7d0) }
-
-var fileDescriptor_98abbdadb327b7d0 = []byte{
- // 1652 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x57, 0xcd, 0x6f, 0xdb, 0xc8,
- 0x15, 0xb7, 0x2d, 0xda, 0xa6, 0x86, 0xb2, 0x44, 0x8f, 0x15, 0x47, 0x9b, 0x00, 0xa6, 0xc1, 0xbd,
- 0xf8, 0xb0, 0x6b, 0xc5, 0x4e, 0xdd, 0x0d, 0xb6, 0xd8, 0x16, 0x61, 0xe2, 0x6d, 0xed, 0x66, 0xd3,
- 0x60, 0xe2, 0xed, 0xa2, 0x45, 0x01, 0x62, 0x44, 0xce, 0x52, 0x5c, 0x93, 0x1c, 0x61, 0x66, 0xa8,
- 0x48, 0xbd, 0x17, 0xe8, 0xb1, 0xe7, 0x9e, 0xfa, 0xe7, 0x2c, 0x7a, 0xda, 0x63, 0xd1, 0x03, 0x51,
- 0x38, 0x40, 0x0f, 0x3e, 0xfa, 0x5e, 0xa0, 0x98, 0x0f, 0x7d, 0xc6, 0x31, 0x7c, 0xd2, 0xfc, 0xde,
- 0xc7, 0xef, 0xcd, 0x7b, 0xf3, 0xa8, 0x37, 0x03, 0xda, 0x44, 0xf4, 0xbb, 0x64, 0x98, 0x77, 0x87,
- 0x47, 0xf2, 0xe7, 0x70, 0xc0, 0xa8, 0xa0, 0x10, 0x10, 0xd1, 0x3f, 0x94, 0x70, 0x78, 0xf4, 0xa8,
- 0x9d, 0xd0, 0x84, 0x2a, 0x71, 0x57, 0xae, 0xb4, 0x85, 0xff, 0xdf, 0x1a, 0xd8, 0x78, 0x83, 0x19,
- 0xce, 0x39, 0x3c, 0x02, 0x75, 0x32, 0xcc, 0xc3, 0x98, 0x14, 0x34, 0xef, 0xac, 0xee, 0xaf, 0x1e,
- 0xd4, 0x83, 0xf6, 0x4d, 0xe5, 0xb9, 0x63, 0x9c, 0x67, 0x5f, 0xfa, 0x53, 0x95, 0x8f, 0x6c, 0x32,
- 0xcc, 0x5f, 0xca, 0x25, 0xfc, 0x0a, 0x6c, 0x91, 0x02, 0xf7, 0x32, 0x12, 0x46, 0x8c, 0x60, 0x41,
- 0x3a, 0x6b, 0xfb, 0xab, 0x07, 0x76, 0xd0, 0xb9, 0xa9, 0xbc, 0xb6, 0x71, 0x9b, 0x57, 0xfb, 0xa8,
- 0xa1, 0xf1, 0x0b, 0x05, 0xe1, 0x17, 0xc0, 0x99, 0xe8, 0x71, 0x96, 0x75, 0x6a, 0xca, 0x79, 0xf7,
- 0xa6, 0xf2, 0xe0, 0xa2, 0x33, 0xce, 0x32, 0x1f, 0x01, 0xe3, 0x8a, 0xb3, 0x0c, 0x3e, 0x07, 0x80,
- 0x8c, 0x04, 0xc3, 0x21, 0x49, 0x07, 0xbc, 0x63, 0xed, 0xd7, 0x0e, 0x6a, 0x81, 0x7f, 0x55, 0x79,
- 0xf5, 0x53, 0x29, 0x3d, 0x3d, 0x7b, 0xc3, 0x6f, 0x2a, 0x6f, 0xdb, 0x90, 0x4c, 0x0d, 0x7d, 0x54,
- 0x57, 0xe0, 0x34, 0x1d, 0x70, 0xf8, 0x1d, 0x68, 0x44, 0x7d, 0x9c, 0x16, 0x61, 0x44, 0x8b, 0xef,
- 0xd3, 0xa4, 0xb3, 0xbe, 0xbf, 0x7a, 0xe0, 0x1c, 0x3f, 0x3c, 0x9c, 0x55, 0xec, 0xf0, 0x85, 0xd4,
- 0xbf, 0x50, 0xea, 0xe0, 0xf1, 0x8f, 0x95, 0xb7, 0x72, 0x53, 0x79, 0x3b, 0x9a, 0x74, 0xde, 0xd5,
- 0x47, 0x4e, 0x34, 0xb3, 0x84, 0xc7, 0xe0, 0x01, 0xce, 0x32, 0xfa, 0x2e, 0x2c, 0x0b, 0x59, 0x62,
- 0x12, 0x09, 0x12, 0x87, 0x62, 0xc4, 0x3b, 0x1b, 0x32, 0x3d, 0xb4, 0xa3, 0x94, 0xdf, 0xce, 0x74,
- 0x17, 0x23, 0x0e, 0x3f, 0x07, 0x10, 0x47, 0x22, 0x1d, 0x92, 0x70, 0xc0, 0x48, 0x44, 0xf3, 0x41,
- 0x9a, 0x11, 0xde, 0xd9, 0xdc, 0xaf, 0x1d, 0xd4, 0xd1, 0xb6, 0xd6, 0xbc, 0x99, 0x29, 0xe0, 0x31,
- 0x68, 0xc8, 0xe3, 0x88, 0xfa, 0xb8, 0x28, 0x48, 0xc6, 0x3b, 0xb6, 0x34, 0x0c, 0x5a, 0x57, 0x95,
- 0xe7, 0x9c, 0xfe, 0xfe, 0x9b, 0x17, 0x46, 0x8c, 0x1c, 0x32, 0xcc, 0x27, 0xc0, 0xff, 0x5f, 0x13,
- 0x38, 0x73, 0x09, 0xc1, 0x3f, 0x81, 0x56, 0x9f, 0xe6, 0x84, 0x0b, 0x82, 0xe3, 0xb0, 0x97, 0xd1,
- 0xe8, 0xd2, 0x9c, 0xf9, 0xd3, 0x7f, 0x57, 0xde, 0x83, 0x88, 0xf2, 0x9c, 0x72, 0x1e, 0x5f, 0x1e,
- 0xa6, 0xb4, 0x9b, 0x63, 0xd1, 0x3f, 0x3c, 0x2b, 0xc4, 0x4d, 0xe5, 0xed, 0xea, 0xf4, 0x97, 0x3c,
- 0x7d, 0xd4, 0x9c, 0x4a, 0x02, 0x29, 0x80, 0x7d, 0xd0, 0x8c, 0x31, 0x0d, 0xbf, 0xa7, 0xec, 0xd2,
- 0x90, 0xaf, 0x29, 0xf2, 0xe0, 0xa3, 0xe4, 0x57, 0x95, 0xd7, 0x78, 0xf9, 0xfc, 0x77, 0x5f, 0x53,
- 0x76, 0xa9, 0x28, 0x6e, 0x2a, 0xef, 0x81, 0x0e, 0xb6, 0x48, 0xe4, 0xa3, 0x46, 0x8c, 0xe9, 0xd4,
- 0x0c, 0x7e, 0x07, 0xdc, 0xa9, 0x01, 0x2f, 0x07, 0x03, 0xca, 0x84, 0x69, 0xa4, 0xcf, 0xaf, 0x2a,
- 0xaf, 0x69, 0x28, 0xdf, 0x6a, 0xcd, 0x4d, 0xe5, 0x3d, 0x5c, 0x22, 0x35, 0x3e, 0x3e, 0x6a, 0x1a,
- 0x5a, 0x63, 0x0a, 0x7b, 0xa0, 0x41, 0xd2, 0xc1, 0xd1, 0xc9, 0x13, 0x93, 0x80, 0xa5, 0x12, 0xf8,
- 0xd5, 0x5d, 0x09, 0x38, 0xa7, 0x67, 0x6f, 0x8e, 0x4e, 0x9e, 0x4c, 0xf6, 0x6f, 0x7a, 0x65, 0x9e,
- 0xc5, 0x47, 0x8e, 0x86, 0x7a, 0xf3, 0x67, 0xc0, 0xc0, 0xb0, 0x8f, 0x79, 0x5f, 0xf5, 0x60, 0x3d,
- 0x38, 0xb8, 0xaa, 0x3c, 0xa0, 0x99, 0x7e, 0x83, 0x79, 0x7f, 0x56, 0xf5, 0xde, 0xf8, 0xcf, 0xb8,
- 0x10, 0x69, 0x99, 0x4f, 0xb8, 0x80, 0x76, 0x96, 0x56, 0xd3, 0xed, 0x9e, 0x98, 0xed, 0x6e, 0xdc,
- 0x77, 0xbb, 0x27, 0xb7, 0x6d, 0xf7, 0x64, 0x71, 0xbb, 0xda, 0x66, 0x1a, 0xe3, 0x99, 0x89, 0xb1,
- 0x79, 0xdf, 0x18, 0xcf, 0x6e, 0x8b, 0xf1, 0x6c, 0x31, 0x86, 0xb6, 0x91, 0x7d, 0xb9, 0x94, 0x67,
- 0xc7, 0xbe, 0x77, 0x5f, 0x7e, 0x50, 0xa1, 0xe6, 0x54, 0xa2, 0xd9, 0x2f, 0x41, 0x3b, 0xa2, 0x05,
- 0x17, 0x52, 0x56, 0xd0, 0x41, 0x46, 0x4c, 0x88, 0xba, 0x0a, 0xf1, 0xec, 0xae, 0x10, 0x8f, 0xcd,
- 0x97, 0x7f, 0x8b, 0xbb, 0x8f, 0x76, 0x16, 0xc5, 0x3a, 0x58, 0x08, 0xdc, 0x01, 0x11, 0x84, 0xf1,
- 0x5e, 0xc9, 0x12, 0x13, 0x08, 0xa8, 0x40, 0x3f, 0xbb, 0x2b, 0x90, 0xe9, 0xd0, 0x65, 0x57, 0x1f,
- 0xb5, 0x66, 0x22, 0x1d, 0xe0, 0x0f, 0xa0, 0x99, 0xca, 0xa8, 0xbd, 0x32, 0x33, 0xf4, 0x8e, 0xa2,
- 0x3f, 0xbe, 0x8b, 0xde, 0x7c, 0x55, 0x8b, 0x8e, 0x3e, 0xda, 0x9a, 0x08, 0x34, 0x75, 0x0c, 0x60,
- 0x5e, 0xa6, 0x2c, 0x4c, 0x32, 0x1c, 0xa5, 0x84, 0x19, 0xfa, 0x86, 0xa2, 0xff, 0xf9, 0x5d, 0xf4,
- 0x9f, 0x68, 0xfa, 0x0f, 0x9d, 0x7d, 0xe4, 0x4a, 0xe1, 0xaf, 0xb5, 0x4c, 0x47, 0x79, 0x0b, 0x1a,
- 0x3d, 0xc2, 0xb2, 0xb4, 0x30, 0xfc, 0x5b, 0x8a, 0xff, 0xc9, 0x5d, 0xfc, 0xa6, 0x83, 0xe6, 0xdd,
- 0x7c, 0xe4, 0x68, 0x38, 0x25, 0xcd, 0x68, 0x11, 0xd3, 0x09, 0xe9, 0xf6, 0xbd, 0x49, 0xe7, 0xdd,
- 0x7c, 0xe4, 0x68, 0xa8, 0x49, 0x13, 0xb0, 0x83, 0x19, 0xa3, 0xef, 0x96, 0x0a, 0x02, 0x15, 0xf7,
- 0x17, 0x77, 0x71, 0x3f, 0xd2, 0xdc, 0xb7, 0x78, 0xfb, 0x68, 0x5b, 0x49, 0x17, 0x4a, 0x12, 0x03,
- 0x98, 0x30, 0x3c, 0x5e, 0x8a, 0xd3, 0xbe, 0x77, 0xe1, 0x3f, 0x74, 0xf6, 0x91, 0x2b, 0x85, 0x0b,
- 0x51, 0x7e, 0x00, 0xed, 0x9c, 0xb0, 0x84, 0x84, 0x05, 0x11, 0x7c, 0x90, 0xa5, 0xc2, 0xc4, 0x79,
- 0x70, 0xef, 0xef, 0xe0, 0x36, 0x77, 0x1f, 0x41, 0x25, 0x7e, 0x6d, 0xa4, 0xd3, 0x2e, 0xe5, 0x7d,
- 0x5c, 0x24, 0x7d, 0x9c, 0x9a, 0x28, 0xbb, 0xf7, 0xee, 0xd2, 0x45, 0x47, 0x1f, 0x6d, 0x4d, 0x04,
- 0xd3, 0xa3, 0x8e, 0x70, 0x11, 0x95, 0x93, 0xa3, 0x7e, 0x78, 0xef, 0xa3, 0x9e, 0x77, 0x93, 0x03,
- 0x5c, 0x41, 0x45, 0x7a, 0x6e, 0xd9, 0x4d, 0xb7, 0x75, 0x6e, 0xd9, 0x2d, 0xd7, 0x3d, 0xb7, 0x6c,
- 0xd7, 0xdd, 0x3e, 0xb7, 0xec, 0x1d, 0xb7, 0x8d, 0xb6, 0xc6, 0x34, 0xa3, 0xe1, 0xf0, 0xa9, 0x76,
- 0x42, 0x0e, 0x79, 0x87, 0xb9, 0xf9, 0xa3, 0x41, 0xcd, 0x08, 0x0b, 0x9c, 0x8d, 0xb9, 0x29, 0x04,
- 0x72, 0x75, 0x79, 0xe6, 0xc6, 0x56, 0x17, 0xac, 0xbf, 0x15, 0xf2, 0xd2, 0xe3, 0x82, 0xda, 0x25,
- 0x19, 0xeb, 0x61, 0x8b, 0xe4, 0x12, 0xb6, 0xc1, 0xfa, 0x10, 0x67, 0xa5, 0xbe, 0x3d, 0xd5, 0x91,
- 0x06, 0xfe, 0x39, 0x68, 0x5d, 0x30, 0x5c, 0x70, 0x39, 0xfe, 0x69, 0xf1, 0x8a, 0x26, 0x1c, 0x42,
- 0x60, 0xa9, 0x39, 0xa1, 0x7d, 0xd5, 0x1a, 0x7e, 0x0a, 0xac, 0x8c, 0x26, 0xbc, 0xb3, 0xb6, 0x5f,
- 0x3b, 0x70, 0x8e, 0x5b, 0xf3, 0xf7, 0x97, 0x57, 0x34, 0x41, 0x4a, 0xe9, 0xff, 0x73, 0x0d, 0xd4,
- 0x5e, 0xd1, 0x04, 0x76, 0xc0, 0x26, 0x8e, 0x63, 0x46, 0x38, 0x37, 0x1c, 0x13, 0x08, 0x77, 0xc1,
- 0x86, 0xa0, 0x83, 0x34, 0xd2, 0x44, 0x75, 0x64, 0x90, 0x0c, 0x19, 0x63, 0x81, 0xd5, 0x48, 0x6d,
- 0x20, 0xb5, 0x96, 0xd7, 0x0f, 0x95, 0x53, 0x58, 0x94, 0x79, 0x8f, 0x30, 0x35, 0x19, 0xad, 0xa0,
- 0x75, 0x5d, 0x79, 0x8e, 0x92, 0xbf, 0x56, 0x62, 0x34, 0x0f, 0xe0, 0x67, 0x60, 0x53, 0x8c, 0xe6,
- 0xa7, 0xdc, 0xce, 0x75, 0xe5, 0xb5, 0xc4, 0x2c, 0x41, 0x39, 0xc4, 0xd0, 0x86, 0x18, 0xa9, 0x61,
- 0xd6, 0x05, 0xb6, 0x18, 0x85, 0x69, 0x11, 0x93, 0x91, 0x1a, 0x64, 0x56, 0xd0, 0xbe, 0xae, 0x3c,
- 0x77, 0xce, 0xfc, 0x4c, 0xea, 0xd0, 0xa6, 0x18, 0xa9, 0x05, 0xfc, 0x0c, 0x00, 0xbd, 0x25, 0x15,
- 0x41, 0xcf, 0xa5, 0xad, 0xeb, 0xca, 0xab, 0x2b, 0xa9, 0xe2, 0x9e, 0x2d, 0xa1, 0x0f, 0xd6, 0x35,
- 0xb7, 0xad, 0xb8, 0x1b, 0xd7, 0x95, 0x67, 0x67, 0x34, 0xd1, 0x9c, 0x5a, 0x25, 0x4b, 0xc5, 0x48,
- 0x4e, 0x87, 0x24, 0x56, 0xc3, 0xc1, 0x46, 0x13, 0xe8, 0xff, 0x65, 0x0d, 0xd8, 0x17, 0x23, 0x44,
- 0x78, 0x99, 0x09, 0xf8, 0x35, 0x70, 0x23, 0x5a, 0x08, 0x86, 0x23, 0x11, 0x2e, 0x94, 0x36, 0x78,
- 0x3c, 0xfb, 0x2b, 0x5f, 0xb6, 0xf0, 0x51, 0x6b, 0x22, 0x7a, 0x6e, 0xea, 0xdf, 0x06, 0xeb, 0xbd,
- 0x8c, 0xd2, 0x5c, 0xf5, 0x40, 0x03, 0x69, 0x00, 0x5f, 0xa9, 0xaa, 0xa9, 0xf3, 0xad, 0xa9, 0xfb,
- 0xe9, 0xe3, 0xf9, 0xf3, 0x5d, 0x6a, 0x8f, 0x60, 0xd7, 0xdc, 0x51, 0x9b, 0x3a, 0xaa, 0xf1, 0xf4,
- 0x65, 0x55, 0x55, 0xfb, 0xb8, 0xa0, 0xc6, 0x88, 0x50, 0xc7, 0xd5, 0x40, 0x72, 0x09, 0x1f, 0x01,
- 0x9b, 0x91, 0x21, 0x61, 0x82, 0xc4, 0xea, 0x58, 0x6c, 0x34, 0xc5, 0xf0, 0x13, 0x60, 0x27, 0x98,
- 0x87, 0x25, 0x27, 0xb1, 0x3e, 0x03, 0xb4, 0x99, 0x60, 0xfe, 0x2d, 0x27, 0xf1, 0x97, 0xd6, 0x5f,
- 0xff, 0xe1, 0xad, 0xf8, 0x18, 0x38, 0xcf, 0xa3, 0x88, 0x70, 0x7e, 0x51, 0x0e, 0x32, 0x72, 0x47,
- 0x6f, 0x1d, 0x83, 0x06, 0x17, 0x94, 0xe1, 0x84, 0x84, 0x97, 0x64, 0x6c, 0x3a, 0x4c, 0xf7, 0x8b,
- 0x91, 0xff, 0x96, 0x8c, 0x39, 0x9a, 0x07, 0x26, 0xc4, 0xdf, 0x2d, 0xe0, 0x5c, 0x30, 0x1c, 0x11,
- 0x73, 0x69, 0x95, 0x5d, 0x2a, 0x21, 0x33, 0x21, 0x0c, 0x92, 0xb1, 0x45, 0x9a, 0x13, 0x5a, 0x0a,
- 0xf3, 0x0d, 0x4d, 0xa0, 0xf4, 0x60, 0x84, 0x8c, 0x48, 0xa4, 0x0a, 0x68, 0x21, 0x83, 0xe0, 0x09,
- 0xd8, 0x8a, 0x53, 0xae, 0x9e, 0x17, 0x5c, 0xe0, 0xe8, 0x52, 0xa7, 0x1f, 0xb8, 0xd7, 0x95, 0xd7,
- 0x30, 0x8a, 0xb7, 0x52, 0x8e, 0x16, 0x10, 0xfc, 0x05, 0x68, 0xcd, 0xdc, 0xd4, 0x6e, 0xf5, 0xb5,
- 0x3e, 0x80, 0xd7, 0x95, 0xd7, 0x9c, 0x9a, 0x2a, 0x0d, 0x5a, 0xc2, 0xf2, 0x8c, 0x63, 0xd2, 0x2b,
- 0x13, 0xd5, 0x76, 0x36, 0xd2, 0x40, 0x4a, 0xb3, 0x34, 0x4f, 0x85, 0x6a, 0xb3, 0x75, 0xa4, 0x01,
- 0x3c, 0x01, 0x75, 0x3a, 0x24, 0x8c, 0xa5, 0x31, 0xe1, 0xea, 0xd2, 0xf0, 0xf1, 0xb7, 0x09, 0x9a,
- 0x59, 0xca, 0xb4, 0xcc, 0xa3, 0x29, 0x27, 0x39, 0x65, 0x63, 0x75, 0x21, 0x30, 0x69, 0x69, 0xc5,
- 0x37, 0x4a, 0x8e, 0x16, 0x10, 0x0c, 0x00, 0x34, 0x6e, 0x8c, 0x88, 0x92, 0x15, 0xa1, 0xfa, 0xe6,
- 0x1b, 0xca, 0x57, 0x7d, 0x79, 0x5a, 0x8b, 0x94, 0xf2, 0x25, 0x16, 0x18, 0x7d, 0x20, 0x81, 0xbf,
- 0x04, 0x50, 0x9f, 0x46, 0xf8, 0x03, 0xa7, 0xd3, 0x67, 0x95, 0x9e, 0xe8, 0x2a, 0xbe, 0xd6, 0x9a,
- 0x3d, 0xbb, 0x1a, 0x9d, 0x73, 0x6a, 0xb2, 0x38, 0xb7, 0x6c, 0xcb, 0x5d, 0x3f, 0xb7, 0xec, 0x4d,
- 0xd7, 0x9e, 0x56, 0xce, 0x64, 0x81, 0x76, 0x26, 0x78, 0x6e, 0x7b, 0xc1, 0x57, 0x3f, 0x5e, 0xed,
- 0xad, 0xfe, 0x74, 0xb5, 0xb7, 0xfa, 0x9f, 0xab, 0xbd, 0xd5, 0xbf, 0xbd, 0xdf, 0x5b, 0xf9, 0xe9,
- 0xfd, 0xde, 0xca, 0xbf, 0xde, 0xef, 0xad, 0xfc, 0xf1, 0xd3, 0x24, 0x15, 0xfd, 0xb2, 0x77, 0x18,
- 0xd1, 0xbc, 0xfb, 0x3a, 0xed, 0xa5, 0xac, 0x54, 0xe5, 0xea, 0x16, 0x6a, 0xdd, 0x1d, 0xc9, 0x17,
- 0x72, 0x6f, 0x43, 0x3d, 0x80, 0x9f, 0xfe, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x48, 0xfd, 0xff,
- 0x3a, 0x0f, 0x00, 0x00,
-}
-
-func (m *Params) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Params) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.EVMChannels) > 0 {
- for iNdEx := len(m.EVMChannels) - 1; iNdEx >= 0; iNdEx-- {
- i -= len(m.EVMChannels[iNdEx])
- copy(dAtA[i:], m.EVMChannels[iNdEx])
- i = encodeVarintEvm(dAtA, i, uint64(len(m.EVMChannels[iNdEx])))
- i--
- dAtA[i] = 0x42
- }
- }
- if len(m.ActivePrecompiles) > 0 {
- for iNdEx := len(m.ActivePrecompiles) - 1; iNdEx >= 0; iNdEx-- {
- i -= len(m.ActivePrecompiles[iNdEx])
- copy(dAtA[i:], m.ActivePrecompiles[iNdEx])
- i = encodeVarintEvm(dAtA, i, uint64(len(m.ActivePrecompiles[iNdEx])))
- i--
- dAtA[i] = 0x3a
- }
- }
- if m.AllowUnprotectedTxs {
- i--
- if m.AllowUnprotectedTxs {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x30
- }
- {
- size, err := m.ChainConfig.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x2a
- if len(m.ExtraEIPs) > 0 {
- dAtA3 := make([]byte, len(m.ExtraEIPs)*10)
- var j2 int
- for _, num1 := range m.ExtraEIPs {
- num := uint64(num1)
- for num >= 1<<7 {
- dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80)
- num >>= 7
- j2++
- }
- dAtA3[j2] = uint8(num)
- j2++
- }
- i -= j2
- copy(dAtA[i:], dAtA3[:j2])
- i = encodeVarintEvm(dAtA, i, uint64(j2))
- i--
- dAtA[i] = 0x22
- }
- if m.EnableCall {
- i--
- if m.EnableCall {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x18
- }
- if m.EnableCreate {
- i--
- if m.EnableCreate {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x10
- }
- if len(m.EvmDenom) > 0 {
- i -= len(m.EvmDenom)
- copy(dAtA[i:], m.EvmDenom)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.EvmDenom)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *ChainConfig) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ChainConfig) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *ChainConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.CancunBlock != nil {
- {
- size := m.CancunBlock.Size()
- i -= size
- if _, err := m.CancunBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1
- i--
- dAtA[i] = 0xba
- }
- if m.ShanghaiBlock != nil {
- {
- size := m.ShanghaiBlock.Size()
- i -= size
- if _, err := m.ShanghaiBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1
- i--
- dAtA[i] = 0xb2
- }
- if m.MergeNetsplitBlock != nil {
- {
- size := m.MergeNetsplitBlock.Size()
- i -= size
- if _, err := m.MergeNetsplitBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1
- i--
- dAtA[i] = 0xaa
- }
- if m.GrayGlacierBlock != nil {
- {
- size := m.GrayGlacierBlock.Size()
- i -= size
- if _, err := m.GrayGlacierBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1
- i--
- dAtA[i] = 0xa2
- }
- if m.ArrowGlacierBlock != nil {
- {
- size := m.ArrowGlacierBlock.Size()
- i -= size
- if _, err := m.ArrowGlacierBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1
- i--
- dAtA[i] = 0x92
- }
- if m.LondonBlock != nil {
- {
- size := m.LondonBlock.Size()
- i -= size
- if _, err := m.LondonBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1
- i--
- dAtA[i] = 0x8a
- }
- if m.BerlinBlock != nil {
- {
- size := m.BerlinBlock.Size()
- i -= size
- if _, err := m.BerlinBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x6a
- }
- if m.MuirGlacierBlock != nil {
- {
- size := m.MuirGlacierBlock.Size()
- i -= size
- if _, err := m.MuirGlacierBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x62
- }
- if m.IstanbulBlock != nil {
- {
- size := m.IstanbulBlock.Size()
- i -= size
- if _, err := m.IstanbulBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x5a
- }
- if m.PetersburgBlock != nil {
- {
- size := m.PetersburgBlock.Size()
- i -= size
- if _, err := m.PetersburgBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x52
- }
- if m.ConstantinopleBlock != nil {
- {
- size := m.ConstantinopleBlock.Size()
- i -= size
- if _, err := m.ConstantinopleBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x4a
- }
- if m.ByzantiumBlock != nil {
- {
- size := m.ByzantiumBlock.Size()
- i -= size
- if _, err := m.ByzantiumBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x42
- }
- if m.EIP158Block != nil {
- {
- size := m.EIP158Block.Size()
- i -= size
- if _, err := m.EIP158Block.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x3a
- }
- if m.EIP155Block != nil {
- {
- size := m.EIP155Block.Size()
- i -= size
- if _, err := m.EIP155Block.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x32
- }
- if len(m.EIP150Hash) > 0 {
- i -= len(m.EIP150Hash)
- copy(dAtA[i:], m.EIP150Hash)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.EIP150Hash)))
- i--
- dAtA[i] = 0x2a
- }
- if m.EIP150Block != nil {
- {
- size := m.EIP150Block.Size()
- i -= size
- if _, err := m.EIP150Block.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x22
- }
- if m.DAOForkSupport {
- i--
- if m.DAOForkSupport {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x18
- }
- if m.DAOForkBlock != nil {
- {
- size := m.DAOForkBlock.Size()
- i -= size
- if _, err := m.DAOForkBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- if m.HomesteadBlock != nil {
- {
- size := m.HomesteadBlock.Size()
- i -= size
- if _, err := m.HomesteadBlock.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *State) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *State) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Value) > 0 {
- i -= len(m.Value)
- copy(dAtA[i:], m.Value)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Value)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Key) > 0 {
- i -= len(m.Key)
- copy(dAtA[i:], m.Key)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Key)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *TransactionLogs) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *TransactionLogs) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *TransactionLogs) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Logs) > 0 {
- for iNdEx := len(m.Logs) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Logs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- }
- if len(m.Hash) > 0 {
- i -= len(m.Hash)
- copy(dAtA[i:], m.Hash)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Hash)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *Log) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Log) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *Log) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.Removed {
- i--
- if m.Removed {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x48
- }
- if m.Index != 0 {
- i = encodeVarintEvm(dAtA, i, uint64(m.Index))
- i--
- dAtA[i] = 0x40
- }
- if len(m.BlockHash) > 0 {
- i -= len(m.BlockHash)
- copy(dAtA[i:], m.BlockHash)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.BlockHash)))
- i--
- dAtA[i] = 0x3a
- }
- if m.TxIndex != 0 {
- i = encodeVarintEvm(dAtA, i, uint64(m.TxIndex))
- i--
- dAtA[i] = 0x30
- }
- if len(m.TxHash) > 0 {
- i -= len(m.TxHash)
- copy(dAtA[i:], m.TxHash)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.TxHash)))
- i--
- dAtA[i] = 0x2a
- }
- if m.BlockNumber != 0 {
- i = encodeVarintEvm(dAtA, i, uint64(m.BlockNumber))
- i--
- dAtA[i] = 0x20
- }
- if len(m.Data) > 0 {
- i -= len(m.Data)
- copy(dAtA[i:], m.Data)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Data)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.Topics) > 0 {
- for iNdEx := len(m.Topics) - 1; iNdEx >= 0; iNdEx-- {
- i -= len(m.Topics[iNdEx])
- copy(dAtA[i:], m.Topics[iNdEx])
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Topics[iNdEx])))
- i--
- dAtA[i] = 0x12
- }
- }
- if len(m.Address) > 0 {
- i -= len(m.Address)
- copy(dAtA[i:], m.Address)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Address)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *TxResult) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *TxResult) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *TxResult) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.GasUsed != 0 {
- i = encodeVarintEvm(dAtA, i, uint64(m.GasUsed))
- i--
- dAtA[i] = 0x30
- }
- if m.Reverted {
- i--
- if m.Reverted {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x28
- }
- if len(m.Ret) > 0 {
- i -= len(m.Ret)
- copy(dAtA[i:], m.Ret)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Ret)))
- i--
- dAtA[i] = 0x22
- }
- {
- size, err := m.TxLogs.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- if len(m.Bloom) > 0 {
- i -= len(m.Bloom)
- copy(dAtA[i:], m.Bloom)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Bloom)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.ContractAddress) > 0 {
- i -= len(m.ContractAddress)
- copy(dAtA[i:], m.ContractAddress)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.ContractAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *AccessTuple) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AccessTuple) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *AccessTuple) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.StorageKeys) > 0 {
- for iNdEx := len(m.StorageKeys) - 1; iNdEx >= 0; iNdEx-- {
- i -= len(m.StorageKeys[iNdEx])
- copy(dAtA[i:], m.StorageKeys[iNdEx])
- i = encodeVarintEvm(dAtA, i, uint64(len(m.StorageKeys[iNdEx])))
- i--
- dAtA[i] = 0x12
- }
- }
- if len(m.Address) > 0 {
- i -= len(m.Address)
- copy(dAtA[i:], m.Address)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Address)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *TraceConfig) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *TraceConfig) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *TraceConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.TracerJsonConfig) > 0 {
- i -= len(m.TracerJsonConfig)
- copy(dAtA[i:], m.TracerJsonConfig)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.TracerJsonConfig)))
- i--
- dAtA[i] = 0x6a
- }
- if m.EnableReturnData {
- i--
- if m.EnableReturnData {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x60
- }
- if m.EnableMemory {
- i--
- if m.EnableMemory {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x58
- }
- if m.Overrides != nil {
- {
- size, err := m.Overrides.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvm(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x52
- }
- if m.Limit != 0 {
- i = encodeVarintEvm(dAtA, i, uint64(m.Limit))
- i--
- dAtA[i] = 0x48
- }
- if m.Debug {
- i--
- if m.Debug {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x40
- }
- if m.DisableStorage {
- i--
- if m.DisableStorage {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x30
- }
- if m.DisableStack {
- i--
- if m.DisableStack {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x28
- }
- if m.Reexec != 0 {
- i = encodeVarintEvm(dAtA, i, uint64(m.Reexec))
- i--
- dAtA[i] = 0x18
- }
- if len(m.Timeout) > 0 {
- i -= len(m.Timeout)
- copy(dAtA[i:], m.Timeout)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Timeout)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Tracer) > 0 {
- i -= len(m.Tracer)
- copy(dAtA[i:], m.Tracer)
- i = encodeVarintEvm(dAtA, i, uint64(len(m.Tracer)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintEvm(dAtA []byte, offset int, v uint64) int {
- offset -= sovEvm(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *Params) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.EvmDenom)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.EnableCreate {
- n += 2
- }
- if m.EnableCall {
- n += 2
- }
- if len(m.ExtraEIPs) > 0 {
- l = 0
- for _, e := range m.ExtraEIPs {
- l += sovEvm(uint64(e))
- }
- n += 1 + sovEvm(uint64(l)) + l
- }
- l = m.ChainConfig.Size()
- n += 1 + l + sovEvm(uint64(l))
- if m.AllowUnprotectedTxs {
- n += 2
- }
- if len(m.ActivePrecompiles) > 0 {
- for _, s := range m.ActivePrecompiles {
- l = len(s)
- n += 1 + l + sovEvm(uint64(l))
- }
- }
- if len(m.EVMChannels) > 0 {
- for _, s := range m.EVMChannels {
- l = len(s)
- n += 1 + l + sovEvm(uint64(l))
- }
- }
- return n
-}
-
-func (m *ChainConfig) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.HomesteadBlock != nil {
- l = m.HomesteadBlock.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.DAOForkBlock != nil {
- l = m.DAOForkBlock.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.DAOForkSupport {
- n += 2
- }
- if m.EIP150Block != nil {
- l = m.EIP150Block.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- l = len(m.EIP150Hash)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.EIP155Block != nil {
- l = m.EIP155Block.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.EIP158Block != nil {
- l = m.EIP158Block.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.ByzantiumBlock != nil {
- l = m.ByzantiumBlock.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.ConstantinopleBlock != nil {
- l = m.ConstantinopleBlock.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.PetersburgBlock != nil {
- l = m.PetersburgBlock.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.IstanbulBlock != nil {
- l = m.IstanbulBlock.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.MuirGlacierBlock != nil {
- l = m.MuirGlacierBlock.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.BerlinBlock != nil {
- l = m.BerlinBlock.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.LondonBlock != nil {
- l = m.LondonBlock.Size()
- n += 2 + l + sovEvm(uint64(l))
- }
- if m.ArrowGlacierBlock != nil {
- l = m.ArrowGlacierBlock.Size()
- n += 2 + l + sovEvm(uint64(l))
- }
- if m.GrayGlacierBlock != nil {
- l = m.GrayGlacierBlock.Size()
- n += 2 + l + sovEvm(uint64(l))
- }
- if m.MergeNetsplitBlock != nil {
- l = m.MergeNetsplitBlock.Size()
- n += 2 + l + sovEvm(uint64(l))
- }
- if m.ShanghaiBlock != nil {
- l = m.ShanghaiBlock.Size()
- n += 2 + l + sovEvm(uint64(l))
- }
- if m.CancunBlock != nil {
- l = m.CancunBlock.Size()
- n += 2 + l + sovEvm(uint64(l))
- }
- return n
-}
-
-func (m *State) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- l = len(m.Value)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- return n
-}
-
-func (m *TransactionLogs) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Hash)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- if len(m.Logs) > 0 {
- for _, e := range m.Logs {
- l = e.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- }
- return n
-}
-
-func (m *Log) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Address)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- if len(m.Topics) > 0 {
- for _, s := range m.Topics {
- l = len(s)
- n += 1 + l + sovEvm(uint64(l))
- }
- }
- l = len(m.Data)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.BlockNumber != 0 {
- n += 1 + sovEvm(uint64(m.BlockNumber))
- }
- l = len(m.TxHash)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.TxIndex != 0 {
- n += 1 + sovEvm(uint64(m.TxIndex))
- }
- l = len(m.BlockHash)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.Index != 0 {
- n += 1 + sovEvm(uint64(m.Index))
- }
- if m.Removed {
- n += 2
- }
- return n
-}
-
-func (m *TxResult) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ContractAddress)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- l = len(m.Bloom)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- l = m.TxLogs.Size()
- n += 1 + l + sovEvm(uint64(l))
- l = len(m.Ret)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.Reverted {
- n += 2
- }
- if m.GasUsed != 0 {
- n += 1 + sovEvm(uint64(m.GasUsed))
- }
- return n
-}
-
-func (m *AccessTuple) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Address)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- if len(m.StorageKeys) > 0 {
- for _, s := range m.StorageKeys {
- l = len(s)
- n += 1 + l + sovEvm(uint64(l))
- }
- }
- return n
-}
-
-func (m *TraceConfig) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Tracer)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- l = len(m.Timeout)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.Reexec != 0 {
- n += 1 + sovEvm(uint64(m.Reexec))
- }
- if m.DisableStack {
- n += 2
- }
- if m.DisableStorage {
- n += 2
- }
- if m.Debug {
- n += 2
- }
- if m.Limit != 0 {
- n += 1 + sovEvm(uint64(m.Limit))
- }
- if m.Overrides != nil {
- l = m.Overrides.Size()
- n += 1 + l + sovEvm(uint64(l))
- }
- if m.EnableMemory {
- n += 2
- }
- if m.EnableReturnData {
- n += 2
- }
- l = len(m.TracerJsonConfig)
- if l > 0 {
- n += 1 + l + sovEvm(uint64(l))
- }
- return n
-}
-
-func sovEvm(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozEvm(x uint64) (n int) {
- return sovEvm(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *Params) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: Params: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EvmDenom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.EvmDenom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EnableCreate", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.EnableCreate = bool(v != 0)
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EnableCall", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.EnableCall = bool(v != 0)
- case 4:
- if wireType == 0 {
- var v int64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.ExtraEIPs = append(m.ExtraEIPs, v)
- } else if wireType == 2 {
- var packedLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- packedLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if packedLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + packedLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var elementCount int
- var count int
- for _, integer := range dAtA[iNdEx:postIndex] {
- if integer < 128 {
- count++
- }
- }
- elementCount = count
- if elementCount != 0 && len(m.ExtraEIPs) == 0 {
- m.ExtraEIPs = make([]int64, 0, elementCount)
- }
- for iNdEx < postIndex {
- var v int64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.ExtraEIPs = append(m.ExtraEIPs, v)
- }
- } else {
- return fmt.Errorf("proto: wrong wireType = %d for field ExtraEIPs", wireType)
- }
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ChainConfig", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.ChainConfig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field AllowUnprotectedTxs", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.AllowUnprotectedTxs = bool(v != 0)
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ActivePrecompiles", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ActivePrecompiles = append(m.ActivePrecompiles, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EVMChannels", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.EVMChannels = append(m.EVMChannels, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvm(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvm
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *ChainConfig) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ChainConfig: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ChainConfig: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field HomesteadBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.HomesteadBlock = &v
- if err := m.HomesteadBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field DAOForkBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.DAOForkBlock = &v
- if err := m.DAOForkBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field DAOForkSupport", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.DAOForkSupport = bool(v != 0)
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EIP150Block", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.EIP150Block = &v
- if err := m.EIP150Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EIP150Hash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.EIP150Hash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EIP155Block", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.EIP155Block = &v
- if err := m.EIP155Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EIP158Block", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.EIP158Block = &v
- if err := m.EIP158Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ByzantiumBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.ByzantiumBlock = &v
- if err := m.ByzantiumBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 9:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ConstantinopleBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.ConstantinopleBlock = &v
- if err := m.ConstantinopleBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 10:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PetersburgBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.PetersburgBlock = &v
- if err := m.PetersburgBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 11:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field IstanbulBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.IstanbulBlock = &v
- if err := m.IstanbulBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 12:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field MuirGlacierBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.MuirGlacierBlock = &v
- if err := m.MuirGlacierBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 13:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field BerlinBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.BerlinBlock = &v
- if err := m.BerlinBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 17:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field LondonBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.LondonBlock = &v
- if err := m.LondonBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 18:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ArrowGlacierBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.ArrowGlacierBlock = &v
- if err := m.ArrowGlacierBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 20:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field GrayGlacierBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.GrayGlacierBlock = &v
- if err := m.GrayGlacierBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 21:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field MergeNetsplitBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.MergeNetsplitBlock = &v
- if err := m.MergeNetsplitBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 22:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ShanghaiBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.ShanghaiBlock = &v
- if err := m.ShanghaiBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 23:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CancunBlock", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.CancunBlock = &v
- if err := m.CancunBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvm(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvm
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *State) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: State: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: State: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Value = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvm(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvm
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *TransactionLogs) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: TransactionLogs: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: TransactionLogs: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Hash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Logs", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Logs = append(m.Logs, &Log{})
- if err := m.Logs[len(m.Logs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvm(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvm
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *Log) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: Log: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: Log: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Address = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Topics", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Topics = append(m.Topics, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
- if m.Data == nil {
- m.Data = []byte{}
- }
- iNdEx = postIndex
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field BlockNumber", wireType)
- }
- m.BlockNumber = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.BlockNumber |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field TxHash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.TxHash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field TxIndex", wireType)
- }
- m.TxIndex = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.TxIndex |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field BlockHash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.BlockHash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 8:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
- }
- m.Index = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Index |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 9:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Removed", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Removed = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipEvm(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvm
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *TxResult) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: TxResult: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: TxResult: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ContractAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Bloom", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Bloom = append(m.Bloom[:0], dAtA[iNdEx:postIndex]...)
- if m.Bloom == nil {
- m.Bloom = []byte{}
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field TxLogs", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.TxLogs.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Ret", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Ret = append(m.Ret[:0], dAtA[iNdEx:postIndex]...)
- if m.Ret == nil {
- m.Ret = []byte{}
- }
- iNdEx = postIndex
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Reverted", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Reverted = bool(v != 0)
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasUsed", wireType)
- }
- m.GasUsed = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.GasUsed |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipEvm(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvm
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AccessTuple) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AccessTuple: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AccessTuple: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Address = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field StorageKeys", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.StorageKeys = append(m.StorageKeys, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvm(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvm
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *TraceConfig) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: TraceConfig: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: TraceConfig: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Tracer", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Tracer = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Timeout = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Reexec", wireType)
- }
- m.Reexec = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Reexec |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field DisableStack", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.DisableStack = bool(v != 0)
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field DisableStorage", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.DisableStorage = bool(v != 0)
- case 8:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Debug", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Debug = bool(v != 0)
- case 9:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType)
- }
- m.Limit = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Limit |= int32(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 10:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Overrides", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Overrides == nil {
- m.Overrides = &ChainConfig{}
- }
- if err := m.Overrides.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 11:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EnableMemory", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.EnableMemory = bool(v != 0)
- case 12:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EnableReturnData", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.EnableReturnData = bool(v != 0)
- case 13:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field TracerJsonConfig", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvm
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvm
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.TracerJsonConfig = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvm(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvm
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipEvm(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvm
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthEvm
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupEvm
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthEvm
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthEvm = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowEvm = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupEvm = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/evm/evmmodule/genesis.go b/x/evm/evmmodule/genesis.go
deleted file mode 100644
index 70fa0cc77..000000000
--- a/x/evm/evmmodule/genesis.go
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evmmodule
-
-import (
- "bytes"
- "fmt"
-
- abci "github.com/cometbft/cometbft/abci/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- gethcommon "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/x/evm"
- "github.com/NibiruChain/nibiru/x/evm/keeper"
-)
-
-// InitGenesis initializes genesis state based on exported genesis
-func InitGenesis(
- ctx sdk.Context,
- k *keeper.Keeper,
- accountKeeper evm.AccountKeeper,
- genState evm.GenesisState,
-) []abci.ValidatorUpdate {
- k.BeginBlock(ctx, abci.RequestBeginBlock{})
- k.SetParams(ctx, genState.Params)
-
- if addr := accountKeeper.GetModuleAddress(evm.ModuleName); addr == nil {
- panic("the EVM module account has not been set")
- }
-
- for _, account := range genState.Accounts {
- address := gethcommon.HexToAddress(account.Address)
- accAddress := sdk.AccAddress(address.Bytes())
- // check that the EVM balance the matches the account balance
- acc := accountKeeper.GetAccount(ctx, accAddress)
- if acc == nil {
- panic(fmt.Errorf("account not found for address %s", account.Address))
- }
-
- ethAcct, ok := acc.(eth.EthAccountI)
- if !ok {
- panic(
- fmt.Errorf("account %s must be an EthAccount interface, got %T",
- account.Address, acc,
- ),
- )
- }
- code := gethcommon.Hex2Bytes(account.Code)
- codeHash := crypto.Keccak256Hash(code)
-
- // we ignore the empty Code hash checking, see ethermint PR#1234
- if len(account.Code) != 0 && !bytes.Equal(ethAcct.GetCodeHash().Bytes(), codeHash.Bytes()) {
- s := "the evm state code doesn't match with the codehash\n"
- panic(fmt.Sprintf("%s account: %s , evm state codehash: %v, ethAccount codehash: %v, evm state code: %s\n",
- s, account.Address, codeHash, ethAcct.GetCodeHash(), account.Code))
- }
-
- k.SetCode(ctx, codeHash.Bytes(), code)
-
- for _, storage := range account.Storage {
- k.SetState(ctx, address, gethcommon.HexToHash(storage.Key), gethcommon.HexToHash(storage.Value).Bytes())
- }
- }
-
- return []abci.ValidatorUpdate{}
-}
-
-// ExportGenesis exports genesis state of the EVM module
-func ExportGenesis(ctx sdk.Context, k *keeper.Keeper, ak evm.AccountKeeper) *evm.GenesisState {
- // TODO: impl ExportGenesis
- return &evm.GenesisState{
- Accounts: []evm.GenesisAccount{},
- Params: evm.Params{},
- }
-}
diff --git a/x/evm/evmmodule/module.go b/x/evm/evmmodule/module.go
deleted file mode 100644
index e12366612..000000000
--- a/x/evm/evmmodule/module.go
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evmmodule
-
-import (
- "context"
- "encoding/json"
- "fmt"
-
- "github.com/gorilla/mux"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/spf13/cobra"
-
- abci "github.com/cometbft/cometbft/abci/types"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
- simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/x/evm"
- "github.com/NibiruChain/nibiru/x/evm/cli"
- "github.com/NibiruChain/nibiru/x/evm/keeper"
-)
-
-// consensusVersion: EVM module consensus version for upgrades.
-const consensusVersion = 1
-
-var (
- _ module.AppModule = AppModule{}
- _ module.AppModuleBasic = AppModuleBasic{}
- _ module.EndBlockAppModule = AppModule{}
- _ module.BeginBlockAppModule = AppModule{}
-)
-
-// AppModuleBasic defines the basic application module used by the evm module.
-type AppModuleBasic struct{}
-
-// Name returns the evm module's name.
-func (AppModuleBasic) Name() string {
- return evm.ModuleName
-}
-
-// RegisterLegacyAminoCodec registers the module's types with the given codec.
-func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- evm.RegisterLegacyAminoCodec(cdc)
-}
-
-// ConsensusVersion returns the consensus state-breaking version for the module.
-func (AppModuleBasic) ConsensusVersion() uint64 {
- return consensusVersion
-}
-
-// DefaultGenesis returns default genesis state as raw bytes for the evm
-// module.
-func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
- return cdc.MustMarshalJSON(evm.DefaultGenesisState())
-}
-
-// ValidateGenesis is the validation check of the Genesis
-func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
- var genesisState evm.GenesisState
- if err := cdc.UnmarshalJSON(bz, &genesisState); err != nil {
- return fmt.Errorf("failed to unmarshal %s genesis state: %w", evm.ModuleName, err)
- }
-
- return genesisState.Validate()
-}
-
-// RegisterRESTRoutes performs a no-op as the EVM module doesn't expose REST
-// endpoints
-func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {
-}
-
-func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) {
- if err := evm.RegisterQueryHandlerClient(context.Background(), serveMux, evm.NewQueryClient(c)); err != nil {
- panic(err)
- }
-}
-
-// GetTxCmd returns the root tx command for the evm module.
-func (AppModuleBasic) GetTxCmd() *cobra.Command {
- return cli.GetTxCmd()
-}
-
-// GetQueryCmd returns no root query command for the evm module.
-func (AppModuleBasic) GetQueryCmd() *cobra.Command {
- return cli.GetQueryCmd()
-}
-
-// RegisterInterfaces registers interfaces and implementations of the evm module.
-func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- evm.RegisterInterfaces(registry)
- eth.RegisterInterfaces(registry)
-}
-
-// ____________________________________________________________________________
-
-// AppModule implements an application module for the evm module.
-type AppModule struct {
- AppModuleBasic
- keeper *keeper.Keeper
- ak evm.AccountKeeper
-}
-
-// NewAppModule creates a new AppModule object
-func NewAppModule(k *keeper.Keeper, ak evm.AccountKeeper) AppModule {
- return AppModule{
- AppModuleBasic: AppModuleBasic{},
- keeper: k,
- ak: ak,
- }
-}
-
-// Name returns the evm module's name.
-func (AppModule) Name() string {
- return evm.ModuleName
-}
-
-// RegisterInvariants interface for registering invariants. Performs a no-op
-// as the evm module doesn't expose invariants.
-func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {
-}
-
-// RegisterServices registers a GRPC query service to respond to the
-// module-specific GRPC queries.
-func (am AppModule) RegisterServices(cfg module.Configurator) {
- evm.RegisterMsgServer(cfg.MsgServer(), am.keeper)
- evm.RegisterQueryServer(cfg.QueryServer(), am.keeper)
-}
-
-// BeginBlock returns the begin block for the evm module.
-func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
- am.keeper.BeginBlock(ctx, req)
-}
-
-// EndBlock returns the end blocker for the evm module. It returns no validator
-// updates.
-func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
- return am.keeper.EndBlock(ctx, req)
-}
-
-// InitGenesis performs genesis initialization for the evm module. It returns
-// no validator updates.
-func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
- var genesisState evm.GenesisState
- cdc.MustUnmarshalJSON(data, &genesisState)
- InitGenesis(ctx, am.keeper, am.ak, genesisState)
- return []abci.ValidatorUpdate{}
-}
-
-// ExportGenesis returns the exported genesis state as raw bytes for the evm
-// module.
-func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
- gs := ExportGenesis(ctx, am.keeper, am.ak)
- return cdc.MustMarshalJSON(gs)
-}
-
-// RegisterStoreDecoder registers a decoder for evm module's types
-func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {
-}
-
-// GenerateGenesisState creates a randomized GenState of the evm module.
-func (AppModule) GenerateGenesisState(_ *module.SimulationState) {
-}
-
-// WeightedOperations returns the all the evm module operations with their respective weights.
-func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
- return nil
-}
diff --git a/x/evm/evmtest/eth.go b/x/evm/evmtest/eth.go
deleted file mode 100644
index 133ddd5fa..000000000
--- a/x/evm/evmtest/eth.go
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evmtest
-
-import (
- "math/big"
- "testing"
-
- cmt "github.com/cometbft/cometbft/types"
- "github.com/stretchr/testify/assert"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
-
- "github.com/cosmos/cosmos-sdk/client"
- gethcommon "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// NewEthAddr generates an Ethereum address.
-func NewEthAddr() gethcommon.Address {
- ethAddr, _ := PrivKeyEth()
- return ethAddr
-}
-
-func NewEthAddrNibiruPair() (
- ethAddr gethcommon.Address,
- privKey *ethsecp256k1.PrivKey,
- nibiruAddr sdk.AccAddress,
-) {
- ethAddr, privKey = PrivKeyEth()
- return ethAddr, privKey, EthPrivKeyToNibiruAddr(ethAddr)
-}
-
-func EthPrivKeyToNibiruAddr(ethAddr gethcommon.Address) sdk.AccAddress {
- return sdk.AccAddress(ethAddr.Bytes())
-}
-
-// PrivKeyEth returns an Ethereum private key and corresponding Eth address.
-func PrivKeyEth() (gethcommon.Address, *ethsecp256k1.PrivKey) {
- privkey, _ := ethsecp256k1.GenerateKey()
- privKeyE, _ := privkey.ToECDSA()
- ethAddr := crypto.PubkeyToAddress(privKeyE.PublicKey)
- return ethAddr, privkey
-}
-
-// NewEthTxMsg: Helper that returns a valid instance of [*evm.MsgEthereumTx].
-func NewEthTxMsg() *evm.MsgEthereumTx {
- return NewEthTxMsgs(1)[0]
-}
-
-func NewEthTxMsgs(count uint64) (ethTxMsgs []*evm.MsgEthereumTx) {
- ethAddr := NewEthAddr()
- startIdx := uint64(1)
- for nonce := startIdx; nonce-startIdx < count; nonce++ {
- ethTxMsgs = append(ethTxMsgs, evm.NewTx(&evm.EvmTxArgs{
- ChainID: big.NewInt(1),
- Nonce: nonce,
- To: ðAddr,
- GasLimit: 100000,
- GasPrice: big.NewInt(1),
- Input: []byte("testinput"),
- Accesses: &gethcore.AccessList{},
- }),
- )
- }
- return ethTxMsgs
-}
-
-// NewEthTxMsgAsCmt: Helper that returns an Ethereum tx msg converted into
-// tx bytes used in the Consensus Engine.
-func NewEthTxMsgAsCmt(t *testing.T) (
- txBz cmt.Tx,
- ethTxMsgs []*evm.MsgEthereumTx,
- clientCtx client.Context,
-) {
- // Build a TxBuilder that can understand Ethereum types
- encCfg := app.MakeEncodingConfig()
- evm.RegisterInterfaces(encCfg.InterfaceRegistry)
- eth.RegisterInterfaces(encCfg.InterfaceRegistry)
- txConfig := encCfg.TxConfig
- clientCtx = client.Context{
- TxConfig: txConfig,
- InterfaceRegistry: encCfg.InterfaceRegistry,
- }
- txBuilder := clientCtx.TxConfig.NewTxBuilder()
-
- // Build a consensus tx with a few Eth tx msgs
- ethTxMsgs = NewEthTxMsgs(3)
- assert.NoError(t,
- txBuilder.SetMsgs(ethTxMsgs[0], ethTxMsgs[1], ethTxMsgs[2]),
- )
- tx := txBuilder.GetTx()
- txBz, err := clientCtx.TxConfig.TxEncoder()(tx)
- assert.NoError(t, err)
- return txBz, ethTxMsgs, clientCtx
-}
diff --git a/x/evm/evmtest/eth_test.go b/x/evm/evmtest/eth_test.go
deleted file mode 100644
index f6f0cb332..000000000
--- a/x/evm/evmtest/eth_test.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evmtest_test
-
-import (
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-type SuiteEVMTest struct {
- suite.Suite
-}
-
-func TestSuiteEVMTest(t *testing.T) {
- suite.Run(t, new(SuiteEVMTest))
-}
-
-func (s *SuiteEVMTest) TestSampleFns() {
- s.T().Log("Test NewEthTxMsg")
- ethTxMsg := evmtest.NewEthTxMsg()
- err := ethTxMsg.ValidateBasic()
- s.NoError(err)
-
- s.T().Log("Test NewEthTxMsgs")
- for _, ethTxMsg := range evmtest.NewEthTxMsgs(3) {
- s.NoError(ethTxMsg.ValidateBasic())
- }
-
- s.T().Log("Test NewEthTxMsgs")
- _, _, _ = evmtest.NewEthTxMsgAsCmt(s.T())
-}
diff --git a/x/evm/evmtest/signer.go b/x/evm/evmtest/signer.go
deleted file mode 100644
index 25fb451fc..000000000
--- a/x/evm/evmtest/signer.go
+++ /dev/null
@@ -1,52 +0,0 @@
-package evmtest
-
-import (
- "fmt"
-
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
-)
-
-var _ keyring.Signer = &Signer{}
-
-// Signer defines a type that is used on testing for signing MsgEthereumTx
-type Signer struct {
- privKey cryptotypes.PrivKey
-}
-
-func NewSigner(sk cryptotypes.PrivKey) keyring.Signer {
- return &Signer{
- privKey: sk,
- }
-}
-
-// Sign signs the message using the underlying private key
-func (s Signer) Sign(_ string, msg []byte) ([]byte, cryptotypes.PubKey, error) {
- if s.privKey.Type() != ethsecp256k1.KeyType {
- return nil, nil, fmt.Errorf(
- "invalid private key type for signing ethereum tx; expected %s, got %s",
- ethsecp256k1.KeyType,
- s.privKey.Type(),
- )
- }
-
- sig, err := s.privKey.Sign(msg)
- if err != nil {
- return nil, nil, err
- }
-
- return sig, s.privKey.PubKey(), nil
-}
-
-// SignByAddress sign byte messages with a user key providing the address.
-func (s Signer) SignByAddress(address sdk.Address, msg []byte) ([]byte, cryptotypes.PubKey, error) {
- signer := sdk.AccAddress(s.privKey.PubKey().Address())
- if !signer.Equals(address) {
- return nil, nil, fmt.Errorf("address mismatch: signer %s ≠ given address %s", signer, address)
- }
-
- return s.Sign("", msg)
-}
diff --git a/x/evm/genesis.go b/x/evm/genesis.go
deleted file mode 100644
index e93c6cedd..000000000
--- a/x/evm/genesis.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "fmt"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-// Validate performs a basic validation of a GenesisAccount fields.
-func (ga GenesisAccount) Validate() error {
- if err := eth.ValidateAddress(ga.Address); err != nil {
- return err
- }
- return ga.Storage.Validate()
-}
-
-// DefaultGenesisState sets default evm genesis state with empty accounts and default params and
-// chain config values.
-func DefaultGenesisState() *GenesisState {
- return &GenesisState{
- Accounts: []GenesisAccount{},
- Params: DefaultParams(),
- }
-}
-
-// Validate performs basic genesis state validation returning an error upon any
-// failure.
-func (gs GenesisState) Validate() error {
- seenAccounts := make(map[string]bool)
- for _, acc := range gs.Accounts {
- if seenAccounts[acc.Address] {
- return fmt.Errorf("duplicated genesis account %s", acc.Address)
- }
- if err := acc.Validate(); err != nil {
- return fmt.Errorf("invalid genesis account %s: %w", acc.Address, err)
- }
- seenAccounts[acc.Address] = true
- }
-
- return gs.Params.Validate()
-}
diff --git a/x/evm/genesis.pb.go b/x/evm/genesis.pb.go
deleted file mode 100644
index 3d7f9ada9..000000000
--- a/x/evm/genesis.pb.go
+++ /dev/null
@@ -1,680 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: eth/evm/v1/genesis.proto
-
-package evm
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// GenesisState defines the evm module's genesis state.
-type GenesisState struct {
- // accounts is an array containing the ethereum genesis accounts.
- Accounts []GenesisAccount `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts"`
- // params defines all the parameters of the module.
- Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
-}
-
-func (m *GenesisState) Reset() { *m = GenesisState{} }
-func (m *GenesisState) String() string { return proto.CompactTextString(m) }
-func (*GenesisState) ProtoMessage() {}
-func (*GenesisState) Descriptor() ([]byte, []int) {
- return fileDescriptor_d41c81841e3983b5, []int{0}
-}
-func (m *GenesisState) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *GenesisState) XXX_Merge(src proto.Message) {
- xxx_messageInfo_GenesisState.Merge(m, src)
-}
-func (m *GenesisState) XXX_Size() int {
- return m.Size()
-}
-func (m *GenesisState) XXX_DiscardUnknown() {
- xxx_messageInfo_GenesisState.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_GenesisState proto.InternalMessageInfo
-
-func (m *GenesisState) GetAccounts() []GenesisAccount {
- if m != nil {
- return m.Accounts
- }
- return nil
-}
-
-func (m *GenesisState) GetParams() Params {
- if m != nil {
- return m.Params
- }
- return Params{}
-}
-
-// GenesisAccount defines an account to be initialized in the genesis state.
-// Its main difference between with Geth's GenesisAccount is that it uses a
-// custom storage type and that it doesn't contain the private key field.
-type GenesisAccount struct {
- // address defines an ethereum hex formated address of an account
- Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
- // code defines the hex bytes of the account code.
- Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
- // storage defines the set of state key values for the account.
- Storage Storage `protobuf:"bytes,3,rep,name=storage,proto3,castrepeated=Storage" json:"storage"`
-}
-
-func (m *GenesisAccount) Reset() { *m = GenesisAccount{} }
-func (m *GenesisAccount) String() string { return proto.CompactTextString(m) }
-func (*GenesisAccount) ProtoMessage() {}
-func (*GenesisAccount) Descriptor() ([]byte, []int) {
- return fileDescriptor_d41c81841e3983b5, []int{1}
-}
-func (m *GenesisAccount) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *GenesisAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_GenesisAccount.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *GenesisAccount) XXX_Merge(src proto.Message) {
- xxx_messageInfo_GenesisAccount.Merge(m, src)
-}
-func (m *GenesisAccount) XXX_Size() int {
- return m.Size()
-}
-func (m *GenesisAccount) XXX_DiscardUnknown() {
- xxx_messageInfo_GenesisAccount.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_GenesisAccount proto.InternalMessageInfo
-
-func (m *GenesisAccount) GetAddress() string {
- if m != nil {
- return m.Address
- }
- return ""
-}
-
-func (m *GenesisAccount) GetCode() string {
- if m != nil {
- return m.Code
- }
- return ""
-}
-
-func (m *GenesisAccount) GetStorage() Storage {
- if m != nil {
- return m.Storage
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*GenesisState)(nil), "eth.evm.v1.GenesisState")
- proto.RegisterType((*GenesisAccount)(nil), "eth.evm.v1.GenesisAccount")
-}
-
-func init() { proto.RegisterFile("eth/evm/v1/genesis.proto", fileDescriptor_d41c81841e3983b5) }
-
-var fileDescriptor_d41c81841e3983b5 = []byte{
- // 297 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0x3f, 0x4e, 0xc3, 0x30,
- 0x18, 0xc5, 0x63, 0x5a, 0x35, 0xd4, 0x45, 0x20, 0xac, 0x0e, 0x51, 0x06, 0xb7, 0x2a, 0x4b, 0x26,
- 0x9b, 0x96, 0xb5, 0x0c, 0x84, 0x81, 0x0d, 0xa1, 0x74, 0x63, 0x73, 0x12, 0x2b, 0xc9, 0x90, 0xb8,
- 0x8a, 0x9d, 0x88, 0x01, 0x71, 0x06, 0xce, 0xc1, 0x49, 0x3a, 0x76, 0x64, 0x02, 0x94, 0x5c, 0x04,
- 0xc5, 0x49, 0x21, 0xdd, 0x9e, 0x3f, 0xff, 0xde, 0xfb, 0xfe, 0x40, 0x8b, 0xab, 0x98, 0xf2, 0x32,
- 0xa5, 0xe5, 0x92, 0x46, 0x3c, 0xe3, 0x32, 0x91, 0x64, 0x9b, 0x0b, 0x25, 0x10, 0xe4, 0x2a, 0x26,
- 0xbc, 0x4c, 0x49, 0xb9, 0xb4, 0xa7, 0x3d, 0xaa, 0x29, 0x69, 0xc2, 0x9e, 0x46, 0x22, 0x12, 0x5a,
- 0xd2, 0x46, 0xb5, 0xd5, 0xc5, 0x1b, 0x3c, 0x7b, 0x68, 0x83, 0x36, 0x8a, 0x29, 0x8e, 0xd6, 0xf0,
- 0x94, 0x05, 0x81, 0x28, 0x32, 0x25, 0x2d, 0x30, 0x1f, 0x38, 0x93, 0x95, 0x4d, 0xfe, 0xa3, 0x49,
- 0xc7, 0xde, 0xb5, 0x88, 0x3b, 0xdc, 0x7d, 0xcd, 0x0c, 0xef, 0xcf, 0x81, 0xae, 0xe1, 0x68, 0xcb,
- 0x72, 0x96, 0x4a, 0xeb, 0x64, 0x0e, 0x9c, 0xc9, 0x0a, 0xf5, 0xbd, 0x4f, 0xfa, 0xa7, 0xf3, 0x74,
- 0xdc, 0xe2, 0x15, 0x9e, 0x1f, 0x67, 0x22, 0x0b, 0x9a, 0x2c, 0x0c, 0x73, 0x2e, 0x9b, 0x01, 0x80,
- 0x33, 0xf6, 0x0e, 0x4f, 0x84, 0xe0, 0x30, 0x10, 0x21, 0xd7, 0xd9, 0x63, 0x4f, 0x6b, 0xb4, 0x86,
- 0xa6, 0x54, 0x22, 0x67, 0x11, 0xb7, 0x06, 0x7a, 0xdc, 0xcb, 0x7e, 0x4b, 0xbd, 0x93, 0x7b, 0xd1,
- 0x74, 0xfc, 0xf8, 0x9e, 0x99, 0x9b, 0x96, 0xf4, 0x0e, 0x16, 0xf7, 0x76, 0x57, 0x61, 0xb0, 0xaf,
- 0x30, 0xf8, 0xa9, 0x30, 0x78, 0xaf, 0xb1, 0xb1, 0xaf, 0xb1, 0xf1, 0x59, 0x63, 0xe3, 0xf9, 0x2a,
- 0x4a, 0x54, 0x5c, 0xf8, 0x24, 0x10, 0x29, 0x7d, 0x4c, 0xfc, 0x24, 0x2f, 0xee, 0x63, 0x96, 0x64,
- 0x34, 0xd3, 0x9a, 0xbe, 0x34, 0x87, 0xf5, 0x47, 0xfa, 0x86, 0x37, 0xbf, 0x01, 0x00, 0x00, 0xff,
- 0xff, 0x58, 0x7a, 0xad, 0xd9, 0x97, 0x01, 0x00, 0x00,
-}
-
-func (m *GenesisState) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Accounts) > 0 {
- for iNdEx := len(m.Accounts) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Accounts[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *GenesisAccount) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *GenesisAccount) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *GenesisAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Storage) > 0 {
- for iNdEx := len(m.Storage) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Storage[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- }
- if len(m.Code) > 0 {
- i -= len(m.Code)
- copy(dAtA[i:], m.Code)
- i = encodeVarintGenesis(dAtA, i, uint64(len(m.Code)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Address) > 0 {
- i -= len(m.Address)
- copy(dAtA[i:], m.Address)
- i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
- offset -= sovGenesis(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *GenesisState) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Accounts) > 0 {
- for _, e := range m.Accounts {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- l = m.Params.Size()
- n += 1 + l + sovGenesis(uint64(l))
- return n
-}
-
-func (m *GenesisAccount) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Address)
- if l > 0 {
- n += 1 + l + sovGenesis(uint64(l))
- }
- l = len(m.Code)
- if l > 0 {
- n += 1 + l + sovGenesis(uint64(l))
- }
- if len(m.Storage) > 0 {
- for _, e := range m.Storage {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- return n
-}
-
-func sovGenesis(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozGenesis(x uint64) (n int) {
- return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *GenesisState) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Accounts", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Accounts = append(m.Accounts, GenesisAccount{})
- if err := m.Accounts[len(m.Accounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipGenesis(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenesis
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *GenesisAccount) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: GenesisAccount: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: GenesisAccount: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Address = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Code = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Storage", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Storage = append(m.Storage, State{})
- if err := m.Storage[len(m.Storage)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipGenesis(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenesis
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipGenesis(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthGenesis
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupGenesis
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenesis
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/evm/genesis_test.go b/x/evm/genesis_test.go
deleted file mode 100644
index 7c1e76a70..000000000
--- a/x/evm/genesis_test.go
+++ /dev/null
@@ -1,228 +0,0 @@
-package evm_test
-
-import (
- "testing"
-
- gethcommon "github.com/ethereum/go-ethereum/common"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-type GenesisSuite struct {
- suite.Suite
-
- address string
- hash gethcommon.Hash
- code string
-}
-
-func (s *GenesisSuite) SetupTest() {
- priv, err := ethsecp256k1.GenerateKey()
- s.Require().NoError(err)
-
- s.address = gethcommon.BytesToAddress(priv.PubKey().Address().Bytes()).String()
- s.hash = gethcommon.BytesToHash([]byte("hash"))
- s.code = gethcommon.Bytes2Hex([]byte{1, 2, 3})
-}
-
-func TestGenesisSuite(t *testing.T) {
- suite.Run(t, new(GenesisSuite))
-}
-
-func (s *GenesisSuite) TestValidateGenesisAccount() {
- testCases := []struct {
- name string
- genAcc evm.GenesisAccount
- expPass bool
- }{
- {
- name: "valid genesis account",
- genAcc: evm.GenesisAccount{
- Address: s.address,
- Code: s.code,
- Storage: evm.Storage{
- evm.NewStateFromEthHashes(s.hash, s.hash),
- },
- },
- expPass: true,
- },
- {
- name: "empty account address bytes",
- genAcc: evm.GenesisAccount{
- Address: "",
- Code: s.code,
- Storage: evm.Storage{
- evm.NewStateFromEthHashes(s.hash, s.hash),
- },
- },
- expPass: false,
- },
- {
- name: "empty code bytes",
- genAcc: evm.GenesisAccount{
- Address: s.address,
- Code: "",
- Storage: evm.Storage{
- evm.NewStateFromEthHashes(s.hash, s.hash),
- },
- },
- expPass: true,
- },
- }
-
- for _, tc := range testCases {
- tc := tc
- err := tc.genAcc.Validate()
- if tc.expPass {
- s.Require().NoError(err, tc.name)
- } else {
- s.Require().Error(err, tc.name)
- }
- }
-}
-
-func (s *GenesisSuite) TestValidateGenesis() {
- testCases := []struct {
- name string
- genState *evm.GenesisState
- expPass bool
- }{
- {
- name: "default",
- genState: evm.DefaultGenesisState(),
- expPass: true,
- },
- {
- name: "valid genesis",
- genState: &evm.GenesisState{
- Accounts: []evm.GenesisAccount{
- {
- Address: s.address,
-
- Code: s.code,
- Storage: evm.Storage{
- {Key: s.hash.String()},
- },
- },
- },
- Params: evm.DefaultParams(),
- },
- expPass: true,
- },
- {
- name: "empty genesis",
- genState: &evm.GenesisState{},
- expPass: false,
- },
- {
- name: "copied genesis",
- genState: &evm.GenesisState{
- Accounts: evm.DefaultGenesisState().Accounts,
- Params: evm.DefaultGenesisState().Params,
- },
- expPass: true,
- },
- {
- name: "invalid genesis",
- genState: &evm.GenesisState{
- Accounts: []evm.GenesisAccount{
- {
- Address: gethcommon.Address{}.String(),
- },
- },
- },
- expPass: false,
- },
- {
- name: "invalid genesis account",
- genState: &evm.GenesisState{
- Accounts: []evm.GenesisAccount{
- {
- Address: "123456",
-
- Code: s.code,
- Storage: evm.Storage{
- {Key: s.hash.String()},
- },
- },
- },
- Params: evm.DefaultParams(),
- },
- expPass: false,
- },
- {
- name: "duplicated genesis account",
- genState: &evm.GenesisState{
- Accounts: []evm.GenesisAccount{
- {
- Address: s.address,
-
- Code: s.code,
- Storage: evm.Storage{
- evm.NewStateFromEthHashes(s.hash, s.hash),
- },
- },
- {
- Address: s.address,
-
- Code: s.code,
- Storage: evm.Storage{
- evm.NewStateFromEthHashes(s.hash, s.hash),
- },
- },
- },
- },
- expPass: false,
- },
- {
- name: "duplicated tx log",
- genState: &evm.GenesisState{
- Accounts: []evm.GenesisAccount{
- {
- Address: s.address,
-
- Code: s.code,
- Storage: evm.Storage{
- {Key: s.hash.String()},
- },
- },
- },
- },
- expPass: false,
- },
- {
- name: "invalid tx log",
- genState: &evm.GenesisState{
- Accounts: []evm.GenesisAccount{
- {
- Address: s.address,
-
- Code: s.code,
- Storage: evm.Storage{
- {Key: s.hash.String()},
- },
- },
- },
- },
- expPass: false,
- },
- {
- name: "invalid params",
- genState: &evm.GenesisState{
- Params: evm.Params{},
- },
- expPass: false,
- },
- }
-
- for _, tc := range testCases {
- err := tc.genState.Validate()
- if tc.expPass {
- s.Require().NoError(err, tc.name)
- continue
- }
- s.Require().Error(err, tc.name)
- }
-}
diff --git a/x/evm/json_tx_args.go b/x/evm/json_tx_args.go
deleted file mode 100644
index 14fde2da3..000000000
--- a/x/evm/json_tx_args.go
+++ /dev/null
@@ -1,249 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "errors"
- "fmt"
- "math/big"
-
- sdkmath "cosmossdk.io/math"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/common/math"
- geth "github.com/ethereum/go-ethereum/core/types"
-)
-
-// JsonTxArgs represents the arguments to construct a new transaction
-// or a message call using JSON-RPC.
-// Duplicate struct definition since geth struct is in internal package
-// Ref: https://github.com/ethereum/go-ethereum/blob/release/1.10.4/internal/ethapi/transaction_args.go#L36
-type JsonTxArgs struct {
- From *common.Address `json:"from"`
- To *common.Address `json:"to"`
- Gas *hexutil.Uint64 `json:"gas"`
- GasPrice *hexutil.Big `json:"gasPrice"`
- MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
- MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
- Value *hexutil.Big `json:"value"`
- Nonce *hexutil.Uint64 `json:"nonce"`
-
- // We accept "data" and "input" for backwards-compatibility reasons.
- // "input" is the newer name and should be preferred by clients.
- // Issue detail: https://github.com/ethereum/go-ethereum/issues/15628
- Data *hexutil.Bytes `json:"data"`
- Input *hexutil.Bytes `json:"input"`
-
- // Introduced by AccessListTxType transaction.
- AccessList *geth.AccessList `json:"accessList,omitempty"`
- ChainID *hexutil.Big `json:"chainId,omitempty"`
-}
-
-// String return the struct in a string format
-func (args *JsonTxArgs) String() string {
- // Todo: There is currently a bug with hexutil.Big when the value its nil, printing would trigger an exception
- return fmt.Sprintf("TransactionArgs{From:%v, To:%v, Gas:%v,"+
- " Nonce:%v, Data:%v, Input:%v, AccessList:%v}",
- args.From,
- args.To,
- args.Gas,
- args.Nonce,
- args.Data,
- args.Input,
- args.AccessList)
-}
-
-// ToTransaction converts the arguments to an ethereum transaction.
-// This assumes that setTxDefaults has been called.
-func (args *JsonTxArgs) ToTransaction() *MsgEthereumTx {
- var (
- chainID, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas sdkmath.Int
- gas, nonce uint64
- from, to string
- )
-
- // Set sender address or use zero address if none specified.
- if args.ChainID != nil {
- chainID = sdkmath.NewIntFromBigInt(args.ChainID.ToInt())
- }
-
- if args.Nonce != nil {
- nonce = uint64(*args.Nonce)
- }
-
- if args.Gas != nil {
- gas = uint64(*args.Gas)
- }
-
- if args.GasPrice != nil {
- gasPrice = sdkmath.NewIntFromBigInt(args.GasPrice.ToInt())
- }
-
- if args.MaxFeePerGas != nil {
- maxFeePerGas = sdkmath.NewIntFromBigInt(args.MaxFeePerGas.ToInt())
- }
-
- if args.MaxPriorityFeePerGas != nil {
- maxPriorityFeePerGas = sdkmath.NewIntFromBigInt(args.MaxPriorityFeePerGas.ToInt())
- }
-
- if args.Value != nil {
- value = sdkmath.NewIntFromBigInt(args.Value.ToInt())
- }
-
- if args.To != nil {
- to = args.To.Hex()
- }
-
- var data TxData
- switch {
- case args.MaxFeePerGas != nil:
- al := AccessList{}
- if args.AccessList != nil {
- al = NewAccessList(args.AccessList)
- }
-
- data = &DynamicFeeTx{
- To: to,
- ChainID: &chainID,
- Nonce: nonce,
- GasLimit: gas,
- GasFeeCap: &maxFeePerGas,
- GasTipCap: &maxPriorityFeePerGas,
- Amount: &value,
- Data: args.GetData(),
- Accesses: al,
- }
- case args.AccessList != nil:
- data = &AccessListTx{
- To: to,
- ChainID: &chainID,
- Nonce: nonce,
- GasLimit: gas,
- GasPrice: &gasPrice,
- Amount: &value,
- Data: args.GetData(),
- Accesses: NewAccessList(args.AccessList),
- }
- default:
- data = &LegacyTx{
- To: to,
- Nonce: nonce,
- GasLimit: gas,
- GasPrice: &gasPrice,
- Amount: &value,
- Data: args.GetData(),
- }
- }
-
- anyData, err := PackTxData(data)
- if err != nil {
- return nil
- }
-
- if args.From != nil {
- from = args.From.Hex()
- }
-
- msg := MsgEthereumTx{
- Data: anyData,
- From: from,
- }
- msg.Hash = msg.AsTransaction().Hash().Hex()
- return &msg
-}
-
-// ToMessage converts the arguments to the Message type used by the core evm.
-// This assumes that setTxDefaults has been called.
-func (args *JsonTxArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (geth.Message, error) {
- // Reject invalid combinations of pre- and post-1559 fee styles
- if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) {
- return geth.Message{}, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
- }
-
- // Set sender address or use zero address if none specified.
- addr := args.GetFrom()
-
- // Set default gas & gas price if none were set
- gas := globalGasCap
- if gas == 0 {
- gas = uint64(math.MaxUint64 / 2)
- }
- if args.Gas != nil {
- gas = uint64(*args.Gas)
- }
- if globalGasCap != 0 && globalGasCap < gas {
- gas = globalGasCap
- }
- var (
- gasPrice *big.Int
- gasFeeCap *big.Int
- gasTipCap *big.Int
- )
- if baseFee == nil {
- // If there's no basefee, then it must be a non-1559 execution
- gasPrice = new(big.Int)
- if args.GasPrice != nil {
- gasPrice = args.GasPrice.ToInt()
- }
- gasFeeCap, gasTipCap = gasPrice, gasPrice
- } else {
- // A basefee is provided, necessitating 1559-type execution
- if args.GasPrice != nil {
- // User specified the legacy gas field, convert to 1559 gas typing
- gasPrice = args.GasPrice.ToInt()
- gasFeeCap, gasTipCap = gasPrice, gasPrice
- } else {
- // User specified 1559 gas feilds (or none), use those
- gasFeeCap = new(big.Int)
- if args.MaxFeePerGas != nil {
- gasFeeCap = args.MaxFeePerGas.ToInt()
- }
- gasTipCap = new(big.Int)
- if args.MaxPriorityFeePerGas != nil {
- gasTipCap = args.MaxPriorityFeePerGas.ToInt()
- }
- // Backfill the legacy gasPrice for EVM execution, unless we're all zeroes
- gasPrice = new(big.Int)
- if gasFeeCap.BitLen() > 0 || gasTipCap.BitLen() > 0 {
- gasPrice = math.BigMin(new(big.Int).Add(gasTipCap, baseFee), gasFeeCap)
- }
- }
- }
- value := new(big.Int)
- if args.Value != nil {
- value = args.Value.ToInt()
- }
- data := args.GetData()
- var accessList geth.AccessList
- if args.AccessList != nil {
- accessList = *args.AccessList
- }
-
- nonce := uint64(0)
- if args.Nonce != nil {
- nonce = uint64(*args.Nonce)
- }
-
- msg := geth.NewMessage(addr, args.To, nonce, value, gas, gasPrice, gasFeeCap, gasTipCap, data, accessList, true)
- return msg, nil
-}
-
-// GetFrom retrieves the transaction sender address.
-func (args *JsonTxArgs) GetFrom() common.Address {
- if args.From == nil {
- return common.Address{}
- }
- return *args.From
-}
-
-// GetData retrieves the transaction calldata. Input field is preferred.
-func (args *JsonTxArgs) GetData() []byte {
- if args.Input != nil {
- return *args.Input
- }
- if args.Data != nil {
- return *args.Data
- }
- return nil
-}
diff --git a/x/evm/json_tx_args_test.go b/x/evm/json_tx_args_test.go
deleted file mode 100644
index 31d73b6f5..000000000
--- a/x/evm/json_tx_args_test.go
+++ /dev/null
@@ -1,290 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm_test
-
-import (
- "fmt"
- "math/big"
-
- ethcommon "github.com/ethereum/go-ethereum/common"
- ethcoretypes "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-func (suite *TxDataTestSuite) TestTxArgsString() {
- testCases := []struct {
- name string
- txArgs evm.JsonTxArgs
- expectedString string
- }{
- {
- "empty tx args",
- evm.JsonTxArgs{},
- "TransactionArgs{From:, To:, Gas:, Nonce:, Data:, Input:, AccessList:}",
- },
- {
- "tx args with fields",
- evm.JsonTxArgs{
- From: &suite.addr,
- To: &suite.addr,
- Gas: &suite.hexUint64,
- Nonce: &suite.hexUint64,
- Input: &suite.hexInputBytes,
- Data: &suite.hexDataBytes,
- AccessList: ðcoretypes.AccessList{},
- },
- fmt.Sprintf("TransactionArgs{From:%v, To:%v, Gas:%v, Nonce:%v, Data:%v, Input:%v, AccessList:%v}",
- &suite.addr,
- &suite.addr,
- &suite.hexUint64,
- &suite.hexUint64,
- &suite.hexDataBytes,
- &suite.hexInputBytes,
- ðcoretypes.AccessList{}),
- },
- }
- for _, tc := range testCases {
- outputString := tc.txArgs.String()
- suite.Require().Equal(outputString, tc.expectedString)
- }
-}
-
-func (suite *TxDataTestSuite) TestConvertTxArgsEthTx() {
- testCases := []struct {
- name string
- txArgs evm.JsonTxArgs
- }{
- {
- "empty tx args",
- evm.JsonTxArgs{},
- },
- {
- "no nil args",
- evm.JsonTxArgs{
- From: &suite.addr,
- To: &suite.addr,
- Gas: &suite.hexUint64,
- GasPrice: &suite.hexBigInt,
- MaxFeePerGas: &suite.hexBigInt,
- MaxPriorityFeePerGas: &suite.hexBigInt,
- Value: &suite.hexBigInt,
- Nonce: &suite.hexUint64,
- Data: &suite.hexDataBytes,
- Input: &suite.hexInputBytes,
- AccessList: ðcoretypes.AccessList{{Address: suite.addr, StorageKeys: []ethcommon.Hash{{0}}}},
- ChainID: &suite.hexBigInt,
- },
- },
- {
- "max fee per gas nil, but access list not nil",
- evm.JsonTxArgs{
- From: &suite.addr,
- To: &suite.addr,
- Gas: &suite.hexUint64,
- GasPrice: &suite.hexBigInt,
- MaxFeePerGas: nil,
- MaxPriorityFeePerGas: &suite.hexBigInt,
- Value: &suite.hexBigInt,
- Nonce: &suite.hexUint64,
- Data: &suite.hexDataBytes,
- Input: &suite.hexInputBytes,
- AccessList: ðcoretypes.AccessList{{Address: suite.addr, StorageKeys: []ethcommon.Hash{{0}}}},
- ChainID: &suite.hexBigInt,
- },
- },
- }
- for _, tc := range testCases {
- res := tc.txArgs.ToTransaction()
- suite.Require().NotNil(res)
- }
-}
-
-func (suite *TxDataTestSuite) TestToMessageEVM() {
- testCases := []struct {
- name string
- txArgs evm.JsonTxArgs
- globalGasCap uint64
- baseFee *big.Int
- expError bool
- }{
- {
- "empty tx args",
- evm.JsonTxArgs{},
- uint64(0),
- nil,
- false,
- },
- {
- "specify gasPrice and (maxFeePerGas or maxPriorityFeePerGas)",
- evm.JsonTxArgs{
- From: &suite.addr,
- To: &suite.addr,
- Gas: &suite.hexUint64,
- GasPrice: &suite.hexBigInt,
- MaxFeePerGas: &suite.hexBigInt,
- MaxPriorityFeePerGas: &suite.hexBigInt,
- Value: &suite.hexBigInt,
- Nonce: &suite.hexUint64,
- Data: &suite.hexDataBytes,
- Input: &suite.hexInputBytes,
- AccessList: ðcoretypes.AccessList{{Address: suite.addr, StorageKeys: []ethcommon.Hash{{0}}}},
- ChainID: &suite.hexBigInt,
- },
- uint64(0),
- nil,
- true,
- },
- {
- "non-1559 execution, zero gas cap",
- evm.JsonTxArgs{
- From: &suite.addr,
- To: &suite.addr,
- Gas: &suite.hexUint64,
- GasPrice: &suite.hexBigInt,
- MaxFeePerGas: nil,
- MaxPriorityFeePerGas: nil,
- Value: &suite.hexBigInt,
- Nonce: &suite.hexUint64,
- Data: &suite.hexDataBytes,
- Input: &suite.hexInputBytes,
- AccessList: ðcoretypes.AccessList{{Address: suite.addr, StorageKeys: []ethcommon.Hash{{0}}}},
- ChainID: &suite.hexBigInt,
- },
- uint64(0),
- nil,
- false,
- },
- {
- "non-1559 execution, nonzero gas cap",
- evm.JsonTxArgs{
- From: &suite.addr,
- To: &suite.addr,
- Gas: &suite.hexUint64,
- GasPrice: &suite.hexBigInt,
- MaxFeePerGas: nil,
- MaxPriorityFeePerGas: nil,
- Value: &suite.hexBigInt,
- Nonce: &suite.hexUint64,
- Data: &suite.hexDataBytes,
- Input: &suite.hexInputBytes,
- AccessList: ðcoretypes.AccessList{{Address: suite.addr, StorageKeys: []ethcommon.Hash{{0}}}},
- ChainID: &suite.hexBigInt,
- },
- uint64(1),
- nil,
- false,
- },
- {
- "1559-type execution, nil gas price",
- evm.JsonTxArgs{
- From: &suite.addr,
- To: &suite.addr,
- Gas: &suite.hexUint64,
- GasPrice: nil,
- MaxFeePerGas: &suite.hexBigInt,
- MaxPriorityFeePerGas: &suite.hexBigInt,
- Value: &suite.hexBigInt,
- Nonce: &suite.hexUint64,
- Data: &suite.hexDataBytes,
- Input: &suite.hexInputBytes,
- AccessList: ðcoretypes.AccessList{{Address: suite.addr, StorageKeys: []ethcommon.Hash{{0}}}},
- ChainID: &suite.hexBigInt,
- },
- uint64(1),
- suite.bigInt,
- false,
- },
- {
- "1559-type execution, non-nil gas price",
- evm.JsonTxArgs{
- From: &suite.addr,
- To: &suite.addr,
- Gas: &suite.hexUint64,
- GasPrice: &suite.hexBigInt,
- MaxFeePerGas: nil,
- MaxPriorityFeePerGas: nil,
- Value: &suite.hexBigInt,
- Nonce: &suite.hexUint64,
- Data: &suite.hexDataBytes,
- Input: &suite.hexInputBytes,
- AccessList: ðcoretypes.AccessList{{Address: suite.addr, StorageKeys: []ethcommon.Hash{{0}}}},
- ChainID: &suite.hexBigInt,
- },
- uint64(1),
- suite.bigInt,
- false,
- },
- }
- for _, tc := range testCases {
- res, err := tc.txArgs.ToMessage(tc.globalGasCap, tc.baseFee)
-
- if tc.expError {
- suite.Require().NotNil(err)
- } else {
- suite.Require().Nil(err)
- suite.Require().NotNil(res)
- }
- }
-}
-
-func (suite *TxDataTestSuite) TestGetFrom() {
- testCases := []struct {
- name string
- txArgs evm.JsonTxArgs
- expAddress ethcommon.Address
- }{
- {
- "empty from field",
- evm.JsonTxArgs{},
- ethcommon.Address{},
- },
- {
- "non-empty from field",
- evm.JsonTxArgs{
- From: &suite.addr,
- },
- suite.addr,
- },
- }
- for _, tc := range testCases {
- retrievedAddress := tc.txArgs.GetFrom()
- suite.Require().Equal(retrievedAddress, tc.expAddress)
- }
-}
-
-func (suite *TxDataTestSuite) TestGetData() {
- testCases := []struct {
- name string
- txArgs evm.JsonTxArgs
- expectedOutput []byte
- }{
- {
- "empty input and data fields",
- evm.JsonTxArgs{
- Data: nil,
- Input: nil,
- },
- nil,
- },
- {
- "empty input field, non-empty data field",
- evm.JsonTxArgs{
- Data: &suite.hexDataBytes,
- Input: nil,
- },
- []byte("data"),
- },
- {
- "non-empty input and data fields",
- evm.JsonTxArgs{
- Data: &suite.hexDataBytes,
- Input: &suite.hexInputBytes,
- },
- []byte("input"),
- },
- }
- for _, tc := range testCases {
- retrievedData := tc.txArgs.GetData()
- suite.Require().Equal(retrievedData, tc.expectedOutput)
- }
-}
diff --git a/x/evm/keeper/evm_state.go b/x/evm/keeper/evm_state.go
deleted file mode 100644
index 5cf7cea3c..000000000
--- a/x/evm/keeper/evm_state.go
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package keeper
-
-import (
- "fmt"
- "slices"
-
- "github.com/NibiruChain/collections"
- "github.com/cosmos/cosmos-sdk/codec"
- sdkstore "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- gethcommon "github.com/ethereum/go-ethereum/common"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-type (
- AccStatePrimaryKey = collections.Pair[gethcommon.Address, gethcommon.Hash]
- CodeHash = []byte
-)
-
-// EvmState isolates the key-value stores (collections) for the x/evm module.
-type EvmState struct {
- ModuleParams collections.Item[evm.Params]
-
- // ContractBytecode: Map from (byte)code hash -> contract bytecode
- ContractBytecode collections.Map[CodeHash, []byte]
-
- // AccState: Map from eth address (account) and hash of a state key -> smart
- // contract state. Each contract essentially has its own key-value store.
- //
- // - primary key (PK): (EthAddr+EthHash). The contract is the primary key
- // because there's exactly one deployer and withdrawer.
- // - value (V): State value bytes.
- AccState collections.Map[
- AccStatePrimaryKey, // account (EthAddr) + state key (EthHash)
- []byte,
- ]
-
- // BlockGasUsed: Gas used by Ethereum txs in the block (transient).
- BlockGasUsed collections.ItemTransient[uint64]
- // BlockLogSize: EVM tx log size for the block (transient).
- BlockLogSize collections.ItemTransient[uint64]
- // BlockTxIndex: EVM tx index for the block (transient).
- BlockTxIndex collections.ItemTransient[uint64]
- // BlockBloom: Bloom filters.
- BlockBloom collections.ItemTransient[[]byte]
-}
-
-func (k *Keeper) EVMState() EvmState { return k.EvmState }
-
-func NewEvmState(
- cdc codec.BinaryCodec,
- storeKey sdkstore.StoreKey,
- storeKeyTransient sdkstore.StoreKey,
-) EvmState {
- return EvmState{
- ModuleParams: collections.NewItem(
- storeKey, evm.KeyPrefixParams,
- collections.ProtoValueEncoder[evm.Params](cdc),
- ),
- ContractBytecode: collections.NewMap(
- storeKey, evm.KeyPrefixAccCodes,
- eth.KeyEncoderBytes,
- eth.ValueEncoderBytes,
- ),
- AccState: collections.NewMap(
- storeKey, evm.KeyPrefixAccState,
- collections.PairKeyEncoder(eth.KeyEncoderEthAddr, eth.KeyEncoderEthHash),
- eth.ValueEncoderBytes,
- ),
- BlockGasUsed: collections.NewItemTransient(
- storeKeyTransient,
- evm.NamespaceBlockGasUsed,
- collections.Uint64ValueEncoder,
- ),
- BlockLogSize: collections.NewItemTransient(
- storeKeyTransient,
- evm.NamespaceBlockLogSize,
- collections.Uint64ValueEncoder,
- ),
- BlockBloom: collections.NewItemTransient(
- storeKeyTransient,
- evm.NamespaceBlockBloom,
- eth.ValueEncoderBytes,
- ),
- BlockTxIndex: collections.NewItemTransient(
- storeKeyTransient,
- evm.NamespaceBlockTxIndex,
- collections.Uint64ValueEncoder,
- ),
- }
-}
-
-// BytesToHex converts a byte array to a hexadecimal string
-func BytesToHex(bz []byte) string {
- return fmt.Sprintf("%x", bz)
-}
-
-func (state EvmState) SetAccCode(ctx sdk.Context, codeHash, code []byte) {
- if len(code) > 0 {
- state.ContractBytecode.Insert(ctx, codeHash, code)
- } else {
- // Ignore collections "key not found" error because erasing an empty
- // state is perfectly valid here.
- _ = state.ContractBytecode.Delete(ctx, codeHash)
- }
-}
-
-func (state EvmState) GetContractBytecode(
- ctx sdk.Context, codeHash []byte,
-) (code []byte) {
- return state.ContractBytecode.GetOr(ctx, codeHash, []byte{})
-}
-
-// GetParams returns the total set of evm parameters.
-func (k Keeper) GetParams(ctx sdk.Context) (params evm.Params) {
- params, _ = k.EvmState.ModuleParams.Get(ctx)
- return params
-}
-
-// SetParams: Setter for the module parameters.
-func (k Keeper) SetParams(ctx sdk.Context, params evm.Params) {
- slices.Sort(params.ActivePrecompiles)
- k.EvmState.ModuleParams.Set(ctx, params)
-}
-
-// SetState update contract storage, delete if value is empty.
-func (state EvmState) SetAccState(
- ctx sdk.Context, addr eth.EthAddr, stateKey eth.EthHash, stateValue []byte,
-) {
- if len(stateValue) != 0 {
- state.AccState.Insert(ctx, collections.Join(addr, stateKey), stateValue)
- } else {
- _ = state.AccState.Delete(ctx, collections.Join(addr, stateKey))
- }
-}
-
-// GetState: Implements `statedb.Keeper` interface: Loads smart contract state.
-func (k *Keeper) GetState(ctx sdk.Context, addr eth.EthAddr, stateKey eth.EthHash) eth.EthHash {
- return gethcommon.BytesToHash(k.EvmState.AccState.GetOr(
- ctx,
- collections.Join(addr, stateKey),
- []byte{},
- ))
-}
diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go
deleted file mode 100644
index ed1c69f16..000000000
--- a/x/evm/keeper/grpc_query.go
+++ /dev/null
@@ -1,278 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package keeper
-
-import (
- "context"
-
- sdkmath "cosmossdk.io/math"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- gethcommon "github.com/ethereum/go-ethereum/common"
-
- "github.com/NibiruChain/nibiru/x/common"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// Compile-time interface assertion
-var _ evm.QueryServer = Keeper{}
-
-// EthAccount: Implements the gRPC query for "/eth.evm.v1.Query/EthAccount".
-// EthAccount retrieves the account details for a given Ethereum hex address.
-//
-// Parameters:
-// - goCtx: The context.Context object representing the request context.
-// - req: Request containing the Ethereum hexadecimal address.
-//
-// Returns:
-// - A pointer to the QueryEthAccountResponse object containing the account details.
-// - An error if the account retrieval process encounters any issues.
-func (k Keeper) EthAccount(
- goCtx context.Context, req *evm.QueryEthAccountRequest,
-) (*evm.QueryEthAccountResponse, error) {
- if err := req.Validate(); err != nil {
- return nil, err
- }
-
- addr := gethcommon.HexToAddress(req.Address)
- ctx := sdk.UnwrapSDKContext(goCtx)
- acct := k.GetAccountOrEmpty(ctx, addr)
-
- return &evm.QueryEthAccountResponse{
- Balance: acct.Balance.String(),
- CodeHash: gethcommon.BytesToHash(acct.CodeHash).Hex(),
- Nonce: acct.Nonce,
- }, nil
-}
-
-// NibiruAccount: Implements the gRPC query for "/eth.evm.v1.Query/NibiruAccount".
-// NibiruAccount retrieves the Cosmos account details for a given Ethereum address.
-//
-// Parameters:
-// - goCtx: The context.Context object representing the request context.
-// - req: The QueryNibiruAccountRequest object containing the Ethereum address.
-//
-// Returns:
-// - A pointer to the QueryNibiruAccountResponse object containing the Cosmos account details.
-// - An error if the account retrieval process encounters any issues.
-func (k Keeper) NibiruAccount(
- goCtx context.Context, req *evm.QueryNibiruAccountRequest,
-) (resp *evm.QueryNibiruAccountResponse, err error) {
- if err := req.Validate(); err != nil {
- return resp, err
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
- ethAddr := gethcommon.HexToAddress(req.Address)
- nibiruAddr := sdk.AccAddress(ethAddr.Bytes())
-
- accountOrNil := k.accountKeeper.GetAccount(ctx, nibiruAddr)
- resp = &evm.QueryNibiruAccountResponse{
- Address: nibiruAddr.String(),
- }
-
- if accountOrNil != nil {
- resp.Sequence = accountOrNil.GetSequence()
- resp.AccountNumber = accountOrNil.GetAccountNumber()
- }
-
- return resp, nil
-}
-
-// ValidatorAccount: Implements the gRPC query for "/eth.evm.v1.Query/ValidatorAccount".
-// ValidatorAccount retrieves the account details for a given validator consensus address.
-//
-// Parameters:
-// - goCtx: The context.Context object representing the request context.
-// - req: The QueryValidatorAccountRequest object containing the validator consensus address.
-//
-// Returns:
-// - A pointer to the QueryValidatorAccountResponse object containing the account details.
-// - An error if the account retrieval process encounters any issues.
-func (k Keeper) ValidatorAccount(
- goCtx context.Context, req *evm.QueryValidatorAccountRequest,
-) (*evm.QueryValidatorAccountResponse, error) {
- // TODO: feat(evm): impl query ValidatorAccount
- return &evm.QueryValidatorAccountResponse{
- AccountAddress: "",
- Sequence: 0,
- AccountNumber: 0,
- }, common.ErrNotImplementedGprc()
-}
-
-// Balance: Implements the gRPC query for "/eth.evm.v1.Query/Balance".
-// Balance retrieves the balance of an Ethereum address in "Ether", which
-// actually refers to NIBI tokens on Nibiru EVM.
-//
-// Parameters:
-// - goCtx: The context.Context object representing the request context.
-// - req: The QueryBalanceRequest object containing the Ethereum address.
-//
-// Returns:
-// - A pointer to the QueryBalanceResponse object containing the balance.
-// - An error if the balance retrieval process encounters any issues.
-func (k Keeper) Balance(goCtx context.Context, req *evm.QueryBalanceRequest) (*evm.QueryBalanceResponse, error) {
- if err := req.Validate(); err != nil {
- return nil, err
- }
- ctx := sdk.UnwrapSDKContext(goCtx)
- balanceInt := k.GetEvmGasBalance(ctx, gethcommon.HexToAddress(req.Address))
- return &evm.QueryBalanceResponse{
- Balance: balanceInt.String(),
- }, nil
-}
-
-// BaseFee implements the Query/BaseFee gRPC method
-func (k Keeper) BaseFee(
- goCtx context.Context, _ *evm.QueryBaseFeeRequest,
-) (*evm.QueryBaseFeeResponse, error) {
- // TODO: feat(evm): impl query BaseFee
- return &evm.QueryBaseFeeResponse{
- BaseFee: &sdkmath.Int{},
- }, common.ErrNotImplementedGprc()
-}
-
-// Storage: Implements the gRPC query for "/eth.evm.v1.Query/Storage".
-// Storage retrieves the storage value for a given Ethereum address and key.
-//
-// Parameters:
-// - goCtx: The context.Context object representing the request context.
-// - req: The QueryStorageRequest object containing the Ethereum address and key.
-//
-// Returns:
-// - A pointer to the QueryStorageResponse object containing the storage value.
-// - An error if the storage retrieval process encounters any issues.
-func (k Keeper) Storage(
- goCtx context.Context, req *evm.QueryStorageRequest,
-) (*evm.QueryStorageResponse, error) {
- if err := req.Validate(); err != nil {
- return nil, err
- }
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- address := gethcommon.HexToAddress(req.Address)
- key := gethcommon.HexToHash(req.Key)
-
- state := k.GetState(ctx, address, key)
- stateHex := state.Hex()
-
- return &evm.QueryStorageResponse{
- Value: stateHex,
- }, nil
-}
-
-// Code: Implements the gRPC query for "/eth.evm.v1.Query/Code".
-// Code retrieves the smart contract bytecode associated with a given Ethereum
-// address.
-//
-// Parameters:
-// - goCtx: The context.Context object representing the request context.
-// - req: The QueryCodeRequest object containing the Ethereum address.
-//
-// Returns:
-// - A pointer to the QueryCodeResponse object containing the code.
-// - An error if the code retrieval process encounters any issues.
-func (k Keeper) Code(goCtx context.Context, req *evm.QueryCodeRequest) (*evm.QueryCodeResponse, error) {
- // TODO: feat(evm): impl query Code
- return &evm.QueryCodeResponse{
- Code: []byte{},
- }, common.ErrNotImplementedGprc()
-}
-
-// Params: Implements the gRPC query for "/eth.evm.v1.Query/Params".
-// Params retrieves the EVM module parameters.
-//
-// Parameters:
-// - goCtx: The context.Context object representing the request context.
-// - req: The QueryParamsRequest object (unused).
-//
-// Returns:
-// - A pointer to the QueryParamsResponse object containing the EVM module parameters.
-// - An error if the parameter retrieval process encounters any issues.
-func (k Keeper) Params(goCtx context.Context, _ *evm.QueryParamsRequest) (*evm.QueryParamsResponse, error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
- params := k.GetParams(ctx)
- return &evm.QueryParamsResponse{
- Params: params,
- }, nil
-}
-
-// EthCall: Implements the gRPC query for "/eth.evm.v1.Query/EthCall".
-// EthCall performs a smart contract call using the eth_call JSON-RPC method.
-//
-// Parameters:
-// - goCtx: The context.Context object representing the request context.
-// - req: The EthCallRequest object containing the call parameters.
-//
-// Returns:
-// - A pointer to the MsgEthereumTxResponse object containing the result of the eth_call.
-// - An error if the eth_call process encounters any issues.
-func (k Keeper) EthCall(
- goCtx context.Context, req *evm.EthCallRequest,
-) (*evm.MsgEthereumTxResponse, error) {
- // TODO: feat(evm): impl query EthCall
- return &evm.MsgEthereumTxResponse{
- Hash: "",
- Logs: []*evm.Log{},
- Ret: []byte{},
- VmError: "",
- GasUsed: 0,
- }, common.ErrNotImplementedGprc()
-}
-
-// EstimateGas: Implements the gRPC query for "/eth.evm.v1.Query/EstimateGas".
-// EstimateGas implements eth_estimateGas rpc api.
-func (k Keeper) EstimateGas(
- goCtx context.Context, req *evm.EthCallRequest,
-) (*evm.EstimateGasResponse, error) {
- // TODO: feat(evm): impl query EstimateGas
- return k.EstimateGasForEvmCallType(goCtx, req, evm.CallTypeRPC)
-}
-
-// EstimateGasForEvmCallType estimates the gas cost of a transaction. This can be
-// called with the "eth_estimateGas" JSON-RPC method or an smart contract query.
-//
-// When [EstimateGas] is called from the JSON-RPC client, we need to reset the
-// gas meter before simulating the transaction (tx) to have an accurate gas
-// estimate txs using EVM extensions.
-//
-// Parameters:
-// - goCtx: The context.Context object representing the request context.
-// - req: The EthCallRequest object containing the transaction parameters.
-//
-// Returns:
-// - A response containing the estimated gas cost.
-// - An error if the gas estimation process encounters any issues.
-func (k Keeper) EstimateGasForEvmCallType(
- goCtx context.Context, req *evm.EthCallRequest, fromType evm.CallType,
-) (*evm.EstimateGasResponse, error) {
- // TODO: feat(evm): impl query EstimateGasForEvmCallType
- return &evm.EstimateGasResponse{
- Gas: 0,
- }, common.ErrNotImplementedGprc()
-}
-
-// TraceTx configures a new tracer according to the provided configuration, and
-// executes the given message in the provided environment. The return value will
-// be tracer dependent.
-func (k Keeper) TraceTx(
- goCtx context.Context, req *evm.QueryTraceTxRequest,
-) (*evm.QueryTraceTxResponse, error) {
- // TODO: feat(evm): impl query TraceTx
- return &evm.QueryTraceTxResponse{
- Data: []byte{},
- }, common.ErrNotImplementedGprc()
-}
-
-// TraceBlock: Implements the gRPC query for "/eth.evm.v1.Query/TraceBlock".
-// Configures a Nibiru EVM tracer that is used to "trace" and analyze
-// the execution of transactions within a given block. Block information is read
-// from the context (goCtx). [TraceBlock] is responsible iterates over each Eth
-// transacion message and calls [TraceEthTxMsg] on it.
-func (k Keeper) TraceBlock(
- goCtx context.Context, req *evm.QueryTraceBlockRequest,
-) (*evm.QueryTraceBlockResponse, error) {
- // TODO: feat(evm): impl query TraceBlock
- return &evm.QueryTraceBlockResponse{
- Data: []byte{},
- }, common.ErrNotImplementedGprc()
-}
diff --git a/x/evm/keeper/grpc_query_test.go b/x/evm/keeper/grpc_query_test.go
deleted file mode 100644
index 46b726076..000000000
--- a/x/evm/keeper/grpc_query_test.go
+++ /dev/null
@@ -1,183 +0,0 @@
-package keeper_test
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
- gethcommon "github.com/ethereum/go-ethereum/common"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/app/codec"
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/evm"
- "github.com/NibiruChain/nibiru/x/evm/evmtest"
- "github.com/NibiruChain/nibiru/x/evm/keeper"
-)
-
-type TestDeps struct {
- chain *app.NibiruApp
- ctx sdk.Context
- encCfg codec.EncodingConfig
- k keeper.Keeper
- genState *evm.GenesisState
- sender Sender
-}
-
-type Sender struct {
- EthAddr gethcommon.Address
- PrivKey *ethsecp256k1.PrivKey
- NibiruAddr sdk.AccAddress
-}
-
-func (s *KeeperSuite) SetupTest() TestDeps {
- testapp.EnsureNibiruPrefix()
- encCfg := app.MakeEncodingConfig()
- evm.RegisterInterfaces(encCfg.InterfaceRegistry)
- eth.RegisterInterfaces(encCfg.InterfaceRegistry)
- chain, ctx := testapp.NewNibiruTestAppAndContext()
-
- ethAddr, privKey, nibiruAddr := evmtest.NewEthAddrNibiruPair()
- return TestDeps{
- chain: chain,
- ctx: ctx,
- encCfg: encCfg,
- k: chain.EvmKeeper,
- genState: evm.DefaultGenesisState(),
- sender: Sender{
- EthAddr: ethAddr,
- PrivKey: privKey,
- NibiruAddr: nibiruAddr,
- },
- }
-}
-
-func InvalidEthAddr() string { return "0x0000" }
-
-type TestCase[In, Out any] struct {
- name string
- // setup: Optional setup function to create the scenario
- setup func(deps *TestDeps)
- scenario func(deps *TestDeps) (
- req In,
- wantResp Out,
- )
- wantErr string
-}
-
-func (s *KeeperSuite) TestQueryNibiruAccount() {
- type In = *evm.QueryNibiruAccountRequest
- type Out = *evm.QueryNibiruAccountResponse
- testCases := []TestCase[In, Out]{
- {
- name: "sad: msg validation",
- scenario: func(deps *TestDeps) (req In, wantResp Out) {
- req = &evm.QueryNibiruAccountRequest{
- Address: InvalidEthAddr(),
- }
- wantResp = &evm.QueryNibiruAccountResponse{
- Address: sdk.AccAddress(gethcommon.Address{}.Bytes()).String(),
- }
- return req, wantResp
- },
- wantErr: "not a valid ethereum hex addr",
- },
- {
- name: "happy",
- scenario: func(deps *TestDeps) (req In, wantResp Out) {
- ethAddr, _, nibiruAddr := evmtest.NewEthAddrNibiruPair()
- req = &evm.QueryNibiruAccountRequest{
- Address: ethAddr.String(),
- }
- wantResp = &evm.QueryNibiruAccountResponse{
- Address: nibiruAddr.String(),
- Sequence: 0,
- AccountNumber: 0,
- }
- return req, wantResp
- },
- wantErr: "",
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- deps := s.SetupTest()
- req, wantResp := tc.scenario(&deps)
- goCtx := sdk.WrapSDKContext(deps.ctx)
- gotResp, err := deps.k.NibiruAccount(goCtx, req)
- if tc.wantErr != "" {
- s.Require().ErrorContains(err, tc.wantErr)
- return
- }
- s.Assert().NoError(err)
- s.EqualValues(wantResp, gotResp)
- })
- }
-}
-
-func (s *KeeperSuite) TestQueryEthAccount() {
- type In = *evm.QueryEthAccountRequest
- type Out = *evm.QueryEthAccountResponse
- testCases := []TestCase[In, Out]{
- {
- name: "sad: msg validation",
- scenario: func(deps *TestDeps) (req In, wantResp Out) {
- req = &evm.QueryEthAccountRequest{
- Address: InvalidEthAddr(),
- }
- wantResp = &evm.QueryEthAccountResponse{
- Balance: "0",
- CodeHash: gethcommon.BytesToHash(evm.EmptyCodeHash).Hex(),
- Nonce: 0,
- }
- return req, wantResp
- },
- wantErr: "not a valid ethereum hex addr",
- },
- {
- name: "happy: fund account + query",
- setup: func(deps *TestDeps) {
- chain := deps.chain
- ethAddr := deps.sender.EthAddr
-
- // fund account with 420 tokens
- coins := sdk.Coins{sdk.NewInt64Coin(evm.DefaultEVMDenom, 420)}
- err := chain.BankKeeper.MintCoins(deps.ctx, evm.ModuleName, coins)
- s.NoError(err)
- err = chain.BankKeeper.SendCoinsFromModuleToAccount(
- deps.ctx, evm.ModuleName, ethAddr.Bytes(), coins)
- s.Require().NoError(err)
- },
- scenario: func(deps *TestDeps) (req In, wantResp Out) {
- req = &evm.QueryEthAccountRequest{
- Address: deps.sender.EthAddr.Hex(),
- }
- wantResp = &evm.QueryEthAccountResponse{
- Balance: "420",
- CodeHash: gethcommon.BytesToHash(evm.EmptyCodeHash).Hex(),
- Nonce: 0,
- }
- return req, wantResp
- },
- wantErr: "",
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- deps := s.SetupTest()
- req, wantResp := tc.scenario(&deps)
- if tc.setup != nil {
- tc.setup(&deps)
- }
- goCtx := sdk.WrapSDKContext(deps.ctx)
- gotResp, err := deps.k.EthAccount(goCtx, req)
- if tc.wantErr != "" {
- s.Require().ErrorContains(err, tc.wantErr)
- return
- }
- s.Assert().NoError(err)
- s.EqualValues(wantResp, gotResp)
- })
- }
-}
diff --git a/x/evm/keeper/hooks.go b/x/evm/keeper/hooks.go
deleted file mode 100644
index d3c3cfdf3..000000000
--- a/x/evm/keeper/hooks.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package keeper
-
-import (
- abci "github.com/cometbft/cometbft/abci/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// BeginBlock sets the sdk Context and EIP155 chain id to the Keeper.
-func (k *Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
- // TODO: feat(evm): impl BeginBlock
-}
-
-// EndBlock also retrieves the bloom filter value from the transient store and commits it to the
-// KVStore. The EVM end block logic doesn't update the validator set, thus it returns
-// an empty slice.
-func (k *Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
- // TODO: feat(evm): impl EndBlock
- return []abci.ValidatorUpdate{}
-}
diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go
deleted file mode 100644
index 7f3a2a813..000000000
--- a/x/evm/keeper/keeper.go
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package keeper
-
-import (
- // "github.com/NibiruChain/nibiru/x/evm"
- "math/big"
-
- "github.com/cosmos/cosmos-sdk/codec"
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- gethcommon "github.com/ethereum/go-ethereum/common"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-type Keeper struct {
- cdc codec.BinaryCodec
- // storeKey: For persistent storage of EVM state.
- storeKey storetypes.StoreKey
- // transientKey: Store key that resets every block during Commit
- transientKey storetypes.StoreKey
-
- // EvmState isolates the key-value stores (collections) for the x/evm module.
- EvmState EvmState
-
- // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account.
- authority sdk.AccAddress
-
- bankKeeper evm.BankKeeper
- accountKeeper evm.AccountKeeper
-}
-
-func NewKeeper(
- cdc codec.BinaryCodec,
- storeKey, transientKey storetypes.StoreKey,
- authority sdk.AccAddress,
- accKeeper evm.AccountKeeper,
- bankKeeper evm.BankKeeper,
-) Keeper {
- if err := sdk.VerifyAddressFormat(authority); err != nil {
- panic(err)
- }
- return Keeper{
- cdc: cdc,
- storeKey: storeKey,
- transientKey: transientKey,
- authority: authority,
- EvmState: NewEvmState(cdc, storeKey, transientKey),
- accountKeeper: accKeeper,
- bankKeeper: bankKeeper,
- }
-}
-
-// GetEvmGasBalance: Implements `evm.EVMKeeper` from
-// "github.com/NibiruChain/nibiru/app/ante/evm": Load account's balance of gas
-// tokens for EVM execution
-func (k *Keeper) GetEvmGasBalance(ctx sdk.Context, addr gethcommon.Address) *big.Int {
- nibiruAddr := sdk.AccAddress(addr.Bytes())
- evmParams := k.GetParams(ctx)
- evmDenom := evmParams.GetEvmDenom()
- // if node is pruned, params is empty. Return invalid value
- if evmDenom == "" {
- return big.NewInt(-1)
- }
- coin := k.bankKeeper.GetBalance(ctx, nibiruAddr, evmDenom)
- return coin.Amount.BigInt()
-}
diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go
deleted file mode 100644
index 8221cc854..000000000
--- a/x/evm/keeper/keeper_test.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package keeper_test
-
-import (
- "testing"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/x/common"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
-)
-
-type KeeperSuite struct {
- suite.Suite
-}
-
-// TestKeeperSuite: Runs all of the tests in the suite.
-func TestKeeperSuite(t *testing.T) {
- s := new(KeeperSuite)
- suite.Run(t, s)
-}
-
-func (s *KeeperSuite) TestMsgServer() {
- chain, ctx := testapp.NewNibiruTestAppAndContext()
- goCtx := sdk.WrapSDKContext(ctx)
- k := chain.EvmKeeper
- for _, testCase := range []func() error{
- func() error {
- _, err := k.EthereumTx(goCtx, nil)
- return err
- },
- func() error {
- _, err := k.UpdateParams(goCtx, nil)
- return err
- },
- } {
- err := testCase()
- s.Require().ErrorContains(err, common.ErrNotImplemented().Error())
- }
-}
-
-func (s *KeeperSuite) TestQuerier() {
- chain, ctx := testapp.NewNibiruTestAppAndContext()
- goCtx := sdk.WrapSDKContext(ctx)
- k := chain.EvmKeeper
- for _, testCase := range []func() error{
- func() error {
- _, err := k.ValidatorAccount(goCtx, nil)
- return err
- },
- func() error {
- _, err := k.BaseFee(goCtx, nil)
- return err
- },
- func() error {
- _, err := k.Code(goCtx, nil)
- return err
- },
- func() error {
- _, err := k.EthCall(goCtx, nil)
- return err
- },
- func() error {
- _, err := k.EstimateGas(goCtx, nil)
- return err
- },
- func() error {
- _, err := k.TraceTx(goCtx, nil)
- return err
- },
- func() error {
- _, err := k.TraceBlock(goCtx, nil)
- return err
- },
- } {
- err := testCase()
- s.Require().ErrorContains(err, common.ErrNotImplemented().Error())
- }
-}
diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go
deleted file mode 100644
index ec94c9e4a..000000000
--- a/x/evm/keeper/msg_server.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package keeper
-
-import (
- "context"
-
- "github.com/NibiruChain/nibiru/x/common"
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-var _ evm.MsgServer = &Keeper{}
-
-func (k *Keeper) EthereumTx(
- goCtx context.Context, msg *evm.MsgEthereumTx,
-) (resp *evm.MsgEthereumTxResponse, err error) {
- // TODO: feat(evm): EthereumTx impl
- return resp, common.ErrNotImplemented()
-}
-
-func (k *Keeper) UpdateParams(
- goCtx context.Context, msg *evm.MsgUpdateParams,
-) (resp *evm.MsgUpdateParamsResponse, err error) {
- // TODO: feat(evm): UpdateParams impl
- return resp, common.ErrNotImplemented()
-}
diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go
deleted file mode 100644
index bb243c806..000000000
--- a/x/evm/keeper/statedb.go
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package keeper
-
-import (
- "math/big"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- gethcommon "github.com/ethereum/go-ethereum/common"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/x/evm"
- "github.com/NibiruChain/nibiru/x/evm/statedb"
-)
-
-// SetState: Update contract storage, delete if value is empty.
-// Implements the `statedb.Keeper` interface.
-// Only called by `StateDB.Commit()`.
-func (k *Keeper) SetState(
- ctx sdk.Context, addr gethcommon.Address, stateKey gethcommon.Hash, stateValue []byte,
-) {
- k.EvmState.SetAccState(ctx, addr, stateKey, stateValue)
-}
-
-// SetCode: Setter for smart contract bytecode. Delete if code is empty.
-// Implements the `statedb.Keeper` interface.
-// Only called by `StateDB.Commit()`.
-func (k *Keeper) SetCode(ctx sdk.Context, codeHash, code []byte) {
- k.EvmState.SetAccCode(ctx, codeHash, code)
-}
-
-// GetAccount: Ethereum account getter for a [statedb.Account].
-// Implements the `statedb.Keeper` interface.
-// Returns nil if the account does not not exist or has the wrong type.
-func (k *Keeper) GetAccount(ctx sdk.Context, addr gethcommon.Address) *statedb.Account {
- acct := k.GetAccountWithoutBalance(ctx, addr)
- if acct == nil {
- return nil
- }
-
- acct.Balance = k.GetEvmGasBalance(ctx, addr)
- return acct
-}
-
-// GetAccountOrEmpty returns empty account if not exist, returns error if it's not `EthAccount`
-func (k *Keeper) GetAccountOrEmpty(
- ctx sdk.Context, addr gethcommon.Address,
-) statedb.Account {
- acct := k.GetAccount(ctx, addr)
- if acct != nil {
- return *acct
- }
- // empty account
- return statedb.Account{
- Balance: new(big.Int),
- CodeHash: evm.EmptyCodeHash,
- }
-}
-
-// GetAccountWithoutBalance load nonce and codehash without balance,
-// more efficient in cases where balance is not needed.
-func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr gethcommon.Address) *statedb.Account {
- nibiruAddr := sdk.AccAddress(addr.Bytes())
- acct := k.accountKeeper.GetAccount(ctx, nibiruAddr)
- if acct == nil {
- return nil
- }
-
- codeHash := evm.EmptyCodeHash
- ethAcct, ok := acct.(eth.EthAccountI)
- if ok {
- codeHash = ethAcct.GetCodeHash().Bytes()
- }
-
- return &statedb.Account{
- Nonce: acct.GetSequence(),
- CodeHash: codeHash,
- }
-}
diff --git a/x/evm/legacy_tx.go b/x/evm/legacy_tx.go
deleted file mode 100644
index e12b019ce..000000000
--- a/x/evm/legacy_tx.go
+++ /dev/null
@@ -1,230 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "math/big"
-
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
-
- errorsmod "cosmossdk.io/errors"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-func NewLegacyTx(tx *gethcore.Transaction) (*LegacyTx, error) {
- txData := &LegacyTx{
- Nonce: tx.Nonce(),
- Data: tx.Data(),
- GasLimit: tx.Gas(),
- }
-
- v, r, s := tx.RawSignatureValues()
- if to := tx.To(); to != nil {
- txData.To = to.Hex()
- }
-
- if tx.Value() != nil {
- amountInt, err := eth.SafeNewIntFromBigInt(tx.Value())
- if err != nil {
- return nil, err
- }
- txData.Amount = &amountInt
- }
-
- if tx.GasPrice() != nil {
- gasPriceInt, err := eth.SafeNewIntFromBigInt(tx.GasPrice())
- if err != nil {
- return nil, err
- }
- txData.GasPrice = &gasPriceInt
- }
-
- txData.SetSignatureValues(tx.ChainId(), v, r, s)
- return txData, nil
-}
-
-// TxType returns the tx type
-func (tx *LegacyTx) TxType() uint8 {
- return gethcore.LegacyTxType
-}
-
-// Copy returns an instance with the same field values
-func (tx *LegacyTx) Copy() TxData {
- return &LegacyTx{
- Nonce: tx.Nonce,
- GasPrice: tx.GasPrice,
- GasLimit: tx.GasLimit,
- To: tx.To,
- Amount: tx.Amount,
- Data: common.CopyBytes(tx.Data),
- V: common.CopyBytes(tx.V),
- R: common.CopyBytes(tx.R),
- S: common.CopyBytes(tx.S),
- }
-}
-
-// GetChainID returns the chain id field from the derived signature values
-func (tx *LegacyTx) GetChainID() *big.Int {
- v, _, _ := tx.GetRawSignatureValues()
- return DeriveChainID(v)
-}
-
-// GetAccessList returns nil
-func (tx *LegacyTx) GetAccessList() gethcore.AccessList {
- return nil
-}
-
-// GetData returns the a copy of the input data bytes.
-func (tx *LegacyTx) GetData() []byte {
- return common.CopyBytes(tx.Data)
-}
-
-// GetGas returns the gas limit.
-func (tx *LegacyTx) GetGas() uint64 {
- return tx.GasLimit
-}
-
-// GetGasPrice returns the gas price field.
-func (tx *LegacyTx) GetGasPrice() *big.Int {
- if tx.GasPrice == nil {
- return nil
- }
- return tx.GasPrice.BigInt()
-}
-
-// GetGasTipCap returns the gas price field.
-func (tx *LegacyTx) GetGasTipCap() *big.Int {
- return tx.GetGasPrice()
-}
-
-// GetGasFeeCap returns the gas price field.
-func (tx *LegacyTx) GetGasFeeCap() *big.Int {
- return tx.GetGasPrice()
-}
-
-// GetValue returns the tx amount.
-func (tx *LegacyTx) GetValue() *big.Int {
- if tx.Amount == nil {
- return nil
- }
- return tx.Amount.BigInt()
-}
-
-// GetNonce returns the account sequence for the transaction.
-func (tx *LegacyTx) GetNonce() uint64 { return tx.Nonce }
-
-// GetTo returns the pointer to the recipient address.
-func (tx *LegacyTx) GetTo() *common.Address {
- if tx.To == "" {
- return nil
- }
- to := common.HexToAddress(tx.To)
- return &to
-}
-
-// AsEthereumData returns an LegacyTx transaction tx from the proto-formatted
-// TxData defined on the Cosmos EVM.
-func (tx *LegacyTx) AsEthereumData() gethcore.TxData {
- v, r, s := tx.GetRawSignatureValues()
- return &gethcore.LegacyTx{
- Nonce: tx.GetNonce(),
- GasPrice: tx.GetGasPrice(),
- Gas: tx.GetGas(),
- To: tx.GetTo(),
- Value: tx.GetValue(),
- Data: tx.GetData(),
- V: v,
- R: r,
- S: s,
- }
-}
-
-// GetRawSignatureValues returns the V, R, S signature values of the transaction.
-// The return values should not be modified by the caller.
-func (tx *LegacyTx) GetRawSignatureValues() (v, r, s *big.Int) {
- return rawSignatureValues(tx.V, tx.R, tx.S)
-}
-
-// SetSignatureValues sets the signature values to the transaction.
-func (tx *LegacyTx) SetSignatureValues(_, v, r, s *big.Int) {
- if v != nil {
- tx.V = v.Bytes()
- }
- if r != nil {
- tx.R = r.Bytes()
- }
- if s != nil {
- tx.S = s.Bytes()
- }
-}
-
-// Validate performs a stateless validation of the tx fields.
-func (tx LegacyTx) Validate() error {
- gasPrice := tx.GetGasPrice()
- if gasPrice == nil {
- return errorsmod.Wrap(ErrInvalidGasPrice, "gas price cannot be nil")
- }
-
- if gasPrice.Sign() == -1 {
- return errorsmod.Wrapf(ErrInvalidGasPrice, "gas price cannot be negative %s", gasPrice)
- }
- if !eth.IsValidInt256(gasPrice) {
- return errorsmod.Wrap(ErrInvalidGasPrice, "out of bound")
- }
- if !eth.IsValidInt256(tx.Fee()) {
- return errorsmod.Wrap(ErrInvalidGasFee, "out of bound")
- }
-
- amount := tx.GetValue()
- // Amount can be 0
- if amount != nil && amount.Sign() == -1 {
- return errorsmod.Wrapf(ErrInvalidAmount, "amount cannot be negative %s", amount)
- }
- if !eth.IsValidInt256(amount) {
- return errorsmod.Wrap(ErrInvalidAmount, "out of bound")
- }
-
- if tx.To != "" {
- if err := eth.ValidateAddress(tx.To); err != nil {
- return errorsmod.Wrap(err, "invalid to address")
- }
- }
-
- chainID := tx.GetChainID()
-
- if chainID == nil {
- return errorsmod.Wrap(
- errortypes.ErrInvalidChainID,
- "chain ID must be derived from LegacyTx txs",
- )
- }
-
- return nil
-}
-
-// Fee returns gasprice * gaslimit.
-func (tx LegacyTx) Fee() *big.Int {
- return fee(tx.GetGasPrice(), tx.GetGas())
-}
-
-// Cost returns amount + gasprice * gaslimit.
-func (tx LegacyTx) Cost() *big.Int {
- return cost(tx.Fee(), tx.GetValue())
-}
-
-// EffectiveGasPrice is the same as GasPrice for LegacyTx
-func (tx LegacyTx) EffectiveGasPrice(_ *big.Int) *big.Int {
- return tx.GetGasPrice()
-}
-
-// EffectiveFee is the same as Fee for LegacyTx
-func (tx LegacyTx) EffectiveFee(_ *big.Int) *big.Int {
- return tx.Fee()
-}
-
-// EffectiveCost is the same as Cost for LegacyTx
-func (tx LegacyTx) EffectiveCost(_ *big.Int) *big.Int {
- return tx.Cost()
-}
diff --git a/x/evm/legacy_tx_test.go b/x/evm/legacy_tx_test.go
deleted file mode 100644
index c5aa9dd50..000000000
--- a/x/evm/legacy_tx_test.go
+++ /dev/null
@@ -1,434 +0,0 @@
-package evm_test
-
-import (
- "math/big"
-
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-func (suite *TxDataTestSuite) TestNewLegacyTx() {
- testCases := []struct {
- name string
- tx *gethcore.Transaction
- }{
- {
- "non-empty Transaction",
- gethcore.NewTx(&gethcore.AccessListTx{
- Nonce: 1,
- Data: []byte("data"),
- Gas: 100,
- Value: big.NewInt(1),
- AccessList: gethcore.AccessList{},
- To: &suite.addr,
- V: big.NewInt(1),
- R: big.NewInt(1),
- S: big.NewInt(1),
- }),
- },
- }
-
- for _, tc := range testCases {
- tx, err := evm.NewLegacyTx(tc.tx)
- suite.Require().NoError(err)
-
- suite.Require().NotEmpty(tc.tx)
- suite.Require().Equal(uint8(0), tx.TxType())
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxTxType() {
- tx := evm.LegacyTx{}
- actual := tx.TxType()
-
- suite.Require().Equal(uint8(0), actual)
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxCopy() {
- tx := &evm.LegacyTx{}
- txData := tx.Copy()
-
- suite.Require().Equal(&evm.LegacyTx{}, txData)
- // TODO: Test for different pointers
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxGetChainID() {
- tx := evm.LegacyTx{}
- actual := tx.GetChainID()
-
- suite.Require().Nil(actual)
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxGetAccessList() {
- tx := evm.LegacyTx{}
- actual := tx.GetAccessList()
-
- suite.Require().Nil(actual)
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxGetData() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- }{
- {
- "non-empty transaction",
- evm.LegacyTx{
- Data: nil,
- },
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetData()
-
- suite.Require().Equal(tc.tx.Data, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxGetGas() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- exp uint64
- }{
- {
- "non-empty gas",
- evm.LegacyTx{
- GasLimit: suite.uint64,
- },
- suite.uint64,
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetGas()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxGetGasPrice() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- exp *big.Int
- }{
- {
- "empty gasPrice",
- evm.LegacyTx{
- GasPrice: nil,
- },
- nil,
- },
- {
- "non-empty gasPrice",
- evm.LegacyTx{
- GasPrice: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetGasFeeCap()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxGetGasTipCap() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- exp *big.Int
- }{
- {
- "non-empty gasPrice",
- evm.LegacyTx{
- GasPrice: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetGasTipCap()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxGetGasFeeCap() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- exp *big.Int
- }{
- {
- "non-empty gasPrice",
- evm.LegacyTx{
- GasPrice: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetGasFeeCap()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxGetValue() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- exp *big.Int
- }{
- {
- "empty amount",
- evm.LegacyTx{
- Amount: nil,
- },
- nil,
- },
- {
- "non-empty amount",
- evm.LegacyTx{
- Amount: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetValue()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxGetNonce() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- exp uint64
- }{
- {
- "none-empty nonce",
- evm.LegacyTx{
- Nonce: suite.uint64,
- },
- suite.uint64,
- },
- }
- for _, tc := range testCases {
- actual := tc.tx.GetNonce()
-
- suite.Require().Equal(tc.exp, actual)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxGetTo() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- exp *common.Address
- }{
- {
- "empty address",
- evm.LegacyTx{
- To: "",
- },
- nil,
- },
- {
- "non-empty address",
- evm.LegacyTx{
- To: suite.hexAddr,
- },
- &suite.addr,
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetTo()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxAsEthereumData() {
- tx := &evm.LegacyTx{}
- txData := tx.AsEthereumData()
-
- suite.Require().Equal(&gethcore.LegacyTx{}, txData)
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxSetSignatureValues() {
- testCases := []struct {
- name string
- v *big.Int
- r *big.Int
- s *big.Int
- }{
- {
- "non-empty values",
- suite.bigInt,
- suite.bigInt,
- suite.bigInt,
- },
- }
- for _, tc := range testCases {
- tx := &evm.LegacyTx{}
- tx.SetSignatureValues(nil, tc.v, tc.r, tc.s)
-
- v, r, s := tx.GetRawSignatureValues()
-
- suite.Require().Equal(tc.v, v, tc.name)
- suite.Require().Equal(tc.r, r, tc.name)
- suite.Require().Equal(tc.s, s, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxValidate() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- expError bool
- }{
- {
- "empty",
- evm.LegacyTx{},
- true,
- },
- {
- "gas price is nil",
- evm.LegacyTx{
- GasPrice: nil,
- },
- true,
- },
- {
- "gas price is negative",
- evm.LegacyTx{
- GasPrice: &suite.sdkMinusOneInt,
- },
- true,
- },
- {
- "amount is negative",
- evm.LegacyTx{
- GasPrice: &suite.sdkInt,
- Amount: &suite.sdkMinusOneInt,
- },
- true,
- },
- {
- "to address is invalid",
- evm.LegacyTx{
- GasPrice: &suite.sdkInt,
- Amount: &suite.sdkInt,
- To: suite.invalidAddr,
- },
- true,
- },
- }
-
- for _, tc := range testCases {
- err := tc.tx.Validate()
-
- if tc.expError {
- suite.Require().Error(err, tc.name)
- continue
- }
-
- suite.Require().NoError(err, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxEffectiveGasPrice() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- baseFee *big.Int
- exp *big.Int
- }{
- {
- "non-empty legacy tx",
- evm.LegacyTx{
- GasPrice: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.EffectiveGasPrice(tc.baseFee)
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxEffectiveFee() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- baseFee *big.Int
- exp *big.Int
- }{
- {
- "non-empty legacy tx",
- evm.LegacyTx{
- GasPrice: &suite.sdkInt,
- GasLimit: uint64(1),
- },
- (&suite.sdkInt).BigInt(),
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.EffectiveFee(tc.baseFee)
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxEffectiveCost() {
- testCases := []struct {
- name string
- tx evm.LegacyTx
- baseFee *big.Int
- exp *big.Int
- }{
- {
- "non-empty legacy tx",
- evm.LegacyTx{
- GasPrice: &suite.sdkInt,
- GasLimit: uint64(1),
- Amount: &suite.sdkZeroInt,
- },
- (&suite.sdkInt).BigInt(),
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.EffectiveCost(tc.baseFee)
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestLegacyTxFeeCost() {
- tx := &evm.LegacyTx{}
-
- suite.Require().Panics(func() { tx.Fee() }, "should panic")
- suite.Require().Panics(func() { tx.Cost() }, "should panic")
-}
diff --git a/x/evm/logs.go b/x/evm/logs.go
deleted file mode 100644
index b96de5d8a..000000000
--- a/x/evm/logs.go
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "errors"
- "fmt"
-
- gethcommon "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-// NewTransactionLogs creates a new NewTransactionLogs instance.
-func NewTransactionLogs(hash gethcommon.Hash, logs []*Log) TransactionLogs {
- return TransactionLogs{
- Hash: hash.String(),
- Logs: logs,
- }
-}
-
-// NewTransactionLogsFromEth creates a new NewTransactionLogs instance using []*ethtypes.Log.
-func NewTransactionLogsFromEth(hash gethcommon.Hash, ethlogs []*gethcore.Log) TransactionLogs {
- return TransactionLogs{
- Hash: hash.String(),
- Logs: NewLogsFromEth(ethlogs),
- }
-}
-
-// Validate performs a basic validation of a GenesisAccount fields.
-func (tx TransactionLogs) Validate() error {
- if eth.IsEmptyHash(tx.Hash) {
- return fmt.Errorf("hash cannot be the empty %s", tx.Hash)
- }
-
- for i, log := range tx.Logs {
- if log == nil {
- return fmt.Errorf("log %d cannot be nil", i)
- }
- if err := log.Validate(); err != nil {
- return fmt.Errorf("invalid log %d: %w", i, err)
- }
- if log.TxHash != tx.Hash {
- return fmt.Errorf("log tx hash mismatch (%s ≠ %s)", log.TxHash, tx.Hash)
- }
- }
- return nil
-}
-
-// EthLogs returns the Ethereum type Logs from the Transaction Logs.
-func (tx TransactionLogs) EthLogs() []*gethcore.Log {
- return LogsToEthereum(tx.Logs)
-}
-
-// Validate performs a basic validation of an ethereum Log fields.
-func (log *Log) Validate() error {
- if err := eth.ValidateAddress(log.Address); err != nil {
- return fmt.Errorf("invalid log address %w", err)
- }
- if eth.IsEmptyHash(log.BlockHash) {
- return fmt.Errorf("block hash cannot be the empty %s", log.BlockHash)
- }
- if log.BlockNumber == 0 {
- return errors.New("block number cannot be zero")
- }
- if eth.IsEmptyHash(log.TxHash) {
- return fmt.Errorf("tx hash cannot be the empty %s", log.TxHash)
- }
- return nil
-}
-
-// ToEthereum returns the Ethereum type Log from a Ethermint proto compatible Log.
-func (log *Log) ToEthereum() *gethcore.Log {
- topics := make([]gethcommon.Hash, len(log.Topics))
- for i, topic := range log.Topics {
- topics[i] = gethcommon.HexToHash(topic)
- }
-
- return &gethcore.Log{
- Address: gethcommon.HexToAddress(log.Address),
- Topics: topics,
- Data: log.Data,
- BlockNumber: log.BlockNumber,
- TxHash: gethcommon.HexToHash(log.TxHash),
- TxIndex: uint(log.TxIndex),
- Index: uint(log.Index),
- BlockHash: gethcommon.HexToHash(log.BlockHash),
- Removed: log.Removed,
- }
-}
-
-func NewLogsFromEth(ethlogs []*gethcore.Log) []*Log {
- var logs []*Log //nolint: prealloc
- for _, ethlog := range ethlogs {
- logs = append(logs, NewLogFromEth(ethlog))
- }
-
- return logs
-}
-
-// LogsToEthereum casts the Ethermint Logs to a slice of Ethereum Logs.
-func LogsToEthereum(logs []*Log) []*gethcore.Log {
- var ethLogs []*gethcore.Log //nolint: prealloc
- for i := range logs {
- ethLogs = append(ethLogs, logs[i].ToEthereum())
- }
- return ethLogs
-}
-
-// NewLogFromEth creates a new Log instance from a Ethereum type Log.
-func NewLogFromEth(log *gethcore.Log) *Log {
- topics := make([]string, len(log.Topics))
- for i, topic := range log.Topics {
- topics[i] = topic.String()
- }
-
- return &Log{
- Address: log.Address.String(),
- Topics: topics,
- Data: log.Data,
- BlockNumber: log.BlockNumber,
- TxHash: log.TxHash.String(),
- TxIndex: uint64(log.TxIndex),
- Index: uint64(log.Index),
- BlockHash: log.BlockHash.String(),
- Removed: log.Removed,
- }
-}
diff --git a/x/evm/logs_test.go b/x/evm/logs_test.go
deleted file mode 100644
index 123ddcf17..000000000
--- a/x/evm/logs_test.go
+++ /dev/null
@@ -1,201 +0,0 @@
-package evm_test
-
-import (
- "testing"
-
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/evm"
- evmtest "github.com/NibiruChain/nibiru/x/evm/evmtest"
-
- "github.com/ethereum/go-ethereum/common"
-)
-
-func TestTransactionLogsValidate(t *testing.T) {
- addr := evmtest.NewEthAddr().String()
-
- testCases := []struct {
- name string
- txLogs evm.TransactionLogs
- expPass bool
- }{
- {
- "valid log",
- evm.TransactionLogs{
- Hash: common.BytesToHash([]byte("tx_hash")).String(),
- Logs: []*evm.Log{
- {
- Address: addr,
- Topics: []string{common.BytesToHash([]byte("topic")).String()},
- Data: []byte("data"),
- BlockNumber: 1,
- TxHash: common.BytesToHash([]byte("tx_hash")).String(),
- TxIndex: 1,
- BlockHash: common.BytesToHash([]byte("block_hash")).String(),
- Index: 1,
- Removed: false,
- },
- },
- },
- true,
- },
- {
- "empty hash",
- evm.TransactionLogs{
- Hash: common.Hash{}.String(),
- },
- false,
- },
- {
- "nil log",
- evm.TransactionLogs{
- Hash: common.BytesToHash([]byte("tx_hash")).String(),
- Logs: []*evm.Log{nil},
- },
- false,
- },
- {
- "invalid log",
- evm.TransactionLogs{
- Hash: common.BytesToHash([]byte("tx_hash")).String(),
- Logs: []*evm.Log{{}},
- },
- false,
- },
- {
- "hash mismatch log",
- evm.TransactionLogs{
- Hash: common.BytesToHash([]byte("tx_hash")).String(),
- Logs: []*evm.Log{
- {
- Address: addr,
- Topics: []string{common.BytesToHash([]byte("topic")).String()},
- Data: []byte("data"),
- BlockNumber: 1,
- TxHash: common.BytesToHash([]byte("other_hash")).String(),
- TxIndex: 1,
- BlockHash: common.BytesToHash([]byte("block_hash")).String(),
- Index: 1,
- Removed: false,
- },
- },
- },
- false,
- },
- }
-
- for _, tc := range testCases {
- tc := tc
- err := tc.txLogs.Validate()
- if tc.expPass {
- require.NoError(t, err, tc.name)
- } else {
- require.Error(t, err, tc.name)
- }
- }
-}
-
-func TestValidateLog(t *testing.T) {
- addr := evmtest.NewEthAddr().String()
-
- testCases := []struct {
- name string
- log *evm.Log
- expPass bool
- }{
- {
- "valid log",
- &evm.Log{
- Address: addr,
- Topics: []string{common.BytesToHash([]byte("topic")).String()},
- Data: []byte("data"),
- BlockNumber: 1,
- TxHash: common.BytesToHash([]byte("tx_hash")).String(),
- TxIndex: 1,
- BlockHash: common.BytesToHash([]byte("block_hash")).String(),
- Index: 1,
- Removed: false,
- },
- true,
- },
- {
- "empty log", &evm.Log{}, false,
- },
- {
- "zero address",
- &evm.Log{
- Address: common.Address{}.String(),
- },
- false,
- },
- {
- "empty block hash",
- &evm.Log{
- Address: addr,
- BlockHash: common.Hash{}.String(),
- },
- false,
- },
- {
- "zero block number",
- &evm.Log{
- Address: addr,
- BlockHash: common.BytesToHash([]byte("block_hash")).String(),
- BlockNumber: 0,
- },
- false,
- },
- {
- "empty tx hash",
- &evm.Log{
- Address: addr,
- BlockHash: common.BytesToHash([]byte("block_hash")).String(),
- BlockNumber: 1,
- TxHash: common.Hash{}.String(),
- },
- false,
- },
- }
-
- for _, tc := range testCases {
- tc := tc
- err := tc.log.Validate()
- if tc.expPass {
- require.NoError(t, err, tc.name)
- } else {
- require.Error(t, err, tc.name)
- }
- }
-}
-
-func TestConversionFunctions(t *testing.T) {
- addr := evmtest.NewEthAddr().String()
-
- txLogs := evm.TransactionLogs{
- Hash: common.BytesToHash([]byte("tx_hash")).String(),
- Logs: []*evm.Log{
- {
- Address: addr,
- Topics: []string{common.BytesToHash([]byte("topic")).String()},
- Data: []byte("data"),
- BlockNumber: 1,
- TxHash: common.BytesToHash([]byte("tx_hash")).String(),
- TxIndex: 1,
- BlockHash: common.BytesToHash([]byte("block_hash")).String(),
- Index: 1,
- Removed: false,
- },
- },
- }
-
- // convert valid log to eth logs and back (and validate)
- conversionLogs := evm.NewTransactionLogsFromEth(common.BytesToHash([]byte("tx_hash")), txLogs.EthLogs())
- conversionErr := conversionLogs.Validate()
-
- // create new transaction logs as copy of old valid one (and validate)
- copyLogs := evm.NewTransactionLogs(common.BytesToHash([]byte("tx_hash")), txLogs.Logs)
- copyErr := copyLogs.Validate()
-
- require.Nil(t, conversionErr)
- require.Nil(t, copyErr)
-}
diff --git a/x/evm/msg.go b/x/evm/msg.go
deleted file mode 100644
index ba8a9e830..000000000
--- a/x/evm/msg.go
+++ /dev/null
@@ -1,451 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "errors"
- "fmt"
- "math/big"
-
- "github.com/cosmos/gogoproto/proto"
-
- sdkmath "cosmossdk.io/math"
-
- errorsmod "cosmossdk.io/errors"
- "github.com/cosmos/cosmos-sdk/client"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- sdk "github.com/cosmos/cosmos-sdk/types"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
- "github.com/cosmos/cosmos-sdk/x/auth/ante"
- "github.com/cosmos/cosmos-sdk/x/auth/signing"
- authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
-
- "github.com/NibiruChain/nibiru/eth"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
-)
-
-var (
- _ sdk.Msg = &MsgEthereumTx{}
- _ sdk.Tx = &MsgEthereumTx{}
- _ ante.GasTx = &MsgEthereumTx{}
- _ sdk.Msg = &MsgUpdateParams{}
-
- _ codectypes.UnpackInterfacesMessage = MsgEthereumTx{}
-)
-
-// message type and route constants
-const (
- // TypeMsgEthereumTx defines the type string of an Ethereum transaction
- TypeMsgEthereumTx = "ethereum_tx"
-)
-
-// NewTx returns a reference to a new Ethereum transaction message.
-func NewTx(
- tx *EvmTxArgs,
-) *MsgEthereumTx {
- return newMsgEthereumTx(tx)
-}
-
-func newMsgEthereumTx(
- tx *EvmTxArgs,
-) *MsgEthereumTx {
- var (
- cid, amt, gp *sdkmath.Int
- toAddr string
- txData TxData
- )
-
- if tx.To != nil {
- toAddr = tx.To.Hex()
- }
-
- if tx.Amount != nil {
- amountInt := sdkmath.NewIntFromBigInt(tx.Amount)
- amt = &amountInt
- }
-
- if tx.ChainID != nil {
- chainIDInt := sdkmath.NewIntFromBigInt(tx.ChainID)
- cid = &chainIDInt
- }
-
- if tx.GasPrice != nil {
- gasPriceInt := sdkmath.NewIntFromBigInt(tx.GasPrice)
- gp = &gasPriceInt
- }
-
- switch {
- case tx.GasFeeCap != nil:
- gtc := sdkmath.NewIntFromBigInt(tx.GasTipCap)
- gfc := sdkmath.NewIntFromBigInt(tx.GasFeeCap)
-
- txData = &DynamicFeeTx{
- ChainID: cid,
- Amount: amt,
- To: toAddr,
- GasTipCap: >c,
- GasFeeCap: &gfc,
- Nonce: tx.Nonce,
- GasLimit: tx.GasLimit,
- Data: tx.Input,
- Accesses: NewAccessList(tx.Accesses),
- }
- case tx.Accesses != nil:
- txData = &AccessListTx{
- ChainID: cid,
- Nonce: tx.Nonce,
- To: toAddr,
- Amount: amt,
- GasLimit: tx.GasLimit,
- GasPrice: gp,
- Data: tx.Input,
- Accesses: NewAccessList(tx.Accesses),
- }
- default:
- txData = &LegacyTx{
- To: toAddr,
- Amount: amt,
- GasPrice: gp,
- Nonce: tx.Nonce,
- GasLimit: tx.GasLimit,
- Data: tx.Input,
- }
- }
-
- dataAny, err := PackTxData(txData)
- if err != nil {
- panic(err)
- }
-
- msg := MsgEthereumTx{Data: dataAny}
- msg.Hash = msg.AsTransaction().Hash().Hex()
- return &msg
-}
-
-// FromEthereumTx populates the message fields from the given ethereum transaction
-func (msg *MsgEthereumTx) FromEthereumTx(tx *gethcore.Transaction) error {
- txData, err := NewTxDataFromTx(tx)
- if err != nil {
- return err
- }
-
- anyTxData, err := PackTxData(txData)
- if err != nil {
- return err
- }
-
- msg.Data = anyTxData
- msg.Hash = tx.Hash().Hex()
- return nil
-}
-
-// Route returns the route value of an MsgEthereumTx.
-func (msg MsgEthereumTx) Route() string { return RouterKey }
-
-// Type returns the type value of an MsgEthereumTx.
-func (msg MsgEthereumTx) Type() string { return TypeMsgEthereumTx }
-
-// ValidateBasic implements the sdk.Msg interface. It performs basic validation
-// checks of a Transaction. If returns an error if validation fails.
-func (msg MsgEthereumTx) ValidateBasic() error {
- if msg.From != "" {
- if err := eth.ValidateAddress(msg.From); err != nil {
- return errorsmod.Wrap(err, "invalid from address")
- }
- }
-
- // Validate Size_ field, should be kept empty
- if msg.Size_ != 0 {
- return errorsmod.Wrapf(errortypes.ErrInvalidRequest, "tx size is deprecated")
- }
-
- txData, err := UnpackTxData(msg.Data)
- if err != nil {
- return errorsmod.Wrap(err, "failed to unpack tx data")
- }
-
- gas := txData.GetGas()
-
- // prevent txs with 0 gas to fill up the mempool
- if gas == 0 {
- return errorsmod.Wrap(ErrInvalidGasLimit, "gas limit must not be zero")
- }
-
- // prevent gas limit from overflow
- if g := new(big.Int).SetUint64(gas); !g.IsInt64() {
- return errorsmod.Wrap(ErrGasOverflow, "gas limit must be less than math.MaxInt64")
- }
-
- if err := txData.Validate(); err != nil {
- return err
- }
-
- // Validate Hash field after validated txData to avoid panic
- txHash := msg.AsTransaction().Hash().Hex()
- if msg.Hash != txHash {
- return errorsmod.Wrapf(errortypes.ErrInvalidRequest, "invalid tx hash %s, expected: %s", msg.Hash, txHash)
- }
-
- return nil
-}
-
-// GetMsgs returns a single MsgEthereumTx as an sdk.Msg.
-func (msg *MsgEthereumTx) GetMsgs() []sdk.Msg {
- return []sdk.Msg{msg}
-}
-
-// GetSigners returns the expected signers for an Ethereum transaction message.
-// For such a message, there should exist only a single 'signer'.
-//
-// NOTE: This method panics if 'Sign' hasn't been called first.
-func (msg *MsgEthereumTx) GetSigners() []sdk.AccAddress {
- data, err := UnpackTxData(msg.Data)
- if err != nil {
- panic(err)
- }
-
- sender, err := msg.GetSender(data.GetChainID())
- if err != nil {
- panic(err)
- }
-
- signer := sdk.AccAddress(sender.Bytes())
- return []sdk.AccAddress{signer}
-}
-
-// GetSignBytes returns the Amino bytes of an Ethereum transaction message used
-// for signing.
-//
-// NOTE: This method cannot be used as a chain ID is needed to create valid bytes
-// to sign over. Use 'RLPSignBytes' instead.
-func (msg MsgEthereumTx) GetSignBytes() []byte {
- panic("must use 'RLPSignBytes' with a chain ID to get the valid bytes to sign")
-}
-
-// Sign calculates a secp256k1 ECDSA signature and signs the transaction. It
-// takes a keyring signer and the chainID to sign an Ethereum transaction according to
-// EIP155 standard.
-// This method mutates the transaction as it populates the V, R, S
-// fields of the Transaction's Signature.
-// The function will fail if the sender address is not defined for the msg or if
-// the sender is not registered on the keyring
-func (msg *MsgEthereumTx) Sign(ethSigner gethcore.Signer, keyringSigner keyring.Signer) error {
- from := msg.GetFrom()
- if from.Empty() {
- return fmt.Errorf("sender address not defined for message")
- }
-
- tx := msg.AsTransaction()
- txHash := ethSigner.Hash(tx)
-
- sig, _, err := keyringSigner.SignByAddress(from, txHash.Bytes())
- if err != nil {
- return err
- }
-
- tx, err = tx.WithSignature(ethSigner, sig)
- if err != nil {
- return err
- }
-
- return msg.FromEthereumTx(tx)
-}
-
-// GetGas implements the GasTx interface. It returns the GasLimit of the transaction.
-func (msg MsgEthereumTx) GetGas() uint64 {
- txData, err := UnpackTxData(msg.Data)
- if err != nil {
- return 0
- }
- return txData.GetGas()
-}
-
-// GetFee returns the fee for non dynamic fee tx
-func (msg MsgEthereumTx) GetFee() *big.Int {
- txData, err := UnpackTxData(msg.Data)
- if err != nil {
- return nil
- }
- return txData.Fee()
-}
-
-// GetEffectiveFee returns the fee for dynamic fee tx
-func (msg MsgEthereumTx) GetEffectiveFee(baseFee *big.Int) *big.Int {
- txData, err := UnpackTxData(msg.Data)
- if err != nil {
- return nil
- }
- return txData.EffectiveFee(baseFee)
-}
-
-// GetFrom loads the ethereum sender address from the sigcache and returns an
-// sdk.AccAddress from its bytes
-func (msg *MsgEthereumTx) GetFrom() sdk.AccAddress {
- if msg.From == "" {
- return nil
- }
-
- return common.HexToAddress(msg.From).Bytes()
-}
-
-// AsTransaction creates an Ethereum Transaction type from the msg fields
-func (msg MsgEthereumTx) AsTransaction() *gethcore.Transaction {
- txData, err := UnpackTxData(msg.Data)
- if err != nil {
- return nil
- }
-
- return gethcore.NewTx(txData.AsEthereumData())
-}
-
-// AsMessage creates an Ethereum core.Message from the msg fields
-func (msg MsgEthereumTx) AsMessage(signer gethcore.Signer, baseFee *big.Int) (core.Message, error) {
- return msg.AsTransaction().AsMessage(signer, baseFee)
-}
-
-// GetSender extracts the sender address from the signature values using the latest signer for the given chainID.
-func (msg *MsgEthereumTx) GetSender(chainID *big.Int) (common.Address, error) {
- signer := gethcore.LatestSignerForChainID(chainID)
- from, err := signer.Sender(msg.AsTransaction())
- if err != nil {
- return common.Address{}, err
- }
-
- msg.From = from.Hex()
- return from, nil
-}
-
-// UnpackInterfaces implements UnpackInterfacesMesssage.UnpackInterfaces
-func (msg MsgEthereumTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
- return unpacker.UnpackAny(msg.Data, new(TxData))
-}
-
-// UnmarshalBinary decodes the canonical encoding of transactions.
-func (msg *MsgEthereumTx) UnmarshalBinary(b []byte) error {
- tx := &gethcore.Transaction{}
- if err := tx.UnmarshalBinary(b); err != nil {
- return err
- }
- return msg.FromEthereumTx(tx)
-}
-
-// BuildTx builds the canonical cosmos tx from ethereum msg
-func (msg *MsgEthereumTx) BuildTx(b client.TxBuilder, evmDenom string) (signing.Tx, error) {
- builder, ok := b.(authtx.ExtensionOptionsTxBuilder)
- if !ok {
- return nil, errors.New("unsupported builder")
- }
-
- option, err := codectypes.NewAnyWithValue(&ExtensionOptionsEthereumTx{})
- if err != nil {
- return nil, err
- }
-
- txData, err := UnpackTxData(msg.Data)
- if err != nil {
- return nil, err
- }
- fees := make(sdk.Coins, 0)
- feeAmt := sdkmath.NewIntFromBigInt(txData.Fee())
- if feeAmt.Sign() > 0 {
- fees = append(fees, sdk.NewCoin(evmDenom, feeAmt))
- }
-
- builder.SetExtensionOptions(option)
-
- // A valid msg should have empty `From`
- msg.From = ""
-
- err = builder.SetMsgs(msg)
- if err != nil {
- return nil, err
- }
- builder.SetFeeAmount(fees)
- builder.SetGasLimit(msg.GetGas())
- tx := builder.GetTx()
- return tx, nil
-}
-
-// GetSigners returns the expected signers for a MsgUpdateParams message.
-func (m MsgUpdateParams) GetSigners() []sdk.AccAddress {
- //#nosec G703 -- gosec raises a warning about a non-handled error which we deliberately ignore here
- addr, _ := sdk.AccAddressFromBech32(m.Authority)
- return []sdk.AccAddress{addr}
-}
-
-// ValidateBasic does a sanity check of the provided data
-func (m *MsgUpdateParams) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
- return errorsmod.Wrap(err, "invalid authority address")
- }
-
- return m.Params.Validate()
-}
-
-// GetSignBytes implements the LegacyMsg interface.
-func (m MsgUpdateParams) GetSignBytes() []byte {
- return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&m))
-}
-
-// UnwrapEthereumMsg extracts MsgEthereumTx from wrapping sdk.Tx
-func UnwrapEthereumMsg(tx *sdk.Tx, ethHash common.Hash) (*MsgEthereumTx, error) {
- if tx == nil {
- return nil, fmt.Errorf("invalid tx: nil")
- }
-
- for _, msg := range (*tx).GetMsgs() {
- ethMsg, ok := msg.(*MsgEthereumTx)
- if !ok {
- return nil, fmt.Errorf("invalid tx type: %T", tx)
- }
- txHash := ethMsg.AsTransaction().Hash()
- ethMsg.Hash = txHash.Hex()
- if txHash == ethHash {
- return ethMsg, nil
- }
- }
-
- return nil, fmt.Errorf("eth tx not found: %s", ethHash)
-}
-
-// EncodeTransactionLogs encodes TransactionLogs slice into a protobuf-encoded
-// byte slice.
-func EncodeTransactionLogs(res *TransactionLogs) ([]byte, error) {
- return proto.Marshal(res)
-}
-
-// DecodeTransactionLogs decodes an protobuf-encoded byte slice into
-// TransactionLogs
-func DecodeTransactionLogs(data []byte) (TransactionLogs, error) {
- var logs TransactionLogs
- err := proto.Unmarshal(data, &logs)
- if err != nil {
- return TransactionLogs{}, err
- }
- return logs, nil
-}
-
-// DecodeTxResponse decodes an protobuf-encoded byte slice into TxResponse
-func DecodeTxResponse(in []byte) (*MsgEthereumTxResponse, error) {
- var txMsgData sdk.TxMsgData
- if err := proto.Unmarshal(in, &txMsgData); err != nil {
- return nil, err
- }
-
- if len(txMsgData.MsgResponses) == 0 {
- return &MsgEthereumTxResponse{}, nil
- }
-
- var res MsgEthereumTxResponse
- if err := proto.Unmarshal(txMsgData.MsgResponses[0].Value, &res); err != nil {
- return nil, errorsmod.Wrap(err, "failed to unmarshal tx response message data")
- }
-
- return &res, nil
-}
-
-var EmptyCodeHash = crypto.Keccak256(nil)
diff --git a/x/evm/msg_test.go b/x/evm/msg_test.go
deleted file mode 100644
index 0bdaa24c9..000000000
--- a/x/evm/msg_test.go
+++ /dev/null
@@ -1,985 +0,0 @@
-package evm_test
-
-import (
- "fmt"
- "math"
- "math/big"
- "reflect"
- "strings"
- "testing"
-
- sdkmath "cosmossdk.io/math"
- "github.com/stretchr/testify/suite"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
-
- "github.com/NibiruChain/nibiru/eth/crypto/ethsecp256k1"
-
- authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/eth/encoding"
- "github.com/NibiruChain/nibiru/x/evm"
- "github.com/NibiruChain/nibiru/x/evm/evmtest"
-)
-
-type MsgsSuite struct {
- suite.Suite
-
- signer keyring.Signer
- from common.Address
- to common.Address
- chainID *big.Int
- hundredBigInt *big.Int
-
- clientCtx client.Context
-}
-
-func TestMsgsSuite(t *testing.T) {
- suite.Run(t, new(MsgsSuite))
-}
-
-func (s *MsgsSuite) SetupTest() {
- from, privFrom := evmtest.PrivKeyEth()
-
- s.signer = evmtest.NewSigner(privFrom)
- s.from = from
- s.to = evmtest.NewEthAddr()
- s.chainID = big.NewInt(1)
- s.hundredBigInt = big.NewInt(100)
-
- encodingConfig := encoding.MakeConfig(app.ModuleBasics)
- s.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig)
-}
-
-func (s *MsgsSuite) TestMsgEthereumTx_Constructor() {
- evmTx := &evm.EvmTxArgs{
- Nonce: 0,
- To: &s.to,
- GasLimit: 100000,
- Input: []byte("test"),
- }
- msg := evm.NewTx(evmTx)
-
- // suite.Require().Equal(msg.Data.To, suite.to.Hex())
- s.Require().Equal(msg.Route(), evm.RouterKey)
- s.Require().Equal(msg.Type(), evm.TypeMsgEthereumTx)
- // suite.Require().NotNil(msg.To())
- s.Require().Equal(msg.GetMsgs(), []sdk.Msg{msg})
- s.Require().Panics(func() { msg.GetSigners() })
- s.Require().Panics(func() { msg.GetSignBytes() })
-
- evmTx2 := &evm.EvmTxArgs{
- Nonce: 0,
- GasLimit: 100000,
- Input: []byte("test"),
- }
- msg = evm.NewTx(evmTx2)
- s.Require().NotNil(msg)
-}
-
-func (s *MsgsSuite) TestMsgEthereumTx_BuildTx() {
- evmTx := &evm.EvmTxArgs{
- Nonce: 0,
- To: &s.to,
- GasLimit: 100000,
- GasPrice: big.NewInt(1),
- GasFeeCap: big.NewInt(1),
- GasTipCap: big.NewInt(0),
- Input: []byte("test"),
- }
- testCases := []struct {
- name string
- msg *evm.MsgEthereumTx
- expError bool
- }{
- {
- "build tx - pass",
- evm.NewTx(evmTx),
- false,
- },
- {
- "build tx - fail: nil data",
- evm.NewTx(evmTx),
- true,
- },
- }
-
- for _, tc := range testCases {
- if strings.Contains(tc.name, "nil data") {
- tc.msg.Data = nil
- }
-
- tx, err := tc.msg.BuildTx(s.clientCtx.TxConfig.NewTxBuilder(), evm.DefaultEVMDenom)
- if tc.expError {
- s.Require().Error(err)
- } else {
- s.Require().NoError(err)
-
- s.Require().Empty(tx.GetMemo())
- s.Require().Empty(tx.GetTimeoutHeight())
- s.Require().Equal(uint64(100000), tx.GetGas())
- s.Require().Equal(sdk.NewCoins(sdk.NewCoin(evm.DefaultEVMDenom, sdkmath.NewInt(100000))), tx.GetFee())
- }
- }
-}
-
-func invalidAddr() string { return "0x0000" }
-
-func (s *MsgsSuite) TestMsgEthereumTx_ValidateBasic() {
- var (
- hundredInt = big.NewInt(100)
- validChainID = big.NewInt(9000)
- zeroInt = big.NewInt(0)
- minusOneInt = big.NewInt(-1)
- //nolint:all
- exp_2_255 = new(big.Int).Exp(big.NewInt(2), big.NewInt(255), nil)
- )
- testCases := []struct {
- msg string
- to string
- amount *big.Int
- gasLimit uint64
- gasPrice *big.Int
- gasFeeCap *big.Int
- gasTipCap *big.Int
- from string
- accessList *gethcore.AccessList
- chainID *big.Int
- expectPass bool
- errMsg string
- }{
- {
- msg: "pass with recipient - Legacy Tx",
- to: s.to.Hex(),
- from: s.from.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: hundredInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: true,
- },
- {
- msg: "pass with recipient - AccessList Tx",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: zeroInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- accessList: &gethcore.AccessList{},
- chainID: validChainID,
- expectPass: true,
- },
- {
- msg: "pass with recipient - DynamicFee Tx",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: zeroInt,
- gasFeeCap: hundredInt,
- gasTipCap: zeroInt,
- accessList: &gethcore.AccessList{},
- chainID: validChainID,
- expectPass: true,
- },
- {
- msg: "pass contract - Legacy Tx",
- to: "",
- from: s.from.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: hundredInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: true,
- },
- {
- msg: "maxInt64 gas limit overflow",
- to: s.to.Hex(),
- from: s.from.Hex(),
- amount: hundredInt,
- gasLimit: math.MaxInt64 + 1,
- gasPrice: hundredInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: false,
- errMsg: "gas limit must be less than math.MaxInt64",
- },
- {
- msg: "nil amount - Legacy Tx",
- to: s.to.Hex(),
- from: s.from.Hex(),
- amount: nil,
- gasLimit: 1000,
- gasPrice: hundredInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: true,
- },
- {
- msg: "negative amount - Legacy Tx",
- to: s.to.Hex(),
- from: s.from.Hex(),
- amount: minusOneInt,
- gasLimit: 1000,
- gasPrice: hundredInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: false,
- errMsg: "amount cannot be negative",
- },
- {
- msg: "zero gas limit - Legacy Tx",
- to: s.to.Hex(),
- from: s.from.Hex(),
- amount: hundredInt,
- gasLimit: 0,
- gasPrice: hundredInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: false,
- errMsg: "gas limit must not be zero",
- },
- {
- msg: "nil gas price - Legacy Tx",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: nil,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: false,
- errMsg: "gas price cannot be nil",
- },
- {
- msg: "negative gas price - Legacy Tx",
- to: s.to.Hex(),
- from: s.from.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: minusOneInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: false,
- errMsg: "gas price cannot be negative",
- },
- {
- msg: "zero gas price - Legacy Tx",
- to: s.to.Hex(),
- from: s.from.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: zeroInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: true,
- },
- {
- msg: "invalid from address - Legacy Tx",
- to: s.to.Hex(),
- from: invalidAddr(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: zeroInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: false,
- errMsg: "invalid from address",
- },
- {
- msg: "out of bound gas fee - Legacy Tx",
- to: s.to.Hex(),
- from: s.from.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: exp_2_255,
- gasFeeCap: nil,
- gasTipCap: nil,
- chainID: validChainID,
- expectPass: false,
- errMsg: "out of bound",
- },
- {
- msg: "nil amount - AccessListTx",
- to: s.to.Hex(),
- amount: nil,
- gasLimit: 1000,
- gasPrice: hundredInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- accessList: &gethcore.AccessList{},
- chainID: validChainID,
- expectPass: true,
- },
- {
- msg: "negative amount - AccessListTx",
- to: s.to.Hex(),
- amount: minusOneInt,
- gasLimit: 1000,
- gasPrice: hundredInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- accessList: &gethcore.AccessList{},
- chainID: validChainID,
- expectPass: false,
- errMsg: "amount cannot be negative",
- },
- {
- msg: "zero gas limit - AccessListTx",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 0,
- gasPrice: zeroInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- accessList: &gethcore.AccessList{},
- chainID: validChainID,
- expectPass: false,
- errMsg: "gas limit must not be zero",
- },
- {
- msg: "nil gas price - AccessListTx",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: nil,
- gasFeeCap: nil,
- gasTipCap: nil,
- accessList: &gethcore.AccessList{},
- chainID: validChainID,
- expectPass: false,
- errMsg: "cannot be nil: invalid gas price",
- },
- {
- msg: "negative gas price - AccessListTx",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: minusOneInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- accessList: &gethcore.AccessList{},
- chainID: validChainID,
- expectPass: false,
- errMsg: "gas price cannot be negative",
- },
- {
- msg: "zero gas price - AccessListTx",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: zeroInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- accessList: &gethcore.AccessList{},
- chainID: validChainID,
- expectPass: true,
- },
- {
- msg: "invalid from address - AccessListTx",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: zeroInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- from: invalidAddr(),
- accessList: &gethcore.AccessList{},
- chainID: validChainID,
- expectPass: false,
- errMsg: "invalid from address",
- },
- {
- msg: "chain ID not set on AccessListTx",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: zeroInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- accessList: &gethcore.AccessList{},
- chainID: nil,
- expectPass: false,
- errMsg: "chain ID must be present on AccessList txs",
- },
- {
- msg: "nil tx.Data - AccessList Tx",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: zeroInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- accessList: &gethcore.AccessList{},
- expectPass: false,
- errMsg: "failed to unpack tx data",
- },
- {
- msg: "happy, valid chain ID",
- to: s.to.Hex(),
- amount: hundredInt,
- gasLimit: 1000,
- gasPrice: zeroInt,
- gasFeeCap: nil,
- gasTipCap: nil,
- accessList: &gethcore.AccessList{},
- chainID: hundredInt,
- expectPass: true,
- errMsg: "",
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.msg, func() {
- to := common.HexToAddress(tc.to)
- evmTx := &evm.EvmTxArgs{
- ChainID: tc.chainID,
- Nonce: 1,
- To: &to,
- Amount: tc.amount,
- GasLimit: tc.gasLimit,
- GasPrice: tc.gasPrice,
- GasFeeCap: tc.gasFeeCap,
- Accesses: tc.accessList,
- }
- tx := evm.NewTx(evmTx)
- tx.From = tc.from
-
- // apply nil assignment here to test ValidateBasic function instead of NewTx
- if strings.Contains(tc.msg, "nil tx.Data") {
- tx.Data = nil
- }
-
- // for legacy_Tx need to sign tx because the chainID is derived
- // from signature
- if tc.accessList == nil && tc.from == s.from.Hex() {
- ethSigner := gethcore.LatestSignerForChainID(tc.chainID)
- err := tx.Sign(ethSigner, s.signer)
- s.Require().NoError(err)
- }
-
- err := tx.ValidateBasic()
-
- if tc.expectPass {
- s.Require().NoError(err)
- } else {
- s.Require().Error(err)
- s.Require().Contains(err.Error(), tc.errMsg)
- }
- })
- }
-}
-
-func (s *MsgsSuite) TestMsgEthereumTx_ValidateBasicAdvanced() {
- hundredInt := big.NewInt(100)
- evmTx := &evm.EvmTxArgs{
- ChainID: hundredInt,
- Nonce: 1,
- Amount: big.NewInt(10),
- GasLimit: 100000,
- GasPrice: big.NewInt(150),
- GasFeeCap: big.NewInt(200),
- }
-
- testCases := []struct {
- msg string
- msgBuilder func() *evm.MsgEthereumTx
- expectPass bool
- }{
- {
- "fails - invalid tx hash",
- func() *evm.MsgEthereumTx {
- msg := evm.NewTx(evmTx)
- msg.Hash = "0x00"
- return msg
- },
- false,
- },
- {
- "fails - invalid size",
- func() *evm.MsgEthereumTx {
- msg := evm.NewTx(evmTx)
- msg.Size_ = 1
- return msg
- },
- false,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.msg, func() {
- err := tc.msgBuilder().ValidateBasic()
- if tc.expectPass {
- s.Require().NoError(err)
- } else {
- s.Require().Error(err)
- }
- })
- }
-}
-
-func (s *MsgsSuite) TestMsgEthereumTx_Sign() {
- testCases := []struct {
- msg string
- txParams *evm.EvmTxArgs
- ethSigner gethcore.Signer
- malleate func(tx *evm.MsgEthereumTx)
- expectPass bool
- }{
- {
- "pass - EIP2930 signer",
- &evm.EvmTxArgs{
- ChainID: s.chainID,
- Nonce: 0,
- To: &s.to,
- GasLimit: 100000,
- Input: []byte("test"),
- Accesses: &gethcore.AccessList{},
- },
- gethcore.NewEIP2930Signer(s.chainID),
- func(tx *evm.MsgEthereumTx) { tx.From = s.from.Hex() },
- true,
- },
- {
- "pass - EIP155 signer",
- &evm.EvmTxArgs{
- ChainID: s.chainID,
- Nonce: 0,
- To: &s.to,
- GasLimit: 100000,
- Input: []byte("test"),
- },
- gethcore.NewEIP155Signer(s.chainID),
- func(tx *evm.MsgEthereumTx) { tx.From = s.from.Hex() },
- true,
- },
- {
- "pass - Homestead signer",
- &evm.EvmTxArgs{
- ChainID: s.chainID,
- Nonce: 0,
- To: &s.to,
- GasLimit: 100000,
- Input: []byte("test"),
- },
- gethcore.HomesteadSigner{},
- func(tx *evm.MsgEthereumTx) { tx.From = s.from.Hex() },
- true,
- },
- {
- "pass - Frontier signer",
- &evm.EvmTxArgs{
- ChainID: s.chainID,
- Nonce: 0,
- To: &s.to,
- GasLimit: 100000,
- Input: []byte("test"),
- },
- gethcore.FrontierSigner{},
- func(tx *evm.MsgEthereumTx) { tx.From = s.from.Hex() },
- true,
- },
- {
- "no from address ",
- &evm.EvmTxArgs{
- ChainID: s.chainID,
- Nonce: 0,
- To: &s.to,
- GasLimit: 100000,
- Input: []byte("test"),
- Accesses: &gethcore.AccessList{},
- },
- gethcore.NewEIP2930Signer(s.chainID),
- func(tx *evm.MsgEthereumTx) { tx.From = "" },
- false,
- },
- {
- "from address ≠ signer address",
- &evm.EvmTxArgs{
- ChainID: s.chainID,
- Nonce: 0,
- To: &s.to,
- GasLimit: 100000,
- Input: []byte("test"),
- Accesses: &gethcore.AccessList{},
- },
- gethcore.NewEIP2930Signer(s.chainID),
- func(tx *evm.MsgEthereumTx) { tx.From = s.to.Hex() },
- false,
- },
- }
-
- for i, tc := range testCases {
- tx := evm.NewTx(tc.txParams)
- tc.malleate(tx)
- err := tx.Sign(tc.ethSigner, s.signer)
- if tc.expectPass {
- s.Require().NoError(err, "valid test %d failed: %s", i, tc.msg)
-
- sender, err := tx.GetSender(s.chainID)
- s.Require().NoError(err, tc.msg)
- s.Require().Equal(tx.From, sender.Hex(), tc.msg)
- } else {
- s.Require().Error(err, "invalid test %d passed: %s", i, tc.msg)
- }
- }
-}
-
-func (s *MsgsSuite) TestMsgEthereumTx_Getters() {
- evmTx := &evm.EvmTxArgs{
- ChainID: s.chainID,
- Nonce: 0,
- To: &s.to,
- GasLimit: 50,
- GasPrice: s.hundredBigInt,
- Accesses: &gethcore.AccessList{},
- }
- testCases := []struct {
- name string
- ethSigner gethcore.Signer
- exp *big.Int
- }{
- {
- "get fee - pass",
-
- gethcore.NewEIP2930Signer(s.chainID),
- big.NewInt(5000),
- },
- {
- "get fee - fail: nil data",
- gethcore.NewEIP2930Signer(s.chainID),
- nil,
- },
- {
- "get effective fee - pass",
-
- gethcore.NewEIP2930Signer(s.chainID),
- big.NewInt(5000),
- },
- {
- "get effective fee - fail: nil data",
- gethcore.NewEIP2930Signer(s.chainID),
- nil,
- },
- {
- "get gas - pass",
- gethcore.NewEIP2930Signer(s.chainID),
- big.NewInt(50),
- },
- {
- "get gas - fail: nil data",
- gethcore.NewEIP2930Signer(s.chainID),
- big.NewInt(0),
- },
- }
-
- var fee, effFee *big.Int
- for _, tc := range testCases {
- tx := evm.NewTx(evmTx)
- if strings.Contains(tc.name, "nil data") {
- tx.Data = nil
- }
- switch {
- case strings.Contains(tc.name, "get fee"):
- fee = tx.GetFee()
- s.Require().Equal(tc.exp, fee)
- case strings.Contains(tc.name, "get effective fee"):
- effFee = tx.GetEffectiveFee(big.NewInt(0))
- s.Require().Equal(tc.exp, effFee)
- case strings.Contains(tc.name, "get gas"):
- gas := tx.GetGas()
- s.Require().Equal(tc.exp.Uint64(), gas)
- }
- }
-}
-
-func (s *MsgsSuite) TestFromEthereumTx() {
- privkey, _ := ethsecp256k1.GenerateKey()
- ethPriv, err := privkey.ToECDSA()
- s.Require().NoError(err)
-
- // 10^80 is more than 256 bits
- //nolint:all
- exp_10_80 := new(big.Int).Mul(big.NewInt(1), new(big.Int).Exp(big.NewInt(10), big.NewInt(80), nil))
-
- testCases := []struct {
- msg string
- expectPass bool
- buildTx func() *gethcore.Transaction
- }{
- {"success, normal tx", true, func() *gethcore.Transaction {
- tx := gethcore.NewTx(&gethcore.AccessListTx{
- Nonce: 0,
- Data: nil,
- To: &s.to,
- Value: big.NewInt(10),
- GasPrice: big.NewInt(1),
- Gas: 21000,
- })
- tx, err := gethcore.SignTx(tx, gethcore.NewEIP2930Signer(s.chainID), ethPriv)
- s.Require().NoError(err)
- return tx
- }},
- {"success, DynamicFeeTx", true, func() *gethcore.Transaction {
- tx := gethcore.NewTx(&gethcore.DynamicFeeTx{
- Nonce: 0,
- Data: nil,
- To: &s.to,
- Value: big.NewInt(10),
- Gas: 21000,
- })
- tx, err := gethcore.SignTx(tx, gethcore.NewLondonSigner(s.chainID), ethPriv)
- s.Require().NoError(err)
- return tx
- }},
- {"fail, value bigger than 256bits - AccessListTx", false, func() *gethcore.Transaction {
- tx := gethcore.NewTx(&gethcore.AccessListTx{
- Nonce: 0,
- Data: nil,
- To: &s.to,
- Value: exp_10_80,
- GasPrice: big.NewInt(1),
- Gas: 21000,
- })
- tx, err := gethcore.SignTx(tx, gethcore.NewEIP2930Signer(s.chainID), ethPriv)
- s.Require().NoError(err)
- return tx
- }},
- {"fail, gas price bigger than 256bits - AccessListTx", false, func() *gethcore.Transaction {
- tx := gethcore.NewTx(&gethcore.AccessListTx{
- Nonce: 0,
- Data: nil,
- To: &s.to,
- Value: big.NewInt(1),
- GasPrice: exp_10_80,
- Gas: 21000,
- })
- tx, err := gethcore.SignTx(tx, gethcore.NewEIP2930Signer(s.chainID), ethPriv)
- s.Require().NoError(err)
- return tx
- }},
- {"fail, value bigger than 256bits - LegacyTx", false, func() *gethcore.Transaction {
- tx := gethcore.NewTx(&gethcore.LegacyTx{
- Nonce: 0,
- Data: nil,
- To: &s.to,
- Value: exp_10_80,
- GasPrice: big.NewInt(1),
- Gas: 21000,
- })
- tx, err := gethcore.SignTx(tx, gethcore.NewEIP2930Signer(s.chainID), ethPriv)
- s.Require().NoError(err)
- return tx
- }},
- {"fail, gas price bigger than 256bits - LegacyTx", false, func() *gethcore.Transaction {
- tx := gethcore.NewTx(&gethcore.LegacyTx{
- Nonce: 0,
- Data: nil,
- To: &s.to,
- Value: big.NewInt(1),
- GasPrice: exp_10_80,
- Gas: 21000,
- })
- tx, err := gethcore.SignTx(tx, gethcore.NewEIP2930Signer(s.chainID), ethPriv)
- s.Require().NoError(err)
- return tx
- }},
- }
-
- for _, tc := range testCases {
- ethTx := tc.buildTx()
- tx := &evm.MsgEthereumTx{}
- err := tx.FromEthereumTx(ethTx)
- if tc.expectPass {
- s.Require().NoError(err)
-
- // round-trip test
- s.Require().NoError(assertEqualTxs(tx.AsTransaction(), ethTx))
- } else {
- s.Require().Error(err)
- }
- }
-}
-
-// TestTxEncoding tests serializing/de-serializing to/from rlp and JSON.
-// adapted from go-ethereum
-func (s *MsgsSuite) TestTxEncoding() {
- key, err := crypto.GenerateKey()
- if err != nil {
- s.T().Fatalf("could not generate key: %v", err)
- }
- var (
- signer = gethcore.NewEIP2930Signer(common.Big1)
- addr = common.HexToAddress("0x0000000000000000000000000000000000000001")
- recipient = common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87")
- accesses = gethcore.AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}}
- )
- for i := uint64(0); i < 500; i++ {
- var txdata gethcore.TxData
- switch i % 5 {
- case 0:
- // Legacy tx.
- txdata = &gethcore.LegacyTx{
- Nonce: i,
- To: &recipient,
- Gas: 1,
- GasPrice: big.NewInt(2),
- Data: []byte("abcdef"),
- }
- case 1:
- // Legacy tx contract creation.
- txdata = &gethcore.LegacyTx{
- Nonce: i,
- Gas: 1,
- GasPrice: big.NewInt(2),
- Data: []byte("abcdef"),
- }
- case 2:
- // Tx with non-zero access list.
- txdata = &gethcore.AccessListTx{
- ChainID: big.NewInt(1),
- Nonce: i,
- To: &recipient,
- Gas: 123457,
- GasPrice: big.NewInt(10),
- AccessList: accesses,
- Data: []byte("abcdef"),
- }
- case 3:
- // Tx with empty access list.
- txdata = &gethcore.AccessListTx{
- ChainID: big.NewInt(1),
- Nonce: i,
- To: &recipient,
- Gas: 123457,
- GasPrice: big.NewInt(10),
- Data: []byte("abcdef"),
- }
- case 4:
- // Contract creation with access list.
- txdata = &gethcore.AccessListTx{
- ChainID: big.NewInt(1),
- Nonce: i,
- Gas: 123457,
- GasPrice: big.NewInt(10),
- AccessList: accesses,
- }
- }
- tx, err := gethcore.SignNewTx(key, signer, txdata)
- if err != nil {
- s.T().Fatalf("could not sign transaction: %v", err)
- }
- // RLP
- parsedTx, err := encodeDecodeBinary(tx)
- if err != nil {
- s.T().Fatal(err)
- }
- err = assertEqualTxs(parsedTx.AsTransaction(), tx)
- s.Require().NoError(err)
- }
-}
-
-func encodeDecodeBinary(tx *gethcore.Transaction) (*evm.MsgEthereumTx, error) {
- data, err := tx.MarshalBinary()
- if err != nil {
- return nil, fmt.Errorf("rlp encoding failed: %v", err)
- }
- parsedTx := &evm.MsgEthereumTx{}
- if err := parsedTx.UnmarshalBinary(data); err != nil {
- return nil, fmt.Errorf("rlp decoding failed: %v", err)
- }
- return parsedTx, nil
-}
-
-func assertEqualTxs(orig *gethcore.Transaction, cpy *gethcore.Transaction) error {
- // compare nonce, price, gaslimit, recipient, amount, payload, V, R, S
- if want, got := orig.Hash(), cpy.Hash(); want != got {
- return fmt.Errorf("parsed tx differs from original tx, want %v, got %v", want, got)
- }
- if want, got := orig.ChainId(), cpy.ChainId(); want.Cmp(got) != 0 {
- return fmt.Errorf("invalid chain id, want %d, got %d", want, got)
- }
- if orig.AccessList() != nil {
- if !reflect.DeepEqual(orig.AccessList(), cpy.AccessList()) {
- return fmt.Errorf("access list wrong")
- }
- }
- return nil
-}
-
-func (s *MsgsSuite) TestUnwrapEthererumMsg() {
- _, err := evm.UnwrapEthereumMsg(nil, common.Hash{})
- s.NotNil(err)
-
- encodingConfig := encoding.MakeConfig(app.ModuleBasics)
- clientCtx := client.Context{}.WithTxConfig(encodingConfig.TxConfig)
- builder, _ := clientCtx.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder)
-
- tx := builder.GetTx().(sdk.Tx)
- _, err = evm.UnwrapEthereumMsg(&tx, common.Hash{})
- s.NotNil(err)
-
- evmTxParams := &evm.EvmTxArgs{
- ChainID: big.NewInt(1),
- Nonce: 0,
- To: &common.Address{},
- Amount: big.NewInt(0),
- GasLimit: 0,
- GasPrice: big.NewInt(0),
- Input: []byte{},
- }
-
- msg := evm.NewTx(evmTxParams)
- err = builder.SetMsgs(msg)
- s.Nil(err)
-
- tx = builder.GetTx().(sdk.Tx)
- unwrappedMsg, err := evm.UnwrapEthereumMsg(&tx, msg.AsTransaction().Hash())
- s.Nil(err)
- s.Equal(unwrappedMsg, msg)
-}
-
-func (s *MsgsSuite) TestTransactionLogsEncodeDecode() {
- addr := evmtest.NewEthAddr().String()
-
- txLogs := evm.TransactionLogs{
- Hash: common.BytesToHash([]byte("tx_hash")).String(),
- Logs: []*evm.Log{
- {
- Address: addr,
- Topics: []string{common.BytesToHash([]byte("topic")).String()},
- Data: []byte("data"),
- BlockNumber: 1,
- TxHash: common.BytesToHash([]byte("tx_hash")).String(),
- TxIndex: 1,
- BlockHash: common.BytesToHash([]byte("block_hash")).String(),
- Index: 1,
- Removed: false,
- },
- },
- }
-
- txLogsEncoded, encodeErr := evm.EncodeTransactionLogs(&txLogs)
- s.Nil(encodeErr)
-
- txLogsEncodedDecoded, decodeErr := evm.DecodeTransactionLogs(txLogsEncoded)
- s.Nil(decodeErr)
- s.Equal(txLogs, txLogsEncodedDecoded)
-}
diff --git a/x/evm/params.go b/x/evm/params.go
deleted file mode 100644
index 8112b61e0..000000000
--- a/x/evm/params.go
+++ /dev/null
@@ -1,253 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "fmt"
- "math/big"
- "sort"
- "strings"
-
- errorsmod "cosmossdk.io/errors"
- sdk "github.com/cosmos/cosmos-sdk/types"
- channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
- host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/params"
- "golang.org/x/exp/slices"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-const (
- // DefaultEVMDenom defines the default EVM denomination
- DefaultEVMDenom = "unibi"
-)
-
-var (
- // DefaultAllowUnprotectedTxs rejects all unprotected txs (i.e false)
- DefaultAllowUnprotectedTxs = false
- // DefaultEnableCreate enables contract creation (i.e true)
- DefaultEnableCreate = true
- // DefaultEnableCall enables contract calls (i.e true)
- DefaultEnableCall = true
- // AvailableEVMExtensions defines the default active precompiles
- AvailableEVMExtensions = []string{}
- DefaultExtraEIPs = []int64{}
- DefaultEVMChannels = []string{}
-)
-
-// NewParams creates a new Params instance
-func NewParams(
- evmDenom string,
- allowUnprotectedTxs,
- enableCreate,
- enableCall bool,
- config ChainConfig,
- extraEIPs []int64,
- activePrecompiles,
- evmChannels []string,
-) Params {
- return Params{
- EvmDenom: evmDenom,
- AllowUnprotectedTxs: allowUnprotectedTxs,
- EnableCreate: enableCreate,
- EnableCall: enableCall,
- ExtraEIPs: extraEIPs,
- ChainConfig: config,
- ActivePrecompiles: activePrecompiles,
- EVMChannels: evmChannels,
- }
-}
-
-// DefaultParams returns default evm parameters
-// ExtraEIPs is empty to prevent overriding the latest hard fork instruction set
-// ActivePrecompiles is empty to prevent overriding the default precompiles
-// from the EVM configuration.
-func DefaultParams() Params {
- return Params{
- EvmDenom: DefaultEVMDenom,
- EnableCreate: DefaultEnableCreate,
- EnableCall: DefaultEnableCall,
- ChainConfig: DefaultChainConfig(),
- ExtraEIPs: DefaultExtraEIPs,
- AllowUnprotectedTxs: DefaultAllowUnprotectedTxs,
- ActivePrecompiles: AvailableEVMExtensions,
- EVMChannels: DefaultEVMChannels,
- }
-}
-
-// validateChannels checks if channels ids are valid
-func validateChannels(i interface{}) error {
- channels, ok := i.([]string)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
-
- for _, channel := range channels {
- if err := host.ChannelIdentifierValidator(channel); err != nil {
- return errorsmod.Wrap(
- channeltypes.ErrInvalidChannelIdentifier, err.Error(),
- )
- }
- }
-
- return nil
-}
-
-// Validate performs basic validation on evm parameters.
-func (p Params) Validate() error {
- if err := validateEVMDenom(p.EvmDenom); err != nil {
- return err
- }
-
- if err := validateEIPs(p.ExtraEIPs); err != nil {
- return err
- }
-
- if err := validateBool(p.EnableCall); err != nil {
- return err
- }
-
- if err := validateBool(p.EnableCreate); err != nil {
- return err
- }
-
- if err := validateBool(p.AllowUnprotectedTxs); err != nil {
- return err
- }
-
- if err := validateChainConfig(p.ChainConfig); err != nil {
- return err
- }
-
- if err := ValidatePrecompiles(p.ActivePrecompiles); err != nil {
- return err
- }
-
- return validateChannels(p.EVMChannels)
-}
-
-// EIPs returns the ExtraEIPS as a int slice
-func (p Params) EIPs() []int {
- eips := make([]int, len(p.ExtraEIPs))
- for i, eip := range p.ExtraEIPs {
- eips[i] = int(eip)
- }
- return eips
-}
-
-// HasCustomPrecompiles returns true if the ActivePrecompiles slice is not empty.
-func (p Params) HasCustomPrecompiles() bool {
- return len(p.ActivePrecompiles) > 0
-}
-
-// GetActivePrecompilesAddrs is a util function that the Active Precompiles
-// as a slice of addresses.
-func (p Params) GetActivePrecompilesAddrs() []common.Address {
- precompiles := make([]common.Address, len(p.ActivePrecompiles))
- for i, precompile := range p.ActivePrecompiles {
- precompiles[i] = common.HexToAddress(precompile)
- }
- return precompiles
-}
-
-// IsEVMChannel returns true if the channel provided is in the list of
-// EVM channels
-func (p Params) IsEVMChannel(channel string) bool {
- return slices.Contains(p.EVMChannels, channel)
-}
-
-// IsActivePrecompile returns true if the given precompile address is
-// registered as an active precompile.
-func (p Params) IsActivePrecompile(address string) bool {
- _, found := sort.Find(len(p.ActivePrecompiles), func(i int) int {
- return strings.Compare(address, p.ActivePrecompiles[i])
- })
-
- return found
-}
-
-func validateEVMDenom(i interface{}) error {
- denom, ok := i.(string)
- if !ok {
- return fmt.Errorf("invalid parameter EVM denom type: %T", i)
- }
-
- return sdk.ValidateDenom(denom)
-}
-
-func validateBool(i interface{}) error {
- _, ok := i.(bool)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
- return nil
-}
-
-func validateEIPs(i interface{}) error {
- eips, ok := i.([]int64)
- if !ok {
- return fmt.Errorf("invalid EIP slice type: %T", i)
- }
-
- uniqueEIPs := make(map[int64]struct{})
-
- for _, eip := range eips {
- if !vm.ValidEip(int(eip)) {
- return fmt.Errorf("EIP %d is not activateable, valid EIPs are: %s", eip, vm.ActivateableEips())
- }
-
- if _, ok := uniqueEIPs[eip]; ok {
- return fmt.Errorf("found duplicate EIP: %d", eip)
- }
- uniqueEIPs[eip] = struct{}{}
- }
-
- return nil
-}
-
-func validateChainConfig(i interface{}) error {
- cfg, ok := i.(ChainConfig)
- if !ok {
- return fmt.Errorf("invalid chain config type: %T", i)
- }
-
- return cfg.Validate()
-}
-
-// ValidatePrecompiles checks if the precompile addresses are valid and unique.
-func ValidatePrecompiles(i interface{}) error {
- precompiles, ok := i.([]string)
- if !ok {
- return fmt.Errorf("invalid precompile slice type: %T", i)
- }
-
- seenPrecompiles := make(map[string]struct{})
- for _, precompile := range precompiles {
- if _, ok := seenPrecompiles[precompile]; ok {
- return fmt.Errorf("duplicate precompile %s", precompile)
- }
-
- if err := eth.ValidateAddress(precompile); err != nil {
- return fmt.Errorf("invalid precompile %s", precompile)
- }
-
- seenPrecompiles[precompile] = struct{}{}
- }
-
- // NOTE: Check that the precompiles are sorted. This is required for the
- // precompiles to be found correctly when using the IsActivePrecompile method,
- // because of the use of sort.Find.
- if !slices.IsSorted(precompiles) {
- return fmt.Errorf("precompiles need to be sorted: %s", precompiles)
- }
-
- return nil
-}
-
-// IsLondon returns if london hardfork is enabled.
-func IsLondon(ethConfig *params.ChainConfig, height int64) bool {
- return ethConfig.IsLondon(big.NewInt(height))
-}
diff --git a/x/evm/query.go b/x/evm/query.go
deleted file mode 100644
index 79235797d..000000000
--- a/x/evm/query.go
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-
- "github.com/NibiruChain/nibiru/eth"
- "github.com/NibiruChain/nibiru/x/common"
-)
-
-func (m QueryTraceTxRequest) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
- for _, msg := range m.Predecessors {
- if err := msg.UnpackInterfaces(unpacker); err != nil {
- return err
- }
- }
- return m.Msg.UnpackInterfaces(unpacker)
-}
-
-func (m QueryTraceBlockRequest) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
- for _, msg := range m.Txs {
- if err := msg.UnpackInterfaces(unpacker); err != nil {
- return err
- }
- }
- return nil
-}
-
-func (req *QueryEthAccountRequest) Validate() error {
- if req == nil {
- return common.ErrNilGrpcMsg()
- }
- if err := eth.ValidateAddress(req.Address); err != nil {
- return status.Error(
- codes.InvalidArgument, err.Error(),
- )
- }
- return nil
-}
-
-func (req *QueryNibiruAccountRequest) Validate() error {
- if req == nil {
- return common.ErrNilGrpcMsg()
- }
-
- if err := eth.ValidateAddress(req.Address); err != nil {
- return status.Error(
- codes.InvalidArgument, err.Error(),
- )
- }
- return nil
-}
-
-func (req *QueryValidatorAccountRequest) Validate() (
- consAddr sdk.ConsAddress, err error,
-) {
- if req == nil {
- return consAddr, status.Error(codes.InvalidArgument, "empty request")
- }
-
- consAddr, err = sdk.ConsAddressFromBech32(req.ConsAddress)
- if err != nil {
- return consAddr, status.Error(
- codes.InvalidArgument, err.Error(),
- )
- }
- return consAddr, nil
-}
-
-func (req *QueryBalanceRequest) Validate() error {
- if req == nil {
- return common.ErrNilGrpcMsg()
- }
-
- if err := eth.ValidateAddress(req.Address); err != nil {
- return status.Error(
- codes.InvalidArgument,
- ErrZeroAddress.Error(),
- )
- }
- return nil
-}
-
-func (req *QueryStorageRequest) Validate() error {
- if req == nil {
- return common.ErrNilGrpcMsg()
- }
- if err := eth.ValidateAddress(req.Address); err != nil {
- return status.Error(
- codes.InvalidArgument,
- ErrZeroAddress.Error(),
- )
- }
- return nil
-}
-
-func (req *QueryCodeRequest) Validate() error {
- if req == nil {
- return common.ErrNilGrpcMsg()
- }
-
- if err := eth.ValidateAddress(req.Address); err != nil {
- return status.Error(
- codes.InvalidArgument,
- ErrZeroAddress.Error(),
- )
- }
- return nil
-}
-
-func (req *EthCallRequest) Validate() error {
- if req == nil {
- return common.ErrNilGrpcMsg()
- }
- return nil
-}
-
-func (req *QueryTraceTxRequest) Validate() error {
- if req == nil {
- return common.ErrNilGrpcMsg()
- }
-
- if req.TraceConfig != nil && req.TraceConfig.Limit < 0 {
- return status.Errorf(codes.InvalidArgument, "output limit cannot be negative, got %d", req.TraceConfig.Limit)
- }
- return nil
-}
-
-func (req *QueryTraceBlockRequest) Validate() error {
- if req == nil {
- return common.ErrNilGrpcMsg()
- }
-
- if req.TraceConfig != nil && req.TraceConfig.Limit < 0 {
- return status.Errorf(codes.InvalidArgument, "output limit cannot be negative, got %d", req.TraceConfig.Limit)
- }
- return nil
-}
diff --git a/x/evm/query.pb.go b/x/evm/query.pb.go
deleted file mode 100644
index 052d10057..000000000
--- a/x/evm/query.pb.go
+++ /dev/null
@@ -1,5990 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: eth/evm/v1/query.proto
-
-package evm
-
-import (
- context "context"
- cosmossdk_io_math "cosmossdk.io/math"
- fmt "fmt"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- query "github.com/cosmos/cosmos-sdk/types/query"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- _ "google.golang.org/protobuf/types/known/timestamppb"
- io "io"
- math "math"
- math_bits "math/bits"
- time "time"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-var _ = time.Kitchen
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// QueryEthAccountRequest is the request type for the Query/Account RPC method.
-type QueryEthAccountRequest struct {
- // address is the ethereum hex address to query the account for.
- Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
-}
-
-func (m *QueryEthAccountRequest) Reset() { *m = QueryEthAccountRequest{} }
-func (m *QueryEthAccountRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryEthAccountRequest) ProtoMessage() {}
-func (*QueryEthAccountRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{0}
-}
-func (m *QueryEthAccountRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryEthAccountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryEthAccountRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryEthAccountRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryEthAccountRequest.Merge(m, src)
-}
-func (m *QueryEthAccountRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryEthAccountRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryEthAccountRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryEthAccountRequest proto.InternalMessageInfo
-
-// QueryEthAccountResponse is the response type for the Query/Account RPC method.
-type QueryEthAccountResponse struct {
- // balance is the balance of the EVM denomination.
- Balance string `protobuf:"bytes,1,opt,name=balance,proto3" json:"balance,omitempty"`
- // code_hash is the hex-formatted code bytes from the EOA.
- CodeHash string `protobuf:"bytes,2,opt,name=code_hash,json=codeHash,proto3" json:"code_hash,omitempty"`
- // nonce is the account's sequence number.
- Nonce uint64 `protobuf:"varint,3,opt,name=nonce,proto3" json:"nonce,omitempty"`
-}
-
-func (m *QueryEthAccountResponse) Reset() { *m = QueryEthAccountResponse{} }
-func (m *QueryEthAccountResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryEthAccountResponse) ProtoMessage() {}
-func (*QueryEthAccountResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{1}
-}
-func (m *QueryEthAccountResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryEthAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryEthAccountResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryEthAccountResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryEthAccountResponse.Merge(m, src)
-}
-func (m *QueryEthAccountResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryEthAccountResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryEthAccountResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryEthAccountResponse proto.InternalMessageInfo
-
-func (m *QueryEthAccountResponse) GetBalance() string {
- if m != nil {
- return m.Balance
- }
- return ""
-}
-
-func (m *QueryEthAccountResponse) GetCodeHash() string {
- if m != nil {
- return m.CodeHash
- }
- return ""
-}
-
-func (m *QueryEthAccountResponse) GetNonce() uint64 {
- if m != nil {
- return m.Nonce
- }
- return 0
-}
-
-// QueryNibiruAccountRequest is the request type for the Query/NibiruAccount RPC
-// method.
-type QueryNibiruAccountRequest struct {
- // address is the ethereum hex address to query the account for.
- Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
-}
-
-func (m *QueryNibiruAccountRequest) Reset() { *m = QueryNibiruAccountRequest{} }
-func (m *QueryNibiruAccountRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryNibiruAccountRequest) ProtoMessage() {}
-func (*QueryNibiruAccountRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{2}
-}
-func (m *QueryNibiruAccountRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryNibiruAccountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryNibiruAccountRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryNibiruAccountRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryNibiruAccountRequest.Merge(m, src)
-}
-func (m *QueryNibiruAccountRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryNibiruAccountRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryNibiruAccountRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryNibiruAccountRequest proto.InternalMessageInfo
-
-// QueryNibiruAccountResponse is the response type for the Query/NibiruAccount
-// RPC method.
-type QueryNibiruAccountResponse struct {
- // Nibiru bech32 account "address"
- Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
- // sequence is the account's sequence number.
- Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"`
- // account_number is the account number
- AccountNumber uint64 `protobuf:"varint,3,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty"`
-}
-
-func (m *QueryNibiruAccountResponse) Reset() { *m = QueryNibiruAccountResponse{} }
-func (m *QueryNibiruAccountResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryNibiruAccountResponse) ProtoMessage() {}
-func (*QueryNibiruAccountResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{3}
-}
-func (m *QueryNibiruAccountResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryNibiruAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryNibiruAccountResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryNibiruAccountResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryNibiruAccountResponse.Merge(m, src)
-}
-func (m *QueryNibiruAccountResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryNibiruAccountResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryNibiruAccountResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryNibiruAccountResponse proto.InternalMessageInfo
-
-func (m *QueryNibiruAccountResponse) GetAddress() string {
- if m != nil {
- return m.Address
- }
- return ""
-}
-
-func (m *QueryNibiruAccountResponse) GetSequence() uint64 {
- if m != nil {
- return m.Sequence
- }
- return 0
-}
-
-func (m *QueryNibiruAccountResponse) GetAccountNumber() uint64 {
- if m != nil {
- return m.AccountNumber
- }
- return 0
-}
-
-// QueryValidatorAccountRequest is the request type for the
-// Query/ValidatorAccount RPC method.
-type QueryValidatorAccountRequest struct {
- // cons_address is the validator cons address to query the account for.
- ConsAddress string `protobuf:"bytes,1,opt,name=cons_address,json=consAddress,proto3" json:"cons_address,omitempty"`
-}
-
-func (m *QueryValidatorAccountRequest) Reset() { *m = QueryValidatorAccountRequest{} }
-func (m *QueryValidatorAccountRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryValidatorAccountRequest) ProtoMessage() {}
-func (*QueryValidatorAccountRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{4}
-}
-func (m *QueryValidatorAccountRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryValidatorAccountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryValidatorAccountRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryValidatorAccountRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryValidatorAccountRequest.Merge(m, src)
-}
-func (m *QueryValidatorAccountRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryValidatorAccountRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryValidatorAccountRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryValidatorAccountRequest proto.InternalMessageInfo
-
-// QueryValidatorAccountResponse is the response type for the
-// Query/ValidatorAccount RPC method.
-type QueryValidatorAccountResponse struct {
- // account_address is the Nibiru address of the account in bech32 format.
- AccountAddress string `protobuf:"bytes,1,opt,name=account_address,json=accountAddress,proto3" json:"account_address,omitempty"`
- // sequence is the account's sequence number.
- Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"`
- // account_number is the account number
- AccountNumber uint64 `protobuf:"varint,3,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty"`
-}
-
-func (m *QueryValidatorAccountResponse) Reset() { *m = QueryValidatorAccountResponse{} }
-func (m *QueryValidatorAccountResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryValidatorAccountResponse) ProtoMessage() {}
-func (*QueryValidatorAccountResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{5}
-}
-func (m *QueryValidatorAccountResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryValidatorAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryValidatorAccountResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryValidatorAccountResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryValidatorAccountResponse.Merge(m, src)
-}
-func (m *QueryValidatorAccountResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryValidatorAccountResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryValidatorAccountResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryValidatorAccountResponse proto.InternalMessageInfo
-
-func (m *QueryValidatorAccountResponse) GetAccountAddress() string {
- if m != nil {
- return m.AccountAddress
- }
- return ""
-}
-
-func (m *QueryValidatorAccountResponse) GetSequence() uint64 {
- if m != nil {
- return m.Sequence
- }
- return 0
-}
-
-func (m *QueryValidatorAccountResponse) GetAccountNumber() uint64 {
- if m != nil {
- return m.AccountNumber
- }
- return 0
-}
-
-// QueryBalanceRequest is the request type for the Query/Balance RPC method.
-type QueryBalanceRequest struct {
- // address is the ethereum hex address to query the balance for.
- Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
-}
-
-func (m *QueryBalanceRequest) Reset() { *m = QueryBalanceRequest{} }
-func (m *QueryBalanceRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryBalanceRequest) ProtoMessage() {}
-func (*QueryBalanceRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{6}
-}
-func (m *QueryBalanceRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryBalanceRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryBalanceRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryBalanceRequest.Merge(m, src)
-}
-func (m *QueryBalanceRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryBalanceRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryBalanceRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryBalanceRequest proto.InternalMessageInfo
-
-// QueryBalanceResponse is the response type for the Query/Balance RPC method.
-type QueryBalanceResponse struct {
- // balance is the balance of the EVM denomination.
- Balance string `protobuf:"bytes,1,opt,name=balance,proto3" json:"balance,omitempty"`
-}
-
-func (m *QueryBalanceResponse) Reset() { *m = QueryBalanceResponse{} }
-func (m *QueryBalanceResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryBalanceResponse) ProtoMessage() {}
-func (*QueryBalanceResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{7}
-}
-func (m *QueryBalanceResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryBalanceResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryBalanceResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryBalanceResponse.Merge(m, src)
-}
-func (m *QueryBalanceResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryBalanceResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryBalanceResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryBalanceResponse proto.InternalMessageInfo
-
-func (m *QueryBalanceResponse) GetBalance() string {
- if m != nil {
- return m.Balance
- }
- return ""
-}
-
-// QueryStorageRequest is the request type for the Query/Storage RPC method.
-type QueryStorageRequest struct {
- // address is the ethereum hex address to query the storage state for.
- Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
- // key defines the key of the storage state
- Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
-}
-
-func (m *QueryStorageRequest) Reset() { *m = QueryStorageRequest{} }
-func (m *QueryStorageRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryStorageRequest) ProtoMessage() {}
-func (*QueryStorageRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{8}
-}
-func (m *QueryStorageRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryStorageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryStorageRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryStorageRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryStorageRequest.Merge(m, src)
-}
-func (m *QueryStorageRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryStorageRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryStorageRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryStorageRequest proto.InternalMessageInfo
-
-// QueryStorageResponse is the response type for the Query/Storage RPC
-// method.
-type QueryStorageResponse struct {
- // value defines the storage state value hash associated with the given key.
- Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
-}
-
-func (m *QueryStorageResponse) Reset() { *m = QueryStorageResponse{} }
-func (m *QueryStorageResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryStorageResponse) ProtoMessage() {}
-func (*QueryStorageResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{9}
-}
-func (m *QueryStorageResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryStorageResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryStorageResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryStorageResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryStorageResponse.Merge(m, src)
-}
-func (m *QueryStorageResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryStorageResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryStorageResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryStorageResponse proto.InternalMessageInfo
-
-func (m *QueryStorageResponse) GetValue() string {
- if m != nil {
- return m.Value
- }
- return ""
-}
-
-// QueryCodeRequest is the request type for the Query/Code RPC method.
-type QueryCodeRequest struct {
- // address is the ethereum hex address to query the code for.
- Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
-}
-
-func (m *QueryCodeRequest) Reset() { *m = QueryCodeRequest{} }
-func (m *QueryCodeRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryCodeRequest) ProtoMessage() {}
-func (*QueryCodeRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{10}
-}
-func (m *QueryCodeRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryCodeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryCodeRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryCodeRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryCodeRequest.Merge(m, src)
-}
-func (m *QueryCodeRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryCodeRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryCodeRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryCodeRequest proto.InternalMessageInfo
-
-// QueryCodeResponse is the response type for the Query/Code RPC
-// method.
-type QueryCodeResponse struct {
- // code represents the code bytes from an ethereum address.
- Code []byte `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
-}
-
-func (m *QueryCodeResponse) Reset() { *m = QueryCodeResponse{} }
-func (m *QueryCodeResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryCodeResponse) ProtoMessage() {}
-func (*QueryCodeResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{11}
-}
-func (m *QueryCodeResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryCodeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryCodeResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryCodeResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryCodeResponse.Merge(m, src)
-}
-func (m *QueryCodeResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryCodeResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryCodeResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryCodeResponse proto.InternalMessageInfo
-
-func (m *QueryCodeResponse) GetCode() []byte {
- if m != nil {
- return m.Code
- }
- return nil
-}
-
-// QueryTxLogsRequest is the request type for the Query/TxLogs RPC method.
-type QueryTxLogsRequest struct {
- // hash is the ethereum transaction hex hash to query the logs for.
- Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
- // pagination defines an optional pagination for the request.
- Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
-}
-
-func (m *QueryTxLogsRequest) Reset() { *m = QueryTxLogsRequest{} }
-func (m *QueryTxLogsRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryTxLogsRequest) ProtoMessage() {}
-func (*QueryTxLogsRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{12}
-}
-func (m *QueryTxLogsRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryTxLogsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryTxLogsRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryTxLogsRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryTxLogsRequest.Merge(m, src)
-}
-func (m *QueryTxLogsRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryTxLogsRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryTxLogsRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryTxLogsRequest proto.InternalMessageInfo
-
-// QueryTxLogsResponse is the response type for the Query/TxLogs RPC method.
-type QueryTxLogsResponse struct {
- // logs represents the ethereum logs generated from the given transaction.
- Logs []*Log `protobuf:"bytes,1,rep,name=logs,proto3" json:"logs,omitempty"`
- // pagination defines the pagination in the response.
- Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
-}
-
-func (m *QueryTxLogsResponse) Reset() { *m = QueryTxLogsResponse{} }
-func (m *QueryTxLogsResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryTxLogsResponse) ProtoMessage() {}
-func (*QueryTxLogsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{13}
-}
-func (m *QueryTxLogsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryTxLogsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryTxLogsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryTxLogsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryTxLogsResponse.Merge(m, src)
-}
-func (m *QueryTxLogsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryTxLogsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryTxLogsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryTxLogsResponse proto.InternalMessageInfo
-
-func (m *QueryTxLogsResponse) GetLogs() []*Log {
- if m != nil {
- return m.Logs
- }
- return nil
-}
-
-func (m *QueryTxLogsResponse) GetPagination() *query.PageResponse {
- if m != nil {
- return m.Pagination
- }
- return nil
-}
-
-// QueryParamsRequest defines the request type for querying x/evm parameters.
-type QueryParamsRequest struct {
-}
-
-func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} }
-func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryParamsRequest) ProtoMessage() {}
-func (*QueryParamsRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{14}
-}
-func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryParamsRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryParamsRequest.Merge(m, src)
-}
-func (m *QueryParamsRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryParamsRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo
-
-// QueryParamsResponse defines the response type for querying x/evm parameters.
-type QueryParamsResponse struct {
- // params define the evm module parameters.
- Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
-}
-
-func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} }
-func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryParamsResponse) ProtoMessage() {}
-func (*QueryParamsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{15}
-}
-func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryParamsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryParamsResponse.Merge(m, src)
-}
-func (m *QueryParamsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryParamsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo
-
-func (m *QueryParamsResponse) GetParams() Params {
- if m != nil {
- return m.Params
- }
- return Params{}
-}
-
-// EthCallRequest defines EthCall request
-type EthCallRequest struct {
- // args uses the same json format as the json rpc api.
- Args []byte `protobuf:"bytes,1,opt,name=args,proto3" json:"args,omitempty"`
- // gas_cap defines the default gas cap to be used
- GasCap uint64 `protobuf:"varint,2,opt,name=gas_cap,json=gasCap,proto3" json:"gas_cap,omitempty"`
- // proposer_address of the requested block in hex format
- ProposerAddress github_com_cosmos_cosmos_sdk_types.ConsAddress `protobuf:"bytes,3,opt,name=proposer_address,json=proposerAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ConsAddress" json:"proposer_address,omitempty"`
- // chain_id is the eip155 chain id parsed from the requested block header
- ChainId int64 `protobuf:"varint,4,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`
-}
-
-func (m *EthCallRequest) Reset() { *m = EthCallRequest{} }
-func (m *EthCallRequest) String() string { return proto.CompactTextString(m) }
-func (*EthCallRequest) ProtoMessage() {}
-func (*EthCallRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{16}
-}
-func (m *EthCallRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EthCallRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EthCallRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EthCallRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EthCallRequest.Merge(m, src)
-}
-func (m *EthCallRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *EthCallRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_EthCallRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EthCallRequest proto.InternalMessageInfo
-
-func (m *EthCallRequest) GetArgs() []byte {
- if m != nil {
- return m.Args
- }
- return nil
-}
-
-func (m *EthCallRequest) GetGasCap() uint64 {
- if m != nil {
- return m.GasCap
- }
- return 0
-}
-
-func (m *EthCallRequest) GetProposerAddress() github_com_cosmos_cosmos_sdk_types.ConsAddress {
- if m != nil {
- return m.ProposerAddress
- }
- return nil
-}
-
-func (m *EthCallRequest) GetChainId() int64 {
- if m != nil {
- return m.ChainId
- }
- return 0
-}
-
-// EstimateGasResponse defines EstimateGas response
-type EstimateGasResponse struct {
- // gas returns the estimated gas
- Gas uint64 `protobuf:"varint,1,opt,name=gas,proto3" json:"gas,omitempty"`
-}
-
-func (m *EstimateGasResponse) Reset() { *m = EstimateGasResponse{} }
-func (m *EstimateGasResponse) String() string { return proto.CompactTextString(m) }
-func (*EstimateGasResponse) ProtoMessage() {}
-func (*EstimateGasResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{17}
-}
-func (m *EstimateGasResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EstimateGasResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EstimateGasResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EstimateGasResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EstimateGasResponse.Merge(m, src)
-}
-func (m *EstimateGasResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *EstimateGasResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_EstimateGasResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EstimateGasResponse proto.InternalMessageInfo
-
-func (m *EstimateGasResponse) GetGas() uint64 {
- if m != nil {
- return m.Gas
- }
- return 0
-}
-
-// QueryTraceTxRequest defines TraceTx request
-type QueryTraceTxRequest struct {
- // msg is the MsgEthereumTx for the requested transaction
- Msg *MsgEthereumTx `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
- // trace_config holds extra parameters to trace functions.
- TraceConfig *TraceConfig `protobuf:"bytes,3,opt,name=trace_config,json=traceConfig,proto3" json:"trace_config,omitempty"`
- // predecessors is an array of transactions included in the same block
- // need to be replayed first to get correct context for tracing.
- Predecessors []*MsgEthereumTx `protobuf:"bytes,4,rep,name=predecessors,proto3" json:"predecessors,omitempty"`
- // block_number of requested transaction
- BlockNumber int64 `protobuf:"varint,5,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"`
- // block_hash of requested transaction
- BlockHash string `protobuf:"bytes,6,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"`
- // block_time of requested transaction
- BlockTime time.Time `protobuf:"bytes,7,opt,name=block_time,json=blockTime,proto3,stdtime" json:"block_time"`
- // proposer_address is the proposer of the requested block
- ProposerAddress github_com_cosmos_cosmos_sdk_types.ConsAddress `protobuf:"bytes,8,opt,name=proposer_address,json=proposerAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ConsAddress" json:"proposer_address,omitempty"`
- // chain_id is the the eip155 chain id parsed from the requested block header
- ChainId int64 `protobuf:"varint,9,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`
- // block_max_gas of the block of the requested transaction
- BlockMaxGas int64 `protobuf:"varint,10,opt,name=block_max_gas,json=blockMaxGas,proto3" json:"block_max_gas,omitempty"`
-}
-
-func (m *QueryTraceTxRequest) Reset() { *m = QueryTraceTxRequest{} }
-func (m *QueryTraceTxRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryTraceTxRequest) ProtoMessage() {}
-func (*QueryTraceTxRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{18}
-}
-func (m *QueryTraceTxRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryTraceTxRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryTraceTxRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryTraceTxRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryTraceTxRequest.Merge(m, src)
-}
-func (m *QueryTraceTxRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryTraceTxRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryTraceTxRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryTraceTxRequest proto.InternalMessageInfo
-
-func (m *QueryTraceTxRequest) GetMsg() *MsgEthereumTx {
- if m != nil {
- return m.Msg
- }
- return nil
-}
-
-func (m *QueryTraceTxRequest) GetTraceConfig() *TraceConfig {
- if m != nil {
- return m.TraceConfig
- }
- return nil
-}
-
-func (m *QueryTraceTxRequest) GetPredecessors() []*MsgEthereumTx {
- if m != nil {
- return m.Predecessors
- }
- return nil
-}
-
-func (m *QueryTraceTxRequest) GetBlockNumber() int64 {
- if m != nil {
- return m.BlockNumber
- }
- return 0
-}
-
-func (m *QueryTraceTxRequest) GetBlockHash() string {
- if m != nil {
- return m.BlockHash
- }
- return ""
-}
-
-func (m *QueryTraceTxRequest) GetBlockTime() time.Time {
- if m != nil {
- return m.BlockTime
- }
- return time.Time{}
-}
-
-func (m *QueryTraceTxRequest) GetProposerAddress() github_com_cosmos_cosmos_sdk_types.ConsAddress {
- if m != nil {
- return m.ProposerAddress
- }
- return nil
-}
-
-func (m *QueryTraceTxRequest) GetChainId() int64 {
- if m != nil {
- return m.ChainId
- }
- return 0
-}
-
-func (m *QueryTraceTxRequest) GetBlockMaxGas() int64 {
- if m != nil {
- return m.BlockMaxGas
- }
- return 0
-}
-
-// QueryTraceTxResponse defines TraceTx response
-type QueryTraceTxResponse struct {
- // data is the response serialized in bytes
- Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
-}
-
-func (m *QueryTraceTxResponse) Reset() { *m = QueryTraceTxResponse{} }
-func (m *QueryTraceTxResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryTraceTxResponse) ProtoMessage() {}
-func (*QueryTraceTxResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{19}
-}
-func (m *QueryTraceTxResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryTraceTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryTraceTxResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryTraceTxResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryTraceTxResponse.Merge(m, src)
-}
-func (m *QueryTraceTxResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryTraceTxResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryTraceTxResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryTraceTxResponse proto.InternalMessageInfo
-
-func (m *QueryTraceTxResponse) GetData() []byte {
- if m != nil {
- return m.Data
- }
- return nil
-}
-
-// QueryTraceBlockRequest defines TraceTx request
-type QueryTraceBlockRequest struct {
- // txs is an array of messages in the block
- Txs []*MsgEthereumTx `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"`
- // trace_config holds extra parameters to trace functions.
- TraceConfig *TraceConfig `protobuf:"bytes,3,opt,name=trace_config,json=traceConfig,proto3" json:"trace_config,omitempty"`
- // block_number of the traced block
- BlockNumber int64 `protobuf:"varint,5,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"`
- // block_hash (hex) of the traced block
- BlockHash string `protobuf:"bytes,6,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"`
- // block_time of the traced block
- BlockTime time.Time `protobuf:"bytes,7,opt,name=block_time,json=blockTime,proto3,stdtime" json:"block_time"`
- // proposer_address is the address of the requested block
- ProposerAddress github_com_cosmos_cosmos_sdk_types.ConsAddress `protobuf:"bytes,8,opt,name=proposer_address,json=proposerAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ConsAddress" json:"proposer_address,omitempty"`
- // chain_id is the eip155 chain id parsed from the requested block header
- ChainId int64 `protobuf:"varint,9,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`
- // block_max_gas of the traced block
- BlockMaxGas int64 `protobuf:"varint,10,opt,name=block_max_gas,json=blockMaxGas,proto3" json:"block_max_gas,omitempty"`
-}
-
-func (m *QueryTraceBlockRequest) Reset() { *m = QueryTraceBlockRequest{} }
-func (m *QueryTraceBlockRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryTraceBlockRequest) ProtoMessage() {}
-func (*QueryTraceBlockRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{20}
-}
-func (m *QueryTraceBlockRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryTraceBlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryTraceBlockRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryTraceBlockRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryTraceBlockRequest.Merge(m, src)
-}
-func (m *QueryTraceBlockRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryTraceBlockRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryTraceBlockRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryTraceBlockRequest proto.InternalMessageInfo
-
-func (m *QueryTraceBlockRequest) GetTxs() []*MsgEthereumTx {
- if m != nil {
- return m.Txs
- }
- return nil
-}
-
-func (m *QueryTraceBlockRequest) GetTraceConfig() *TraceConfig {
- if m != nil {
- return m.TraceConfig
- }
- return nil
-}
-
-func (m *QueryTraceBlockRequest) GetBlockNumber() int64 {
- if m != nil {
- return m.BlockNumber
- }
- return 0
-}
-
-func (m *QueryTraceBlockRequest) GetBlockHash() string {
- if m != nil {
- return m.BlockHash
- }
- return ""
-}
-
-func (m *QueryTraceBlockRequest) GetBlockTime() time.Time {
- if m != nil {
- return m.BlockTime
- }
- return time.Time{}
-}
-
-func (m *QueryTraceBlockRequest) GetProposerAddress() github_com_cosmos_cosmos_sdk_types.ConsAddress {
- if m != nil {
- return m.ProposerAddress
- }
- return nil
-}
-
-func (m *QueryTraceBlockRequest) GetChainId() int64 {
- if m != nil {
- return m.ChainId
- }
- return 0
-}
-
-func (m *QueryTraceBlockRequest) GetBlockMaxGas() int64 {
- if m != nil {
- return m.BlockMaxGas
- }
- return 0
-}
-
-// QueryTraceBlockResponse defines TraceBlock response
-type QueryTraceBlockResponse struct {
- // data is the response serialized in bytes
- Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
-}
-
-func (m *QueryTraceBlockResponse) Reset() { *m = QueryTraceBlockResponse{} }
-func (m *QueryTraceBlockResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryTraceBlockResponse) ProtoMessage() {}
-func (*QueryTraceBlockResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{21}
-}
-func (m *QueryTraceBlockResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryTraceBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryTraceBlockResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryTraceBlockResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryTraceBlockResponse.Merge(m, src)
-}
-func (m *QueryTraceBlockResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryTraceBlockResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryTraceBlockResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryTraceBlockResponse proto.InternalMessageInfo
-
-func (m *QueryTraceBlockResponse) GetData() []byte {
- if m != nil {
- return m.Data
- }
- return nil
-}
-
-// QueryBaseFeeRequest defines the request type for querying the EIP1559 base
-// fee.
-type QueryBaseFeeRequest struct {
-}
-
-func (m *QueryBaseFeeRequest) Reset() { *m = QueryBaseFeeRequest{} }
-func (m *QueryBaseFeeRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryBaseFeeRequest) ProtoMessage() {}
-func (*QueryBaseFeeRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{22}
-}
-func (m *QueryBaseFeeRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryBaseFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryBaseFeeRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryBaseFeeRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryBaseFeeRequest.Merge(m, src)
-}
-func (m *QueryBaseFeeRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryBaseFeeRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryBaseFeeRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryBaseFeeRequest proto.InternalMessageInfo
-
-// QueryBaseFeeResponse returns the EIP1559 base fee.
-type QueryBaseFeeResponse struct {
- // base_fee is the EIP1559 base fee
- BaseFee *cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=base_fee,json=baseFee,proto3,customtype=cosmossdk.io/math.Int" json:"base_fee,omitempty"`
-}
-
-func (m *QueryBaseFeeResponse) Reset() { *m = QueryBaseFeeResponse{} }
-func (m *QueryBaseFeeResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryBaseFeeResponse) ProtoMessage() {}
-func (*QueryBaseFeeResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_ffa36cdc5add14ed, []int{23}
-}
-func (m *QueryBaseFeeResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryBaseFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryBaseFeeResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryBaseFeeResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryBaseFeeResponse.Merge(m, src)
-}
-func (m *QueryBaseFeeResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryBaseFeeResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryBaseFeeResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryBaseFeeResponse proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*QueryEthAccountRequest)(nil), "eth.evm.v1.QueryEthAccountRequest")
- proto.RegisterType((*QueryEthAccountResponse)(nil), "eth.evm.v1.QueryEthAccountResponse")
- proto.RegisterType((*QueryNibiruAccountRequest)(nil), "eth.evm.v1.QueryNibiruAccountRequest")
- proto.RegisterType((*QueryNibiruAccountResponse)(nil), "eth.evm.v1.QueryNibiruAccountResponse")
- proto.RegisterType((*QueryValidatorAccountRequest)(nil), "eth.evm.v1.QueryValidatorAccountRequest")
- proto.RegisterType((*QueryValidatorAccountResponse)(nil), "eth.evm.v1.QueryValidatorAccountResponse")
- proto.RegisterType((*QueryBalanceRequest)(nil), "eth.evm.v1.QueryBalanceRequest")
- proto.RegisterType((*QueryBalanceResponse)(nil), "eth.evm.v1.QueryBalanceResponse")
- proto.RegisterType((*QueryStorageRequest)(nil), "eth.evm.v1.QueryStorageRequest")
- proto.RegisterType((*QueryStorageResponse)(nil), "eth.evm.v1.QueryStorageResponse")
- proto.RegisterType((*QueryCodeRequest)(nil), "eth.evm.v1.QueryCodeRequest")
- proto.RegisterType((*QueryCodeResponse)(nil), "eth.evm.v1.QueryCodeResponse")
- proto.RegisterType((*QueryTxLogsRequest)(nil), "eth.evm.v1.QueryTxLogsRequest")
- proto.RegisterType((*QueryTxLogsResponse)(nil), "eth.evm.v1.QueryTxLogsResponse")
- proto.RegisterType((*QueryParamsRequest)(nil), "eth.evm.v1.QueryParamsRequest")
- proto.RegisterType((*QueryParamsResponse)(nil), "eth.evm.v1.QueryParamsResponse")
- proto.RegisterType((*EthCallRequest)(nil), "eth.evm.v1.EthCallRequest")
- proto.RegisterType((*EstimateGasResponse)(nil), "eth.evm.v1.EstimateGasResponse")
- proto.RegisterType((*QueryTraceTxRequest)(nil), "eth.evm.v1.QueryTraceTxRequest")
- proto.RegisterType((*QueryTraceTxResponse)(nil), "eth.evm.v1.QueryTraceTxResponse")
- proto.RegisterType((*QueryTraceBlockRequest)(nil), "eth.evm.v1.QueryTraceBlockRequest")
- proto.RegisterType((*QueryTraceBlockResponse)(nil), "eth.evm.v1.QueryTraceBlockResponse")
- proto.RegisterType((*QueryBaseFeeRequest)(nil), "eth.evm.v1.QueryBaseFeeRequest")
- proto.RegisterType((*QueryBaseFeeResponse)(nil), "eth.evm.v1.QueryBaseFeeResponse")
-}
-
-func init() { proto.RegisterFile("eth/evm/v1/query.proto", fileDescriptor_ffa36cdc5add14ed) }
-
-var fileDescriptor_ffa36cdc5add14ed = []byte{
- // 1454 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4f, 0x6f, 0x1b, 0x45,
- 0x14, 0xcf, 0xc6, 0x4e, 0xec, 0x3c, 0xa7, 0x6d, 0x98, 0xa6, 0x4d, 0xb2, 0x4d, 0xec, 0x74, 0x43,
- 0x93, 0xb4, 0xb4, 0xbb, 0x4d, 0x40, 0x20, 0x2a, 0x2a, 0xd4, 0x44, 0x69, 0x28, 0xfd, 0xa3, 0x62,
- 0x22, 0x0e, 0x48, 0xc8, 0x1a, 0xaf, 0x27, 0xeb, 0x55, 0xbc, 0x3b, 0xee, 0xce, 0x38, 0x38, 0x94,
- 0x5e, 0xe8, 0x05, 0x89, 0x03, 0x95, 0xf8, 0x02, 0x3d, 0xf1, 0x15, 0xf8, 0x04, 0x48, 0x3d, 0x56,
- 0xe2, 0x82, 0x38, 0x14, 0xd4, 0x72, 0xe0, 0xcc, 0x91, 0x13, 0x9a, 0x3f, 0x6b, 0xaf, 0xed, 0x75,
- 0x42, 0xf9, 0x73, 0xe3, 0xb4, 0x3b, 0x33, 0x6f, 0xde, 0xef, 0xf7, 0xe6, 0xcd, 0xbc, 0xf7, 0x83,
- 0xd3, 0x84, 0xd7, 0x1d, 0xb2, 0x1f, 0x38, 0xfb, 0x6b, 0xce, 0xbd, 0x16, 0x89, 0x0e, 0xec, 0x66,
- 0x44, 0x39, 0x45, 0x40, 0x78, 0xdd, 0x26, 0xfb, 0x81, 0xbd, 0xbf, 0x66, 0x5e, 0x70, 0x29, 0x0b,
- 0x28, 0x73, 0xaa, 0x98, 0x11, 0x65, 0xe4, 0xec, 0xaf, 0x55, 0x09, 0xc7, 0x6b, 0x4e, 0x13, 0x7b,
- 0x7e, 0x88, 0xb9, 0x4f, 0x43, 0xb5, 0xcf, 0x9c, 0x4e, 0xf8, 0x13, 0xdb, 0xd5, 0xec, 0xc9, 0xc4,
- 0x2c, 0x6f, 0xc7, 0xa6, 0x1e, 0xf5, 0xa8, 0xfc, 0x75, 0xc4, 0x9f, 0x9e, 0x9d, 0xf7, 0x28, 0xf5,
- 0x1a, 0xc4, 0xc1, 0x4d, 0xdf, 0xc1, 0x61, 0x48, 0xb9, 0xf4, 0xce, 0xf4, 0x6a, 0x49, 0xaf, 0xca,
- 0x51, 0xb5, 0xb5, 0xeb, 0x70, 0x3f, 0x20, 0x8c, 0xe3, 0xa0, 0xa9, 0x0c, 0xac, 0x77, 0xe0, 0xf4,
- 0x07, 0x82, 0xe1, 0x16, 0xaf, 0x5f, 0x73, 0x5d, 0xda, 0x0a, 0x79, 0x99, 0xdc, 0x6b, 0x11, 0xc6,
- 0xd1, 0x2c, 0xe4, 0x70, 0xad, 0x16, 0x11, 0xc6, 0x66, 0x8d, 0x45, 0x63, 0x75, 0xa2, 0x1c, 0x0f,
- 0xaf, 0xe4, 0xbf, 0x7c, 0x5c, 0x1a, 0xf9, 0xed, 0x71, 0x69, 0xc4, 0xda, 0x85, 0x99, 0x81, 0xdd,
- 0xac, 0x49, 0x43, 0x46, 0xc4, 0xf6, 0x2a, 0x6e, 0xe0, 0xd0, 0x25, 0xf1, 0x76, 0x3d, 0x44, 0x67,
- 0x60, 0xc2, 0xa5, 0x35, 0x52, 0xa9, 0x63, 0x56, 0x9f, 0x1d, 0x95, 0x6b, 0x79, 0x31, 0xf1, 0x1e,
- 0x66, 0x75, 0x34, 0x0d, 0x63, 0x21, 0x15, 0x9b, 0x32, 0x8b, 0xc6, 0x6a, 0xb6, 0xac, 0x06, 0xd6,
- 0xbb, 0x30, 0x27, 0x71, 0xee, 0xf8, 0x55, 0x3f, 0x6a, 0xfd, 0x0d, 0xa2, 0x07, 0x60, 0xa6, 0x39,
- 0xe8, 0x72, 0x4d, 0xf7, 0x80, 0x4c, 0xc8, 0x33, 0x01, 0x23, 0x18, 0x8d, 0x4a, 0x46, 0x9d, 0x31,
- 0x3a, 0x07, 0xc7, 0xb1, 0x72, 0x54, 0x09, 0x5b, 0x41, 0x95, 0x44, 0x9a, 0xf3, 0x31, 0x3d, 0x7b,
- 0x47, 0x4e, 0x5a, 0x37, 0x61, 0x5e, 0x42, 0x7f, 0x84, 0x1b, 0x7e, 0x0d, 0x73, 0x1a, 0xf5, 0xd1,
- 0x3f, 0x0b, 0x93, 0x2e, 0x0d, 0x59, 0xa5, 0x97, 0x41, 0x41, 0xcc, 0x5d, 0x1b, 0x88, 0xe3, 0x2b,
- 0x03, 0x16, 0x86, 0x78, 0xd3, 0xb1, 0xac, 0xc0, 0x89, 0x98, 0x55, 0xaf, 0xc7, 0x98, 0xec, 0xb5,
- 0x7f, 0x2f, 0xb4, 0xb7, 0xe1, 0xa4, 0x24, 0xb3, 0xa1, 0x32, 0xfb, 0x32, 0x09, 0xb9, 0x0c, 0xd3,
- 0xbd, 0x5b, 0x8f, 0xba, 0x36, 0xd6, 0x4d, 0x0d, 0xf6, 0x21, 0xa7, 0x11, 0xf6, 0x8e, 0x06, 0x43,
- 0x53, 0x90, 0xd9, 0x23, 0x07, 0xfa, 0x86, 0x89, 0xdf, 0x04, 0xfc, 0x45, 0x0d, 0xdf, 0x71, 0xa6,
- 0xe1, 0xa7, 0x61, 0x6c, 0x1f, 0x37, 0x5a, 0x31, 0xb8, 0x1a, 0x58, 0x6f, 0xc2, 0x94, 0xb4, 0xde,
- 0xa4, 0xb5, 0x97, 0x0a, 0x72, 0x05, 0x5e, 0x49, 0xec, 0xd3, 0x10, 0x08, 0xb2, 0xe2, 0xb6, 0xcb,
- 0x5d, 0x93, 0x65, 0xf9, 0x6f, 0x7d, 0x06, 0x48, 0x1a, 0xee, 0xb4, 0x6f, 0x51, 0x8f, 0xc5, 0x10,
- 0x08, 0xb2, 0xf2, 0x8d, 0x28, 0xff, 0xf2, 0x1f, 0x5d, 0x07, 0xe8, 0xd6, 0x10, 0x19, 0x5b, 0x61,
- 0x7d, 0xd9, 0x56, 0x05, 0xc7, 0x16, 0x05, 0xc7, 0x56, 0x55, 0x49, 0x17, 0x1c, 0xfb, 0x6e, 0xf7,
- 0xa8, 0xca, 0x89, 0x9d, 0x09, 0x92, 0x0f, 0x0d, 0x7d, 0xb0, 0x31, 0xb8, 0xe6, 0xb9, 0x04, 0xd9,
- 0x06, 0xf5, 0x44, 0x74, 0x99, 0xd5, 0xc2, 0xfa, 0x09, 0xbb, 0x5b, 0xe0, 0xec, 0x5b, 0xd4, 0x2b,
- 0xcb, 0x45, 0xb4, 0x9d, 0x42, 0x67, 0xe5, 0x48, 0x3a, 0x0a, 0x21, 0xc9, 0xc7, 0x9a, 0xd6, 0x27,
- 0x70, 0x17, 0x47, 0x38, 0x88, 0x4f, 0xc0, 0xda, 0xd6, 0xd4, 0xe2, 0x59, 0x4d, 0xed, 0x32, 0x8c,
- 0x37, 0xe5, 0x8c, 0x3c, 0x9a, 0xc2, 0x3a, 0x4a, 0x92, 0x53, 0xb6, 0x1b, 0xd9, 0x27, 0xcf, 0x4a,
- 0x23, 0x65, 0x6d, 0x67, 0x7d, 0x67, 0xc0, 0xf1, 0x2d, 0x5e, 0xdf, 0xc4, 0x8d, 0x46, 0xe2, 0x74,
- 0x71, 0xe4, 0xb1, 0x38, 0x0f, 0xe2, 0x1f, 0xcd, 0x40, 0xce, 0xc3, 0xac, 0xe2, 0xe2, 0xa6, 0x7e,
- 0x12, 0xe3, 0x1e, 0x66, 0x9b, 0xb8, 0x89, 0x3e, 0x81, 0xa9, 0x66, 0x44, 0x9b, 0x94, 0x91, 0xa8,
- 0xf3, 0xac, 0xc4, 0x93, 0x98, 0xdc, 0x58, 0xff, 0xe3, 0x59, 0xc9, 0xf6, 0x7c, 0x5e, 0x6f, 0x55,
- 0x6d, 0x97, 0x06, 0x8e, 0xae, 0xfd, 0xea, 0x73, 0x89, 0xd5, 0xf6, 0x1c, 0x7e, 0xd0, 0x24, 0xcc,
- 0xde, 0xec, 0xbe, 0xe7, 0xf2, 0x89, 0xd8, 0x57, 0xfc, 0x16, 0xe7, 0x20, 0xef, 0xd6, 0xb1, 0x1f,
- 0x56, 0xfc, 0xda, 0x6c, 0x76, 0xd1, 0x58, 0xcd, 0x94, 0x73, 0x72, 0x7c, 0xa3, 0x66, 0xad, 0xc0,
- 0xc9, 0x2d, 0xc6, 0xfd, 0x00, 0x73, 0xb2, 0x8d, 0xbb, 0x47, 0x30, 0x05, 0x19, 0x0f, 0x2b, 0xf2,
- 0xd9, 0xb2, 0xf8, 0xb5, 0x7e, 0xcf, 0xc4, 0x79, 0x8c, 0xb0, 0x4b, 0x76, 0xda, 0x71, 0x9c, 0xaf,
- 0x41, 0x26, 0x60, 0x9e, 0x3e, 0xa9, 0xb9, 0xe4, 0x49, 0xdd, 0x66, 0xde, 0x16, 0xaf, 0x93, 0x88,
- 0xb4, 0x82, 0x9d, 0x76, 0x59, 0x58, 0xa1, 0x2b, 0x30, 0xc9, 0xc5, 0xf6, 0x8a, 0x4b, 0xc3, 0x5d,
- 0xdf, 0x93, 0x31, 0x16, 0xd6, 0x67, 0x92, 0xbb, 0xa4, 0xfb, 0x4d, 0xb9, 0x5c, 0x2e, 0xf0, 0xee,
- 0x00, 0x5d, 0x85, 0xc9, 0x66, 0x44, 0x6a, 0xc4, 0x25, 0x8c, 0xd1, 0x88, 0xcd, 0x66, 0xe5, 0xc5,
- 0x39, 0x04, 0xb1, 0xc7, 0x5c, 0xd4, 0xc1, 0x6a, 0x83, 0xba, 0x7b, 0x71, 0xc5, 0x19, 0x93, 0xe7,
- 0x50, 0x90, 0x73, 0xaa, 0xde, 0xa0, 0x05, 0x00, 0x65, 0x22, 0x9f, 0xc5, 0xb8, 0x7c, 0x16, 0x13,
- 0x72, 0x46, 0xf6, 0x8e, 0xcd, 0x78, 0x59, 0x34, 0xb9, 0xd9, 0x9c, 0xa4, 0x6e, 0xda, 0xaa, 0x03,
- 0xda, 0x71, 0x07, 0xb4, 0x77, 0xe2, 0x0e, 0xb8, 0x91, 0x17, 0x57, 0xe4, 0xd1, 0xcf, 0x25, 0x43,
- 0x3b, 0x11, 0x2b, 0xa9, 0x99, 0xce, 0xff, 0x37, 0x99, 0x9e, 0xe8, 0xc9, 0x34, 0xb2, 0xe0, 0x98,
- 0xa2, 0x1f, 0xe0, 0x76, 0x45, 0x24, 0x17, 0x12, 0x27, 0x70, 0x1b, 0xb7, 0xb7, 0x31, 0x7b, 0x3f,
- 0x9b, 0x1f, 0x9d, 0xca, 0x94, 0xf3, 0xbc, 0x5d, 0xf1, 0xc3, 0x1a, 0x69, 0x5b, 0x17, 0x74, 0x1d,
- 0xeb, 0xe4, 0xbc, 0x5b, 0x64, 0x6a, 0x98, 0xe3, 0xf8, 0x72, 0x8b, 0x7f, 0xeb, 0xdb, 0x8c, 0xee,
- 0xf5, 0xd2, 0x78, 0x43, 0x78, 0x4d, 0xdc, 0x11, 0xde, 0x8e, 0x9f, 0xfa, 0x61, 0x77, 0x84, 0xb7,
- 0xd9, 0x3f, 0xba, 0x23, 0xff, 0x27, 0xf9, 0xe8, 0x24, 0x5b, 0x97, 0xb4, 0xaa, 0x4a, 0xe6, 0xe9,
- 0x90, 0xbc, 0x9e, 0xea, 0x74, 0x61, 0x46, 0xae, 0x93, 0xb8, 0xda, 0x5b, 0xb7, 0x3a, 0x1d, 0x56,
- 0x4f, 0x6b, 0x17, 0x6f, 0x40, 0x5e, 0x14, 0xe6, 0xca, 0x2e, 0xd1, 0x5d, 0x6e, 0x63, 0xee, 0xa7,
- 0x67, 0xa5, 0x53, 0x2a, 0x42, 0x56, 0xdb, 0xb3, 0x7d, 0xea, 0x04, 0x98, 0xd7, 0xed, 0x1b, 0x21,
- 0x17, 0xdd, 0x57, 0xee, 0x5e, 0xff, 0xbe, 0x00, 0x63, 0xd2, 0x1d, 0x7a, 0x68, 0x00, 0x74, 0xf5,
- 0x1e, 0xb2, 0x92, 0x79, 0x4f, 0x97, 0x92, 0xe6, 0xd2, 0xa1, 0x36, 0x8a, 0x97, 0x75, 0xf1, 0x8b,
- 0x1f, 0x7e, 0xfd, 0x66, 0x74, 0x19, 0xbd, 0xea, 0x84, 0x52, 0xa4, 0x75, 0x54, 0x31, 0xaf, 0x57,
- 0xb4, 0xec, 0x70, 0xee, 0xeb, 0x64, 0x3d, 0x40, 0x5f, 0x1b, 0x70, 0xac, 0x47, 0xcc, 0xa1, 0x73,
- 0x03, 0x20, 0x69, 0x6a, 0xd1, 0x5c, 0x3e, 0xca, 0x4c, 0xd3, 0x71, 0x24, 0x9d, 0xf3, 0x68, 0xa5,
- 0x8f, 0x8e, 0x1a, 0xa5, 0x30, 0x7a, 0x6c, 0xc0, 0x54, 0xbf, 0x2a, 0x43, 0xab, 0x03, 0x68, 0x43,
- 0x64, 0xa0, 0x79, 0xfe, 0x2f, 0x58, 0x6a, 0x6a, 0x6f, 0x49, 0x6a, 0x6b, 0xc8, 0xe9, 0xa3, 0xb6,
- 0x1f, 0x6f, 0xe8, 0xb2, 0x4b, 0x2a, 0xcb, 0x07, 0xe8, 0x53, 0xc8, 0x69, 0xbd, 0x85, 0x4a, 0x03,
- 0x70, 0xbd, 0x22, 0xce, 0x5c, 0x1c, 0x6e, 0xa0, 0x69, 0x9c, 0x97, 0x34, 0x96, 0xd0, 0xd9, 0x3e,
- 0x1a, 0x5a, 0xb0, 0xb1, 0xc4, 0xd9, 0x7c, 0x0e, 0x39, 0xad, 0xb4, 0x52, 0x80, 0x7b, 0x05, 0x5d,
- 0x0a, 0x70, 0x9f, 0x48, 0xb3, 0x6c, 0x09, 0xbc, 0x8a, 0x96, 0xfb, 0x80, 0x99, 0xb2, 0xeb, 0xe2,
- 0x3a, 0xf7, 0xf7, 0xc8, 0xc1, 0x03, 0xb4, 0x07, 0x59, 0xa1, 0xc0, 0xd0, 0xfc, 0x80, 0xe7, 0x84,
- 0xa0, 0x33, 0x17, 0x86, 0xac, 0x6a, 0xd0, 0x65, 0x09, 0xba, 0x88, 0x8a, 0x7d, 0xa0, 0x42, 0xbf,
- 0x25, 0x43, 0xad, 0xc3, 0xb8, 0x52, 0x20, 0xa8, 0x38, 0xe0, 0xb0, 0x47, 0xdc, 0x98, 0xa5, 0xa1,
- 0xeb, 0x1a, 0x72, 0x41, 0x42, 0xce, 0xa0, 0x53, 0x7d, 0x90, 0x4a, 0xd3, 0x20, 0x1f, 0x72, 0x5a,
- 0xd2, 0x20, 0x33, 0xe9, 0xaa, 0x57, 0xe7, 0x98, 0x67, 0x87, 0x97, 0xf3, 0x18, 0xa8, 0x24, 0x81,
- 0xe6, 0xd0, 0x4c, 0xca, 0xd3, 0x73, 0x85, 0x7f, 0x0a, 0x85, 0x84, 0x08, 0x39, 0x14, 0xae, 0x27,
- 0xaa, 0x14, 0xe5, 0x62, 0x2d, 0x49, 0xb0, 0x05, 0x74, 0xa6, 0x1f, 0x4c, 0xdb, 0x8a, 0xaa, 0x88,
- 0x02, 0xc8, 0xe9, 0x96, 0x96, 0x72, 0x61, 0x7a, 0x05, 0x4e, 0xca, 0x85, 0xe9, 0xeb, 0x86, 0x43,
- 0xe3, 0x53, 0x6d, 0x8c, 0xb7, 0xd1, 0x01, 0x40, 0xb7, 0xd8, 0xa6, 0x94, 0xb4, 0x81, 0x8e, 0x99,
- 0x52, 0xd2, 0x06, 0xab, 0xb5, 0x65, 0x49, 0xdc, 0x79, 0x64, 0xa6, 0xe2, 0xca, 0x92, 0x2f, 0x22,
- 0xd5, 0x15, 0x3a, 0xf5, 0x4d, 0x26, 0x4b, 0x7a, 0xea, 0x9b, 0xec, 0x29, 0xee, 0x43, 0x23, 0x8d,
- 0x2b, 0xfe, 0xc6, 0xd5, 0x27, 0xcf, 0x8b, 0xc6, 0xd3, 0xe7, 0x45, 0xe3, 0x97, 0xe7, 0x45, 0xe3,
- 0xd1, 0x8b, 0xe2, 0xc8, 0xd3, 0x17, 0xc5, 0x91, 0x1f, 0x5f, 0x14, 0x47, 0x3e, 0x5e, 0x4a, 0x74,
- 0x3d, 0x55, 0x12, 0x37, 0x45, 0xcf, 0x8a, 0x1d, 0xb5, 0x85, 0xab, 0xea, 0xb8, 0xec, 0xb0, 0xaf,
- 0xff, 0x19, 0x00, 0x00, 0xff, 0xff, 0x97, 0xcf, 0x5e, 0xd9, 0x07, 0x11, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// QueryClient is the client API for Query service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type QueryClient interface {
- // EthAccount queries an Ethereum account.
- EthAccount(ctx context.Context, in *QueryEthAccountRequest, opts ...grpc.CallOption) (*QueryEthAccountResponse, error)
- // NibiruAccount queries the Bech32 Nibiru address corresponding to Nibiru EVM account.
- NibiruAccount(ctx context.Context, in *QueryNibiruAccountRequest, opts ...grpc.CallOption) (*QueryNibiruAccountResponse, error)
- // ValidatorAccount queries an Ethereum account's from a validator consensus
- // Address.
- ValidatorAccount(ctx context.Context, in *QueryValidatorAccountRequest, opts ...grpc.CallOption) (*QueryValidatorAccountResponse, error)
- // Balance queries the balance of a the EVM denomination for a single
- // EthAccount.
- Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error)
- // Storage queries the balance of all coins for a single account.
- Storage(ctx context.Context, in *QueryStorageRequest, opts ...grpc.CallOption) (*QueryStorageResponse, error)
- // Code queries the balance of all coins for a single account.
- Code(ctx context.Context, in *QueryCodeRequest, opts ...grpc.CallOption) (*QueryCodeResponse, error)
- // Params queries the parameters of x/evm module.
- Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
- // EthCall implements the `eth_call` rpc api
- EthCall(ctx context.Context, in *EthCallRequest, opts ...grpc.CallOption) (*MsgEthereumTxResponse, error)
- // EstimateGas implements the `eth_estimateGas` rpc api
- EstimateGas(ctx context.Context, in *EthCallRequest, opts ...grpc.CallOption) (*EstimateGasResponse, error)
- // TraceTx implements the `debug_traceTransaction` rpc api
- TraceTx(ctx context.Context, in *QueryTraceTxRequest, opts ...grpc.CallOption) (*QueryTraceTxResponse, error)
- // TraceBlock implements the `debug_traceBlockByNumber` and `debug_traceBlockByHash` rpc api
- TraceBlock(ctx context.Context, in *QueryTraceBlockRequest, opts ...grpc.CallOption) (*QueryTraceBlockResponse, error)
- // BaseFee queries the base fee of the parent block of the current block,
- // it's similar to feemarket module's method, but also checks london hardfork status.
- BaseFee(ctx context.Context, in *QueryBaseFeeRequest, opts ...grpc.CallOption) (*QueryBaseFeeResponse, error)
-}
-
-type queryClient struct {
- cc grpc1.ClientConn
-}
-
-func NewQueryClient(cc grpc1.ClientConn) QueryClient {
- return &queryClient{cc}
-}
-
-func (c *queryClient) EthAccount(ctx context.Context, in *QueryEthAccountRequest, opts ...grpc.CallOption) (*QueryEthAccountResponse, error) {
- out := new(QueryEthAccountResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/EthAccount", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) NibiruAccount(ctx context.Context, in *QueryNibiruAccountRequest, opts ...grpc.CallOption) (*QueryNibiruAccountResponse, error) {
- out := new(QueryNibiruAccountResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/NibiruAccount", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) ValidatorAccount(ctx context.Context, in *QueryValidatorAccountRequest, opts ...grpc.CallOption) (*QueryValidatorAccountResponse, error) {
- out := new(QueryValidatorAccountResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/ValidatorAccount", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) {
- out := new(QueryBalanceResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/Balance", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) Storage(ctx context.Context, in *QueryStorageRequest, opts ...grpc.CallOption) (*QueryStorageResponse, error) {
- out := new(QueryStorageResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/Storage", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) Code(ctx context.Context, in *QueryCodeRequest, opts ...grpc.CallOption) (*QueryCodeResponse, error) {
- out := new(QueryCodeResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/Code", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) {
- out := new(QueryParamsResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/Params", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) EthCall(ctx context.Context, in *EthCallRequest, opts ...grpc.CallOption) (*MsgEthereumTxResponse, error) {
- out := new(MsgEthereumTxResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/EthCall", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) EstimateGas(ctx context.Context, in *EthCallRequest, opts ...grpc.CallOption) (*EstimateGasResponse, error) {
- out := new(EstimateGasResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/EstimateGas", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) TraceTx(ctx context.Context, in *QueryTraceTxRequest, opts ...grpc.CallOption) (*QueryTraceTxResponse, error) {
- out := new(QueryTraceTxResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/TraceTx", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) TraceBlock(ctx context.Context, in *QueryTraceBlockRequest, opts ...grpc.CallOption) (*QueryTraceBlockResponse, error) {
- out := new(QueryTraceBlockResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/TraceBlock", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) BaseFee(ctx context.Context, in *QueryBaseFeeRequest, opts ...grpc.CallOption) (*QueryBaseFeeResponse, error) {
- out := new(QueryBaseFeeResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Query/BaseFee", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// QueryServer is the server API for Query service.
-type QueryServer interface {
- // EthAccount queries an Ethereum account.
- EthAccount(context.Context, *QueryEthAccountRequest) (*QueryEthAccountResponse, error)
- // NibiruAccount queries the Bech32 Nibiru address corresponding to Nibiru EVM account.
- NibiruAccount(context.Context, *QueryNibiruAccountRequest) (*QueryNibiruAccountResponse, error)
- // ValidatorAccount queries an Ethereum account's from a validator consensus
- // Address.
- ValidatorAccount(context.Context, *QueryValidatorAccountRequest) (*QueryValidatorAccountResponse, error)
- // Balance queries the balance of a the EVM denomination for a single
- // EthAccount.
- Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error)
- // Storage queries the balance of all coins for a single account.
- Storage(context.Context, *QueryStorageRequest) (*QueryStorageResponse, error)
- // Code queries the balance of all coins for a single account.
- Code(context.Context, *QueryCodeRequest) (*QueryCodeResponse, error)
- // Params queries the parameters of x/evm module.
- Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
- // EthCall implements the `eth_call` rpc api
- EthCall(context.Context, *EthCallRequest) (*MsgEthereumTxResponse, error)
- // EstimateGas implements the `eth_estimateGas` rpc api
- EstimateGas(context.Context, *EthCallRequest) (*EstimateGasResponse, error)
- // TraceTx implements the `debug_traceTransaction` rpc api
- TraceTx(context.Context, *QueryTraceTxRequest) (*QueryTraceTxResponse, error)
- // TraceBlock implements the `debug_traceBlockByNumber` and `debug_traceBlockByHash` rpc api
- TraceBlock(context.Context, *QueryTraceBlockRequest) (*QueryTraceBlockResponse, error)
- // BaseFee queries the base fee of the parent block of the current block,
- // it's similar to feemarket module's method, but also checks london hardfork status.
- BaseFee(context.Context, *QueryBaseFeeRequest) (*QueryBaseFeeResponse, error)
-}
-
-// UnimplementedQueryServer can be embedded to have forward compatible implementations.
-type UnimplementedQueryServer struct {
-}
-
-func (*UnimplementedQueryServer) EthAccount(ctx context.Context, req *QueryEthAccountRequest) (*QueryEthAccountResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EthAccount not implemented")
-}
-func (*UnimplementedQueryServer) NibiruAccount(ctx context.Context, req *QueryNibiruAccountRequest) (*QueryNibiruAccountResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method NibiruAccount not implemented")
-}
-func (*UnimplementedQueryServer) ValidatorAccount(ctx context.Context, req *QueryValidatorAccountRequest) (*QueryValidatorAccountResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ValidatorAccount not implemented")
-}
-func (*UnimplementedQueryServer) Balance(ctx context.Context, req *QueryBalanceRequest) (*QueryBalanceResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Balance not implemented")
-}
-func (*UnimplementedQueryServer) Storage(ctx context.Context, req *QueryStorageRequest) (*QueryStorageResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Storage not implemented")
-}
-func (*UnimplementedQueryServer) Code(ctx context.Context, req *QueryCodeRequest) (*QueryCodeResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Code not implemented")
-}
-func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
-}
-func (*UnimplementedQueryServer) EthCall(ctx context.Context, req *EthCallRequest) (*MsgEthereumTxResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EthCall not implemented")
-}
-func (*UnimplementedQueryServer) EstimateGas(ctx context.Context, req *EthCallRequest) (*EstimateGasResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EstimateGas not implemented")
-}
-func (*UnimplementedQueryServer) TraceTx(ctx context.Context, req *QueryTraceTxRequest) (*QueryTraceTxResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method TraceTx not implemented")
-}
-func (*UnimplementedQueryServer) TraceBlock(ctx context.Context, req *QueryTraceBlockRequest) (*QueryTraceBlockResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method TraceBlock not implemented")
-}
-func (*UnimplementedQueryServer) BaseFee(ctx context.Context, req *QueryBaseFeeRequest) (*QueryBaseFeeResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method BaseFee not implemented")
-}
-
-func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
- s.RegisterService(&_Query_serviceDesc, srv)
-}
-
-func _Query_EthAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryEthAccountRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).EthAccount(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/EthAccount",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).EthAccount(ctx, req.(*QueryEthAccountRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_NibiruAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryNibiruAccountRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).NibiruAccount(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/NibiruAccount",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).NibiruAccount(ctx, req.(*QueryNibiruAccountRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_ValidatorAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryValidatorAccountRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).ValidatorAccount(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/ValidatorAccount",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).ValidatorAccount(ctx, req.(*QueryValidatorAccountRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_Balance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryBalanceRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Balance(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/Balance",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Balance(ctx, req.(*QueryBalanceRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_Storage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryStorageRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Storage(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/Storage",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Storage(ctx, req.(*QueryStorageRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_Code_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryCodeRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Code(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/Code",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Code(ctx, req.(*QueryCodeRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryParamsRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Params(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/Params",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_EthCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(EthCallRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).EthCall(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/EthCall",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).EthCall(ctx, req.(*EthCallRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_EstimateGas_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(EthCallRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).EstimateGas(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/EstimateGas",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).EstimateGas(ctx, req.(*EthCallRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_TraceTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryTraceTxRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).TraceTx(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/TraceTx",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).TraceTx(ctx, req.(*QueryTraceTxRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_TraceBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryTraceBlockRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).TraceBlock(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/TraceBlock",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).TraceBlock(ctx, req.(*QueryTraceBlockRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_BaseFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryBaseFeeRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).BaseFee(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Query/BaseFee",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).BaseFee(ctx, req.(*QueryBaseFeeRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Query_serviceDesc = grpc.ServiceDesc{
- ServiceName: "eth.evm.v1.Query",
- HandlerType: (*QueryServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "EthAccount",
- Handler: _Query_EthAccount_Handler,
- },
- {
- MethodName: "NibiruAccount",
- Handler: _Query_NibiruAccount_Handler,
- },
- {
- MethodName: "ValidatorAccount",
- Handler: _Query_ValidatorAccount_Handler,
- },
- {
- MethodName: "Balance",
- Handler: _Query_Balance_Handler,
- },
- {
- MethodName: "Storage",
- Handler: _Query_Storage_Handler,
- },
- {
- MethodName: "Code",
- Handler: _Query_Code_Handler,
- },
- {
- MethodName: "Params",
- Handler: _Query_Params_Handler,
- },
- {
- MethodName: "EthCall",
- Handler: _Query_EthCall_Handler,
- },
- {
- MethodName: "EstimateGas",
- Handler: _Query_EstimateGas_Handler,
- },
- {
- MethodName: "TraceTx",
- Handler: _Query_TraceTx_Handler,
- },
- {
- MethodName: "TraceBlock",
- Handler: _Query_TraceBlock_Handler,
- },
- {
- MethodName: "BaseFee",
- Handler: _Query_BaseFee_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "eth/evm/v1/query.proto",
-}
-
-func (m *QueryEthAccountRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryEthAccountRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryEthAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Address) > 0 {
- i -= len(m.Address)
- copy(dAtA[i:], m.Address)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Address)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryEthAccountResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryEthAccountResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryEthAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.Nonce != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.Nonce))
- i--
- dAtA[i] = 0x18
- }
- if len(m.CodeHash) > 0 {
- i -= len(m.CodeHash)
- copy(dAtA[i:], m.CodeHash)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.CodeHash)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Balance) > 0 {
- i -= len(m.Balance)
- copy(dAtA[i:], m.Balance)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Balance)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryNibiruAccountRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryNibiruAccountRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryNibiruAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Address) > 0 {
- i -= len(m.Address)
- copy(dAtA[i:], m.Address)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Address)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryNibiruAccountResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryNibiruAccountResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryNibiruAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.AccountNumber != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.AccountNumber))
- i--
- dAtA[i] = 0x18
- }
- if m.Sequence != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.Sequence))
- i--
- dAtA[i] = 0x10
- }
- if len(m.Address) > 0 {
- i -= len(m.Address)
- copy(dAtA[i:], m.Address)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Address)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryValidatorAccountRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryValidatorAccountRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryValidatorAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.ConsAddress) > 0 {
- i -= len(m.ConsAddress)
- copy(dAtA[i:], m.ConsAddress)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryValidatorAccountResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryValidatorAccountResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryValidatorAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.AccountNumber != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.AccountNumber))
- i--
- dAtA[i] = 0x18
- }
- if m.Sequence != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.Sequence))
- i--
- dAtA[i] = 0x10
- }
- if len(m.AccountAddress) > 0 {
- i -= len(m.AccountAddress)
- copy(dAtA[i:], m.AccountAddress)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.AccountAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryBalanceRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryBalanceRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryBalanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Address) > 0 {
- i -= len(m.Address)
- copy(dAtA[i:], m.Address)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Address)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryBalanceResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryBalanceResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryBalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Balance) > 0 {
- i -= len(m.Balance)
- copy(dAtA[i:], m.Balance)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Balance)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryStorageRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryStorageRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryStorageRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Key) > 0 {
- i -= len(m.Key)
- copy(dAtA[i:], m.Key)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Key)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Address) > 0 {
- i -= len(m.Address)
- copy(dAtA[i:], m.Address)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Address)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryStorageResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryStorageResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryStorageResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Value) > 0 {
- i -= len(m.Value)
- copy(dAtA[i:], m.Value)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Value)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryCodeRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryCodeRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryCodeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Address) > 0 {
- i -= len(m.Address)
- copy(dAtA[i:], m.Address)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Address)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryCodeResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryCodeResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Code) > 0 {
- i -= len(m.Code)
- copy(dAtA[i:], m.Code)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Code)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryTxLogsRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryTxLogsRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryTxLogsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.Pagination != nil {
- {
- size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- if len(m.Hash) > 0 {
- i -= len(m.Hash)
- copy(dAtA[i:], m.Hash)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Hash)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryTxLogsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryTxLogsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryTxLogsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.Pagination != nil {
- {
- size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- if len(m.Logs) > 0 {
- for iNdEx := len(m.Logs) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Logs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *EthCallRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EthCallRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EthCallRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.ChainId != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.ChainId))
- i--
- dAtA[i] = 0x20
- }
- if len(m.ProposerAddress) > 0 {
- i -= len(m.ProposerAddress)
- copy(dAtA[i:], m.ProposerAddress)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.ProposerAddress)))
- i--
- dAtA[i] = 0x1a
- }
- if m.GasCap != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.GasCap))
- i--
- dAtA[i] = 0x10
- }
- if len(m.Args) > 0 {
- i -= len(m.Args)
- copy(dAtA[i:], m.Args)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Args)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EstimateGasResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EstimateGasResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EstimateGasResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.Gas != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.Gas))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryTraceTxRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryTraceTxRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryTraceTxRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.BlockMaxGas != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.BlockMaxGas))
- i--
- dAtA[i] = 0x50
- }
- if m.ChainId != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.ChainId))
- i--
- dAtA[i] = 0x48
- }
- if len(m.ProposerAddress) > 0 {
- i -= len(m.ProposerAddress)
- copy(dAtA[i:], m.ProposerAddress)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.ProposerAddress)))
- i--
- dAtA[i] = 0x42
- }
- n4, err4 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.BlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.BlockTime):])
- if err4 != nil {
- return 0, err4
- }
- i -= n4
- i = encodeVarintQuery(dAtA, i, uint64(n4))
- i--
- dAtA[i] = 0x3a
- if len(m.BlockHash) > 0 {
- i -= len(m.BlockHash)
- copy(dAtA[i:], m.BlockHash)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.BlockHash)))
- i--
- dAtA[i] = 0x32
- }
- if m.BlockNumber != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.BlockNumber))
- i--
- dAtA[i] = 0x28
- }
- if len(m.Predecessors) > 0 {
- for iNdEx := len(m.Predecessors) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Predecessors[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x22
- }
- }
- if m.TraceConfig != nil {
- {
- size, err := m.TraceConfig.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- if m.Msg != nil {
- {
- size, err := m.Msg.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryTraceTxResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryTraceTxResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryTraceTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Data) > 0 {
- i -= len(m.Data)
- copy(dAtA[i:], m.Data)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Data)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryTraceBlockRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryTraceBlockRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryTraceBlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.BlockMaxGas != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.BlockMaxGas))
- i--
- dAtA[i] = 0x50
- }
- if m.ChainId != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.ChainId))
- i--
- dAtA[i] = 0x48
- }
- if len(m.ProposerAddress) > 0 {
- i -= len(m.ProposerAddress)
- copy(dAtA[i:], m.ProposerAddress)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.ProposerAddress)))
- i--
- dAtA[i] = 0x42
- }
- n7, err7 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.BlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.BlockTime):])
- if err7 != nil {
- return 0, err7
- }
- i -= n7
- i = encodeVarintQuery(dAtA, i, uint64(n7))
- i--
- dAtA[i] = 0x3a
- if len(m.BlockHash) > 0 {
- i -= len(m.BlockHash)
- copy(dAtA[i:], m.BlockHash)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.BlockHash)))
- i--
- dAtA[i] = 0x32
- }
- if m.BlockNumber != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.BlockNumber))
- i--
- dAtA[i] = 0x28
- }
- if m.TraceConfig != nil {
- {
- size, err := m.TraceConfig.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- if len(m.Txs) > 0 {
- for iNdEx := len(m.Txs) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Txs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryTraceBlockResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryTraceBlockResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryTraceBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Data) > 0 {
- i -= len(m.Data)
- copy(dAtA[i:], m.Data)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Data)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryBaseFeeRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryBaseFeeRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryBaseFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryBaseFeeResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryBaseFeeResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryBaseFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.BaseFee != nil {
- {
- size := m.BaseFee.Size()
- i -= size
- if _, err := m.BaseFee.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
- offset -= sovQuery(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *QueryEthAccountRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Address)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryEthAccountResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Balance)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- l = len(m.CodeHash)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- if m.Nonce != 0 {
- n += 1 + sovQuery(uint64(m.Nonce))
- }
- return n
-}
-
-func (m *QueryNibiruAccountRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Address)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryNibiruAccountResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Address)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- if m.Sequence != 0 {
- n += 1 + sovQuery(uint64(m.Sequence))
- }
- if m.AccountNumber != 0 {
- n += 1 + sovQuery(uint64(m.AccountNumber))
- }
- return n
-}
-
-func (m *QueryValidatorAccountRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ConsAddress)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryValidatorAccountResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.AccountAddress)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- if m.Sequence != 0 {
- n += 1 + sovQuery(uint64(m.Sequence))
- }
- if m.AccountNumber != 0 {
- n += 1 + sovQuery(uint64(m.AccountNumber))
- }
- return n
-}
-
-func (m *QueryBalanceRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Address)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryBalanceResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Balance)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryStorageRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Address)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryStorageResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Value)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryCodeRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Address)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryCodeResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Code)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryTxLogsRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Hash)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- if m.Pagination != nil {
- l = m.Pagination.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryTxLogsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Logs) > 0 {
- for _, e := range m.Logs {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- if m.Pagination != nil {
- l = m.Pagination.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryParamsRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryParamsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Params.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *EthCallRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Args)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- if m.GasCap != 0 {
- n += 1 + sovQuery(uint64(m.GasCap))
- }
- l = len(m.ProposerAddress)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- if m.ChainId != 0 {
- n += 1 + sovQuery(uint64(m.ChainId))
- }
- return n
-}
-
-func (m *EstimateGasResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.Gas != 0 {
- n += 1 + sovQuery(uint64(m.Gas))
- }
- return n
-}
-
-func (m *QueryTraceTxRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.Msg != nil {
- l = m.Msg.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- if m.TraceConfig != nil {
- l = m.TraceConfig.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- if len(m.Predecessors) > 0 {
- for _, e := range m.Predecessors {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- if m.BlockNumber != 0 {
- n += 1 + sovQuery(uint64(m.BlockNumber))
- }
- l = len(m.BlockHash)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.BlockTime)
- n += 1 + l + sovQuery(uint64(l))
- l = len(m.ProposerAddress)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- if m.ChainId != 0 {
- n += 1 + sovQuery(uint64(m.ChainId))
- }
- if m.BlockMaxGas != 0 {
- n += 1 + sovQuery(uint64(m.BlockMaxGas))
- }
- return n
-}
-
-func (m *QueryTraceTxResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Data)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryTraceBlockRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Txs) > 0 {
- for _, e := range m.Txs {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- if m.TraceConfig != nil {
- l = m.TraceConfig.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- if m.BlockNumber != 0 {
- n += 1 + sovQuery(uint64(m.BlockNumber))
- }
- l = len(m.BlockHash)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.BlockTime)
- n += 1 + l + sovQuery(uint64(l))
- l = len(m.ProposerAddress)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- if m.ChainId != 0 {
- n += 1 + sovQuery(uint64(m.ChainId))
- }
- if m.BlockMaxGas != 0 {
- n += 1 + sovQuery(uint64(m.BlockMaxGas))
- }
- return n
-}
-
-func (m *QueryTraceBlockResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Data)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryBaseFeeRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryBaseFeeResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.BaseFee != nil {
- l = m.BaseFee.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func sovQuery(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozQuery(x uint64) (n int) {
- return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *QueryEthAccountRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryEthAccountRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryEthAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Address = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryEthAccountResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryEthAccountResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryEthAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Balance = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CodeHash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.CodeHash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType)
- }
- m.Nonce = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Nonce |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryNibiruAccountRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryNibiruAccountRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryNibiruAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Address = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryNibiruAccountResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryNibiruAccountResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryNibiruAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Address = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType)
- }
- m.Sequence = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Sequence |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field AccountNumber", wireType)
- }
- m.AccountNumber = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.AccountNumber |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryValidatorAccountRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryValidatorAccountRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryValidatorAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ConsAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ConsAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryValidatorAccountResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryValidatorAccountResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryValidatorAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AccountAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.AccountAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType)
- }
- m.Sequence = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Sequence |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field AccountNumber", wireType)
- }
- m.AccountNumber = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.AccountNumber |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryBalanceRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryBalanceRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryBalanceRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Address = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryBalanceResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryBalanceResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryBalanceResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Balance = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryStorageRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryStorageRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryStorageRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Address = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryStorageResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryStorageResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryStorageResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Value = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryCodeRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryCodeRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryCodeRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Address = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryCodeResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryCodeResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryCodeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Code = append(m.Code[:0], dAtA[iNdEx:postIndex]...)
- if m.Code == nil {
- m.Code = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryTxLogsRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryTxLogsRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryTxLogsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Hash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Pagination == nil {
- m.Pagination = &query.PageRequest{}
- }
- if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryTxLogsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryTxLogsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryTxLogsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Logs", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Logs = append(m.Logs, &Log{})
- if err := m.Logs[len(m.Logs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Pagination == nil {
- m.Pagination = &query.PageResponse{}
- }
- if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EthCallRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EthCallRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EthCallRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Args", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Args = append(m.Args[:0], dAtA[iNdEx:postIndex]...)
- if m.Args == nil {
- m.Args = []byte{}
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasCap", wireType)
- }
- m.GasCap = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.GasCap |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ProposerAddress", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ProposerAddress = append(m.ProposerAddress[:0], dAtA[iNdEx:postIndex]...)
- if m.ProposerAddress == nil {
- m.ProposerAddress = []byte{}
- }
- iNdEx = postIndex
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType)
- }
- m.ChainId = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ChainId |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EstimateGasResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EstimateGasResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EstimateGasResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Gas", wireType)
- }
- m.Gas = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Gas |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryTraceTxRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryTraceTxRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryTraceTxRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Msg == nil {
- m.Msg = &MsgEthereumTx{}
- }
- if err := m.Msg.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field TraceConfig", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.TraceConfig == nil {
- m.TraceConfig = &TraceConfig{}
- }
- if err := m.TraceConfig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Predecessors", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Predecessors = append(m.Predecessors, &MsgEthereumTx{})
- if err := m.Predecessors[len(m.Predecessors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field BlockNumber", wireType)
- }
- m.BlockNumber = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.BlockNumber |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field BlockHash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.BlockHash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field BlockTime", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.BlockTime, dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ProposerAddress", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ProposerAddress = append(m.ProposerAddress[:0], dAtA[iNdEx:postIndex]...)
- if m.ProposerAddress == nil {
- m.ProposerAddress = []byte{}
- }
- iNdEx = postIndex
- case 9:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType)
- }
- m.ChainId = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ChainId |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 10:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field BlockMaxGas", wireType)
- }
- m.BlockMaxGas = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.BlockMaxGas |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryTraceTxResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryTraceTxResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryTraceTxResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
- if m.Data == nil {
- m.Data = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryTraceBlockRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryTraceBlockRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryTraceBlockRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Txs", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Txs = append(m.Txs, &MsgEthereumTx{})
- if err := m.Txs[len(m.Txs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field TraceConfig", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.TraceConfig == nil {
- m.TraceConfig = &TraceConfig{}
- }
- if err := m.TraceConfig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field BlockNumber", wireType)
- }
- m.BlockNumber = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.BlockNumber |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field BlockHash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.BlockHash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field BlockTime", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.BlockTime, dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ProposerAddress", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ProposerAddress = append(m.ProposerAddress[:0], dAtA[iNdEx:postIndex]...)
- if m.ProposerAddress == nil {
- m.ProposerAddress = []byte{}
- }
- iNdEx = postIndex
- case 9:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType)
- }
- m.ChainId = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ChainId |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 10:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field BlockMaxGas", wireType)
- }
- m.BlockMaxGas = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.BlockMaxGas |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryTraceBlockResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryTraceBlockResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryTraceBlockResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
- if m.Data == nil {
- m.Data = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryBaseFeeRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryBaseFeeRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryBaseFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryBaseFeeResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryBaseFeeResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryBaseFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field BaseFee", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.BaseFee = &v
- if err := m.BaseFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipQuery(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthQuery
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupQuery
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthQuery
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/evm/query.pb.gw.go b/x/evm/query.pb.gw.go
deleted file mode 100644
index fd0ecc413..000000000
--- a/x/evm/query.pb.gw.go
+++ /dev/null
@@ -1,1178 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: eth/evm/v1/query.proto
-
-/*
-Package evm is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package evm
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-func request_Query_EthAccount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryEthAccountRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
- }
-
- protoReq.Address, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
- }
-
- msg, err := client.EthAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_EthAccount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryEthAccountRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
- }
-
- protoReq.Address, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
- }
-
- msg, err := server.EthAccount(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_NibiruAccount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryNibiruAccountRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
- }
-
- protoReq.Address, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
- }
-
- msg, err := client.NibiruAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_NibiruAccount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryNibiruAccountRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
- }
-
- protoReq.Address, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
- }
-
- msg, err := server.NibiruAccount(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_ValidatorAccount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryValidatorAccountRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["cons_address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "cons_address")
- }
-
- protoReq.ConsAddress, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "cons_address", err)
- }
-
- msg, err := client.ValidatorAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_ValidatorAccount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryValidatorAccountRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["cons_address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "cons_address")
- }
-
- protoReq.ConsAddress, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "cons_address", err)
- }
-
- msg, err := server.ValidatorAccount(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_Balance_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryBalanceRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
- }
-
- protoReq.Address, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
- }
-
- msg, err := client.Balance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Balance_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryBalanceRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
- }
-
- protoReq.Address, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
- }
-
- msg, err := server.Balance(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_Storage_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryStorageRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
- }
-
- protoReq.Address, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
- }
-
- val, ok = pathParams["key"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key")
- }
-
- protoReq.Key, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err)
- }
-
- msg, err := client.Storage(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Storage_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryStorageRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
- }
-
- protoReq.Address, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
- }
-
- val, ok = pathParams["key"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key")
- }
-
- protoReq.Key, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err)
- }
-
- msg, err := server.Storage(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_Code_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryCodeRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
- }
-
- protoReq.Address, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
- }
-
- msg, err := client.Code(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Code_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryCodeRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["address"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
- }
-
- protoReq.Address, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
- }
-
- msg, err := server.Code(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryParamsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryParamsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.Params(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Query_EthCall_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Query_EthCall_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq EthCallRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EthCall_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.EthCall(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_EthCall_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq EthCallRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EthCall_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.EthCall(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Query_EstimateGas_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Query_EstimateGas_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq EthCallRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EstimateGas_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.EstimateGas(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_EstimateGas_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq EthCallRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EstimateGas_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.EstimateGas(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Query_TraceTx_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Query_TraceTx_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryTraceTxRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TraceTx_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.TraceTx(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_TraceTx_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryTraceTxRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TraceTx_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.TraceTx(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Query_TraceBlock_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Query_TraceBlock_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryTraceBlockRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TraceBlock_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.TraceBlock(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_TraceBlock_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryTraceBlockRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TraceBlock_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.TraceBlock(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_BaseFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryBaseFeeRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.BaseFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_BaseFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryBaseFeeRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.BaseFee(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
-// UnaryRPC :call QueryServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
-func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
-
- mux.Handle("GET", pattern_Query_EthAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_EthAccount_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EthAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_NibiruAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_NibiruAccount_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_NibiruAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_ValidatorAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_ValidatorAccount_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_ValidatorAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Balance_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Balance_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Storage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Storage_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Storage_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Code_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Code_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Code_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_EthCall_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_EthCall_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EthCall_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_EstimateGas_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_EstimateGas_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EstimateGas_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_TraceTx_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_TraceTx_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_TraceTx_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_TraceBlock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_TraceBlock_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_TraceBlock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_BaseFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_BaseFee_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_BaseFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterQueryHandler(ctx, mux, conn)
-}
-
-// RegisterQueryHandler registers the http handlers for service Query to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
-}
-
-// RegisterQueryHandlerClient registers the http handlers for service Query
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "QueryClient" to call the correct interceptors.
-func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
-
- mux.Handle("GET", pattern_Query_EthAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_EthAccount_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EthAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_NibiruAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_NibiruAccount_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_NibiruAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_ValidatorAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_ValidatorAccount_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_ValidatorAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Balance_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Balance_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Storage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Storage_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Storage_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Code_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Code_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Code_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_EthCall_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_EthCall_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EthCall_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_EstimateGas_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_EstimateGas_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EstimateGas_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_TraceTx_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_TraceTx_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_TraceTx_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_TraceBlock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_TraceBlock_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_TraceBlock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_BaseFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_BaseFee_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_BaseFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Query_EthAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "evm", "v1", "eth_account", "address"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_NibiruAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "evm", "v1", "nibiru_account", "address"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_ValidatorAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "evm", "v1", "validator_account", "cons_address"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_Balance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "evm", "v1", "balances", "address"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_Storage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"nibiru", "evm", "v1", "storage", "address", "key"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_Code_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "evm", "v1", "codes", "address"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "evm", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_EthCall_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "evm", "v1", "eth_call"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_EstimateGas_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "evm", "v1", "estimate_gas"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_TraceTx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "evm", "v1", "trace_tx"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_TraceBlock_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "evm", "v1", "trace_block"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_BaseFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "evm", "v1", "base_fee"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Query_EthAccount_0 = runtime.ForwardResponseMessage
-
- forward_Query_NibiruAccount_0 = runtime.ForwardResponseMessage
-
- forward_Query_ValidatorAccount_0 = runtime.ForwardResponseMessage
-
- forward_Query_Balance_0 = runtime.ForwardResponseMessage
-
- forward_Query_Storage_0 = runtime.ForwardResponseMessage
-
- forward_Query_Code_0 = runtime.ForwardResponseMessage
-
- forward_Query_Params_0 = runtime.ForwardResponseMessage
-
- forward_Query_EthCall_0 = runtime.ForwardResponseMessage
-
- forward_Query_EstimateGas_0 = runtime.ForwardResponseMessage
-
- forward_Query_TraceTx_0 = runtime.ForwardResponseMessage
-
- forward_Query_TraceBlock_0 = runtime.ForwardResponseMessage
-
- forward_Query_BaseFee_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/evm/query_test.go b/x/evm/query_test.go
deleted file mode 100644
index f32a9704b..000000000
--- a/x/evm/query_test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/x/common"
-)
-
-type TestSuite struct {
- suite.Suite
-}
-
-// TestNilQueries: Checks that all expected sad paths for nil msgs error
-func (s *TestSuite) TestNilQueries() {
- for _, testCase := range []func() error{
- func() error {
- var req *QueryEthAccountRequest = nil
- return req.Validate()
- },
- func() error {
- var req *QueryNibiruAccountRequest = nil
- return req.Validate()
- },
- func() error {
- var req *QueryValidatorAccountRequest = nil
- _, err := req.Validate()
- return err
- },
- func() error {
- var req *QueryBalanceRequest = nil
- return req.Validate()
- },
- func() error {
- var req *QueryStorageRequest = nil
- return req.Validate()
- },
- func() error {
- var req *QueryCodeRequest = nil
- return req.Validate()
- },
- func() error {
- var req *EthCallRequest = nil
- return req.Validate()
- },
- func() error {
- var req *QueryTraceTxRequest = nil
- return req.Validate()
- },
- func() error {
- var req *QueryTraceBlockRequest = nil
- return req.Validate()
- },
- } {
- err := testCase()
- s.Require().ErrorContains(err, common.ErrNilGrpcMsg().Error())
- }
-}
diff --git a/x/evm/state.go b/x/evm/state.go
deleted file mode 100644
index 892e260ab..000000000
--- a/x/evm/state.go
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "fmt"
- "strings"
-
- errorsmod "cosmossdk.io/errors"
- "github.com/ethereum/go-ethereum/common"
-)
-
-// Storage represents the account Storage map as a slice of single key value
-// State pairs. This is to prevent non determinism at genesis initialization or export.
-type Storage []State
-
-// Validate performs a basic validation of the Storage fields.
-func (s Storage) Validate() error {
- seenStorage := make(map[string]bool)
- for i, state := range s {
- if seenStorage[state.Key] {
- return errorsmod.Wrapf(ErrInvalidState, "duplicate state key %d: %s", i, state.Key)
- }
-
- if err := state.Validate(); err != nil {
- return err
- }
-
- seenStorage[state.Key] = true
- }
- return nil
-}
-
-// String implements the stringer interface
-func (s Storage) String() string {
- var str string
- for _, state := range s {
- str += fmt.Sprintf("%s\n", state.String())
- }
-
- return str
-}
-
-// Copy returns a copy of storage.
-func (s Storage) Copy() Storage {
- cpy := make(Storage, len(s))
- copy(cpy, s)
-
- return cpy
-}
-
-// Validate performs a basic validation of the State fields. Note that [State]
-// can be empty.
-func (s State) Validate() error {
- if strings.TrimSpace(s.Key) == "" {
- return errorsmod.Wrap(ErrInvalidState, "state key hash cannot be blank")
- }
-
- return nil
-}
-
-// NewStateFromEthHashes creates a [State] struct from Eth hashes.
-func NewStateFromEthHashes(key, value common.Hash) State {
- return State{
- Key: key.String(),
- Value: value.String(),
- }
-}
diff --git a/x/evm/state_test.go b/x/evm/state_test.go
deleted file mode 100644
index 482ef512a..000000000
--- a/x/evm/state_test.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package evm
-
-import (
- "testing"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/stretchr/testify/suite"
-)
-
-type SuiteStorage struct {
- suite.Suite
-}
-
-func TestSuiteStorage(t *testing.T) {
- suite.Run(t, new(SuiteStorage))
-}
-
-func (s *SuiteStorage) TestStorageString() {
- storage := Storage{NewStateFromEthHashes(common.BytesToHash([]byte("key")), common.BytesToHash([]byte("value")))}
- str := "key:\"0x00000000000000000000000000000000000000000000000000000000006b6579\" value:\"0x00000000000000000000000000000000000000000000000000000076616c7565\" \n"
- s.Equal(str, storage.String())
-}
-
-func (s *SuiteStorage) TestStorageValidate() {
- testCases := []struct {
- name string
- storage Storage
- wantPass bool
- }{
- {
- name: "valid storage",
- storage: Storage{
- NewStateFromEthHashes(common.BytesToHash([]byte{1, 2, 3}), common.BytesToHash([]byte{1, 2, 3})),
- },
- wantPass: true,
- },
- {
- name: "empty storage key bytes",
- storage: Storage{
- {Key: ""},
- },
- wantPass: false,
- },
- {
- name: "duplicated storage key",
- storage: Storage{
- {Key: common.BytesToHash([]byte{1, 2, 3}).String()},
- {Key: common.BytesToHash([]byte{1, 2, 3}).String()},
- },
- wantPass: false,
- },
- }
-
- for _, tc := range testCases {
- tc := tc
- err := tc.storage.Validate()
- if tc.wantPass {
- s.NoError(err, tc.name)
- } else {
- s.Error(err, tc.name)
- }
- }
-}
-
-func (s *SuiteStorage) TestStorageCopy() {
- testCases := []struct {
- name string
- storage Storage
- }{
- {
- "single storage",
- Storage{
- NewStateFromEthHashes(common.BytesToHash([]byte{1, 2, 3}), common.BytesToHash([]byte{1, 2, 3})),
- },
- },
- {
- "empty storage key value bytes",
- Storage{
- {Key: common.Hash{}.String(), Value: common.Hash{}.String()},
- },
- },
- {
- "empty storage",
- Storage{},
- },
- }
-
- for _, tc := range testCases {
- tc := tc
- s.Require().Equal(tc.storage, tc.storage.Copy(), tc.name)
- }
-}
diff --git a/x/evm/statedb/access_list.go b/x/evm/statedb/access_list.go
deleted file mode 100644
index 4513a9164..000000000
--- a/x/evm/statedb/access_list.go
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright 2020 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see .
-
-package statedb
-
-import (
- "github.com/ethereum/go-ethereum/common"
-)
-
-type accessList struct {
- addresses map[common.Address]int
- slots []map[common.Hash]struct{}
-}
-
-// ContainsAddress returns true if the address is in the access list.
-func (al *accessList) ContainsAddress(address common.Address) bool {
- _, ok := al.addresses[address]
- return ok
-}
-
-// Contains checks if a slot within an account is present in the access list, returning
-// separate flags for the presence of the account and the slot respectively.
-func (al *accessList) Contains(address common.Address, slot common.Hash) (addressPresent bool, slotPresent bool) {
- idx, ok := al.addresses[address]
- if !ok {
- // no such address (and hence zero slots)
- return false, false
- }
- if idx == -1 {
- // address yes, but no slots
- return true, false
- }
- _, slotPresent = al.slots[idx][slot]
- return true, slotPresent
-}
-
-// newAccessList creates a new accessList.
-func newAccessList() *accessList {
- return &accessList{
- addresses: make(map[common.Address]int),
- }
-}
-
-// AddAddress adds an address to the access list, and returns 'true' if the operation
-// caused a change (addr was not previously in the list).
-func (al *accessList) AddAddress(address common.Address) bool {
- if _, present := al.addresses[address]; present {
- return false
- }
- al.addresses[address] = -1
- return true
-}
-
-// AddSlot adds the specified (addr, slot) combo to the access list.
-// Return values are:
-// - address added
-// - slot added
-// For any 'true' value returned, a corresponding journal entry must be made.
-func (al *accessList) AddSlot(address common.Address, slot common.Hash) (addrChange bool, slotChange bool) {
- idx, addrPresent := al.addresses[address]
- if !addrPresent || idx == -1 {
- // Address not present, or addr present but no slots there
- al.addresses[address] = len(al.slots)
- slotmap := map[common.Hash]struct{}{slot: {}}
- al.slots = append(al.slots, slotmap)
- return !addrPresent, true
- }
- // There is already an (address,slot) mapping
- slotmap := al.slots[idx]
- if _, ok := slotmap[slot]; !ok {
- slotmap[slot] = struct{}{}
- // Journal add slot change
- return false, true
- }
- // No changes required
- return false, false
-}
-
-// DeleteSlot removes an (address, slot)-tuple from the access list.
-// This operation needs to be performed in the same order as the addition happened.
-// This method is meant to be used by the journal, which maintains ordering of
-// operations.
-func (al *accessList) DeleteSlot(address common.Address, slot common.Hash) {
- idx, addrOk := al.addresses[address]
- if !addrOk {
- panic("reverting slot change, address not present in list")
- }
- slotmap := al.slots[idx]
- delete(slotmap, slot)
- // If that was the last (first) slot, remove it
- // Since additions and rollbacks are always performed in order,
- // we can delete the item without worrying about screwing up later indices
- if len(slotmap) == 0 {
- al.slots = al.slots[:idx]
- al.addresses[address] = -1
- }
-}
-
-// DeleteAddress removes an address from the access list. This operation
-// needs to be performed in the same order as the addition happened.
-// This method is meant to be used by the journal, which maintains ordering of
-// operations.
-func (al *accessList) DeleteAddress(address common.Address) {
- delete(al.addresses, address)
-}
diff --git a/x/evm/statedb/config.go b/x/evm/statedb/config.go
deleted file mode 100644
index 22f056433..000000000
--- a/x/evm/statedb/config.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package statedb
-
-import (
- "math/big"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/params"
-
- "github.com/NibiruChain/nibiru/x/evm"
-)
-
-// TxConfig encapulates the readonly information of current tx for `StateDB`.
-type TxConfig struct {
- BlockHash common.Hash // hash of current block
- TxHash common.Hash // hash of current tx
- TxIndex uint // the index of current transaction
- LogIndex uint // the index of next log within current block
-}
-
-// NewTxConfig returns a TxConfig
-func NewTxConfig(bhash, thash common.Hash, txIndex, logIndex uint) TxConfig {
- return TxConfig{
- BlockHash: bhash,
- TxHash: thash,
- TxIndex: txIndex,
- LogIndex: logIndex,
- }
-}
-
-// NewEmptyTxConfig construct an empty TxConfig,
-// used in context where there's no transaction, e.g. `eth_call`/`eth_estimateGas`.
-func NewEmptyTxConfig(bhash common.Hash) TxConfig {
- return TxConfig{
- BlockHash: bhash,
- TxHash: common.Hash{},
- TxIndex: 0,
- LogIndex: 0,
- }
-}
-
-// EVMConfig encapsulates common parameters needed to create an EVM to execute a message
-// It's mainly to reduce the number of method parameters
-type EVMConfig struct {
- Params evm.Params
- ChainConfig *params.ChainConfig
- CoinBase common.Address
- BaseFee *big.Int
-}
diff --git a/x/evm/statedb/interfaces.go b/x/evm/statedb/interfaces.go
deleted file mode 100644
index 4ef8b2862..000000000
--- a/x/evm/statedb/interfaces.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package statedb
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/vm"
-)
-
-// ExtStateDB defines an extension to the interface provided by the go-ethereum
-// codebase to support additional state transition functionalities. In particular
-// it supports appending a new entry to the state journal through
-// AppendJournalEntry so that the state can be reverted after running
-// stateful precompiled contracts.
-type ExtStateDB interface {
- vm.StateDB
- AppendJournalEntry(JournalEntry)
-}
-
-// Keeper provide underlying storage of StateDB
-type Keeper interface {
- // GetAccount: Ethereum account getter for a [statedb.Account].
- GetAccount(ctx sdk.Context, addr common.Address) *Account
- GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash
- GetCode(ctx sdk.Context, codeHash common.Hash) []byte
-
- // ForEachStorage: Iterator over contract storage.
- ForEachStorage(
- ctx sdk.Context, addr common.Address,
- stopIter func(key, value common.Hash) bool,
- )
-
- SetAccount(ctx sdk.Context, addr common.Address, account Account) error
- SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte)
- // SetCode: Setter for smart contract bytecode. Delete if code is empty.
- SetCode(ctx sdk.Context, codeHash []byte, code []byte)
-
- // DeleteAccount handles contract's suicide call, clearing the balance,
- // contract bytecode, contract state, and its native account.
- DeleteAccount(ctx sdk.Context, addr common.Address) error
-}
diff --git a/x/evm/statedb/journal.go b/x/evm/statedb/journal.go
deleted file mode 100644
index 14bb7b1df..000000000
--- a/x/evm/statedb/journal.go
+++ /dev/null
@@ -1,241 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see .
-
-package statedb
-
-import (
- "bytes"
- "math/big"
- "sort"
-
- "github.com/ethereum/go-ethereum/common"
-)
-
-// JournalEntry is a modification entry in the state change journal that can be
-// Reverted on demand.
-type JournalEntry interface {
- // Revert undoes the changes introduced by this journal entry.
- Revert(*StateDB)
-
- // Dirtied returns the Ethereum address modified by this journal entry.
- Dirtied() *common.Address
-}
-
-// journal contains the list of state modifications applied since the last state
-// commit. These are tracked to be able to be reverted in the case of an execution
-// exception or request for reversal.
-type journal struct {
- entries []JournalEntry // Current changes tracked by the journal
- dirties map[common.Address]int // Dirty accounts and the number of changes
-}
-
-// newJournal creates a new initialized journal.
-func newJournal() *journal {
- return &journal{
- dirties: make(map[common.Address]int),
- }
-}
-
-// sortedDirties sort the dirty addresses for deterministic iteration
-func (j *journal) sortedDirties() []common.Address {
- keys := make([]common.Address, 0, len(j.dirties))
- for k := range j.dirties {
- keys = append(keys, k)
- }
- sort.Slice(keys, func(i, j int) bool {
- return bytes.Compare(keys[i].Bytes(), keys[j].Bytes()) < 0
- })
- return keys
-}
-
-// append inserts a new modification entry to the end of the change journal.
-func (j *journal) append(entry JournalEntry) {
- j.entries = append(j.entries, entry)
- if addr := entry.Dirtied(); addr != nil {
- j.dirties[*addr]++
- }
-}
-
-// Revert undoes a batch of journalled modifications along with any Reverted
-// dirty handling too.
-func (j *journal) Revert(statedb *StateDB, snapshot int) {
- for i := len(j.entries) - 1; i >= snapshot; i-- {
- // Undo the changes made by the operation
- j.entries[i].Revert(statedb)
-
- // Drop any dirty tracking induced by the change
- if addr := j.entries[i].Dirtied(); addr != nil {
- if j.dirties[*addr]--; j.dirties[*addr] == 0 {
- delete(j.dirties, *addr)
- }
- }
- }
- j.entries = j.entries[:snapshot]
-}
-
-// length returns the current number of entries in the journal.
-func (j *journal) length() int {
- return len(j.entries)
-}
-
-type (
- // Changes to the account trie.
- createObjectChange struct {
- account *common.Address
- }
- resetObjectChange struct {
- prev *stateObject
- }
- suicideChange struct {
- account *common.Address
- prev bool // whether account had already suicided
- prevbalance *big.Int
- }
-
- // Changes to individual accounts.
- balanceChange struct {
- account *common.Address
- prev *big.Int
- }
- nonceChange struct {
- account *common.Address
- prev uint64
- }
- storageChange struct {
- account *common.Address
- key, prevalue common.Hash
- }
- codeChange struct {
- account *common.Address
- prevcode, prevhash []byte
- }
-
- // Changes to other state values.
- refundChange struct {
- prev uint64
- }
- addLogChange struct{}
-
- // Changes to the access list
- accessListAddAccountChange struct {
- address *common.Address
- }
- accessListAddSlotChange struct {
- address *common.Address
- slot *common.Hash
- }
-)
-
-func (ch createObjectChange) Revert(s *StateDB) {
- delete(s.stateObjects, *ch.account)
-}
-
-func (ch createObjectChange) Dirtied() *common.Address {
- return ch.account
-}
-
-func (ch resetObjectChange) Revert(s *StateDB) {
- s.setStateObject(ch.prev)
-}
-
-func (ch resetObjectChange) Dirtied() *common.Address {
- return nil
-}
-
-func (ch suicideChange) Revert(s *StateDB) {
- obj := s.getStateObject(*ch.account)
- if obj != nil {
- obj.suicided = ch.prev
- obj.setBalance(ch.prevbalance)
- }
-}
-
-func (ch suicideChange) Dirtied() *common.Address {
- return ch.account
-}
-
-func (ch balanceChange) Revert(s *StateDB) {
- s.getStateObject(*ch.account).setBalance(ch.prev)
-}
-
-func (ch balanceChange) Dirtied() *common.Address {
- return ch.account
-}
-
-func (ch nonceChange) Revert(s *StateDB) {
- s.getStateObject(*ch.account).setNonce(ch.prev)
-}
-
-func (ch nonceChange) Dirtied() *common.Address {
- return ch.account
-}
-
-func (ch codeChange) Revert(s *StateDB) {
- s.getStateObject(*ch.account).setCode(common.BytesToHash(ch.prevhash), ch.prevcode)
-}
-
-func (ch codeChange) Dirtied() *common.Address {
- return ch.account
-}
-
-func (ch storageChange) Revert(s *StateDB) {
- s.getStateObject(*ch.account).setState(ch.key, ch.prevalue)
-}
-
-func (ch storageChange) Dirtied() *common.Address {
- return ch.account
-}
-
-func (ch refundChange) Revert(s *StateDB) {
- s.refund = ch.prev
-}
-
-func (ch refundChange) Dirtied() *common.Address {
- return nil
-}
-
-func (ch addLogChange) Revert(s *StateDB) {
- s.logs = s.logs[:len(s.logs)-1]
-}
-
-func (ch addLogChange) Dirtied() *common.Address {
- return nil
-}
-
-func (ch accessListAddAccountChange) Revert(s *StateDB) {
- /*
- One important invariant here, is that whenever a (addr, slot) is added, if the
- addr is not already present, the add causes two journal entries:
- - one for the address,
- - one for the (address,slot)
- Therefore, when unrolling the change, we can always blindly delete the
- (addr) at this point, since no storage adds can remain when come upon
- a single (addr) change.
- */
- s.accessList.DeleteAddress(*ch.address)
-}
-
-func (ch accessListAddAccountChange) Dirtied() *common.Address {
- return nil
-}
-
-func (ch accessListAddSlotChange) Revert(s *StateDB) {
- s.accessList.DeleteSlot(*ch.address, *ch.slot)
-}
-
-func (ch accessListAddSlotChange) Dirtied() *common.Address {
- return nil
-}
diff --git a/x/evm/statedb/mock_test.go b/x/evm/statedb/mock_test.go
deleted file mode 100644
index b4324abe9..000000000
--- a/x/evm/statedb/mock_test.go
+++ /dev/null
@@ -1,115 +0,0 @@
-package statedb_test
-
-import (
- "bytes"
- "errors"
- "math/big"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
-
- "github.com/NibiruChain/nibiru/x/evm/statedb"
-)
-
-var (
- _ statedb.Keeper = &MockKeeper{}
- errAddress common.Address = common.BigToAddress(big.NewInt(100))
- emptyCodeHash = crypto.Keccak256(nil)
-)
-
-type MockAcount struct {
- account statedb.Account
- states statedb.Storage
-}
-
-type MockKeeper struct {
- accounts map[common.Address]MockAcount
- codes map[common.Hash][]byte
-}
-
-func NewMockKeeper() *MockKeeper {
- return &MockKeeper{
- accounts: make(map[common.Address]MockAcount),
- codes: make(map[common.Hash][]byte),
- }
-}
-
-func (k MockKeeper) GetAccount(_ sdk.Context, addr common.Address) *statedb.Account {
- acct, ok := k.accounts[addr]
- if !ok {
- return nil
- }
- return &acct.account
-}
-
-func (k MockKeeper) GetState(_ sdk.Context, addr common.Address, key common.Hash) common.Hash {
- return k.accounts[addr].states[key]
-}
-
-func (k MockKeeper) GetCode(_ sdk.Context, codeHash common.Hash) []byte {
- return k.codes[codeHash]
-}
-
-func (k MockKeeper) ForEachStorage(_ sdk.Context, addr common.Address, cb func(key, value common.Hash) bool) {
- if acct, ok := k.accounts[addr]; ok {
- for k, v := range acct.states {
- if !cb(k, v) {
- return
- }
- }
- }
-}
-
-func (k MockKeeper) SetAccount(_ sdk.Context, addr common.Address, account statedb.Account) error {
- if addr == errAddress {
- return errors.New("mock db error")
- }
- acct, exists := k.accounts[addr]
- if exists {
- // update
- acct.account = account
- k.accounts[addr] = acct
- } else {
- k.accounts[addr] = MockAcount{account: account, states: make(statedb.Storage)}
- }
- return nil
-}
-
-func (k MockKeeper) SetState(_ sdk.Context, addr common.Address, key common.Hash, value []byte) {
- if acct, ok := k.accounts[addr]; ok {
- if len(value) == 0 {
- delete(acct.states, key)
- } else {
- acct.states[key] = common.BytesToHash(value)
- }
- }
-}
-
-func (k MockKeeper) SetCode(_ sdk.Context, codeHash []byte, code []byte) {
- k.codes[common.BytesToHash(codeHash)] = code
-}
-
-func (k MockKeeper) DeleteAccount(_ sdk.Context, addr common.Address) error {
- if addr == errAddress {
- return errors.New("mock db error")
- }
- old := k.accounts[addr]
- delete(k.accounts, addr)
- if !bytes.Equal(old.account.CodeHash, emptyCodeHash) {
- delete(k.codes, common.BytesToHash(old.account.CodeHash))
- }
- return nil
-}
-
-func (k MockKeeper) Clone() *MockKeeper {
- accounts := make(map[common.Address]MockAcount, len(k.accounts))
- for k, v := range k.accounts {
- accounts[k] = v
- }
- codes := make(map[common.Hash][]byte, len(k.codes))
- for k, v := range k.codes {
- codes[k] = v
- }
- return &MockKeeper{accounts, codes}
-}
diff --git a/x/evm/statedb/state_object.go b/x/evm/statedb/state_object.go
deleted file mode 100644
index c473e1d73..000000000
--- a/x/evm/statedb/state_object.go
+++ /dev/null
@@ -1,236 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package statedb
-
-import (
- "bytes"
- "math/big"
- "sort"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
-)
-
-var emptyCodeHash = crypto.Keccak256(nil)
-
-// Account is the Ethereum consensus representation of accounts.
-// These objects are stored in the storage of auth module.
-type Account struct {
- Nonce uint64
- Balance *big.Int
- CodeHash []byte
-}
-
-// NewEmptyAccount returns an empty account.
-func NewEmptyAccount() *Account {
- return &Account{
- Balance: new(big.Int),
- CodeHash: emptyCodeHash,
- }
-}
-
-// IsContract returns if the account contains contract code.
-func (acct Account) IsContract() bool {
- return !bytes.Equal(acct.CodeHash, emptyCodeHash)
-}
-
-// Storage represents in-memory cache/buffer of contract storage.
-type Storage map[common.Hash]common.Hash
-
-// SortedKeys sort the keys for deterministic iteration
-func (s Storage) SortedKeys() []common.Hash {
- keys := make([]common.Hash, 0, len(s))
- for k := range s {
- keys = append(keys, k)
- }
- sort.Slice(keys, func(i, j int) bool {
- return bytes.Compare(keys[i].Bytes(), keys[j].Bytes()) < 0
- })
- return keys
-}
-
-// stateObject is the state of an acount
-type stateObject struct {
- db *StateDB
-
- account Account
- code []byte
-
- // state storage
- originStorage Storage
- dirtyStorage Storage
-
- address common.Address
-
- // flags
- dirtyCode bool
- suicided bool
-}
-
-// newObject creates a state object.
-func newObject(db *StateDB, address common.Address, account Account) *stateObject {
- if account.Balance == nil {
- account.Balance = new(big.Int)
- }
- if account.CodeHash == nil {
- account.CodeHash = emptyCodeHash
- }
- return &stateObject{
- db: db,
- address: address,
- account: account,
- originStorage: make(Storage),
- dirtyStorage: make(Storage),
- }
-}
-
-// empty returns whether the account is considered empty.
-func (s *stateObject) empty() bool {
- return s.account.Nonce == 0 && s.account.Balance.Sign() == 0 && bytes.Equal(s.account.CodeHash, emptyCodeHash)
-}
-
-func (s *stateObject) markSuicided() {
- s.suicided = true
-}
-
-// AddBalance adds amount to s's balance.
-// It is used to add funds to the destination account of a transfer.
-func (s *stateObject) AddBalance(amount *big.Int) {
- if amount.Sign() == 0 {
- return
- }
- s.SetBalance(new(big.Int).Add(s.Balance(), amount))
-}
-
-// SubBalance removes amount from s's balance.
-// It is used to remove funds from the origin account of a transfer.
-func (s *stateObject) SubBalance(amount *big.Int) {
- if amount.Sign() == 0 {
- return
- }
- s.SetBalance(new(big.Int).Sub(s.Balance(), amount))
-}
-
-// SetBalance update account balance.
-func (s *stateObject) SetBalance(amount *big.Int) {
- s.db.journal.append(balanceChange{
- account: &s.address,
- prev: new(big.Int).Set(s.account.Balance),
- })
- s.setBalance(amount)
-}
-
-func (s *stateObject) setBalance(amount *big.Int) {
- s.account.Balance = amount
-}
-
-//
-// Attribute accessors
-//
-
-// Returns the address of the contract/account
-func (s *stateObject) Address() common.Address {
- return s.address
-}
-
-// Code returns the contract code associated with this object, if any.
-func (s *stateObject) Code() []byte {
- if s.code != nil {
- return s.code
- }
- if bytes.Equal(s.CodeHash(), emptyCodeHash) {
- return nil
- }
- code := s.db.keeper.GetCode(s.db.ctx, common.BytesToHash(s.CodeHash()))
- s.code = code
- return code
-}
-
-// CodeSize returns the size of the contract code associated with this object,
-// or zero if none.
-func (s *stateObject) CodeSize() int {
- return len(s.Code())
-}
-
-// SetCode set contract code to account
-func (s *stateObject) SetCode(codeHash common.Hash, code []byte) {
- prevcode := s.Code()
- s.db.journal.append(codeChange{
- account: &s.address,
- prevhash: s.CodeHash(),
- prevcode: prevcode,
- })
- s.setCode(codeHash, code)
-}
-
-func (s *stateObject) setCode(codeHash common.Hash, code []byte) {
- s.code = code
- s.account.CodeHash = codeHash[:]
- s.dirtyCode = true
-}
-
-// SetCode set nonce to account
-func (s *stateObject) SetNonce(nonce uint64) {
- s.db.journal.append(nonceChange{
- account: &s.address,
- prev: s.account.Nonce,
- })
- s.setNonce(nonce)
-}
-
-func (s *stateObject) setNonce(nonce uint64) {
- s.account.Nonce = nonce
-}
-
-// CodeHash returns the code hash of account
-func (s *stateObject) CodeHash() []byte {
- return s.account.CodeHash
-}
-
-// Balance returns the balance of account
-func (s *stateObject) Balance() *big.Int {
- return s.account.Balance
-}
-
-// Nonce returns the nonce of account
-func (s *stateObject) Nonce() uint64 {
- return s.account.Nonce
-}
-
-// GetCommittedState query the committed state
-func (s *stateObject) GetCommittedState(key common.Hash) common.Hash {
- if value, cached := s.originStorage[key]; cached {
- return value
- }
- // If no live objects are available, load it from keeper
- value := s.db.keeper.GetState(s.db.ctx, s.Address(), key)
- s.originStorage[key] = value
- return value
-}
-
-// GetState query the current state (including dirty state)
-func (s *stateObject) GetState(key common.Hash) common.Hash {
- if value, dirty := s.dirtyStorage[key]; dirty {
- return value
- }
- return s.GetCommittedState(key)
-}
-
-// SetState sets the contract state
-func (s *stateObject) SetState(key common.Hash, value common.Hash) {
- // If the new value is the same as old, don't set
- prev := s.GetState(key)
- if prev == value {
- return
- }
- // New value is different, update and journal the change
- s.db.journal.append(storageChange{
- account: &s.address,
- key: key,
- prevalue: prev,
- })
- s.setState(key, value)
-}
-
-func (s *stateObject) setState(key, value common.Hash) {
- s.dirtyStorage[key] = value
-}
diff --git a/x/evm/statedb/statedb.go b/x/evm/statedb/statedb.go
deleted file mode 100644
index e06ef3708..000000000
--- a/x/evm/statedb/statedb.go
+++ /dev/null
@@ -1,469 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package statedb
-
-import (
- "fmt"
- "math/big"
- "sort"
-
- errorsmod "cosmossdk.io/errors"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/crypto"
-)
-
-// revision is the identifier of a version of state.
-// it consists of an auto-increment id and a journal index.
-// it's safer to use than using journal index alone.
-type revision struct {
- id int
- journalIndex int
-}
-
-var _ vm.StateDB = &StateDB{}
-
-// StateDB structs within the ethereum protocol are used to store anything
-// within the merkle trie. StateDBs take care of caching and storing
-// nested states. It's the general query interface to retrieve:
-// * Contracts
-// * Accounts
-type StateDB struct {
- keeper Keeper
- ctx sdk.Context
-
- // Journal of state modifications. This is the backbone of
- // Snapshot and RevertToSnapshot.
- journal *journal
- validRevisions []revision
- nextRevisionID int
-
- stateObjects map[common.Address]*stateObject
-
- txConfig TxConfig
-
- // The refund counter, also used by state transitioning.
- refund uint64
-
- // Per-transaction logs
- logs []*gethcore.Log
-
- // Per-transaction access list
- accessList *accessList
-}
-
-// New creates a new state from a given trie.
-func New(ctx sdk.Context, keeper Keeper, txConfig TxConfig) *StateDB {
- return &StateDB{
- keeper: keeper,
- ctx: ctx,
- stateObjects: make(map[common.Address]*stateObject),
- journal: newJournal(),
- accessList: newAccessList(),
-
- txConfig: txConfig,
- }
-}
-
-// Keeper returns the underlying `Keeper`
-func (s *StateDB) Keeper() Keeper {
- return s.keeper
-}
-
-// GetContext returns the transaction Context.
-func (s *StateDB) GetContext() sdk.Context {
- return s.ctx
-}
-
-// AddLog adds a log, called by evm.
-func (s *StateDB) AddLog(log *gethcore.Log) {
- s.journal.append(addLogChange{})
-
- log.TxHash = s.txConfig.TxHash
- log.BlockHash = s.txConfig.BlockHash
- log.TxIndex = s.txConfig.TxIndex
- log.Index = s.txConfig.LogIndex + uint(len(s.logs))
- s.logs = append(s.logs, log)
-}
-
-// Logs returns the logs of current transaction.
-func (s *StateDB) Logs() []*gethcore.Log {
- return s.logs
-}
-
-// AddRefund adds gas to the refund counter
-func (s *StateDB) AddRefund(gas uint64) {
- s.journal.append(refundChange{prev: s.refund})
- s.refund += gas
-}
-
-// SubRefund removes gas from the refund counter.
-// This method will panic if the refund counter goes below zero
-func (s *StateDB) SubRefund(gas uint64) {
- s.journal.append(refundChange{prev: s.refund})
- if gas > s.refund {
- panic(fmt.Sprintf("Refund counter below zero (gas: %d > refund: %d)", gas, s.refund))
- }
- s.refund -= gas
-}
-
-// Exist reports whether the given account address exists in the state.
-// Notably this also returns true for suicided accounts.
-func (s *StateDB) Exist(addr common.Address) bool {
- return s.getStateObject(addr) != nil
-}
-
-// Empty returns whether the state object is either non-existent
-// or empty according to the EIP161 specification (balance = nonce = code = 0)
-func (s *StateDB) Empty(addr common.Address) bool {
- so := s.getStateObject(addr)
- return so == nil || so.empty()
-}
-
-// GetBalance retrieves the balance from the given address or 0 if object not found
-func (s *StateDB) GetBalance(addr common.Address) *big.Int {
- stateObject := s.getStateObject(addr)
- if stateObject != nil {
- return stateObject.Balance()
- }
- return common.Big0
-}
-
-// GetNonce returns the nonce of account, 0 if not exists.
-func (s *StateDB) GetNonce(addr common.Address) uint64 {
- stateObject := s.getStateObject(addr)
- if stateObject != nil {
- return stateObject.Nonce()
- }
-
- return 0
-}
-
-// GetCode returns the code of account, nil if not exists.
-func (s *StateDB) GetCode(addr common.Address) []byte {
- stateObject := s.getStateObject(addr)
- if stateObject != nil {
- return stateObject.Code()
- }
- return nil
-}
-
-// GetCodeSize returns the code size of account.
-func (s *StateDB) GetCodeSize(addr common.Address) int {
- stateObject := s.getStateObject(addr)
- if stateObject != nil {
- return stateObject.CodeSize()
- }
- return 0
-}
-
-// GetCodeHash returns the code hash of account.
-func (s *StateDB) GetCodeHash(addr common.Address) common.Hash {
- stateObject := s.getStateObject(addr)
- if stateObject == nil {
- return common.Hash{}
- }
- return common.BytesToHash(stateObject.CodeHash())
-}
-
-// GetState retrieves a value from the given account's storage trie.
-func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash {
- stateObject := s.getStateObject(addr)
- if stateObject != nil {
- return stateObject.GetState(hash)
- }
- return common.Hash{}
-}
-
-// GetCommittedState retrieves a value from the given account's committed storage trie.
-func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash {
- stateObject := s.getStateObject(addr)
- if stateObject != nil {
- return stateObject.GetCommittedState(hash)
- }
- return common.Hash{}
-}
-
-// GetRefund returns the current value of the refund counter.
-func (s *StateDB) GetRefund() uint64 {
- return s.refund
-}
-
-// HasSuicided returns if the contract is suicided in current transaction.
-func (s *StateDB) HasSuicided(addr common.Address) bool {
- stateObject := s.getStateObject(addr)
- if stateObject != nil {
- return stateObject.suicided
- }
- return false
-}
-
-// AddPreimage records a SHA3 preimage seen by the VM.
-// AddPreimage performs a no-op since the EnablePreimageRecording flag is disabled
-// on the vm.Config during state transitions. No store trie preimages are written
-// to the database.
-func (s *StateDB) AddPreimage(_ common.Hash, _ []byte) {}
-
-// getStateObject retrieves a state object given by the address, returning nil if
-// the object is not found.
-func (s *StateDB) getStateObject(addr common.Address) *stateObject {
- // Prefer live objects if any is available
- if obj := s.stateObjects[addr]; obj != nil {
- return obj
- }
- // If no live objects are available, load it from keeper
- account := s.keeper.GetAccount(s.ctx, addr)
- if account == nil {
- return nil
- }
- // Insert into the live set
- obj := newObject(s, addr, *account)
- s.setStateObject(obj)
- return obj
-}
-
-// getOrNewStateObject retrieves a state object or create a new state object if nil.
-func (s *StateDB) getOrNewStateObject(addr common.Address) *stateObject {
- stateObject := s.getStateObject(addr)
- if stateObject == nil {
- stateObject, _ = s.createObject(addr)
- }
- return stateObject
-}
-
-// createObject creates a new state object. If there is an existing account with
-// the given address, it is overwritten and returned as the second return value.
-func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) {
- prev = s.getStateObject(addr)
-
- newobj = newObject(s, addr, Account{})
- if prev == nil {
- s.journal.append(createObjectChange{account: &addr})
- } else {
- s.journal.append(resetObjectChange{prev: prev})
- }
- s.setStateObject(newobj)
- if prev != nil {
- return newobj, prev
- }
- return newobj, nil
-}
-
-// CreateAccount explicitly creates a state object. If a state object with the address
-// already exists the balance is carried over to the new account.
-//
-// CreateAccount is called during the EVM CREATE operation. The situation might arise that
-// a contract does the following:
-//
-// 1. sends funds to sha(account ++ (nonce + 1))
-// 2. tx_create(sha(account ++ nonce)) (note that this gets the address of 1)
-//
-// Carrying over the balance ensures that Ether doesn't disappear.
-func (s *StateDB) CreateAccount(addr common.Address) {
- newObj, prev := s.createObject(addr)
- if prev != nil {
- newObj.setBalance(prev.account.Balance)
- }
-}
-
-// ForEachStorage iterate the contract storage, the iteration order is not defined.
-func (s *StateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool) error {
- so := s.getStateObject(addr)
- if so == nil {
- return nil
- }
- s.keeper.ForEachStorage(s.ctx, addr, func(key, value common.Hash) bool {
- if value, dirty := so.dirtyStorage[key]; dirty {
- return cb(key, value)
- }
- if len(value) > 0 {
- return cb(key, value)
- }
- return true
- })
- return nil
-}
-
-func (s *StateDB) setStateObject(object *stateObject) {
- s.stateObjects[object.Address()] = object
-}
-
-/*
- * SETTERS
- */
-
-// AddBalance adds amount to the account associated with addr.
-func (s *StateDB) AddBalance(addr common.Address, amount *big.Int) {
- stateObject := s.getOrNewStateObject(addr)
- if stateObject != nil {
- stateObject.AddBalance(amount)
- }
-}
-
-// SubBalance subtracts amount from the account associated with addr.
-func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) {
- stateObject := s.getOrNewStateObject(addr)
- if stateObject != nil {
- stateObject.SubBalance(amount)
- }
-}
-
-// SetNonce sets the nonce of account.
-func (s *StateDB) SetNonce(addr common.Address, nonce uint64) {
- stateObject := s.getOrNewStateObject(addr)
- if stateObject != nil {
- stateObject.SetNonce(nonce)
- }
-}
-
-// SetCode sets the code of account.
-func (s *StateDB) SetCode(addr common.Address, code []byte) {
- stateObject := s.getOrNewStateObject(addr)
- if stateObject != nil {
- stateObject.SetCode(crypto.Keccak256Hash(code), code)
- }
-}
-
-// SetState sets the contract state.
-func (s *StateDB) SetState(addr common.Address, key, value common.Hash) {
- stateObject := s.getOrNewStateObject(addr)
- if stateObject != nil {
- stateObject.SetState(key, value)
- }
-}
-
-// Suicide marks the given account as suicided.
-// This clears the account balance.
-//
-// The account's state object is still available until the state is committed,
-// getStateObject will return a non-nil account after Suicide.
-func (s *StateDB) Suicide(addr common.Address) bool {
- stateObject := s.getStateObject(addr)
- if stateObject == nil {
- return false
- }
- s.journal.append(suicideChange{
- account: &addr,
- prev: stateObject.suicided,
- prevbalance: new(big.Int).Set(stateObject.Balance()),
- })
- stateObject.markSuicided()
- stateObject.account.Balance = new(big.Int)
-
- return true
-}
-
-// PrepareAccessList handles the preparatory steps for executing a state transition with
-// regards to both EIP-2929 and EIP-2930:
-//
-// - Add sender to access list (2929)
-// - Add destination to access list (2929)
-// - Add precompiles to access list (2929)
-// - Add the contents of the optional tx access list (2930)
-//
-// This method should only be called if Yolov3/Berlin/2929+2930 is applicable at the current number.
-func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, list gethcore.AccessList) {
- s.AddAddressToAccessList(sender)
- if dst != nil {
- s.AddAddressToAccessList(*dst)
- // If it's a create-tx, the destination will be added inside evm.create
- }
- for _, addr := range precompiles {
- s.AddAddressToAccessList(addr)
- }
- for _, el := range list {
- s.AddAddressToAccessList(el.Address)
- for _, key := range el.StorageKeys {
- s.AddSlotToAccessList(el.Address, key)
- }
- }
-}
-
-// AddAddressToAccessList adds the given address to the access list
-func (s *StateDB) AddAddressToAccessList(addr common.Address) {
- if s.accessList.AddAddress(addr) {
- s.journal.append(accessListAddAccountChange{&addr})
- }
-}
-
-// AddSlotToAccessList adds the given (address, slot)-tuple to the access list
-func (s *StateDB) AddSlotToAccessList(addr common.Address, slot common.Hash) {
- addrMod, slotMod := s.accessList.AddSlot(addr, slot)
- if addrMod {
- // In practice, this should not happen, since there is no way to enter the
- // scope of 'address' without having the 'address' become already added
- // to the access list (via call-variant, create, etc).
- // Better safe than sorry, though
- s.journal.append(accessListAddAccountChange{&addr})
- }
- if slotMod {
- s.journal.append(accessListAddSlotChange{
- address: &addr,
- slot: &slot,
- })
- }
-}
-
-// AddressInAccessList returns true if the given address is in the access list.
-func (s *StateDB) AddressInAccessList(addr common.Address) bool {
- return s.accessList.ContainsAddress(addr)
-}
-
-// SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.
-func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool) {
- return s.accessList.Contains(addr, slot)
-}
-
-// Snapshot returns an identifier for the current revision of the state.
-func (s *StateDB) Snapshot() int {
- id := s.nextRevisionID
- s.nextRevisionID++
- s.validRevisions = append(s.validRevisions, revision{id, s.journal.length()})
- return id
-}
-
-// RevertToSnapshot reverts all state changes made since the given revision.
-func (s *StateDB) RevertToSnapshot(revid int) {
- // Find the snapshot in the stack of valid snapshots.
- idx := sort.Search(len(s.validRevisions), func(i int) bool {
- return s.validRevisions[i].id >= revid
- })
- if idx == len(s.validRevisions) || s.validRevisions[idx].id != revid {
- panic(fmt.Errorf("revision id %v cannot be reverted", revid))
- }
- snapshot := s.validRevisions[idx].journalIndex
-
- // Replay the journal to undo changes and remove invalidated snapshots
- s.journal.Revert(s, snapshot)
- s.validRevisions = s.validRevisions[:idx]
-}
-
-// Commit writes the dirty states to keeper
-// the StateDB object should be discarded after committed.
-func (s *StateDB) Commit() error {
- for _, addr := range s.journal.sortedDirties() {
- obj := s.stateObjects[addr]
- if obj.suicided {
- if err := s.keeper.DeleteAccount(s.ctx, obj.Address()); err != nil {
- return errorsmod.Wrap(err, "failed to delete account")
- }
- } else {
- if obj.code != nil && obj.dirtyCode {
- s.keeper.SetCode(s.ctx, obj.CodeHash(), obj.code)
- }
- if err := s.keeper.SetAccount(s.ctx, obj.Address(), obj.account); err != nil {
- return errorsmod.Wrap(err, "failed to set account")
- }
- for _, key := range obj.dirtyStorage.SortedKeys() {
- value := obj.dirtyStorage[key]
- // Skip noop changes, persist actual changes
- if value == obj.originStorage[key] {
- continue
- }
- s.keeper.SetState(s.ctx, obj.Address(), key, value.Bytes())
- }
- }
- }
- return nil
-}
diff --git a/x/evm/statedb/statedb_test.go b/x/evm/statedb/statedb_test.go
deleted file mode 100644
index 21d4ac27e..000000000
--- a/x/evm/statedb/statedb_test.go
+++ /dev/null
@@ -1,586 +0,0 @@
-package statedb_test
-
-import (
- "math/big"
- "testing"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/x/evm/statedb"
-)
-
-var (
- address common.Address = common.BigToAddress(big.NewInt(101))
- address2 common.Address = common.BigToAddress(big.NewInt(102))
- address3 common.Address = common.BigToAddress(big.NewInt(103))
- blockHash common.Hash = common.BigToHash(big.NewInt(9999))
- emptyTxConfig statedb.TxConfig = statedb.NewEmptyTxConfig(blockHash)
-)
-
-type StateDBTestSuite struct {
- suite.Suite
-}
-
-func (suite *StateDBTestSuite) TestAccount() {
- key1 := common.BigToHash(big.NewInt(1))
- value1 := common.BigToHash(big.NewInt(2))
- key2 := common.BigToHash(big.NewInt(3))
- value2 := common.BigToHash(big.NewInt(4))
- testCases := []struct {
- name string
- malleate func(*statedb.StateDB)
- }{
- {"non-exist account", func(db *statedb.StateDB) {
- suite.Require().Equal(false, db.Exist(address))
- suite.Require().Equal(true, db.Empty(address))
- suite.Require().Equal(big.NewInt(0), db.GetBalance(address))
- suite.Require().Equal([]byte(nil), db.GetCode(address))
- suite.Require().Equal(common.Hash{}, db.GetCodeHash(address))
- suite.Require().Equal(uint64(0), db.GetNonce(address))
- }},
- {"empty account", func(db *statedb.StateDB) {
- db.CreateAccount(address)
- suite.Require().NoError(db.Commit())
-
- keeper := db.Keeper().(*MockKeeper)
- acct := keeper.accounts[address]
- suite.Require().Equal(statedb.NewEmptyAccount(), &acct.account)
- suite.Require().Empty(acct.states)
- suite.Require().False(acct.account.IsContract())
-
- db = statedb.New(sdk.Context{}, keeper, emptyTxConfig)
- suite.Require().Equal(true, db.Exist(address))
- suite.Require().Equal(true, db.Empty(address))
- suite.Require().Equal(big.NewInt(0), db.GetBalance(address))
- suite.Require().Equal([]byte(nil), db.GetCode(address))
- suite.Require().Equal(common.BytesToHash(emptyCodeHash), db.GetCodeHash(address))
- suite.Require().Equal(uint64(0), db.GetNonce(address))
- }},
- {"suicide", func(db *statedb.StateDB) {
- // non-exist account.
- suite.Require().False(db.Suicide(address))
- suite.Require().False(db.HasSuicided(address))
-
- // create a contract account
- db.CreateAccount(address)
- db.SetCode(address, []byte("hello world"))
- db.AddBalance(address, big.NewInt(100))
- db.SetState(address, key1, value1)
- db.SetState(address, key2, value2)
- suite.Require().NoError(db.Commit())
-
- // suicide
- db = statedb.New(sdk.Context{}, db.Keeper(), emptyTxConfig)
- suite.Require().False(db.HasSuicided(address))
- suite.Require().True(db.Suicide(address))
-
- // check dirty state
- suite.Require().True(db.HasSuicided(address))
- // balance is cleared
- suite.Require().Equal(big.NewInt(0), db.GetBalance(address))
- // but code and state are still accessible in dirty state
- suite.Require().Equal(value1, db.GetState(address, key1))
- suite.Require().Equal([]byte("hello world"), db.GetCode(address))
-
- suite.Require().NoError(db.Commit())
-
- // not accessible from StateDB anymore
- db = statedb.New(sdk.Context{}, db.Keeper(), emptyTxConfig)
- suite.Require().False(db.Exist(address))
-
- // and cleared in keeper too
- keeper := db.Keeper().(*MockKeeper)
- suite.Require().Empty(keeper.accounts)
- suite.Require().Empty(keeper.codes)
- }},
- }
- for _, tc := range testCases {
- suite.Run(tc.name, func() {
- keeper := NewMockKeeper()
- db := statedb.New(sdk.Context{}, keeper, emptyTxConfig)
- tc.malleate(db)
- })
- }
-}
-
-func (suite *StateDBTestSuite) TestAccountOverride() {
- keeper := NewMockKeeper()
- db := statedb.New(sdk.Context{}, keeper, emptyTxConfig)
- // test balance carry over when overwritten
- amount := big.NewInt(1)
-
- // init an EOA account, account overridden only happens on EOA account.
- db.AddBalance(address, amount)
- db.SetNonce(address, 1)
-
- // override
- db.CreateAccount(address)
-
- // check balance is not lost
- suite.Require().Equal(amount, db.GetBalance(address))
- // but nonce is reset
- suite.Require().Equal(uint64(0), db.GetNonce(address))
-}
-
-func (suite *StateDBTestSuite) TestDBError() {
- testCases := []struct {
- name string
- malleate func(vm.StateDB)
- }{
- {"set account", func(db vm.StateDB) {
- db.SetNonce(errAddress, 1)
- }},
- {"delete account", func(db vm.StateDB) {
- db.SetNonce(errAddress, 1)
- suite.Require().True(db.Suicide(errAddress))
- }},
- }
- for _, tc := range testCases {
- db := statedb.New(sdk.Context{}, NewMockKeeper(), emptyTxConfig)
- tc.malleate(db)
- suite.Require().Error(db.Commit())
- }
-}
-
-func (suite *StateDBTestSuite) TestBalance() {
- // NOTE: no need to test overflow/underflow, that is guaranteed by evm implementation.
- testCases := []struct {
- name string
- malleate func(*statedb.StateDB)
- expBalance *big.Int
- }{
- {"add balance", func(db *statedb.StateDB) {
- db.AddBalance(address, big.NewInt(10))
- }, big.NewInt(10)},
- {"sub balance", func(db *statedb.StateDB) {
- db.AddBalance(address, big.NewInt(10))
- // get dirty balance
- suite.Require().Equal(big.NewInt(10), db.GetBalance(address))
- db.SubBalance(address, big.NewInt(2))
- }, big.NewInt(8)},
- {"add zero balance", func(db *statedb.StateDB) {
- db.AddBalance(address, big.NewInt(0))
- }, big.NewInt(0)},
- {"sub zero balance", func(db *statedb.StateDB) {
- db.SubBalance(address, big.NewInt(0))
- }, big.NewInt(0)},
- }
-
- for _, tc := range testCases {
- suite.Run(tc.name, func() {
- keeper := NewMockKeeper()
- db := statedb.New(sdk.Context{}, keeper, emptyTxConfig)
- tc.malleate(db)
-
- // check dirty state
- suite.Require().Equal(tc.expBalance, db.GetBalance(address))
- suite.Require().NoError(db.Commit())
- // check committed balance too
- suite.Require().Equal(tc.expBalance, keeper.accounts[address].account.Balance)
- })
- }
-}
-
-func (suite *StateDBTestSuite) TestState() {
- key1 := common.BigToHash(big.NewInt(1))
- value1 := common.BigToHash(big.NewInt(1))
- testCases := []struct {
- name string
- malleate func(*statedb.StateDB)
- expStates statedb.Storage
- }{
- {"empty state", func(db *statedb.StateDB) {
- }, nil},
- {"set empty value", func(db *statedb.StateDB) {
- db.SetState(address, key1, common.Hash{})
- }, statedb.Storage{}},
- {"noop state change", func(db *statedb.StateDB) {
- db.SetState(address, key1, value1)
- db.SetState(address, key1, common.Hash{})
- }, statedb.Storage{}},
- {"set state", func(db *statedb.StateDB) {
- // check empty initial state
- suite.Require().Equal(common.Hash{}, db.GetState(address, key1))
- suite.Require().Equal(common.Hash{}, db.GetCommittedState(address, key1))
-
- // set state
- db.SetState(address, key1, value1)
- // query dirty state
- suite.Require().Equal(value1, db.GetState(address, key1))
- // check committed state is still not exist
- suite.Require().Equal(common.Hash{}, db.GetCommittedState(address, key1))
-
- // set same value again, should be noop
- db.SetState(address, key1, value1)
- suite.Require().Equal(value1, db.GetState(address, key1))
- }, statedb.Storage{
- key1: value1,
- }},
- }
-
- for _, tc := range testCases {
- suite.Run(tc.name, func() {
- keeper := NewMockKeeper()
- db := statedb.New(sdk.Context{}, keeper, emptyTxConfig)
- tc.malleate(db)
- suite.Require().NoError(db.Commit())
-
- // check committed states in keeper
- suite.Require().Equal(tc.expStates, keeper.accounts[address].states)
-
- // check ForEachStorage
- db = statedb.New(sdk.Context{}, keeper, emptyTxConfig)
- collected := CollectContractStorage(db)
- if len(tc.expStates) > 0 {
- suite.Require().Equal(tc.expStates, collected)
- } else {
- suite.Require().Empty(collected)
- }
- })
- }
-}
-
-func (suite *StateDBTestSuite) TestCode() {
- code := []byte("hello world")
- codeHash := crypto.Keccak256Hash(code)
-
- testCases := []struct {
- name string
- malleate func(vm.StateDB)
- expCode []byte
- expCodeHash common.Hash
- }{
- {"non-exist account", func(vm.StateDB) {}, nil, common.Hash{}},
- {"empty account", func(db vm.StateDB) {
- db.CreateAccount(address)
- }, nil, common.BytesToHash(emptyCodeHash)},
- {"set code", func(db vm.StateDB) {
- db.SetCode(address, code)
- }, code, codeHash},
- }
-
- for _, tc := range testCases {
- suite.Run(tc.name, func() {
- keeper := NewMockKeeper()
- db := statedb.New(sdk.Context{}, keeper, emptyTxConfig)
- tc.malleate(db)
-
- // check dirty state
- suite.Require().Equal(tc.expCode, db.GetCode(address))
- suite.Require().Equal(len(tc.expCode), db.GetCodeSize(address))
- suite.Require().Equal(tc.expCodeHash, db.GetCodeHash(address))
-
- suite.Require().NoError(db.Commit())
-
- // check again
- db = statedb.New(sdk.Context{}, keeper, emptyTxConfig)
- suite.Require().Equal(tc.expCode, db.GetCode(address))
- suite.Require().Equal(len(tc.expCode), db.GetCodeSize(address))
- suite.Require().Equal(tc.expCodeHash, db.GetCodeHash(address))
- })
- }
-}
-
-func (suite *StateDBTestSuite) TestRevertSnapshot() {
- v1 := common.BigToHash(big.NewInt(1))
- v2 := common.BigToHash(big.NewInt(2))
- v3 := common.BigToHash(big.NewInt(3))
- testCases := []struct {
- name string
- malleate func(vm.StateDB)
- }{
- {"set state", func(db vm.StateDB) {
- db.SetState(address, v1, v3)
- }},
- {"set nonce", func(db vm.StateDB) {
- db.SetNonce(address, 10)
- }},
- {"change balance", func(db vm.StateDB) {
- db.AddBalance(address, big.NewInt(10))
- db.SubBalance(address, big.NewInt(5))
- }},
- {"override account", func(db vm.StateDB) {
- db.CreateAccount(address)
- }},
- {"set code", func(db vm.StateDB) {
- db.SetCode(address, []byte("hello world"))
- }},
- {"suicide", func(db vm.StateDB) {
- db.SetState(address, v1, v2)
- db.SetCode(address, []byte("hello world"))
- suite.Require().True(db.Suicide(address))
- }},
- {"add log", func(db vm.StateDB) {
- db.AddLog(&gethcore.Log{
- Address: address,
- })
- }},
- {"add refund", func(db vm.StateDB) {
- db.AddRefund(10)
- db.SubRefund(5)
- }},
- {"access list", func(db vm.StateDB) {
- db.AddAddressToAccessList(address)
- db.AddSlotToAccessList(address, v1)
- }},
- }
- for _, tc := range testCases {
- suite.Run(tc.name, func() {
- ctx := sdk.Context{}
- keeper := NewMockKeeper()
-
- {
- // do some arbitrary changes to the storage
- db := statedb.New(ctx, keeper, emptyTxConfig)
- db.SetNonce(address, 1)
- db.AddBalance(address, big.NewInt(100))
- db.SetCode(address, []byte("hello world"))
- db.SetState(address, v1, v2)
- db.SetNonce(address2, 1)
- suite.Require().NoError(db.Commit())
- }
-
- originalKeeper := keeper.Clone()
-
- // run test
- db := statedb.New(ctx, keeper, emptyTxConfig)
- rev := db.Snapshot()
- tc.malleate(db)
- db.RevertToSnapshot(rev)
-
- // check empty states after revert
- suite.Require().Zero(db.GetRefund())
- suite.Require().Empty(db.Logs())
-
- suite.Require().NoError(db.Commit())
-
- // check keeper should stay the same
- suite.Require().Equal(originalKeeper, keeper)
- })
- }
-}
-
-func (suite *StateDBTestSuite) TestNestedSnapshot() {
- key := common.BigToHash(big.NewInt(1))
- value1 := common.BigToHash(big.NewInt(1))
- value2 := common.BigToHash(big.NewInt(2))
-
- db := statedb.New(sdk.Context{}, NewMockKeeper(), emptyTxConfig)
-
- rev1 := db.Snapshot()
- db.SetState(address, key, value1)
-
- rev2 := db.Snapshot()
- db.SetState(address, key, value2)
- suite.Require().Equal(value2, db.GetState(address, key))
-
- db.RevertToSnapshot(rev2)
- suite.Require().Equal(value1, db.GetState(address, key))
-
- db.RevertToSnapshot(rev1)
- suite.Require().Equal(common.Hash{}, db.GetState(address, key))
-}
-
-func (suite *StateDBTestSuite) TestInvalidSnapshotId() {
- db := statedb.New(sdk.Context{}, NewMockKeeper(), emptyTxConfig)
- suite.Require().Panics(func() {
- db.RevertToSnapshot(1)
- })
-}
-
-func (suite *StateDBTestSuite) TestAccessList() {
- value1 := common.BigToHash(big.NewInt(1))
- value2 := common.BigToHash(big.NewInt(2))
-
- testCases := []struct {
- name string
- malleate func(vm.StateDB)
- }{
- {"add address", func(db vm.StateDB) {
- suite.Require().False(db.AddressInAccessList(address))
- db.AddAddressToAccessList(address)
- suite.Require().True(db.AddressInAccessList(address))
-
- addrPresent, slotPresent := db.SlotInAccessList(address, value1)
- suite.Require().True(addrPresent)
- suite.Require().False(slotPresent)
-
- // add again, should be no-op
- db.AddAddressToAccessList(address)
- suite.Require().True(db.AddressInAccessList(address))
- }},
- {"add slot", func(db vm.StateDB) {
- addrPresent, slotPresent := db.SlotInAccessList(address, value1)
- suite.Require().False(addrPresent)
- suite.Require().False(slotPresent)
- db.AddSlotToAccessList(address, value1)
- addrPresent, slotPresent = db.SlotInAccessList(address, value1)
- suite.Require().True(addrPresent)
- suite.Require().True(slotPresent)
-
- // add another slot
- db.AddSlotToAccessList(address, value2)
- addrPresent, slotPresent = db.SlotInAccessList(address, value2)
- suite.Require().True(addrPresent)
- suite.Require().True(slotPresent)
-
- // add again, should be noop
- db.AddSlotToAccessList(address, value2)
- addrPresent, slotPresent = db.SlotInAccessList(address, value2)
- suite.Require().True(addrPresent)
- suite.Require().True(slotPresent)
- }},
- {"prepare access list", func(db vm.StateDB) {
- al := gethcore.AccessList{{
- Address: address3,
- StorageKeys: []common.Hash{value1},
- }}
-
- db.PrepareAccessList(address, &address2, vm.PrecompiledAddressesBerlin, al)
-
- // check sender and dst
- suite.Require().True(db.AddressInAccessList(address))
- suite.Require().True(db.AddressInAccessList(address2))
- // check precompiles
- suite.Require().True(db.AddressInAccessList(common.BytesToAddress([]byte{1})))
- // check AccessList
- suite.Require().True(db.AddressInAccessList(address3))
- addrPresent, slotPresent := db.SlotInAccessList(address3, value1)
- suite.Require().True(addrPresent)
- suite.Require().True(slotPresent)
- addrPresent, slotPresent = db.SlotInAccessList(address3, value2)
- suite.Require().True(addrPresent)
- suite.Require().False(slotPresent)
- }},
- }
-
- for _, tc := range testCases {
- db := statedb.New(sdk.Context{}, NewMockKeeper(), emptyTxConfig)
- tc.malleate(db)
- }
-}
-
-func (suite *StateDBTestSuite) TestLog() {
- txHash := common.BytesToHash([]byte("tx"))
- // use a non-default tx config
- txConfig := statedb.NewTxConfig(
- blockHash,
- txHash,
- 1, 1,
- )
- db := statedb.New(sdk.Context{}, NewMockKeeper(), txConfig)
- data := []byte("hello world")
- db.AddLog(&gethcore.Log{
- Address: address,
- Topics: []common.Hash{},
- Data: data,
- BlockNumber: 1,
- })
- suite.Require().Equal(1, len(db.Logs()))
- expecedLog := &gethcore.Log{
- Address: address,
- Topics: []common.Hash{},
- Data: data,
- BlockNumber: 1,
- BlockHash: blockHash,
- TxHash: txHash,
- TxIndex: 1,
- Index: 1,
- }
- suite.Require().Equal(expecedLog, db.Logs()[0])
-
- db.AddLog(&gethcore.Log{
- Address: address,
- Topics: []common.Hash{},
- Data: data,
- BlockNumber: 1,
- })
- suite.Require().Equal(2, len(db.Logs()))
- expecedLog.Index++
- suite.Require().Equal(expecedLog, db.Logs()[1])
-}
-
-func (suite *StateDBTestSuite) TestRefund() {
- testCases := []struct {
- name string
- malleate func(vm.StateDB)
- expRefund uint64
- expPanic bool
- }{
- {"add refund", func(db vm.StateDB) {
- db.AddRefund(uint64(10))
- }, 10, false},
- {"sub refund", func(db vm.StateDB) {
- db.AddRefund(uint64(10))
- db.SubRefund(uint64(5))
- }, 5, false},
- {"negative refund counter", func(db vm.StateDB) {
- db.AddRefund(uint64(5))
- db.SubRefund(uint64(10))
- }, 0, true},
- }
- for _, tc := range testCases {
- db := statedb.New(sdk.Context{}, NewMockKeeper(), emptyTxConfig)
- if !tc.expPanic {
- tc.malleate(db)
- suite.Require().Equal(tc.expRefund, db.GetRefund())
- } else {
- suite.Require().Panics(func() {
- tc.malleate(db)
- })
- }
- }
-}
-
-func (suite *StateDBTestSuite) TestIterateStorage() {
- key1 := common.BigToHash(big.NewInt(1))
- value1 := common.BigToHash(big.NewInt(2))
- key2 := common.BigToHash(big.NewInt(3))
- value2 := common.BigToHash(big.NewInt(4))
-
- keeper := NewMockKeeper()
- db := statedb.New(sdk.Context{}, keeper, emptyTxConfig)
- db.SetState(address, key1, value1)
- db.SetState(address, key2, value2)
-
- // ForEachStorage only iterate committed state
- suite.Require().Empty(CollectContractStorage(db))
-
- suite.Require().NoError(db.Commit())
-
- storage := CollectContractStorage(db)
- suite.Require().Equal(2, len(storage))
- suite.Require().Equal(keeper.accounts[address].states, storage)
-
- // break early iteration
- storage = make(statedb.Storage)
- err := db.ForEachStorage(address, func(k, v common.Hash) bool {
- storage[k] = v
- // return false to break early
- return false
- })
- suite.Require().NoError(err)
- suite.Require().Equal(1, len(storage))
-}
-
-func CollectContractStorage(db vm.StateDB) statedb.Storage {
- storage := make(statedb.Storage)
- err := db.ForEachStorage(address, func(k, v common.Hash) bool {
- storage[k] = v
- return true
- })
- if err != nil {
- return nil
- }
-
- return storage
-}
-
-func TestStateDBTestSuite(t *testing.T) {
- suite.Run(t, &StateDBTestSuite{})
-}
diff --git a/x/evm/tx.go b/x/evm/tx.go
deleted file mode 100644
index c247506aa..000000000
--- a/x/evm/tx.go
+++ /dev/null
@@ -1,361 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "math"
- "math/big"
-
- "github.com/ethereum/go-ethereum/common"
- gethmath "github.com/ethereum/go-ethereum/common/math"
- gethcore "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/core/vm"
-
- errorsmod "cosmossdk.io/errors"
- sdkmath "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- errortypes "github.com/cosmos/cosmos-sdk/types/errors"
-
- "github.com/NibiruChain/nibiru/eth"
-)
-
-// EvmTxArgs encapsulates all possible params to create all EVM txs types.
-// This includes LegacyTx, DynamicFeeTx and AccessListTx
-type EvmTxArgs struct { //revive:disable-line:exported
- Nonce uint64
- GasLimit uint64
- Input []byte
- GasFeeCap *big.Int
- GasPrice *big.Int
- ChainID *big.Int
- Amount *big.Int
- GasTipCap *big.Int
- To *common.Address
- Accesses *gethcore.AccessList
-}
-
-// DefaultPriorityReduction is the default amount of price values required for 1 unit of priority.
-// Because priority is `int64` while price is `big.Int`, it's necessary to scale down the range to keep it more pratical.
-// The default value is the same as the `sdk.DefaultPowerReduction`.
-var DefaultPriorityReduction = sdk.DefaultPowerReduction
-
-// GetTxPriority returns the priority of a given Ethereum tx. It relies of the
-// priority reduction global variable to calculate the tx priority given the tx
-// tip price:
-//
-// tx_priority = tip_price / priority_reduction
-func GetTxPriority(txData TxData, baseFee *big.Int) (priority int64) {
- // calculate priority based on effective gas price
- tipPrice := txData.EffectiveGasPrice(baseFee)
- // if london hardfork is not enabled, tipPrice is the gasPrice
- if baseFee != nil {
- tipPrice = new(big.Int).Sub(tipPrice, baseFee)
- }
-
- priority = math.MaxInt64
- priorityBig := new(big.Int).Quo(tipPrice, DefaultPriorityReduction.BigInt())
-
- // safety check
- if priorityBig.IsInt64() {
- priority = priorityBig.Int64()
- }
-
- return priority
-}
-
-// Failed returns if the contract execution failed in vm errors
-func (m *MsgEthereumTxResponse) Failed() bool {
- return len(m.VmError) > 0
-}
-
-// Return is a helper function to help caller distinguish between revert reason
-// and function return. Return returns the data after execution if no error occurs.
-func (m *MsgEthereumTxResponse) Return() []byte {
- if m.Failed() {
- return nil
- }
- return common.CopyBytes(m.Ret)
-}
-
-// Revert returns the concrete revert reason if the execution is aborted by `REVERT`
-// opcode. Note the reason can be nil if no data supplied with revert opcode.
-func (m *MsgEthereumTxResponse) Revert() []byte {
- if m.VmError != vm.ErrExecutionReverted.Error() {
- return nil
- }
- return common.CopyBytes(m.Ret)
-}
-
-func NewDynamicFeeTx(tx *gethcore.Transaction) (*DynamicFeeTx, error) {
- txData := &DynamicFeeTx{
- Nonce: tx.Nonce(),
- Data: tx.Data(),
- GasLimit: tx.Gas(),
- }
-
- v, r, s := tx.RawSignatureValues()
- if to := tx.To(); to != nil {
- txData.To = to.Hex()
- }
-
- if tx.Value() != nil {
- amountInt, err := eth.SafeNewIntFromBigInt(tx.Value())
- if err != nil {
- return nil, err
- }
- txData.Amount = &amountInt
- }
-
- if tx.GasFeeCap() != nil {
- gasFeeCapInt, err := eth.SafeNewIntFromBigInt(tx.GasFeeCap())
- if err != nil {
- return nil, err
- }
- txData.GasFeeCap = &gasFeeCapInt
- }
-
- if tx.GasTipCap() != nil {
- gasTipCapInt, err := eth.SafeNewIntFromBigInt(tx.GasTipCap())
- if err != nil {
- return nil, err
- }
- txData.GasTipCap = &gasTipCapInt
- }
-
- if tx.AccessList() != nil {
- al := tx.AccessList()
- txData.Accesses = NewAccessList(&al)
- }
-
- txData.SetSignatureValues(tx.ChainId(), v, r, s)
- return txData, nil
-}
-
-// TxType returns the tx type
-func (tx *DynamicFeeTx) TxType() uint8 {
- return gethcore.DynamicFeeTxType
-}
-
-// Copy returns an instance with the same field values
-func (tx *DynamicFeeTx) Copy() TxData {
- return &DynamicFeeTx{
- ChainID: tx.ChainID,
- Nonce: tx.Nonce,
- GasTipCap: tx.GasTipCap,
- GasFeeCap: tx.GasFeeCap,
- GasLimit: tx.GasLimit,
- To: tx.To,
- Amount: tx.Amount,
- Data: common.CopyBytes(tx.Data),
- Accesses: tx.Accesses,
- V: common.CopyBytes(tx.V),
- R: common.CopyBytes(tx.R),
- S: common.CopyBytes(tx.S),
- }
-}
-
-// GetChainID returns the chain id field from the DynamicFeeTx
-func (tx *DynamicFeeTx) GetChainID() *big.Int {
- if tx.ChainID == nil {
- return nil
- }
-
- return tx.ChainID.BigInt()
-}
-
-// GetAccessList returns the AccessList field.
-func (tx *DynamicFeeTx) GetAccessList() gethcore.AccessList {
- if tx.Accesses == nil {
- return nil
- }
- return *tx.Accesses.ToEthAccessList()
-}
-
-// GetData returns the a copy of the input data bytes.
-func (tx *DynamicFeeTx) GetData() []byte {
- return common.CopyBytes(tx.Data)
-}
-
-// GetGas returns the gas limit.
-func (tx *DynamicFeeTx) GetGas() uint64 {
- return tx.GasLimit
-}
-
-// GetGasPrice returns the gas fee cap field.
-func (tx *DynamicFeeTx) GetGasPrice() *big.Int {
- return tx.GetGasFeeCap()
-}
-
-// GetGasTipCap returns the gas tip cap field.
-func (tx *DynamicFeeTx) GetGasTipCap() *big.Int {
- if tx.GasTipCap == nil {
- return nil
- }
- return tx.GasTipCap.BigInt()
-}
-
-// GetGasFeeCap returns the gas fee cap field.
-func (tx *DynamicFeeTx) GetGasFeeCap() *big.Int {
- if tx.GasFeeCap == nil {
- return nil
- }
- return tx.GasFeeCap.BigInt()
-}
-
-// GetValue returns the tx amount.
-func (tx *DynamicFeeTx) GetValue() *big.Int {
- if tx.Amount == nil {
- return nil
- }
-
- return tx.Amount.BigInt()
-}
-
-// GetNonce returns the account sequence for the transaction.
-func (tx *DynamicFeeTx) GetNonce() uint64 { return tx.Nonce }
-
-// GetTo returns the pointer to the recipient address.
-func (tx *DynamicFeeTx) GetTo() *common.Address {
- if tx.To == "" {
- return nil
- }
- to := common.HexToAddress(tx.To)
- return &to
-}
-
-// AsEthereumData returns an DynamicFeeTx transaction tx from the proto-formatted
-// TxData defined on the Cosmos EVM.
-func (tx *DynamicFeeTx) AsEthereumData() gethcore.TxData {
- v, r, s := tx.GetRawSignatureValues()
- return &gethcore.DynamicFeeTx{
- ChainID: tx.GetChainID(),
- Nonce: tx.GetNonce(),
- GasTipCap: tx.GetGasTipCap(),
- GasFeeCap: tx.GetGasFeeCap(),
- Gas: tx.GetGas(),
- To: tx.GetTo(),
- Value: tx.GetValue(),
- Data: tx.GetData(),
- AccessList: tx.GetAccessList(),
- V: v,
- R: r,
- S: s,
- }
-}
-
-// GetRawSignatureValues returns the V, R, S signature values of the transaction.
-// The return values should not be modified by the caller.
-func (tx *DynamicFeeTx) GetRawSignatureValues() (v, r, s *big.Int) {
- return rawSignatureValues(tx.V, tx.R, tx.S)
-}
-
-// SetSignatureValues sets the signature values to the transaction.
-func (tx *DynamicFeeTx) SetSignatureValues(chainID, v, r, s *big.Int) {
- if v != nil {
- tx.V = v.Bytes()
- }
- if r != nil {
- tx.R = r.Bytes()
- }
- if s != nil {
- tx.S = s.Bytes()
- }
- if chainID != nil {
- chainIDInt := sdkmath.NewIntFromBigInt(chainID)
- tx.ChainID = &chainIDInt
- }
-}
-
-// Validate performs a stateless validation of the tx fields.
-func (tx DynamicFeeTx) Validate() error {
- if tx.GasTipCap == nil {
- return errorsmod.Wrap(ErrInvalidGasCap, "gas tip cap cannot nil")
- }
-
- if tx.GasFeeCap == nil {
- return errorsmod.Wrap(ErrInvalidGasCap, "gas fee cap cannot nil")
- }
-
- if tx.GasTipCap.IsNegative() {
- return errorsmod.Wrapf(ErrInvalidGasCap, "gas tip cap cannot be negative %s", tx.GasTipCap)
- }
-
- if tx.GasFeeCap.IsNegative() {
- return errorsmod.Wrapf(ErrInvalidGasCap, "gas fee cap cannot be negative %s", tx.GasFeeCap)
- }
-
- if !eth.IsValidInt256(tx.GetGasTipCap()) {
- return errorsmod.Wrap(ErrInvalidGasCap, "out of bound")
- }
-
- if !eth.IsValidInt256(tx.GetGasFeeCap()) {
- return errorsmod.Wrap(ErrInvalidGasCap, "out of bound")
- }
-
- if tx.GasFeeCap.LT(*tx.GasTipCap) {
- return errorsmod.Wrapf(
- ErrInvalidGasCap, "max priority fee per gas higher than max fee per gas (%s > %s)",
- tx.GasTipCap, tx.GasFeeCap,
- )
- }
-
- if !eth.IsValidInt256(tx.Fee()) {
- return errorsmod.Wrap(ErrInvalidGasFee, "out of bound")
- }
-
- amount := tx.GetValue()
- // Amount can be 0
- if amount != nil && amount.Sign() == -1 {
- return errorsmod.Wrapf(ErrInvalidAmount, "amount cannot be negative %s", amount)
- }
- if !eth.IsValidInt256(amount) {
- return errorsmod.Wrap(ErrInvalidAmount, "out of bound")
- }
-
- if tx.To != "" {
- if err := eth.ValidateAddress(tx.To); err != nil {
- return errorsmod.Wrap(err, "invalid to address")
- }
- }
-
- chainID := tx.GetChainID()
-
- if chainID == nil {
- return errorsmod.Wrap(
- errortypes.ErrInvalidChainID,
- "chain ID must be present on AccessList txs",
- )
- }
-
- return nil
-}
-
-// Fee returns gasprice * gaslimit.
-func (tx DynamicFeeTx) Fee() *big.Int {
- return fee(tx.GetGasFeeCap(), tx.GasLimit)
-}
-
-// Cost returns amount + gasprice * gaslimit.
-func (tx DynamicFeeTx) Cost() *big.Int {
- return cost(tx.Fee(), tx.GetValue())
-}
-
-// EffectiveGasPrice computes the effective gas price based on eip-1559 rules
-// `effectiveGasPrice = min(baseFee + tipCap, feeCap)`
-func EffectiveGasPrice(baseFee, feeCap, tipCap *big.Int) *big.Int {
- return gethmath.BigMin(new(big.Int).Add(tipCap, baseFee), feeCap)
-}
-
-// EffectiveGasPrice returns the effective gas price
-func (tx *DynamicFeeTx) EffectiveGasPrice(baseFee *big.Int) *big.Int {
- return EffectiveGasPrice(baseFee, tx.GasFeeCap.BigInt(), tx.GasTipCap.BigInt())
-}
-
-// EffectiveFee returns effective_gasprice * gaslimit.
-func (tx DynamicFeeTx) EffectiveFee(baseFee *big.Int) *big.Int {
- return fee(tx.EffectiveGasPrice(baseFee), tx.GasLimit)
-}
-
-// EffectiveCost returns amount + effective_gasprice * gaslimit.
-func (tx DynamicFeeTx) EffectiveCost(baseFee *big.Int) *big.Int {
- return cost(tx.EffectiveFee(baseFee), tx.GetValue())
-}
diff --git a/x/evm/tx.pb.go b/x/evm/tx.pb.go
deleted file mode 100644
index b86d83cfa..000000000
--- a/x/evm/tx.pb.go
+++ /dev/null
@@ -1,3263 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: eth/evm/v1/tx.proto
-
-package evm
-
-import (
- context "context"
- cosmossdk_io_math "cosmossdk.io/math"
- encoding_binary "encoding/binary"
- fmt "fmt"
- _ "github.com/cosmos/cosmos-proto"
- types "github.com/cosmos/cosmos-sdk/codec/types"
- _ "github.com/cosmos/cosmos-sdk/types/msgservice"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// MsgEthereumTx encapsulates an Ethereum transaction as an SDK message.
-type MsgEthereumTx struct {
- // data is inner transaction data of the Ethereum transaction
- Data *types.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
- // size is the encoded storage size of the transaction (DEPRECATED)
- Size_ float64 `protobuf:"fixed64,2,opt,name=size,proto3" json:"-"`
- // hash of the transaction in hex format
- Hash string `protobuf:"bytes,3,opt,name=hash,proto3" json:"hash,omitempty" rlp:"-"`
- // from is the ethereum signer address in hex format. This address value is checked
- // against the address derived from the signature (V, R, S) using the
- // secp256k1 elliptic curve
- From string `protobuf:"bytes,4,opt,name=from,proto3" json:"from,omitempty"`
-}
-
-func (m *MsgEthereumTx) Reset() { *m = MsgEthereumTx{} }
-func (m *MsgEthereumTx) String() string { return proto.CompactTextString(m) }
-func (*MsgEthereumTx) ProtoMessage() {}
-func (*MsgEthereumTx) Descriptor() ([]byte, []int) {
- return fileDescriptor_82a0bfe4f0bab953, []int{0}
-}
-func (m *MsgEthereumTx) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgEthereumTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgEthereumTx.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgEthereumTx) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgEthereumTx.Merge(m, src)
-}
-func (m *MsgEthereumTx) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgEthereumTx) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgEthereumTx.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgEthereumTx proto.InternalMessageInfo
-
-// LegacyTx is the transaction data of regular Ethereum transactions.
-// NOTE: All non-protected transactions (i.e non EIP155 signed) will fail if the
-// AllowUnprotectedTxs parameter is disabled.
-type LegacyTx struct {
- // nonce corresponds to the account nonce (transaction sequence).
- Nonce uint64 `protobuf:"varint,1,opt,name=nonce,proto3" json:"nonce,omitempty"`
- // gas_price defines the value for each gas unit
- GasPrice *cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=gas_price,json=gasPrice,proto3,customtype=cosmossdk.io/math.Int" json:"gas_price,omitempty"`
- // gas defines the gas limit defined for the transaction.
- GasLimit uint64 `protobuf:"varint,3,opt,name=gas,proto3" json:"gas,omitempty"`
- // to is the hex formatted address of the recipient
- To string `protobuf:"bytes,4,opt,name=to,proto3" json:"to,omitempty"`
- // value defines the unsigned integer value of the transaction amount.
- Amount *cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value,omitempty"`
- // data is the data payload bytes of the transaction.
- Data []byte `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"`
- // v defines the signature value
- V []byte `protobuf:"bytes,7,opt,name=v,proto3" json:"v,omitempty"`
- // r defines the signature value
- R []byte `protobuf:"bytes,8,opt,name=r,proto3" json:"r,omitempty"`
- // s define the signature value
- S []byte `protobuf:"bytes,9,opt,name=s,proto3" json:"s,omitempty"`
-}
-
-func (m *LegacyTx) Reset() { *m = LegacyTx{} }
-func (m *LegacyTx) String() string { return proto.CompactTextString(m) }
-func (*LegacyTx) ProtoMessage() {}
-func (*LegacyTx) Descriptor() ([]byte, []int) {
- return fileDescriptor_82a0bfe4f0bab953, []int{1}
-}
-func (m *LegacyTx) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *LegacyTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_LegacyTx.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *LegacyTx) XXX_Merge(src proto.Message) {
- xxx_messageInfo_LegacyTx.Merge(m, src)
-}
-func (m *LegacyTx) XXX_Size() int {
- return m.Size()
-}
-func (m *LegacyTx) XXX_DiscardUnknown() {
- xxx_messageInfo_LegacyTx.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_LegacyTx proto.InternalMessageInfo
-
-// AccessListTx is the data of EIP-2930 access list transactions.
-type AccessListTx struct {
- // chain_id of the destination EVM chain
- ChainID *cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3,customtype=cosmossdk.io/math.Int" json:"chainID"`
- // nonce corresponds to the account nonce (transaction sequence).
- Nonce uint64 `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"`
- // gas_price defines the value for each gas unit
- GasPrice *cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=gas_price,json=gasPrice,proto3,customtype=cosmossdk.io/math.Int" json:"gas_price,omitempty"`
- // gas defines the gas limit defined for the transaction.
- GasLimit uint64 `protobuf:"varint,4,opt,name=gas,proto3" json:"gas,omitempty"`
- // to is the recipient address in hex format
- To string `protobuf:"bytes,5,opt,name=to,proto3" json:"to,omitempty"`
- // value defines the unsigned integer value of the transaction amount.
- Amount *cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value,omitempty"`
- // data is the data payload bytes of the transaction.
- Data []byte `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"`
- // accesses is an array of access tuples
- Accesses AccessList `protobuf:"bytes,8,rep,name=accesses,proto3,castrepeated=AccessList" json:"accessList"`
- // v defines the signature value
- V []byte `protobuf:"bytes,9,opt,name=v,proto3" json:"v,omitempty"`
- // r defines the signature value
- R []byte `protobuf:"bytes,10,opt,name=r,proto3" json:"r,omitempty"`
- // s define the signature value
- S []byte `protobuf:"bytes,11,opt,name=s,proto3" json:"s,omitempty"`
-}
-
-func (m *AccessListTx) Reset() { *m = AccessListTx{} }
-func (m *AccessListTx) String() string { return proto.CompactTextString(m) }
-func (*AccessListTx) ProtoMessage() {}
-func (*AccessListTx) Descriptor() ([]byte, []int) {
- return fileDescriptor_82a0bfe4f0bab953, []int{2}
-}
-func (m *AccessListTx) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *AccessListTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_AccessListTx.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *AccessListTx) XXX_Merge(src proto.Message) {
- xxx_messageInfo_AccessListTx.Merge(m, src)
-}
-func (m *AccessListTx) XXX_Size() int {
- return m.Size()
-}
-func (m *AccessListTx) XXX_DiscardUnknown() {
- xxx_messageInfo_AccessListTx.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_AccessListTx proto.InternalMessageInfo
-
-// DynamicFeeTx is the data of EIP-1559 dinamic fee transactions.
-type DynamicFeeTx struct {
- // chain_id of the destination EVM chain
- ChainID *cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3,customtype=cosmossdk.io/math.Int" json:"chainID"`
- // nonce corresponds to the account nonce (transaction sequence).
- Nonce uint64 `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"`
- // gas_tip_cap defines the max value for the gas tip
- GasTipCap *cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=gas_tip_cap,json=gasTipCap,proto3,customtype=cosmossdk.io/math.Int" json:"gas_tip_cap,omitempty"`
- // gas_fee_cap defines the max value for the gas fee
- GasFeeCap *cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=gas_fee_cap,json=gasFeeCap,proto3,customtype=cosmossdk.io/math.Int" json:"gas_fee_cap,omitempty"`
- // gas defines the gas limit defined for the transaction.
- GasLimit uint64 `protobuf:"varint,5,opt,name=gas,proto3" json:"gas,omitempty"`
- // to is the hex formatted address of the recipient
- To string `protobuf:"bytes,6,opt,name=to,proto3" json:"to,omitempty"`
- // value defines the the transaction amount.
- Amount *cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value,omitempty"`
- // data is the data payload bytes of the transaction.
- Data []byte `protobuf:"bytes,8,opt,name=data,proto3" json:"data,omitempty"`
- // accesses is an array of access tuples
- Accesses AccessList `protobuf:"bytes,9,rep,name=accesses,proto3,castrepeated=AccessList" json:"accessList"`
- // v defines the signature value
- V []byte `protobuf:"bytes,10,opt,name=v,proto3" json:"v,omitempty"`
- // r defines the signature value
- R []byte `protobuf:"bytes,11,opt,name=r,proto3" json:"r,omitempty"`
- // s define the signature value
- S []byte `protobuf:"bytes,12,opt,name=s,proto3" json:"s,omitempty"`
-}
-
-func (m *DynamicFeeTx) Reset() { *m = DynamicFeeTx{} }
-func (m *DynamicFeeTx) String() string { return proto.CompactTextString(m) }
-func (*DynamicFeeTx) ProtoMessage() {}
-func (*DynamicFeeTx) Descriptor() ([]byte, []int) {
- return fileDescriptor_82a0bfe4f0bab953, []int{3}
-}
-func (m *DynamicFeeTx) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *DynamicFeeTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_DynamicFeeTx.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *DynamicFeeTx) XXX_Merge(src proto.Message) {
- xxx_messageInfo_DynamicFeeTx.Merge(m, src)
-}
-func (m *DynamicFeeTx) XXX_Size() int {
- return m.Size()
-}
-func (m *DynamicFeeTx) XXX_DiscardUnknown() {
- xxx_messageInfo_DynamicFeeTx.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_DynamicFeeTx proto.InternalMessageInfo
-
-// ExtensionOptionsEthereumTx is an extension option for ethereum transactions
-type ExtensionOptionsEthereumTx struct {
-}
-
-func (m *ExtensionOptionsEthereumTx) Reset() { *m = ExtensionOptionsEthereumTx{} }
-func (m *ExtensionOptionsEthereumTx) String() string { return proto.CompactTextString(m) }
-func (*ExtensionOptionsEthereumTx) ProtoMessage() {}
-func (*ExtensionOptionsEthereumTx) Descriptor() ([]byte, []int) {
- return fileDescriptor_82a0bfe4f0bab953, []int{4}
-}
-func (m *ExtensionOptionsEthereumTx) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *ExtensionOptionsEthereumTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_ExtensionOptionsEthereumTx.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *ExtensionOptionsEthereumTx) XXX_Merge(src proto.Message) {
- xxx_messageInfo_ExtensionOptionsEthereumTx.Merge(m, src)
-}
-func (m *ExtensionOptionsEthereumTx) XXX_Size() int {
- return m.Size()
-}
-func (m *ExtensionOptionsEthereumTx) XXX_DiscardUnknown() {
- xxx_messageInfo_ExtensionOptionsEthereumTx.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ExtensionOptionsEthereumTx proto.InternalMessageInfo
-
-// MsgEthereumTxResponse defines the Msg/EthereumTx response type.
-type MsgEthereumTxResponse struct {
- // hash of the ethereum transaction in hex format. This hash differs from the
- // Tendermint sha256 hash of the transaction bytes. See
- // https://github.com/tendermint/tendermint/issues/6539 for reference
- Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
- // logs contains the transaction hash and the proto-compatible ethereum
- // logs.
- Logs []*Log `protobuf:"bytes,2,rep,name=logs,proto3" json:"logs,omitempty"`
- // ret is the returned data from evm function (result or data supplied with revert
- // opcode)
- Ret []byte `protobuf:"bytes,3,opt,name=ret,proto3" json:"ret,omitempty"`
- // vm_error is the error returned by vm execution
- VmError string `protobuf:"bytes,4,opt,name=vm_error,json=vmError,proto3" json:"vm_error,omitempty"`
- // gas_used specifies how much gas was consumed by the transaction
- GasUsed uint64 `protobuf:"varint,5,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"`
-}
-
-func (m *MsgEthereumTxResponse) Reset() { *m = MsgEthereumTxResponse{} }
-func (m *MsgEthereumTxResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgEthereumTxResponse) ProtoMessage() {}
-func (*MsgEthereumTxResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_82a0bfe4f0bab953, []int{5}
-}
-func (m *MsgEthereumTxResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgEthereumTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgEthereumTxResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgEthereumTxResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgEthereumTxResponse.Merge(m, src)
-}
-func (m *MsgEthereumTxResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgEthereumTxResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgEthereumTxResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgEthereumTxResponse proto.InternalMessageInfo
-
-// MsgUpdateParams defines a Msg for updating the x/evm module parameters.
-type MsgUpdateParams struct {
- // authority is the address of the governance account.
- Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"`
- // params defines the x/evm parameters to update.
- // NOTE: All parameters must be supplied.
- Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
-}
-
-func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} }
-func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) }
-func (*MsgUpdateParams) ProtoMessage() {}
-func (*MsgUpdateParams) Descriptor() ([]byte, []int) {
- return fileDescriptor_82a0bfe4f0bab953, []int{6}
-}
-func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgUpdateParams) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgUpdateParams.Merge(m, src)
-}
-func (m *MsgUpdateParams) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgUpdateParams) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo
-
-func (m *MsgUpdateParams) GetAuthority() string {
- if m != nil {
- return m.Authority
- }
- return ""
-}
-
-func (m *MsgUpdateParams) GetParams() Params {
- if m != nil {
- return m.Params
- }
- return Params{}
-}
-
-// MsgUpdateParamsResponse defines the response structure for executing a
-// MsgUpdateParams message.
-type MsgUpdateParamsResponse struct {
-}
-
-func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} }
-func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgUpdateParamsResponse) ProtoMessage() {}
-func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_82a0bfe4f0bab953, []int{7}
-}
-func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src)
-}
-func (m *MsgUpdateParamsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*MsgEthereumTx)(nil), "eth.evm.v1.MsgEthereumTx")
- proto.RegisterType((*LegacyTx)(nil), "eth.evm.v1.LegacyTx")
- proto.RegisterType((*AccessListTx)(nil), "eth.evm.v1.AccessListTx")
- proto.RegisterType((*DynamicFeeTx)(nil), "eth.evm.v1.DynamicFeeTx")
- proto.RegisterType((*ExtensionOptionsEthereumTx)(nil), "eth.evm.v1.ExtensionOptionsEthereumTx")
- proto.RegisterType((*MsgEthereumTxResponse)(nil), "eth.evm.v1.MsgEthereumTxResponse")
- proto.RegisterType((*MsgUpdateParams)(nil), "eth.evm.v1.MsgUpdateParams")
- proto.RegisterType((*MsgUpdateParamsResponse)(nil), "eth.evm.v1.MsgUpdateParamsResponse")
-}
-
-func init() { proto.RegisterFile("eth/evm/v1/tx.proto", fileDescriptor_82a0bfe4f0bab953) }
-
-var fileDescriptor_82a0bfe4f0bab953 = []byte{
- // 956 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x95, 0xbf, 0x6f, 0x23, 0x45,
- 0x14, 0xc7, 0xbd, 0xf6, 0xfa, 0xd7, 0xd8, 0xe4, 0xd0, 0x90, 0x53, 0xd6, 0xe6, 0xe4, 0x35, 0x9b,
- 0xc6, 0x42, 0xca, 0x2e, 0x17, 0x24, 0xa4, 0x8b, 0x44, 0x11, 0x5f, 0x72, 0xe8, 0x50, 0x02, 0xd1,
- 0xe2, 0x34, 0x34, 0xd6, 0x64, 0x3d, 0x19, 0x8f, 0xf0, 0xee, 0xac, 0x76, 0xc6, 0x96, 0x4d, 0x79,
- 0x15, 0x12, 0x05, 0x20, 0x7a, 0x44, 0x4d, 0x45, 0x71, 0x05, 0xff, 0x01, 0x27, 0xaa, 0x13, 0x34,
- 0x88, 0xc2, 0x20, 0x07, 0x09, 0x29, 0x25, 0x05, 0x35, 0x9a, 0x99, 0x75, 0x6c, 0xdf, 0xc9, 0x01,
- 0x22, 0x74, 0xdd, 0xbc, 0x79, 0x3f, 0xe6, 0xcd, 0xf7, 0xb3, 0xfb, 0x06, 0xbc, 0x82, 0x45, 0xdf,
- 0xc3, 0xa3, 0xd0, 0x1b, 0xdd, 0xf5, 0xc4, 0xd8, 0x8d, 0x13, 0x26, 0x18, 0x04, 0x58, 0xf4, 0x5d,
- 0x3c, 0x0a, 0xdd, 0xd1, 0xdd, 0xfa, 0x56, 0xc0, 0x78, 0xc8, 0xb8, 0x17, 0x72, 0x22, 0x63, 0x42,
- 0x4e, 0x74, 0x50, 0xbd, 0xa6, 0x1d, 0x5d, 0x65, 0x79, 0xda, 0x48, 0x5d, 0x9b, 0x4b, 0x45, 0x65,
- 0x99, 0x74, 0x97, 0x30, 0xc2, 0x74, 0xb4, 0x5c, 0xa5, 0xbb, 0x77, 0x08, 0x63, 0x64, 0x80, 0x3d,
- 0x14, 0x53, 0x0f, 0x45, 0x11, 0x13, 0x48, 0x50, 0x16, 0xcd, 0x2b, 0xd5, 0x52, 0xaf, 0xb2, 0xce,
- 0x86, 0xe7, 0x1e, 0x8a, 0x26, 0xda, 0xe5, 0x7c, 0x66, 0x80, 0x97, 0x8e, 0x39, 0x39, 0x14, 0x7d,
- 0x9c, 0xe0, 0x61, 0xd8, 0x19, 0xc3, 0x16, 0x30, 0x7b, 0x48, 0x20, 0xcb, 0x68, 0x1a, 0xad, 0xca,
- 0xee, 0xa6, 0xab, 0x73, 0xdd, 0x79, 0xae, 0xbb, 0x1f, 0x4d, 0x7c, 0x15, 0x01, 0x6b, 0xc0, 0xe4,
- 0xf4, 0x63, 0x6c, 0x65, 0x9b, 0x46, 0xcb, 0x68, 0xe7, 0x2f, 0xa7, 0xb6, 0xb1, 0xe3, 0xab, 0x2d,
- 0x68, 0x03, 0xb3, 0x8f, 0x78, 0xdf, 0xca, 0x35, 0x8d, 0x56, 0xb9, 0x5d, 0xf9, 0x73, 0x6a, 0x17,
- 0x93, 0x41, 0xbc, 0xe7, 0xec, 0x38, 0xbe, 0x72, 0x40, 0x08, 0xcc, 0xf3, 0x84, 0x85, 0x96, 0x29,
- 0x03, 0x7c, 0xb5, 0xde, 0x33, 0x3f, 0xf9, 0xda, 0xce, 0x38, 0x5f, 0x64, 0x41, 0xe9, 0x08, 0x13,
- 0x14, 0x4c, 0x3a, 0x63, 0xb8, 0x09, 0xf2, 0x11, 0x8b, 0x02, 0xac, 0xba, 0x31, 0x7d, 0x6d, 0xc0,
- 0xb7, 0x40, 0x99, 0x20, 0xa9, 0x19, 0x0d, 0xf4, 0xe9, 0xe5, 0x76, 0xed, 0x97, 0xa9, 0x7d, 0x5b,
- 0xcb, 0xc7, 0x7b, 0x1f, 0xb9, 0x94, 0x79, 0x21, 0x12, 0x7d, 0xf7, 0x61, 0x24, 0xfc, 0x12, 0x41,
- 0xfc, 0x44, 0x86, 0xc2, 0x06, 0xc8, 0x11, 0xc4, 0x55, 0x53, 0x66, 0xbb, 0x3a, 0x9b, 0xda, 0xa5,
- 0x77, 0x10, 0x3f, 0xa2, 0x21, 0x15, 0xbe, 0x74, 0xc0, 0x0d, 0x90, 0x15, 0x2c, 0x6d, 0x29, 0x2b,
- 0x18, 0xbc, 0x07, 0xf2, 0x23, 0x34, 0x18, 0x62, 0x2b, 0xaf, 0xce, 0xd8, 0x5e, 0x7b, 0xc6, 0x6c,
- 0x6a, 0x17, 0xf6, 0x43, 0x36, 0x8c, 0x84, 0xaf, 0x33, 0xe4, 0xfd, 0x94, 0x8a, 0x85, 0xa6, 0xd1,
- 0xaa, 0xa6, 0x7a, 0x55, 0x81, 0x31, 0xb2, 0x8a, 0x6a, 0xc3, 0x18, 0x49, 0x2b, 0xb1, 0x4a, 0xda,
- 0x4a, 0xa4, 0xc5, 0xad, 0xb2, 0xb6, 0xf8, 0xde, 0x86, 0x54, 0xe2, 0x87, 0xc7, 0x3b, 0x85, 0xce,
- 0xf8, 0x00, 0x09, 0xe4, 0x7c, 0x97, 0x03, 0xd5, 0xfd, 0x20, 0xc0, 0x9c, 0x1f, 0x51, 0x2e, 0x3a,
- 0x63, 0xf8, 0x2e, 0x28, 0x05, 0x7d, 0x44, 0xa3, 0x2e, 0xed, 0x29, 0x69, 0xca, 0x6d, 0xef, 0xba,
- 0xe6, 0x8a, 0xf7, 0x65, 0xf0, 0xc3, 0x83, 0xcb, 0xa9, 0x5d, 0x0c, 0xf4, 0xd2, 0x4f, 0x17, 0xbd,
- 0x85, 0xc6, 0xd9, 0xb5, 0x1a, 0xe7, 0xfe, 0xb3, 0xc6, 0xe6, 0xf5, 0x1a, 0xe7, 0x9f, 0xd7, 0xb8,
- 0x70, 0x63, 0x8d, 0x8b, 0x4b, 0x1a, 0x9f, 0x82, 0x12, 0x52, 0x42, 0x61, 0x6e, 0x95, 0x9a, 0xb9,
- 0x56, 0x65, 0x77, 0xcb, 0x5d, 0xfc, 0x87, 0xae, 0x16, 0xb1, 0x33, 0x8c, 0x07, 0xb8, 0xdd, 0x7c,
- 0x32, 0xb5, 0x33, 0x97, 0x53, 0x1b, 0xa0, 0x2b, 0x65, 0xbf, 0xf9, 0xd5, 0x06, 0x0b, 0x9d, 0xfd,
- 0xab, 0x52, 0x1a, 0x5d, 0x79, 0x05, 0x1d, 0x58, 0x41, 0x57, 0x59, 0x87, 0xee, 0xaf, 0x1c, 0xa8,
- 0x1e, 0x4c, 0x22, 0x14, 0xd2, 0xe0, 0x01, 0xc6, 0x2f, 0x04, 0xdd, 0x3d, 0x50, 0x91, 0xe8, 0x04,
- 0x8d, 0xbb, 0x01, 0x8a, 0xff, 0x19, 0x9e, 0x04, 0xdd, 0xa1, 0xf1, 0x7d, 0x14, 0xcf, 0x53, 0xcf,
- 0x31, 0x56, 0xa9, 0xe6, 0xbf, 0x49, 0x7d, 0x80, 0xb1, 0x4c, 0x4d, 0xc1, 0xe7, 0xaf, 0x07, 0x5f,
- 0x78, 0x1e, 0x7c, 0xf1, 0xc6, 0xe0, 0x4b, 0x6b, 0xc0, 0x97, 0xff, 0x67, 0xf0, 0x60, 0x05, 0x7c,
- 0x65, 0x05, 0x7c, 0x75, 0x1d, 0x78, 0x07, 0xd4, 0x0f, 0xc7, 0x02, 0x47, 0x9c, 0xb2, 0xe8, 0xfd,
- 0x58, 0x8d, 0xe3, 0xc5, 0x94, 0x4d, 0x67, 0xdd, 0x57, 0x06, 0xb8, 0xbd, 0x32, 0x7d, 0x7d, 0xcc,
- 0x63, 0x16, 0x71, 0x75, 0x45, 0x35, 0x40, 0x0d, 0x3d, 0x1f, 0xd5, 0xcc, 0xdc, 0x06, 0xe6, 0x80,
- 0x11, 0x6e, 0x65, 0xd5, 0xf5, 0x6e, 0x2d, 0x5f, 0xef, 0x88, 0x11, 0x5f, 0x39, 0xe1, 0xcb, 0x20,
- 0x97, 0x60, 0xa1, 0xa0, 0x57, 0x7d, 0xb9, 0x84, 0x35, 0x50, 0x1a, 0x85, 0x5d, 0x9c, 0x24, 0x2c,
- 0x49, 0x67, 0x5b, 0x71, 0x14, 0x1e, 0x4a, 0x53, 0xba, 0x24, 0xee, 0x21, 0xc7, 0x3d, 0x0d, 0xce,
- 0x2f, 0x12, 0xc4, 0x4f, 0x39, 0xee, 0xa5, 0x0d, 0x7e, 0x6a, 0x80, 0x5b, 0xc7, 0x9c, 0x9c, 0xc6,
- 0x3d, 0x24, 0xf0, 0x09, 0x4a, 0x50, 0xc8, 0xe5, 0x64, 0x40, 0x43, 0xd1, 0x67, 0x09, 0x15, 0x93,
- 0xf4, 0x0b, 0xb6, 0x7e, 0x7c, 0xbc, 0xb3, 0x99, 0x3e, 0x5e, 0xfb, 0xbd, 0x5e, 0x82, 0x39, 0xff,
- 0x40, 0x24, 0x34, 0x22, 0xfe, 0x22, 0x14, 0xbe, 0x01, 0x0a, 0xb1, 0xaa, 0xa0, 0xbe, 0xd6, 0xca,
- 0x2e, 0x5c, 0xbe, 0x80, 0xae, 0xdd, 0x36, 0x25, 0x1a, 0x3f, 0x8d, 0xdb, 0xdb, 0x78, 0xf4, 0xc7,
- 0xb7, 0xaf, 0x2f, 0x2a, 0x38, 0x35, 0xb0, 0xf5, 0x4c, 0x33, 0x73, 0xbd, 0x76, 0xbf, 0x37, 0x40,
- 0xee, 0x98, 0x13, 0x18, 0x01, 0xb0, 0xf4, 0x96, 0xd5, 0x96, 0x8f, 0x58, 0x11, 0xba, 0xfe, 0xda,
- 0x5a, 0xd7, 0xbc, 0xa6, 0xe3, 0x3c, 0xfa, 0xe9, 0xf7, 0x2f, 0xb3, 0x77, 0x9c, 0xba, 0x17, 0xd1,
- 0x33, 0x9a, 0x0c, 0xaf, 0x1e, 0xe3, 0x34, 0xb4, 0x2b, 0xc6, 0xf0, 0x04, 0x54, 0x57, 0xc4, 0x79,
- 0xf5, 0x99, 0xb2, 0xcb, 0xce, 0xfa, 0xf6, 0x35, 0xce, 0xf9, 0xa9, 0xed, 0xb7, 0x9f, 0xcc, 0x1a,
- 0xc6, 0xd3, 0x59, 0xc3, 0xf8, 0x6d, 0xd6, 0x30, 0x3e, 0xbf, 0x68, 0x64, 0x9e, 0x5e, 0x34, 0x32,
- 0x3f, 0x5f, 0x34, 0x32, 0x1f, 0x6e, 0x13, 0x2a, 0xfa, 0xc3, 0x33, 0x37, 0x60, 0xa1, 0xf7, 0x9e,
- 0xea, 0x48, 0xcd, 0x86, 0x79, 0x77, 0x63, 0xd9, 0xdf, 0x59, 0x41, 0x3d, 0xd4, 0x6f, 0xfe, 0x1d,
- 0x00, 0x00, 0xff, 0xff, 0x10, 0x4e, 0x86, 0x00, 0x93, 0x08, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// MsgClient is the client API for Msg service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type MsgClient interface {
- // EthereumTx defines a method submitting Ethereum transactions.
- EthereumTx(ctx context.Context, in *MsgEthereumTx, opts ...grpc.CallOption) (*MsgEthereumTxResponse, error)
- // UpdateParams defined a governance operation for updating the x/evm module parameters.
- // The authority is hard-coded to the Cosmos SDK x/gov module account
- UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
-}
-
-type msgClient struct {
- cc grpc1.ClientConn
-}
-
-func NewMsgClient(cc grpc1.ClientConn) MsgClient {
- return &msgClient{cc}
-}
-
-func (c *msgClient) EthereumTx(ctx context.Context, in *MsgEthereumTx, opts ...grpc.CallOption) (*MsgEthereumTxResponse, error) {
- out := new(MsgEthereumTxResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Msg/EthereumTx", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) {
- out := new(MsgUpdateParamsResponse)
- err := c.cc.Invoke(ctx, "/eth.evm.v1.Msg/UpdateParams", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// MsgServer is the server API for Msg service.
-type MsgServer interface {
- // EthereumTx defines a method submitting Ethereum transactions.
- EthereumTx(context.Context, *MsgEthereumTx) (*MsgEthereumTxResponse, error)
- // UpdateParams defined a governance operation for updating the x/evm module parameters.
- // The authority is hard-coded to the Cosmos SDK x/gov module account
- UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
-}
-
-// UnimplementedMsgServer can be embedded to have forward compatible implementations.
-type UnimplementedMsgServer struct {
-}
-
-func (*UnimplementedMsgServer) EthereumTx(ctx context.Context, req *MsgEthereumTx) (*MsgEthereumTxResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EthereumTx not implemented")
-}
-func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
-}
-
-func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
- s.RegisterService(&_Msg_serviceDesc, srv)
-}
-
-func _Msg_EthereumTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgEthereumTx)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).EthereumTx(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Msg/EthereumTx",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).EthereumTx(ctx, req.(*MsgEthereumTx))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgUpdateParams)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).UpdateParams(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/eth.evm.v1.Msg/UpdateParams",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Msg_serviceDesc = grpc.ServiceDesc{
- ServiceName: "eth.evm.v1.Msg",
- HandlerType: (*MsgServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "EthereumTx",
- Handler: _Msg_EthereumTx_Handler,
- },
- {
- MethodName: "UpdateParams",
- Handler: _Msg_UpdateParams_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "eth/evm/v1/tx.proto",
-}
-
-func (m *MsgEthereumTx) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgEthereumTx) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgEthereumTx) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.From) > 0 {
- i -= len(m.From)
- copy(dAtA[i:], m.From)
- i = encodeVarintTx(dAtA, i, uint64(len(m.From)))
- i--
- dAtA[i] = 0x22
- }
- if len(m.Hash) > 0 {
- i -= len(m.Hash)
- copy(dAtA[i:], m.Hash)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Hash)))
- i--
- dAtA[i] = 0x1a
- }
- if m.Size_ != 0 {
- i -= 8
- encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Size_))))
- i--
- dAtA[i] = 0x11
- }
- if m.Data != nil {
- {
- size, err := m.Data.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *LegacyTx) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LegacyTx) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *LegacyTx) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.S) > 0 {
- i -= len(m.S)
- copy(dAtA[i:], m.S)
- i = encodeVarintTx(dAtA, i, uint64(len(m.S)))
- i--
- dAtA[i] = 0x4a
- }
- if len(m.R) > 0 {
- i -= len(m.R)
- copy(dAtA[i:], m.R)
- i = encodeVarintTx(dAtA, i, uint64(len(m.R)))
- i--
- dAtA[i] = 0x42
- }
- if len(m.V) > 0 {
- i -= len(m.V)
- copy(dAtA[i:], m.V)
- i = encodeVarintTx(dAtA, i, uint64(len(m.V)))
- i--
- dAtA[i] = 0x3a
- }
- if len(m.Data) > 0 {
- i -= len(m.Data)
- copy(dAtA[i:], m.Data)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Data)))
- i--
- dAtA[i] = 0x32
- }
- if m.Amount != nil {
- {
- size := m.Amount.Size()
- i -= size
- if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x2a
- }
- if len(m.To) > 0 {
- i -= len(m.To)
- copy(dAtA[i:], m.To)
- i = encodeVarintTx(dAtA, i, uint64(len(m.To)))
- i--
- dAtA[i] = 0x22
- }
- if m.GasLimit != 0 {
- i = encodeVarintTx(dAtA, i, uint64(m.GasLimit))
- i--
- dAtA[i] = 0x18
- }
- if m.GasPrice != nil {
- {
- size := m.GasPrice.Size()
- i -= size
- if _, err := m.GasPrice.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- if m.Nonce != 0 {
- i = encodeVarintTx(dAtA, i, uint64(m.Nonce))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func (m *AccessListTx) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AccessListTx) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *AccessListTx) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.S) > 0 {
- i -= len(m.S)
- copy(dAtA[i:], m.S)
- i = encodeVarintTx(dAtA, i, uint64(len(m.S)))
- i--
- dAtA[i] = 0x5a
- }
- if len(m.R) > 0 {
- i -= len(m.R)
- copy(dAtA[i:], m.R)
- i = encodeVarintTx(dAtA, i, uint64(len(m.R)))
- i--
- dAtA[i] = 0x52
- }
- if len(m.V) > 0 {
- i -= len(m.V)
- copy(dAtA[i:], m.V)
- i = encodeVarintTx(dAtA, i, uint64(len(m.V)))
- i--
- dAtA[i] = 0x4a
- }
- if len(m.Accesses) > 0 {
- for iNdEx := len(m.Accesses) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Accesses[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x42
- }
- }
- if len(m.Data) > 0 {
- i -= len(m.Data)
- copy(dAtA[i:], m.Data)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Data)))
- i--
- dAtA[i] = 0x3a
- }
- if m.Amount != nil {
- {
- size := m.Amount.Size()
- i -= size
- if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x32
- }
- if len(m.To) > 0 {
- i -= len(m.To)
- copy(dAtA[i:], m.To)
- i = encodeVarintTx(dAtA, i, uint64(len(m.To)))
- i--
- dAtA[i] = 0x2a
- }
- if m.GasLimit != 0 {
- i = encodeVarintTx(dAtA, i, uint64(m.GasLimit))
- i--
- dAtA[i] = 0x20
- }
- if m.GasPrice != nil {
- {
- size := m.GasPrice.Size()
- i -= size
- if _, err := m.GasPrice.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- if m.Nonce != 0 {
- i = encodeVarintTx(dAtA, i, uint64(m.Nonce))
- i--
- dAtA[i] = 0x10
- }
- if m.ChainID != nil {
- {
- size := m.ChainID.Size()
- i -= size
- if _, err := m.ChainID.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *DynamicFeeTx) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *DynamicFeeTx) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *DynamicFeeTx) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.S) > 0 {
- i -= len(m.S)
- copy(dAtA[i:], m.S)
- i = encodeVarintTx(dAtA, i, uint64(len(m.S)))
- i--
- dAtA[i] = 0x62
- }
- if len(m.R) > 0 {
- i -= len(m.R)
- copy(dAtA[i:], m.R)
- i = encodeVarintTx(dAtA, i, uint64(len(m.R)))
- i--
- dAtA[i] = 0x5a
- }
- if len(m.V) > 0 {
- i -= len(m.V)
- copy(dAtA[i:], m.V)
- i = encodeVarintTx(dAtA, i, uint64(len(m.V)))
- i--
- dAtA[i] = 0x52
- }
- if len(m.Accesses) > 0 {
- for iNdEx := len(m.Accesses) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Accesses[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x4a
- }
- }
- if len(m.Data) > 0 {
- i -= len(m.Data)
- copy(dAtA[i:], m.Data)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Data)))
- i--
- dAtA[i] = 0x42
- }
- if m.Amount != nil {
- {
- size := m.Amount.Size()
- i -= size
- if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x3a
- }
- if len(m.To) > 0 {
- i -= len(m.To)
- copy(dAtA[i:], m.To)
- i = encodeVarintTx(dAtA, i, uint64(len(m.To)))
- i--
- dAtA[i] = 0x32
- }
- if m.GasLimit != 0 {
- i = encodeVarintTx(dAtA, i, uint64(m.GasLimit))
- i--
- dAtA[i] = 0x28
- }
- if m.GasFeeCap != nil {
- {
- size := m.GasFeeCap.Size()
- i -= size
- if _, err := m.GasFeeCap.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x22
- }
- if m.GasTipCap != nil {
- {
- size := m.GasTipCap.Size()
- i -= size
- if _, err := m.GasTipCap.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- if m.Nonce != 0 {
- i = encodeVarintTx(dAtA, i, uint64(m.Nonce))
- i--
- dAtA[i] = 0x10
- }
- if m.ChainID != nil {
- {
- size := m.ChainID.Size()
- i -= size
- if _, err := m.ChainID.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *ExtensionOptionsEthereumTx) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ExtensionOptionsEthereumTx) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *ExtensionOptionsEthereumTx) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgEthereumTxResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgEthereumTxResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgEthereumTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.GasUsed != 0 {
- i = encodeVarintTx(dAtA, i, uint64(m.GasUsed))
- i--
- dAtA[i] = 0x28
- }
- if len(m.VmError) > 0 {
- i -= len(m.VmError)
- copy(dAtA[i:], m.VmError)
- i = encodeVarintTx(dAtA, i, uint64(len(m.VmError)))
- i--
- dAtA[i] = 0x22
- }
- if len(m.Ret) > 0 {
- i -= len(m.Ret)
- copy(dAtA[i:], m.Ret)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Ret)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.Logs) > 0 {
- for iNdEx := len(m.Logs) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Logs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- }
- if len(m.Hash) > 0 {
- i -= len(m.Hash)
- copy(dAtA[i:], m.Hash)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Hash)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Authority) > 0 {
- i -= len(m.Authority)
- copy(dAtA[i:], m.Authority)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Authority)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
- offset -= sovTx(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *MsgEthereumTx) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.Data != nil {
- l = m.Data.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.Size_ != 0 {
- n += 9
- }
- l = len(m.Hash)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.From)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *LegacyTx) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.Nonce != 0 {
- n += 1 + sovTx(uint64(m.Nonce))
- }
- if m.GasPrice != nil {
- l = m.GasPrice.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.GasLimit != 0 {
- n += 1 + sovTx(uint64(m.GasLimit))
- }
- l = len(m.To)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if m.Amount != nil {
- l = m.Amount.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.Data)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.V)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.R)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.S)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *AccessListTx) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.ChainID != nil {
- l = m.ChainID.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.Nonce != 0 {
- n += 1 + sovTx(uint64(m.Nonce))
- }
- if m.GasPrice != nil {
- l = m.GasPrice.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.GasLimit != 0 {
- n += 1 + sovTx(uint64(m.GasLimit))
- }
- l = len(m.To)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if m.Amount != nil {
- l = m.Amount.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.Data)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if len(m.Accesses) > 0 {
- for _, e := range m.Accesses {
- l = e.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- }
- l = len(m.V)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.R)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.S)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *DynamicFeeTx) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.ChainID != nil {
- l = m.ChainID.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.Nonce != 0 {
- n += 1 + sovTx(uint64(m.Nonce))
- }
- if m.GasTipCap != nil {
- l = m.GasTipCap.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.GasFeeCap != nil {
- l = m.GasFeeCap.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.GasLimit != 0 {
- n += 1 + sovTx(uint64(m.GasLimit))
- }
- l = len(m.To)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if m.Amount != nil {
- l = m.Amount.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.Data)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if len(m.Accesses) > 0 {
- for _, e := range m.Accesses {
- l = e.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- }
- l = len(m.V)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.R)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.S)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *ExtensionOptionsEthereumTx) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgEthereumTxResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Hash)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if len(m.Logs) > 0 {
- for _, e := range m.Logs {
- l = e.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- }
- l = len(m.Ret)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.VmError)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if m.GasUsed != 0 {
- n += 1 + sovTx(uint64(m.GasUsed))
- }
- return n
-}
-
-func (m *MsgUpdateParams) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Authority)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = m.Params.Size()
- n += 1 + l + sovTx(uint64(l))
- return n
-}
-
-func (m *MsgUpdateParamsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func sovTx(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozTx(x uint64) (n int) {
- return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *MsgEthereumTx) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgEthereumTx: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgEthereumTx: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Data == nil {
- m.Data = &types.Any{}
- }
- if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 1 {
- return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType)
- }
- var v uint64
- if (iNdEx + 8) > l {
- return io.ErrUnexpectedEOF
- }
- v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:]))
- iNdEx += 8
- m.Size_ = float64(math.Float64frombits(v))
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Hash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field From", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.From = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LegacyTx) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LegacyTx: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LegacyTx: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType)
- }
- m.Nonce = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Nonce |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasPrice", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.GasPrice = &v
- if err := m.GasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType)
- }
- m.GasLimit = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.GasLimit |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field To", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.To = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.Amount = &v
- if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
- if m.Data == nil {
- m.Data = []byte{}
- }
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field V", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.V = append(m.V[:0], dAtA[iNdEx:postIndex]...)
- if m.V == nil {
- m.V = []byte{}
- }
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field R", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.R = append(m.R[:0], dAtA[iNdEx:postIndex]...)
- if m.R == nil {
- m.R = []byte{}
- }
- iNdEx = postIndex
- case 9:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field S", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.S = append(m.S[:0], dAtA[iNdEx:postIndex]...)
- if m.S == nil {
- m.S = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AccessListTx) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AccessListTx: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AccessListTx: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ChainID", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.ChainID = &v
- if err := m.ChainID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType)
- }
- m.Nonce = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Nonce |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasPrice", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.GasPrice = &v
- if err := m.GasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType)
- }
- m.GasLimit = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.GasLimit |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field To", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.To = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.Amount = &v
- if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
- if m.Data == nil {
- m.Data = []byte{}
- }
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Accesses", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Accesses = append(m.Accesses, AccessTuple{})
- if err := m.Accesses[len(m.Accesses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 9:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field V", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.V = append(m.V[:0], dAtA[iNdEx:postIndex]...)
- if m.V == nil {
- m.V = []byte{}
- }
- iNdEx = postIndex
- case 10:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field R", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.R = append(m.R[:0], dAtA[iNdEx:postIndex]...)
- if m.R == nil {
- m.R = []byte{}
- }
- iNdEx = postIndex
- case 11:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field S", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.S = append(m.S[:0], dAtA[iNdEx:postIndex]...)
- if m.S == nil {
- m.S = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: DynamicFeeTx: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: DynamicFeeTx: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ChainID", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.ChainID = &v
- if err := m.ChainID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType)
- }
- m.Nonce = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Nonce |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasTipCap", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.GasTipCap = &v
- if err := m.GasTipCap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasFeeCap", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.GasFeeCap = &v
- if err := m.GasFeeCap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType)
- }
- m.GasLimit = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.GasLimit |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field To", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.To = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v cosmossdk_io_math.Int
- m.Amount = &v
- if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
- if m.Data == nil {
- m.Data = []byte{}
- }
- iNdEx = postIndex
- case 9:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Accesses", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Accesses = append(m.Accesses, AccessTuple{})
- if err := m.Accesses[len(m.Accesses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 10:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field V", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.V = append(m.V[:0], dAtA[iNdEx:postIndex]...)
- if m.V == nil {
- m.V = []byte{}
- }
- iNdEx = postIndex
- case 11:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field R", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.R = append(m.R[:0], dAtA[iNdEx:postIndex]...)
- if m.R == nil {
- m.R = []byte{}
- }
- iNdEx = postIndex
- case 12:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field S", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.S = append(m.S[:0], dAtA[iNdEx:postIndex]...)
- if m.S == nil {
- m.S = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *ExtensionOptionsEthereumTx) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ExtensionOptionsEthereumTx: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ExtensionOptionsEthereumTx: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgEthereumTxResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgEthereumTxResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgEthereumTxResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Hash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Logs", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Logs = append(m.Logs, &Log{})
- if err := m.Logs[len(m.Logs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Ret", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + byteLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Ret = append(m.Ret[:0], dAtA[iNdEx:postIndex]...)
- if m.Ret == nil {
- m.Ret = []byte{}
- }
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field VmError", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.VmError = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field GasUsed", wireType)
- }
- m.GasUsed = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.GasUsed |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Authority = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipTx(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthTx
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupTx
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthTx
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowTx = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/evm/tx.pb.gw.go b/x/evm/tx.pb.gw.go
deleted file mode 100644
index 2a54a3b55..000000000
--- a/x/evm/tx.pb.gw.go
+++ /dev/null
@@ -1,171 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: eth/evm/v1/tx.proto
-
-/*
-Package evm is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package evm
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-var (
- filter_Msg_EthereumTx_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_EthereumTx_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgEthereumTx
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_EthereumTx_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.EthereumTx(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_EthereumTx_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgEthereumTx
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_EthereumTx_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.EthereumTx(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux".
-// UnaryRPC :call MsgServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead.
-func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error {
-
- mux.Handle("POST", pattern_Msg_EthereumTx_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_EthereumTx_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_EthereumTx_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterMsgHandler(ctx, mux, conn)
-}
-
-// RegisterMsgHandler registers the http handlers for service Msg to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn))
-}
-
-// RegisterMsgHandlerClient registers the http handlers for service Msg
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "MsgClient" to call the correct interceptors.
-func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error {
-
- mux.Handle("POST", pattern_Msg_EthereumTx_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_EthereumTx_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_EthereumTx_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Msg_EthereumTx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "evm", "v1", "ethereum_tx"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Msg_EthereumTx_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/evm/tx_data.go b/x/evm/tx_data.go
deleted file mode 100644
index ddf6a355e..000000000
--- a/x/evm/tx_data.go
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "math/big"
-
- "github.com/ethereum/go-ethereum/common"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-)
-
-var (
- _ TxData = &LegacyTx{}
- _ TxData = &AccessListTx{}
- _ TxData = &DynamicFeeTx{}
-)
-
-// TxData implements the Ethereum transaction tx structure. It is used
-// solely as intended in Ethereum abiding by the protocol.
-type TxData interface {
- // TODO: embed ethtypes.TxData. See https://github.com/ethereum/go-ethereum/issues/23154
-
- TxType() byte
- Copy() TxData
- GetChainID() *big.Int
- GetAccessList() gethcore.AccessList
- GetData() []byte
- GetNonce() uint64
- GetGas() uint64
- GetGasPrice() *big.Int
- GetGasTipCap() *big.Int
- GetGasFeeCap() *big.Int
- GetValue() *big.Int
- GetTo() *common.Address
-
- GetRawSignatureValues() (v, r, s *big.Int)
- SetSignatureValues(chainID, v, r, s *big.Int)
-
- AsEthereumData() gethcore.TxData
- Validate() error
-
- // static fee
- Fee() *big.Int
- Cost() *big.Int
-
- // effective gasPrice/fee/cost according to current base fee
- EffectiveGasPrice(baseFee *big.Int) *big.Int
- EffectiveFee(baseFee *big.Int) *big.Int
- EffectiveCost(baseFee *big.Int) *big.Int
-}
-
-// NOTE: All non-protected transactions (i.e non EIP155 signed) will fail if the
-// AllowUnprotectedTxs parameter is disabled.
-func NewTxDataFromTx(tx *gethcore.Transaction) (TxData, error) {
- var txData TxData
- var err error
- switch tx.Type() {
- case gethcore.DynamicFeeTxType:
- txData, err = NewDynamicFeeTx(tx)
- case gethcore.AccessListTxType:
- txData, err = newAccessListTx(tx)
- default:
- txData, err = NewLegacyTx(tx)
- }
- if err != nil {
- return nil, err
- }
-
- return txData, nil
-}
-
-// DeriveChainID derives the chain id from the given v parameter.
-//
-// CONTRACT: v value is either:
-//
-// - {0,1} + CHAIN_ID * 2 + 35, if EIP155 is used
-// - {0,1} + 27, otherwise
-//
-// Ref: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md
-func DeriveChainID(v *big.Int) *big.Int {
- if v == nil || v.Sign() < 1 {
- return nil
- }
-
- if v.BitLen() <= 64 {
- v := v.Uint64()
- if v == 27 || v == 28 {
- return new(big.Int)
- }
-
- if v < 35 {
- return nil
- }
-
- // V MUST be of the form {0,1} + CHAIN_ID * 2 + 35
- return new(big.Int).SetUint64((v - 35) / 2)
- }
- v = new(big.Int).Sub(v, big.NewInt(35))
- return v.Div(v, big.NewInt(2))
-}
-
-func rawSignatureValues(vBz, rBz, sBz []byte) (v, r, s *big.Int) {
- if len(vBz) > 0 {
- v = new(big.Int).SetBytes(vBz)
- }
- if len(rBz) > 0 {
- r = new(big.Int).SetBytes(rBz)
- }
- if len(sBz) > 0 {
- s = new(big.Int).SetBytes(sBz)
- }
- return v, r, s
-}
-
-func fee(gasPrice *big.Int, gas uint64) *big.Int {
- gasLimit := new(big.Int).SetUint64(gas)
- return new(big.Int).Mul(gasPrice, gasLimit)
-}
-
-func cost(fee, value *big.Int) *big.Int {
- if value != nil {
- return new(big.Int).Add(fee, value)
- }
- return fee
-}
diff --git a/x/evm/tx_data_test.go b/x/evm/tx_data_test.go
deleted file mode 100644
index ec2d893e1..000000000
--- a/x/evm/tx_data_test.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package evm
-
-import (
- "math/big"
- "testing"
-
- sdkmath "cosmossdk.io/math"
- "github.com/stretchr/testify/require"
-)
-
-func TestTxData_chainID(t *testing.T) {
- chainID := sdkmath.NewInt(1)
-
- testCases := []struct {
- msg string
- data TxData
- expChainID *big.Int
- }{
- {
- "access list tx", &AccessListTx{Accesses: AccessList{}, ChainID: &chainID}, big.NewInt(1),
- },
- {
- "access list tx, nil chain ID", &AccessListTx{Accesses: AccessList{}}, nil,
- },
- {
- "legacy tx, derived", &LegacyTx{}, nil,
- },
- }
-
- for _, tc := range testCases {
- chainID := tc.data.GetChainID()
- require.Equal(t, chainID, tc.expChainID, tc.msg)
- }
-}
-
-func TestTxData_DeriveChainID(t *testing.T) {
- bitLen64, ok := new(big.Int).SetString("0x8000000000000000", 0)
- require.True(t, ok)
-
- bitLen80, ok := new(big.Int).SetString("0x80000000000000000000", 0)
- require.True(t, ok)
-
- expBitLen80, ok := new(big.Int).SetString("302231454903657293676526", 0)
- require.True(t, ok)
-
- testCases := []struct {
- msg string
- data TxData
- expChainID *big.Int
- }{
- {
- "v = -1", &LegacyTx{V: big.NewInt(-1).Bytes()}, nil,
- },
- {
- "v = 0", &LegacyTx{V: big.NewInt(0).Bytes()}, nil,
- },
- {
- "v = 1", &LegacyTx{V: big.NewInt(1).Bytes()}, nil,
- },
- {
- "v = 27", &LegacyTx{V: big.NewInt(27).Bytes()}, new(big.Int),
- },
- {
- "v = 28", &LegacyTx{V: big.NewInt(28).Bytes()}, new(big.Int),
- },
- {
- "Ethereum mainnet", &LegacyTx{V: big.NewInt(37).Bytes()}, big.NewInt(1),
- },
- {
- "chain ID 9000", &LegacyTx{V: big.NewInt(18035).Bytes()}, big.NewInt(9000),
- },
- {
- "bit len 64", &LegacyTx{V: bitLen64.Bytes()}, big.NewInt(4611686018427387886),
- },
- {
- "bit len 80", &LegacyTx{V: bitLen80.Bytes()}, expBitLen80,
- },
- {
- "v = nil ", &LegacyTx{V: nil}, nil,
- },
- }
-
- for _, tc := range testCases {
- v, _, _ := tc.data.GetRawSignatureValues()
-
- chainID := DeriveChainID(v)
- require.Equal(t, tc.expChainID, chainID, tc.msg)
- }
-}
diff --git a/x/evm/tx_test.go b/x/evm/tx_test.go
deleted file mode 100644
index 929a599c2..000000000
--- a/x/evm/tx_test.go
+++ /dev/null
@@ -1,679 +0,0 @@
-package evm_test
-
-import (
- "math/big"
- "testing"
-
- sdkmath "cosmossdk.io/math"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- gethcore "github.com/ethereum/go-ethereum/core/types"
-
- "github.com/NibiruChain/nibiru/x/evm"
- "github.com/NibiruChain/nibiru/x/evm/evmtest"
-
- "github.com/stretchr/testify/suite"
-)
-
-type TxDataTestSuite struct {
- suite.Suite
-
- sdkInt sdkmath.Int
- uint64 uint64
- hexUint64 hexutil.Uint64
- bigInt *big.Int
- hexBigInt hexutil.Big
- overflowBigInt *big.Int
- sdkZeroInt sdkmath.Int
- sdkMinusOneInt sdkmath.Int
- invalidAddr string
- addr common.Address
- hexAddr string
- hexDataBytes hexutil.Bytes
- hexInputBytes hexutil.Bytes
-}
-
-func (suite *TxDataTestSuite) SetupTest() {
- suite.sdkInt = sdkmath.NewInt(9001)
- suite.uint64 = suite.sdkInt.Uint64()
- suite.hexUint64 = hexutil.Uint64(100)
- suite.bigInt = big.NewInt(1)
- suite.hexBigInt = hexutil.Big(*big.NewInt(1))
- suite.overflowBigInt = big.NewInt(0).Exp(big.NewInt(10), big.NewInt(256), nil)
- suite.sdkZeroInt = sdkmath.ZeroInt()
- suite.sdkMinusOneInt = sdkmath.NewInt(-1)
- suite.invalidAddr = "123456"
-
- suite.addr = evmtest.NewEthAddr()
-
- suite.hexAddr = suite.addr.Hex()
- suite.hexDataBytes = hexutil.Bytes([]byte("data"))
- suite.hexInputBytes = hexutil.Bytes([]byte("input"))
-}
-
-func TestTxDataTestSuite(t *testing.T) {
- suite.Run(t, new(TxDataTestSuite))
-}
-
-func (suite *TxDataTestSuite) TestNewDynamicFeeTx() {
- testCases := []struct {
- name string
- expError bool
- tx *gethcore.Transaction
- }{
- {
- "non-empty tx",
- false,
- gethcore.NewTx(&gethcore.DynamicFeeTx{
- Nonce: 1,
- Data: []byte("data"),
- Gas: 100,
- Value: big.NewInt(1),
- AccessList: gethcore.AccessList{},
- To: &suite.addr,
- V: suite.bigInt,
- R: suite.bigInt,
- S: suite.bigInt,
- }),
- },
- {
- "value out of bounds tx",
- true,
- gethcore.NewTx(&gethcore.DynamicFeeTx{
- Nonce: 1,
- Data: []byte("data"),
- Gas: 100,
- Value: suite.overflowBigInt,
- AccessList: gethcore.AccessList{},
- To: &suite.addr,
- V: suite.bigInt,
- R: suite.bigInt,
- S: suite.bigInt,
- }),
- },
- {
- "gas fee cap out of bounds tx",
- true,
- gethcore.NewTx(&gethcore.DynamicFeeTx{
- Nonce: 1,
- Data: []byte("data"),
- Gas: 100,
- GasFeeCap: suite.overflowBigInt,
- Value: big.NewInt(1),
- AccessList: gethcore.AccessList{},
- To: &suite.addr,
- V: suite.bigInt,
- R: suite.bigInt,
- S: suite.bigInt,
- }),
- },
- {
- "gas tip cap out of bounds tx",
- true,
- gethcore.NewTx(&gethcore.DynamicFeeTx{
- Nonce: 1,
- Data: []byte("data"),
- Gas: 100,
- GasTipCap: suite.overflowBigInt,
- Value: big.NewInt(1),
- AccessList: gethcore.AccessList{},
- To: &suite.addr,
- V: suite.bigInt,
- R: suite.bigInt,
- S: suite.bigInt,
- }),
- },
- }
- for _, tc := range testCases {
- tx, err := evm.NewDynamicFeeTx(tc.tx)
-
- if tc.expError {
- suite.Require().Error(err)
- } else {
- suite.Require().NoError(err)
- suite.Require().NotEmpty(tx)
- suite.Require().Equal(uint8(2), tx.TxType())
- }
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxAsEthereumData() {
- feeConfig := &gethcore.DynamicFeeTx{
- Nonce: 1,
- Data: []byte("data"),
- Gas: 100,
- Value: big.NewInt(1),
- AccessList: gethcore.AccessList{},
- To: &suite.addr,
- V: suite.bigInt,
- R: suite.bigInt,
- S: suite.bigInt,
- }
-
- tx := gethcore.NewTx(feeConfig)
-
- dynamicFeeTx, err := evm.NewDynamicFeeTx(tx)
- suite.Require().NoError(err)
-
- res := dynamicFeeTx.AsEthereumData()
- resTx := gethcore.NewTx(res)
-
- suite.Require().Equal(feeConfig.Nonce, resTx.Nonce())
- suite.Require().Equal(feeConfig.Data, resTx.Data())
- suite.Require().Equal(feeConfig.Gas, resTx.Gas())
- suite.Require().Equal(feeConfig.Value, resTx.Value())
- suite.Require().Equal(feeConfig.AccessList, resTx.AccessList())
- suite.Require().Equal(feeConfig.To, resTx.To())
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxCopy() {
- tx := &evm.DynamicFeeTx{}
- txCopy := tx.Copy()
-
- suite.Require().Equal(&evm.DynamicFeeTx{}, txCopy)
- // TODO: Test for different pointers
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxGetChainID() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- exp *big.Int
- }{
- {
- "empty chainID",
- evm.DynamicFeeTx{
- ChainID: nil,
- },
- nil,
- },
- {
- "non-empty chainID",
- evm.DynamicFeeTx{
- ChainID: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetChainID()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxGetAccessList() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- exp gethcore.AccessList
- }{
- {
- "empty accesses",
- evm.DynamicFeeTx{
- Accesses: nil,
- },
- nil,
- },
- {
- "nil",
- evm.DynamicFeeTx{
- Accesses: evm.NewAccessList(nil),
- },
- nil,
- },
- {
- "non-empty accesses",
- evm.DynamicFeeTx{
- Accesses: evm.AccessList{
- {
- Address: suite.hexAddr,
- StorageKeys: []string{},
- },
- },
- },
- gethcore.AccessList{
- {
- Address: suite.addr,
- StorageKeys: []common.Hash{},
- },
- },
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetAccessList()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxGetData() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- }{
- {
- "non-empty transaction",
- evm.DynamicFeeTx{
- Data: nil,
- },
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetData()
-
- suite.Require().Equal(tc.tx.Data, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxGetGas() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- exp uint64
- }{
- {
- "non-empty gas",
- evm.DynamicFeeTx{
- GasLimit: suite.uint64,
- },
- suite.uint64,
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetGas()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxGetGasPrice() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- exp *big.Int
- }{
- {
- "non-empty gasFeeCap",
- evm.DynamicFeeTx{
- GasFeeCap: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetGasPrice()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxGetGasTipCap() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- exp *big.Int
- }{
- {
- "empty gasTipCap",
- evm.DynamicFeeTx{
- GasTipCap: nil,
- },
- nil,
- },
- {
- "non-empty gasTipCap",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetGasTipCap()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxGetGasFeeCap() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- exp *big.Int
- }{
- {
- "empty gasFeeCap",
- evm.DynamicFeeTx{
- GasFeeCap: nil,
- },
- nil,
- },
- {
- "non-empty gasFeeCap",
- evm.DynamicFeeTx{
- GasFeeCap: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetGasFeeCap()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxGetValue() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- exp *big.Int
- }{
- {
- "empty amount",
- evm.DynamicFeeTx{
- Amount: nil,
- },
- nil,
- },
- {
- "non-empty amount",
- evm.DynamicFeeTx{
- Amount: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetValue()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxGetNonce() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- exp uint64
- }{
- {
- "non-empty nonce",
- evm.DynamicFeeTx{
- Nonce: suite.uint64,
- },
- suite.uint64,
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetNonce()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxGetTo() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- exp *common.Address
- }{
- {
- "empty suite.address",
- evm.DynamicFeeTx{
- To: "",
- },
- nil,
- },
- {
- "non-empty suite.address",
- evm.DynamicFeeTx{
- To: suite.hexAddr,
- },
- &suite.addr,
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.GetTo()
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxSetSignatureValues() {
- testCases := []struct {
- name string
- chainID *big.Int
- r *big.Int
- v *big.Int
- s *big.Int
- }{
- {
- "empty values",
- nil,
- nil,
- nil,
- nil,
- },
- {
- "non-empty values",
- suite.bigInt,
- suite.bigInt,
- suite.bigInt,
- suite.bigInt,
- },
- }
-
- for _, tc := range testCases {
- tx := &evm.DynamicFeeTx{}
- tx.SetSignatureValues(tc.chainID, tc.v, tc.r, tc.s)
-
- v, r, s := tx.GetRawSignatureValues()
- chainID := tx.GetChainID()
-
- suite.Require().Equal(tc.v, v, tc.name)
- suite.Require().Equal(tc.r, r, tc.name)
- suite.Require().Equal(tc.s, s, tc.name)
- suite.Require().Equal(tc.chainID, chainID, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxValidate() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- expError bool
- }{
- {
- "empty",
- evm.DynamicFeeTx{},
- true,
- },
- {
- "gas tip cap is nil",
- evm.DynamicFeeTx{
- GasTipCap: nil,
- },
- true,
- },
- {
- "gas fee cap is nil",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkZeroInt,
- },
- true,
- },
- {
- "gas tip cap is negative",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkMinusOneInt,
- GasFeeCap: &suite.sdkZeroInt,
- },
- true,
- },
- {
- "gas tip cap is negative",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkZeroInt,
- GasFeeCap: &suite.sdkMinusOneInt,
- },
- true,
- },
- {
- "gas fee cap < gas tip cap",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkInt,
- GasFeeCap: &suite.sdkZeroInt,
- },
- true,
- },
- {
- "amount is negative",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkInt,
- GasFeeCap: &suite.sdkInt,
- Amount: &suite.sdkMinusOneInt,
- },
- true,
- },
- {
- "to suite.address is invalid",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkInt,
- GasFeeCap: &suite.sdkInt,
- Amount: &suite.sdkInt,
- To: suite.invalidAddr,
- },
- true,
- },
- {
- "chain ID not present on AccessList txs",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkInt,
- GasFeeCap: &suite.sdkInt,
- Amount: &suite.sdkInt,
- To: suite.hexAddr,
- ChainID: nil,
- },
- true,
- },
- {
- "no errors",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkInt,
- GasFeeCap: &suite.sdkInt,
- Amount: &suite.sdkInt,
- To: suite.hexAddr,
- ChainID: &suite.sdkInt,
- },
- false,
- },
- }
-
- for _, tc := range testCases {
- err := tc.tx.Validate()
-
- if tc.expError {
- suite.Require().Error(err, tc.name)
- continue
- }
-
- suite.Require().NoError(err, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxEffectiveGasPrice() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- baseFee *big.Int
- exp *big.Int
- }{
- {
- "non-empty dynamic fee tx",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkInt,
- GasFeeCap: &suite.sdkInt,
- },
- (&suite.sdkInt).BigInt(),
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.EffectiveGasPrice(tc.baseFee)
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxEffectiveFee() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- baseFee *big.Int
- exp *big.Int
- }{
- {
- "non-empty dynamic fee tx",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkInt,
- GasFeeCap: &suite.sdkInt,
- GasLimit: uint64(1),
- },
- (&suite.sdkInt).BigInt(),
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.EffectiveFee(tc.baseFee)
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxEffectiveCost() {
- testCases := []struct {
- name string
- tx evm.DynamicFeeTx
- baseFee *big.Int
- exp *big.Int
- }{
- {
- "non-empty dynamic fee tx",
- evm.DynamicFeeTx{
- GasTipCap: &suite.sdkInt,
- GasFeeCap: &suite.sdkInt,
- GasLimit: uint64(1),
- Amount: &suite.sdkZeroInt,
- },
- (&suite.sdkInt).BigInt(),
- (&suite.sdkInt).BigInt(),
- },
- }
-
- for _, tc := range testCases {
- actual := tc.tx.EffectiveCost(tc.baseFee)
-
- suite.Require().Equal(tc.exp, actual, tc.name)
- }
-}
-
-func (suite *TxDataTestSuite) TestDynamicFeeTxFeeCost() {
- tx := &evm.DynamicFeeTx{}
- suite.Require().Panics(func() { tx.Fee() }, "should panic")
- suite.Require().Panics(func() { tx.Cost() }, "should panic")
-}
diff --git a/x/evm/vmtracer.go b/x/evm/vmtracer.go
deleted file mode 100644
index 5438d778d..000000000
--- a/x/evm/vmtracer.go
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) 2023-2024 Nibi, Inc.
-package evm
-
-import (
- "math/big"
- "os"
- "time"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/eth/tracers/logger"
- "github.com/ethereum/go-ethereum/params"
-)
-
-const (
- TracerAccessList = "access_list"
- TracerJSON = "json"
- TracerStruct = "struct"
- TracerMarkdown = "markdown"
-)
-
-// NewTracer creates a new Logger tracer to collect execution traces from an
-// EVM transaction.
-func NewTracer(tracer string, msg core.Message, cfg *params.ChainConfig, height int64) vm.EVMLogger {
- // TODO: enable additional log configuration
- logCfg := &logger.Config{
- Debug: true,
- }
-
- // FIXME: inconsistent logging between stdout and stderr
- switch tracer {
- case TracerAccessList:
- preCompiles := vm.DefaultActivePrecompiles(cfg.Rules(big.NewInt(height), cfg.MergeNetsplitBlock != nil))
- return logger.NewAccessListTracer(msg.AccessList(), msg.From(), *msg.To(), preCompiles)
- case TracerJSON:
- return logger.NewJSONLogger(logCfg, os.Stderr)
- case TracerMarkdown:
- return logger.NewMarkdownLogger(logCfg, os.Stdout)
- case TracerStruct:
- return logger.NewStructLogger(logCfg)
- default:
- return NewNoOpTracer()
- }
-}
-
-// TxTraceResult is the result of a single transaction trace during a block trace.
-type TxTraceResult struct {
- Result interface{} `json:"result,omitempty"` // Trace results produced by the tracer
- Error string `json:"error,omitempty"` // Trace failure produced by the tracer
-}
-
-var _ vm.EVMLogger = &NoOpTracer{}
-
-// NoOpTracer is an empty implementation of vm.Tracer interface
-type NoOpTracer struct{}
-
-// NewNoOpTracer creates a no-op vm.Tracer
-func NewNoOpTracer() *NoOpTracer {
- return &NoOpTracer{}
-}
-
-// CaptureStart implements vm.Tracer interface
-//
-//nolint:revive // allow unused parameters to indicate expected signature
-func (dt NoOpTracer) CaptureStart(env *vm.EVM,
- from common.Address,
- to common.Address,
- create bool,
- input []byte,
- gas uint64,
- value *big.Int) {
-}
-
-// CaptureState implements vm.Tracer interface
-//
-//nolint:revive // allow unused parameters to indicate expected signature
-func (dt NoOpTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
-}
-
-// CaptureFault implements vm.Tracer interface
-//
-//nolint:revive // allow unused parameters to indicate expected signature
-func (dt NoOpTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error) {
-}
-
-// CaptureEnd implements vm.Tracer interface
-//
-//nolint:revive // allow unused parameters to indicate expected signature
-func (dt NoOpTracer) CaptureEnd(output []byte, gasUsed uint64, tm time.Duration, err error) {}
-
-// CaptureEnter implements vm.Tracer interface
-//
-//nolint:revive // allow unused parameters to indicate expected signature
-func (dt NoOpTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
-}
-
-// CaptureExit implements vm.Tracer interface
-//
-//nolint:revive // allow unused parameters to indicate expected signature
-func (dt NoOpTracer) CaptureExit(output []byte, gasUsed uint64, err error) {}
-
-// CaptureTxStart implements vm.Tracer interface
-//
-//nolint:revive // allow unused parameters to indicate expected signature
-func (dt NoOpTracer) CaptureTxStart(gasLimit uint64) {}
-
-// CaptureTxEnd implements vm.Tracer interface
-//
-//nolint:revive // allow unused parameters to indicate expected signature
-func (dt NoOpTracer) CaptureTxEnd(restGas uint64) {}
diff --git a/x/genmsg/genesis.go b/x/genmsg/genesis.go
deleted file mode 100644
index b0a46de96..000000000
--- a/x/genmsg/genesis.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package genmsg
-
-import (
- "fmt"
-
- "github.com/cosmos/cosmos-sdk/codec"
- "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- v1 "github.com/NibiruChain/nibiru/x/genmsg/v1"
-)
-
-func anyToMsg(ir types.InterfaceRegistry, anyMsg *types.Any) (sdk.Msg, error) {
- var sdkMsg sdk.Msg
- err := ir.UnpackAny(anyMsg, &sdkMsg)
- if err != nil {
- return nil, err
- }
- if err = sdkMsg.ValidateBasic(); err != nil {
- return nil, err
- }
- return sdkMsg, nil
-}
-
-func validateGenesis(cdc codec.JSONCodec, genesis *v1.GenesisState) error {
- interfaceRegistryProvider, ok := cdc.(interface {
- InterfaceRegistry() types.InterfaceRegistry
- })
- if !ok {
- return fmt.Errorf("codec does not implement InterfaceRegistry")
- }
- interfaceRegistry := interfaceRegistryProvider.InterfaceRegistry()
- // check if all messages are known by the codec
- for i, anyMsg := range genesis.Messages {
- if _, err := anyToMsg(interfaceRegistry, anyMsg); err != nil {
- return fmt.Errorf("at index %d: %w", i, err)
- }
- }
- return nil
-}
-
-func initGenesis(context sdk.Context, cdc codec.JSONCodec, router MessageRouter, genesis *v1.GenesisState) error {
- interfaceRegistryProvider, ok := cdc.(interface {
- InterfaceRegistry() types.InterfaceRegistry
- })
- if !ok {
- return fmt.Errorf("codec does not implement InterfaceRegistry")
- }
- interfaceRegistry := interfaceRegistryProvider.InterfaceRegistry()
-
- // execute all messages in order
- for i, anyMsg := range genesis.Messages {
- msg, err := anyToMsg(interfaceRegistry, anyMsg)
- if err != nil {
- return fmt.Errorf("at index %d: message decoding: %w", i, err)
- }
- handler := router.Handler(msg)
- if handler == nil {
- return fmt.Errorf("at index %d: no handler for message %T %s", i, msg, msg)
- }
- _, err = handler(context, msg)
- if err != nil {
- return fmt.Errorf("at index %d: message processing: %w", i, err)
- }
- }
- return nil
-}
diff --git a/x/genmsg/genesis_test.go b/x/genmsg/genesis_test.go
deleted file mode 100644
index b4e601114..000000000
--- a/x/genmsg/genesis_test.go
+++ /dev/null
@@ -1,111 +0,0 @@
-package genmsg
-
-import (
- "testing"
-
- "github.com/cosmos/cosmos-sdk/baseapp"
- "github.com/cosmos/cosmos-sdk/codec"
- "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
- "github.com/gogo/protobuf/proto"
- "github.com/stretchr/testify/require"
-
- v1 "github.com/NibiruChain/nibiru/x/genmsg/v1"
-)
-
-type mockRouter struct {
- handler func(msg sdk.Msg) baseapp.MsgServiceHandler
-}
-
-func (m mockRouter) Handler(msg sdk.Msg) baseapp.MsgServiceHandler { return m.handler(msg) }
-
-func makeCodec(_ *testing.T) codec.JSONCodec {
- ir := types.NewInterfaceRegistry()
- cdc := codec.NewProtoCodec(ir)
- ir.RegisterInterface(sdk.MsgInterfaceProtoName, (*sdk.Msg)(nil), &banktypes.MsgSend{})
- return cdc
-}
-
-func newGenesisFromMsgs(t *testing.T, cdc codec.JSONCodec, msgs ...proto.Message) *v1.GenesisState {
- genesis := new(v1.GenesisState)
- for _, msg := range msgs {
- anyProto, err := types.NewAnyWithValue(msg)
- require.NoError(t, err)
- genesis.Messages = append(genesis.Messages, anyProto)
- }
- genesisJSON, err := cdc.MarshalJSON(genesis)
- require.NoError(t, err)
- genesis = new(v1.GenesisState)
- require.NoError(t, cdc.UnmarshalJSON(genesisJSON, genesis))
- return genesis
-}
-
-func Test_initGenesis(t *testing.T) {
- cdc := makeCodec(t)
- ctx := sdk.Context{}
-
- t.Run("works - no msgs", func(t *testing.T) {
- r := mockRouter{func(msg sdk.Msg) baseapp.MsgServiceHandler {
- return func(ctx sdk.Context, req sdk.Msg) (*sdk.Result, error) {
- return &sdk.Result{}, nil
- }
- }}
-
- err := initGenesis(ctx, cdc, r, newGenesisFromMsgs(t, cdc))
- require.NoError(t, err)
- })
-
- t.Run("works - with message", func(t *testing.T) {
- called := false
- r := mockRouter{func(msg sdk.Msg) baseapp.MsgServiceHandler {
- return func(ctx sdk.Context, req sdk.Msg) (*sdk.Result, error) {
- called = true
- return &sdk.Result{}, nil
- }
- }}
-
- err := initGenesis(ctx, cdc, r, newGenesisFromMsgs(t, cdc, &banktypes.MsgSend{
- FromAddress: sdk.AccAddress("a").String(),
- ToAddress: sdk.AccAddress("b").String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin("test", 1000)),
- }))
- require.NoError(t, err)
- require.True(t, called)
- })
-
- t.Run("fails - handler is nil", func(t *testing.T) {
- r := mockRouter{func(msg sdk.Msg) baseapp.MsgServiceHandler {
- return nil
- }}
-
- err := initGenesis(ctx, cdc, r, newGenesisFromMsgs(t, cdc, &banktypes.MsgSend{
- FromAddress: sdk.AccAddress("a").String(),
- ToAddress: sdk.AccAddress("b").String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin("test", 1000)),
- }))
- require.Error(t, err)
- })
-}
-
-func Test_validateGenesis(t *testing.T) {
- cdc := makeCodec(t)
- t.Run("works - empty", func(t *testing.T) {
- err := validateGenesis(cdc, &v1.GenesisState{})
- require.NoError(t, err)
- })
- t.Run("works - with messages", func(t *testing.T) {
- genesis := newGenesisFromMsgs(t, cdc, &banktypes.MsgSend{
- FromAddress: sdk.AccAddress("sender").String(),
- ToAddress: sdk.AccAddress("receiver").String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin("test", 1000)),
- })
- err := validateGenesis(cdc, genesis)
- require.NoError(t, err)
- })
- t.Run("fails - validate basic", func(t *testing.T) {
- genesis := newGenesisFromMsgs(t, cdc, &banktypes.MsgSend{})
- err := validateGenesis(cdc, genesis)
- require.Error(t, err)
- })
-}
diff --git a/x/genmsg/integration_test.go b/x/genmsg/integration_test.go
deleted file mode 100644
index e37476649..000000000
--- a/x/genmsg/integration_test.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package genmsg_test
-
-import (
- "testing"
-
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/genmsg"
- v1 "github.com/NibiruChain/nibiru/x/genmsg/v1"
-)
-
-func TestIntegration(t *testing.T) {
- senderAddr := sdk.AccAddress("sender")
- recvAddr := sdk.AccAddress("recv")
-
- encoding := app.MakeEncodingConfig()
- appGenesis := app.NewDefaultGenesisState(encoding.Codec)
-
- appGenesis[banktypes.ModuleName] = encoding.Codec.MustMarshalJSON(&banktypes.GenesisState{
- Balances: []banktypes.Balance{
- {
- Address: senderAddr.String(),
- Coins: sdk.NewCoins(sdk.NewInt64Coin("unibi", 100000)),
- },
- },
- })
-
- testMsg := &banktypes.MsgSend{
- FromAddress: senderAddr.String(),
- ToAddress: recvAddr.String(),
- Amount: sdk.NewCoins(sdk.NewInt64Coin("unibi", 1000)),
- }
-
- anyMsg, err := codectypes.NewAnyWithValue(testMsg)
- require.NoError(t, err)
-
- appGenesis[genmsg.ModuleName] = encoding.Codec.MustMarshalJSON(
- &v1.GenesisState{
- Messages: []*codectypes.Any{anyMsg},
- },
- )
-
- app := testapp.NewNibiruTestApp(appGenesis)
- ctx := app.NewContext(false, tmproto.Header{
- Height: 1,
- })
-
- balance, err := app.BankKeeper.Balance(ctx, &banktypes.QueryBalanceRequest{
- Address: recvAddr.String(),
- Denom: "unibi",
- })
- require.NoError(t, err)
- require.True(t, balance.Balance.Equal(sdk.NewInt64Coin("unibi", 1000)))
-}
diff --git a/x/genmsg/module.go b/x/genmsg/module.go
deleted file mode 100644
index f20ae9b74..000000000
--- a/x/genmsg/module.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package genmsg
-
-import (
- "encoding/json"
- "fmt"
-
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cosmos/cosmos-sdk/baseapp"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/codec"
- "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/spf13/cobra"
-
- v1 "github.com/NibiruChain/nibiru/x/genmsg/v1"
-)
-
-const (
- ModuleName = "genmsg"
-)
-
-var _ module.AppModule = (*AppModule)(nil)
-
-// MessageRouter ADR 031 request type routing
-type MessageRouter interface {
- Handler(msg sdk.Msg) baseapp.MsgServiceHandler
-}
-
-func NewAppModule(h MessageRouter) AppModule {
- return AppModule{h}
-}
-
-type AppModule struct {
- router MessageRouter
-}
-
-func (a AppModule) Name() string { return ModuleName }
-
-func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
- return cdc.MustMarshalJSON(new(v1.GenesisState))
-}
-
-func (AppModule) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
- state := new(v1.GenesisState)
- if err := cdc.UnmarshalJSON(bz, state); err != nil {
- return fmt.Errorf("failed to unmarshal x/%s genesis state: %w", ModuleName, err)
- }
- return validateGenesis(cdc, state)
-}
-
-func (a AppModule) InitGenesis(context sdk.Context, codec codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate {
- state := new(v1.GenesisState)
- codec.MustUnmarshalJSON(message, state)
- err := initGenesis(context, codec, a.router, state)
- if err != nil {
- panic(err)
- }
- return nil
-}
-
-func (a AppModule) ExportGenesis(_ sdk.Context, codec codec.JSONCodec) json.RawMessage {
- return codec.MustMarshalJSON(new(v1.GenesisState))
-}
-
-func (a AppModule) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {}
-
-func (a AppModule) GetTxCmd() *cobra.Command { return nil }
-
-func (a AppModule) GetQueryCmd() *cobra.Command { return nil }
-
-func (a AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
-
-func (a AppModule) RegisterServices(_ module.Configurator) {}
-
-func (a AppModule) ConsensusVersion() uint64 { return 0 }
-
-func (a AppModule) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {}
-
-func (a AppModule) RegisterInterfaces(_ types.InterfaceRegistry) {}
diff --git a/x/genmsg/v1/genmsg.pb.go b/x/genmsg/v1/genmsg.pb.go
deleted file mode 100644
index 2a056f1aa..000000000
--- a/x/genmsg/v1/genmsg.pb.go
+++ /dev/null
@@ -1,329 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/genmsg/v1/genmsg.proto
-
-package v1
-
-import (
- fmt "fmt"
- types "github.com/cosmos/cosmos-sdk/codec/types"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// GenesisState represents the messages to be processed during genesis by the genmsg module.
-type GenesisState struct {
- Messages []*types.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
-}
-
-func (m *GenesisState) Reset() { *m = GenesisState{} }
-func (m *GenesisState) String() string { return proto.CompactTextString(m) }
-func (*GenesisState) ProtoMessage() {}
-func (*GenesisState) Descriptor() ([]byte, []int) {
- return fileDescriptor_861b6a68d8c1c2d0, []int{0}
-}
-func (m *GenesisState) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *GenesisState) XXX_Merge(src proto.Message) {
- xxx_messageInfo_GenesisState.Merge(m, src)
-}
-func (m *GenesisState) XXX_Size() int {
- return m.Size()
-}
-func (m *GenesisState) XXX_DiscardUnknown() {
- xxx_messageInfo_GenesisState.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_GenesisState proto.InternalMessageInfo
-
-func (m *GenesisState) GetMessages() []*types.Any {
- if m != nil {
- return m.Messages
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*GenesisState)(nil), "nibiru.genmsg.v1.GenesisState")
-}
-
-func init() { proto.RegisterFile("nibiru/genmsg/v1/genmsg.proto", fileDescriptor_861b6a68d8c1c2d0) }
-
-var fileDescriptor_861b6a68d8c1c2d0 = []byte{
- // 188 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0xcb, 0x4c, 0xca,
- 0x2c, 0x2a, 0xd5, 0x4f, 0x4f, 0xcd, 0xcb, 0x2d, 0x4e, 0xd7, 0x2f, 0x33, 0x84, 0xb2, 0xf4, 0x0a,
- 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0x20, 0xd2, 0x7a, 0x50, 0xc1, 0x32, 0x43, 0x29, 0xc9, 0xf4,
- 0xfc, 0xfc, 0xf4, 0x9c, 0x54, 0x7d, 0xb0, 0x7c, 0x52, 0x69, 0x9a, 0x7e, 0x62, 0x5e, 0x25, 0x44,
- 0xb1, 0x92, 0x03, 0x17, 0x8f, 0x7b, 0x6a, 0x5e, 0x6a, 0x71, 0x66, 0x71, 0x70, 0x49, 0x62, 0x49,
- 0xaa, 0x90, 0x01, 0x17, 0x47, 0x6e, 0x6a, 0x71, 0x71, 0x62, 0x7a, 0x6a, 0xb1, 0x04, 0xa3, 0x02,
- 0xb3, 0x06, 0xb7, 0x91, 0x88, 0x1e, 0x44, 0xb7, 0x1e, 0x4c, 0xb7, 0x9e, 0x63, 0x5e, 0x65, 0x10,
- 0x5c, 0x95, 0x93, 0xf3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7,
- 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x69, 0xa6,
- 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xfb, 0x81, 0xdd, 0xe4, 0x9c, 0x91,
- 0x98, 0x99, 0xa7, 0x0f, 0x75, 0x7e, 0x05, 0xc2, 0x03, 0x49, 0x6c, 0x60, 0xc3, 0x8d, 0x01, 0x01,
- 0x00, 0x00, 0xff, 0xff, 0x90, 0xff, 0x3f, 0x5e, 0xdb, 0x00, 0x00, 0x00,
-}
-
-func (m *GenesisState) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Messages) > 0 {
- for iNdEx := len(m.Messages) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Messages[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenmsg(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintGenmsg(dAtA []byte, offset int, v uint64) int {
- offset -= sovGenmsg(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *GenesisState) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Messages) > 0 {
- for _, e := range m.Messages {
- l = e.Size()
- n += 1 + l + sovGenmsg(uint64(l))
- }
- }
- return n
-}
-
-func sovGenmsg(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozGenmsg(x uint64) (n int) {
- return sovGenmsg(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *GenesisState) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenmsg
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Messages", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenmsg
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenmsg
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenmsg
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Messages = append(m.Messages, &types.Any{})
- if err := m.Messages[len(m.Messages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipGenmsg(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenmsg
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipGenmsg(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenmsg
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenmsg
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenmsg
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthGenmsg
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupGenmsg
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenmsg
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthGenmsg = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowGenmsg = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupGenmsg = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/inflation/client/cli/query.go b/x/inflation/client/cli/query.go
deleted file mode 100644
index 53db6f67c..000000000
--- a/x/inflation/client/cli/query.go
+++ /dev/null
@@ -1,213 +0,0 @@
-package cli
-
-import (
- "context"
- "fmt"
-
- "github.com/spf13/cobra"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
-
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// GetQueryCmd returns the cli query commands for the inflation module.
-func GetQueryCmd() *cobra.Command {
- cmd := &cobra.Command{
- Use: types.ModuleName,
- Short: "Querying commands for the inflation module",
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- cmd.AddCommand(
- GetPeriod(),
- GetEpochMintProvision(),
- GetSkippedEpochs(),
- GetCirculatingSupply(),
- GetInflationRate(),
- GetParams(),
- )
-
- return cmd
-}
-
-// GetPeriod implements a command to return the current inflation
-// period
-func GetPeriod() *cobra.Command {
- cmd := &cobra.Command{
- Use: "period",
- Short: "Query the current inflation period",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
-
- queryClient := types.NewQueryClient(clientCtx)
-
- params := &types.QueryPeriodRequest{}
- res, err := queryClient.Period(context.Background(), params)
- if err != nil {
- return err
- }
-
- return clientCtx.PrintString(fmt.Sprintf("%v\n", res.Period))
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
-
-// GetEpochMintProvision implements a command to return the current inflation
-// epoch provisions value.
-func GetEpochMintProvision() *cobra.Command {
- cmd := &cobra.Command{
- Use: "epoch-mint-provision",
- Short: "Query the current inflation epoch provisions value",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
-
- queryClient := types.NewQueryClient(clientCtx)
-
- req := &types.QueryEpochMintProvisionRequest{}
- res, err := queryClient.EpochMintProvision(context.Background(), req)
- if err != nil {
- return err
- }
-
- return clientCtx.PrintString(fmt.Sprintf("%s\n", res.EpochMintProvision))
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
-
-// GetSkippedEpochs implements a command to return the current inflation
-// period
-func GetSkippedEpochs() *cobra.Command {
- cmd := &cobra.Command{
- Use: "skipped-epochs",
- Short: "Query the current number of skipped epochs",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
-
- queryClient := types.NewQueryClient(clientCtx)
-
- req := &types.QuerySkippedEpochsRequest{}
- res, err := queryClient.SkippedEpochs(context.Background(), req)
- if err != nil {
- return err
- }
-
- return clientCtx.PrintString(fmt.Sprintf("%v\n", res.SkippedEpochs))
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
-
-// GetCirculatingSupply implements a command to return the current circulating supply
-func GetCirculatingSupply() *cobra.Command {
- cmd := &cobra.Command{
- Use: "circulating-supply",
- Short: "Query the current supply of tokens in circulation",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
-
- queryClient := types.NewQueryClient(clientCtx)
-
- req := &types.QueryCirculatingSupplyRequest{}
- res, err := queryClient.CirculatingSupply(context.Background(), req)
- if err != nil {
- return err
- }
-
- return clientCtx.PrintString(fmt.Sprintf("%s\n", res.CirculatingSupply))
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
-
-// GetInflationRate implements a command to return the inflation rate in %
-func GetInflationRate() *cobra.Command {
- cmd := &cobra.Command{
- Use: "inflation-rate",
- Short: "Query the inflation rate of the current period",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
-
- queryClient := types.NewQueryClient(clientCtx)
-
- req := &types.QueryInflationRateRequest{}
- res, err := queryClient.InflationRate(context.Background(), req)
- if err != nil {
- return err
- }
-
- return clientCtx.PrintString(fmt.Sprintf("%s%%\n", res.InflationRate))
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
-
-// GetParams implements a command to return the current inflation
-// parameters.
-func GetParams() *cobra.Command {
- cmd := &cobra.Command{
- Use: "params",
- Short: "Query the current inflation parameters",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, _ []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
-
- queryClient := types.NewQueryClient(clientCtx)
-
- req := &types.QueryParamsRequest{}
- res, err := queryClient.Params(context.Background(), req)
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(&res.Params)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
diff --git a/x/inflation/client/cli/tx.go b/x/inflation/client/cli/tx.go
deleted file mode 100644
index 5e073a4d3..000000000
--- a/x/inflation/client/cli/tx.go
+++ /dev/null
@@ -1,171 +0,0 @@
-package cli
-
-import (
- "strings"
-
- "cosmossdk.io/math"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/client/tx"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// GetTxCmd returns the transaction commands for this module
-func GetTxCmd() *cobra.Command {
- inflationTxCmd := &cobra.Command{
- Use: types.ModuleName,
- Short: "Inflation module subcommands",
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- inflationTxCmd.AddCommand(
- CmdToggleInflation(),
- CmdEditInflationParams(),
- )
-
- return inflationTxCmd
-}
-
-func CmdToggleInflation() *cobra.Command {
- cmd := &cobra.Command{
- Use: "toggle-inflation [true | false]",
- Args: cobra.ExactArgs(1),
- Short: "Toggle inflation on or off",
- Long: strings.TrimSpace(`
-Toggle inflation on or off.
-
-Requires sudo permissions.
-
-$ nibid tx inflation toggle-inflation true
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- msg := &types.MsgToggleInflation{
- Sender: clientCtx.GetFromAddress().String(),
- Enable: args[0] == "true",
- }
-
- if err := msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
-
- return cmd
-}
-
-func CmdEditInflationParams() *cobra.Command {
- cmd := &cobra.Command{
- Use: "edit-params --staking-proportion [staking-proportion] --community-pool-proportion [community-pool-proportion] --strategic-reserves-proportion [strategic-reserves-proportion] --polynomial-factors [polynomial-factors] --epochs-per-period [epochs-per-period] --periods-per-year [periods-per-year] --max-period [max-period]",
- Args: cobra.ExactArgs(0),
- Short: "Edit the inflation module parameters",
- Long: strings.TrimSpace(`
-Edit the inflation module parameters.
-
-Requires sudo permissions.
-
---staking-proportion: the proportion of minted tokens to be distributed to stakers
---community-pool-proportion: the proportion of minted tokens to be distributed to the community pool
---strategic-reserves-proportion: the proportion of minted tokens to be distributed to validators
-
---polynomial-factors: the polynomial factors of the inflation distribution curve
---epochs-per-period: the number of epochs per period
---periods-per-year: the number of periods per year
---max-period: the maximum number of periods
-
-$ nibid tx oracle edit-params --staking-proportion 0.6 --community-pool-proportion 0.2 --strategic-reserves-proportion 0.2 --polynomial-factors 0.1,0.2,0.3,0.4,0.5,0.6 --epochs-per-period 100 --periods-per-year 100 --max-period 100
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- msg := &types.MsgEditInflationParams{
- Sender: clientCtx.GetFromAddress().String(),
- }
-
- var stakingProportionDec sdk.Dec
- if stakingProportion, _ := cmd.Flags().GetString("staking-proportion"); stakingProportion != "" {
- stakingProportionDec = math.LegacyMustNewDecFromStr(stakingProportion)
- msg.InflationDistribution.StakingRewards = stakingProportionDec
- }
-
- var communityPoolProportionDec sdk.Dec
- if communityPoolProportion, _ := cmd.Flags().GetString("community-pool-proportion"); communityPoolProportion != "" {
- communityPoolProportionDec = math.LegacyMustNewDecFromStr(communityPoolProportion)
- msg.InflationDistribution.CommunityPool = communityPoolProportionDec
- }
-
- var strategicReservesProportionDec sdk.Dec
- if strategicReservesProportion, _ := cmd.Flags().GetString("strategic-reserves-proportion"); strategicReservesProportion != "" {
- strategicReservesProportionDec = math.LegacyMustNewDecFromStr(strategicReservesProportion)
- msg.InflationDistribution.StrategicReserves = strategicReservesProportionDec
- }
-
- if !stakingProportionDec.IsNil() && !communityPoolProportionDec.IsNil() && !strategicReservesProportionDec.IsNil() {
- msg.InflationDistribution = &types.InflationDistribution{
- StakingRewards: stakingProportionDec,
- CommunityPool: communityPoolProportionDec,
- StrategicReserves: strategicReservesProportionDec,
- }
- }
-
- if polynomialFactors, _ := cmd.Flags().GetString("polynomial-factors"); polynomialFactors != "" {
- polynomialFactorsArr := strings.Split(polynomialFactors, ",")
- realPolynomialFactors := make([]sdk.Dec, len(polynomialFactorsArr))
- for i, factor := range polynomialFactorsArr {
- factorDec := math.LegacyMustNewDecFromStr(factor)
- realPolynomialFactors[i] = factorDec
- }
- msg.PolynomialFactors = realPolynomialFactors
- }
-
- if epochsPerPeriod, _ := cmd.Flags().GetUint64("epochs-per-period"); epochsPerPeriod != 0 {
- epochsPerPeriodInt := sdk.NewIntFromUint64(epochsPerPeriod)
- msg.EpochsPerPeriod = &epochsPerPeriodInt
- }
-
- if periodsPerYear, _ := cmd.Flags().GetUint64("periods-per-year"); periodsPerYear != 0 {
- periodsPerYearInt := sdk.NewIntFromUint64(periodsPerYear)
- msg.PeriodsPerYear = &periodsPerYearInt
- }
-
- if maxPeriod, _ := cmd.Flags().GetUint64("max-period"); maxPeriod != 0 {
- maxPeriodInt := sdk.NewIntFromUint64(maxPeriod)
- msg.MaxPeriod = &maxPeriodInt
- }
-
- if err := msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
-
- cmd.Flags().String("staking-proportion", "", "the proportion of minted tokens to be distributed to stakers")
- cmd.Flags().String("community-pool-proportion", "", "the proportion of minted tokens to be distributed to the community pool")
- cmd.Flags().String("strategic-reserves-proportion", "", "the proportion of minted tokens to be distributed to validators")
- cmd.Flags().String("polynomial-factors", "", "the polynomial factors of the inflation distribution curve")
- cmd.Flags().Uint64("epochs-per-period", 0, "the number of epochs per period")
- cmd.Flags().Uint64("periods-per-year", 0, "the number of periods per year")
- cmd.Flags().Uint64("max-period", 0, "the maximum number of periods")
-
- return cmd
-}
diff --git a/x/inflation/doc.go b/x/inflation/doc.go
deleted file mode 100644
index 59130a449..000000000
--- a/x/inflation/doc.go
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-Package inflation implements the token inflation for the staking and utility
-token of the network as described by the "Community" portion of the Nibiru Chain
-tokenomics. The inflation curve is implemented as a polynomial that corresponds
-to a normalized exponential decay until the network reaches its maximum supply.
-
-References:
- - https://github.com/NibiruChain/tokenomics
- - https://nibiru.fi/docs/learn/tokenomics.html
-*/
-package inflation
diff --git a/x/inflation/genesis.go b/x/inflation/genesis.go
deleted file mode 100644
index b55da1322..000000000
--- a/x/inflation/genesis.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package inflation
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/inflation/keeper"
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// InitGenesis import module genesis
-func InitGenesis(
- ctx sdk.Context,
- k keeper.Keeper,
- ak types.AccountKeeper,
- _ types.StakingKeeper,
- data types.GenesisState,
-) {
- // Ensure inflation module account is set on genesis
- if acc := ak.GetModuleAccount(ctx, types.ModuleName); acc == nil {
- panic("the inflation module account has not been set")
- }
-
- // Set genesis state
- k.Params.Set(ctx, data.Params)
-
- period := data.Period
- k.CurrentPeriod.Set(ctx, period)
-
- skippedEpochs := data.SkippedEpochs
- k.NumSkippedEpochs.Set(ctx, skippedEpochs)
-}
-
-// ExportGenesis returns a GenesisState for a given context and keeper.
-func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
- return &types.GenesisState{
- Params: k.GetParams(ctx),
- Period: k.CurrentPeriod.Peek(ctx),
- SkippedEpochs: k.NumSkippedEpochs.Peek(ctx),
- }
-}
diff --git a/x/inflation/keeper/grpc_query.go b/x/inflation/keeper/grpc_query.go
deleted file mode 100644
index 6e9f6dffd..000000000
--- a/x/inflation/keeper/grpc_query.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package keeper
-
-import (
- "context"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "cosmossdk.io/math"
-
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// querier implements the module's gRPC "QueryServer" interface
-type querier struct {
- Keeper
-}
-
-// NewQuerier returns an implementation of the [types.QueryServer] interface
-// for the provided [Keeper].
-func NewQuerier(keeper Keeper) types.QueryServer {
- return &querier{Keeper: keeper}
-}
-
-var _ types.QueryServer = querier{}
-
-// Params is a gRPC query for the module parameters
-func (q querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
- params := q.GetParams(ctx)
-
- return &types.QueryParamsResponse{Params: params}, nil
-}
-
-// Period returns the current period of the inflation module.
-func (k Keeper) Period(
- c context.Context,
- _ *types.QueryPeriodRequest,
-) (*types.QueryPeriodResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
- period := k.CurrentPeriod.Peek(ctx)
- return &types.QueryPeriodResponse{Period: period}, nil
-}
-
-// EpochMintProvision returns the EpochMintProvision of the inflation module.
-func (k Keeper) EpochMintProvision(
- c context.Context,
- _ *types.QueryEpochMintProvisionRequest,
-) (*types.QueryEpochMintProvisionResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
- epochMintProvision := k.GetEpochMintProvision(ctx)
- coin := sdk.NewDecCoinFromDec(denoms.NIBI, epochMintProvision)
- return &types.QueryEpochMintProvisionResponse{EpochMintProvision: coin}, nil
-}
-
-// SkippedEpochs returns the number of skipped Epochs of the inflation module.
-func (k Keeper) SkippedEpochs(
- c context.Context,
- _ *types.QuerySkippedEpochsRequest,
-) (*types.QuerySkippedEpochsResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
- skippedEpochs := k.NumSkippedEpochs.Peek(ctx)
- return &types.QuerySkippedEpochsResponse{SkippedEpochs: skippedEpochs}, nil
-}
-
-// InflationRate returns the inflation rate for the current period.
-func (k Keeper) InflationRate(
- c context.Context,
- _ *types.QueryInflationRateRequest,
-) (*types.QueryInflationRateResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
- inflationRate := k.GetInflationRate(ctx, denoms.NIBI)
- return &types.QueryInflationRateResponse{InflationRate: inflationRate}, nil
-}
-
-// CirculatingSupply returns the total supply in circulation excluding the team
-// allocation in the first year
-func (k Keeper) CirculatingSupply(
- c context.Context,
- _ *types.QueryCirculatingSupplyRequest,
-) (*types.QueryCirculatingSupplyResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
-
- circulatingSupply := k.GetCirculatingSupply(ctx, denoms.NIBI)
- circulatingToDec := math.LegacyNewDecFromInt(circulatingSupply)
- coin := sdk.NewDecCoinFromDec(denoms.NIBI, circulatingToDec)
-
- return &types.QueryCirculatingSupplyResponse{CirculatingSupply: coin}, nil
-}
diff --git a/x/inflation/keeper/grpc_query_test.go b/x/inflation/keeper/grpc_query_test.go
deleted file mode 100644
index 6c8e666b7..000000000
--- a/x/inflation/keeper/grpc_query_test.go
+++ /dev/null
@@ -1,109 +0,0 @@
-package keeper_test
-
-import (
- "testing"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/x/inflation/keeper"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
-
- inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-type QueryServerSuite struct {
- suite.Suite
-
- nibiruApp *app.NibiruApp
- ctx sdk.Context
-}
-
-func (s *QueryServerSuite) SetupSuite() {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
- s.nibiruApp = nibiruApp
- s.ctx = ctx
-}
-
-func TestSuite_QueryServerSuite_RunAll(t *testing.T) {
- suite.Run(t, new(QueryServerSuite))
-}
-
-func (s *QueryServerSuite) TestQueryPeriod() {
- nibiruApp, ctx := s.nibiruApp, s.ctx
-
- resp, err := nibiruApp.InflationKeeper.Period(
- sdk.WrapSDKContext(ctx), &inflationtypes.QueryPeriodRequest{},
- )
-
- s.NoError(err)
- s.Assert().Equal(uint64(0), resp.Period)
-
- nibiruApp.InflationKeeper.CurrentPeriod.Next(ctx)
-
- resp, err = nibiruApp.InflationKeeper.Period(
- sdk.WrapSDKContext(ctx), &inflationtypes.QueryPeriodRequest{},
- )
- s.NoError(err)
- s.Assert().Equal(uint64(1), resp.Period)
-}
-
-func (s *QueryServerSuite) TestQuerySkippedEpochs() {
- nibiruApp, ctx := s.nibiruApp, s.ctx
- resp, err := nibiruApp.InflationKeeper.SkippedEpochs(
- sdk.WrapSDKContext(ctx), &inflationtypes.QuerySkippedEpochsRequest{},
- )
-
- s.Require().NoError(err)
- s.Assert().Equal(uint64(0), resp.SkippedEpochs)
-
- nibiruApp.InflationKeeper.NumSkippedEpochs.Next(ctx)
-
- resp, err = nibiruApp.InflationKeeper.SkippedEpochs(
- sdk.WrapSDKContext(ctx), &inflationtypes.QuerySkippedEpochsRequest{},
- )
- s.NoError(err)
- s.Assert().Equal(uint64(1), resp.SkippedEpochs)
-}
-
-func (s *QueryServerSuite) TestQueryEpochMintProvision() {
- nibiruApp, ctx := s.nibiruApp, s.ctx
- resp, err := nibiruApp.InflationKeeper.EpochMintProvision(
- sdk.WrapSDKContext(ctx), &inflationtypes.QueryEpochMintProvisionRequest{},
- )
- s.NoError(err)
- s.NotNil(resp)
-}
-
-func (s *QueryServerSuite) TestQueryInflationRate() {
- nibiruApp, ctx := s.nibiruApp, s.ctx
- resp, err := nibiruApp.InflationKeeper.InflationRate(
- sdk.WrapSDKContext(ctx), &inflationtypes.QueryInflationRateRequest{},
- )
- s.NoError(err)
- s.NotNil(resp)
-}
-
-func (s *QueryServerSuite) TestQueryCirculatingSupply() {
- nibiruApp, ctx := s.nibiruApp, s.ctx
- resp, err := nibiruApp.InflationKeeper.CirculatingSupply(
- sdk.WrapSDKContext(ctx), &inflationtypes.QueryCirculatingSupplyRequest{},
- )
- s.NoError(err)
- s.NotNil(resp)
-}
-
-func (s *QueryServerSuite) TestQueryParams() {
- nibiruApp, ctx := s.nibiruApp, s.ctx
- resp, err := nibiruApp.InflationKeeper.Params.Get(ctx)
- s.NoError(err)
- s.NotNil(resp)
-
- queryServer := keeper.NewQuerier(nibiruApp.InflationKeeper)
-
- resp2, err := queryServer.Params(sdk.WrapSDKContext(ctx), &inflationtypes.QueryParamsRequest{})
- s.NoError(err)
- s.NotNil(resp2)
-}
diff --git a/x/inflation/keeper/hooks.go b/x/inflation/keeper/hooks.go
deleted file mode 100644
index 0c78c3e0d..000000000
--- a/x/inflation/keeper/hooks.go
+++ /dev/null
@@ -1,169 +0,0 @@
-package keeper
-
-import (
- "fmt"
-
- "github.com/armon/go-metrics"
- "github.com/cosmos/cosmos-sdk/telemetry"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/common/denoms"
- epochstypes "github.com/NibiruChain/nibiru/x/epochs/types"
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// Hooks implements module-specific calls ([epochstypes.EpochHooks]) that will
-// occur at the end of every epoch. Hooks is meant for use with with
-// `EpochsKeeper.SetHooks`. These functions run outside of the normal body of
-// transactions.
-type Hooks struct {
- K Keeper
-}
-
-var _ epochstypes.EpochHooks = Hooks{}
-
-// Hooks implements module-speecific calls that will occur in the ABCI
-// BeginBlock logic.
-func (k Keeper) Hooks() Hooks {
- return Hooks{k}
-}
-
-// BeforeEpochStart is a hook that runs just prior to the start of a new epoch.
-func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber uint64) {
- // Perform no operations; we don't need to do anything here
- _, _, _ = ctx, epochIdentifier, epochNumber
-}
-
-// AfterEpochEnd is a hook that runs just prior to the first block whose
-// timestamp is after the end of an epoch duration.
-// AfterEpochEnd mints and allocates coins at the end of each epoch.
-// If inflation is disabled as a module parameter, the state for
-// "NumSkippedEpochs" increments.
-func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber uint64) {
- if epochIdentifier != epochstypes.DayEpochID {
- return
- }
-
- params := h.K.GetParams(ctx)
-
- // Skip inflation if it is disabled and increment number of skipped epochs
- if !params.InflationEnabled {
- var prevSkippedEpochs uint64
- if !params.HasInflationStarted {
- // If the inflation never started, we use epochNumber as the number of skipped epochs
- // to avoid missing periods when we upgrade a chain.
- h.K.NumSkippedEpochs.Set(ctx, epochNumber)
- prevSkippedEpochs = epochNumber
- } else {
- prevSkippedEpochs = h.K.NumSkippedEpochs.Next(ctx)
- }
-
- h.K.Logger(ctx).Debug(
- "skipping inflation mint and allocation",
- "height", ctx.BlockHeight(),
- "epoch-id", epochIdentifier,
- "epoch-number", epochNumber,
- "skipped-epochs", prevSkippedEpochs,
- )
- return
- }
-
- // mint coins, update supply
- period := h.K.CurrentPeriod.Peek(ctx)
- epochsPerPeriod := h.K.GetEpochsPerPeriod(ctx)
-
- epochMintProvision := types.CalculateEpochMintProvision(
- params,
- period,
- )
-
- if !epochMintProvision.IsPositive() {
- h.K.Logger(ctx).Error(
- "SKIPPING INFLATION: negative epoch mint provision",
- "value", epochMintProvision.String(),
- )
- return
- }
-
- mintedCoin := sdk.Coin{
- Denom: denoms.NIBI,
- Amount: epochMintProvision.TruncateInt(),
- }
-
- staking, strategic, communityPool, err := h.K.MintAndAllocateInflation(ctx, mintedCoin, params)
- if err != nil {
- h.K.Logger(ctx).Error(
- "SKIPPING INFLATION: failed to mint and allocate inflation",
- "error", err,
- )
- return
- }
-
- // If period is passed, update the period. A period is
- // passed if the current epoch number surpasses the epochsPerPeriod for the
- // current period. Skipped epochs are subtracted to only account for epochs
- // where inflation minted tokens.
- //
- // Examples:
- // Given, epochNumber = 1, period = 0, epochPerPeriod = 30, skippedEpochs = 0
- // => 1 - 30 * 0 - 0 < 30
- // => nothing to do here
- // Given, epochNumber = 70, period = 1, epochPerPeriod = 30, skippedEpochs = 10
- // => 70 - 1 * 30 - 10 >= 30
- // => a period has ended! we set a new period
- // Given, epochNumber = 42099, period = 0, epochPerPeriod = 30, skippedEpochs = 42069
- // => 42099 - 0 * 30 - 42069 >= 30
- // => a period has ended! we set a new period
- numSkippedEpochs := h.K.NumSkippedEpochs.Peek(ctx)
- if int64(epochNumber)-
- int64(epochsPerPeriod*period)-
- int64(numSkippedEpochs) >= int64(epochsPerPeriod) {
- periodBeforeIncrement := h.K.CurrentPeriod.Next(ctx)
-
- h.K.Logger(ctx).Info(fmt.Sprintf("setting new period: %d", periodBeforeIncrement+1))
- }
-
- defer func() {
- stakingAmt := staking.Amount
- strategicAmt := strategic.Amount
- cpAmt := communityPool.Amount
-
- if mintedCoin.Amount.IsInt64() {
- telemetry.IncrCounterWithLabels(
- []string{types.ModuleName, "allocate", "total"},
- float32(mintedCoin.Amount.Int64()),
- []metrics.Label{telemetry.NewLabel("denom", mintedCoin.Denom)},
- )
- }
- if stakingAmt.IsInt64() {
- telemetry.IncrCounterWithLabels(
- []string{types.ModuleName, "allocate", "staking", "total"},
- float32(stakingAmt.Int64()),
- []metrics.Label{telemetry.NewLabel("denom", mintedCoin.Denom)},
- )
- }
- if strategicAmt.IsInt64() {
- telemetry.IncrCounterWithLabels(
- []string{types.ModuleName, "allocate", "strategic", "total"},
- float32(strategicAmt.Int64()),
- []metrics.Label{telemetry.NewLabel("denom", mintedCoin.Denom)},
- )
- }
- if cpAmt.IsInt64() {
- telemetry.IncrCounterWithLabels(
- []string{types.ModuleName, "allocate", "community_pool", "total"},
- float32(cpAmt.Int64()),
- []metrics.Label{telemetry.NewLabel("denom", mintedCoin.Denom)},
- )
- }
- }()
-
- ctx.EventManager().EmitEvent(
- sdk.NewEvent(
- types.EventTypeInflation,
- sdk.NewAttribute(types.AttributeEpochNumber, fmt.Sprintf("%d", epochNumber-numSkippedEpochs)),
- sdk.NewAttribute(types.AttributeKeyEpochProvisions, epochMintProvision.String()),
- sdk.NewAttribute(sdk.AttributeKeyAmount, mintedCoin.Amount.String()),
- ),
- )
-}
diff --git a/x/inflation/keeper/hooks_test.go b/x/inflation/keeper/hooks_test.go
deleted file mode 100644
index 73114a535..000000000
--- a/x/inflation/keeper/hooks_test.go
+++ /dev/null
@@ -1,295 +0,0 @@
-package keeper_test
-
-import (
- "fmt"
- "testing"
- "time"
-
- "cosmossdk.io/math"
- sdkmath "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- epochstypes "github.com/NibiruChain/nibiru/x/epochs/types"
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// TestEpochIdentifierAfterEpochEnd: Ensures that the amount in the community
-// pool after an epoch ends is greater than the amount before the epoch ends
-// with the default module parameters.
-func TestEpochIdentifierAfterEpochEnd(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
-
- params := nibiruApp.InflationKeeper.GetParams(ctx)
- params.InflationEnabled = true
- nibiruApp.InflationKeeper.Params.Set(ctx, params)
-
- feePoolOld := nibiruApp.DistrKeeper.GetFeePool(ctx)
- nibiruApp.EpochsKeeper.AfterEpochEnd(ctx, epochstypes.DayEpochID, 1)
- feePoolNew := nibiruApp.DistrKeeper.GetFeePool(ctx)
-
- require.Greater(t, feePoolNew.CommunityPool.AmountOf(denoms.NIBI).BigInt().Uint64(),
- feePoolOld.CommunityPool.AmountOf(denoms.NIBI).BigInt().Uint64())
-}
-
-// TestPeriodChangesSkippedEpochsAfterEpochEnd: Tests whether current period and
-// the number of skipped epochs are accurately updated and that skipped epochs
-// are handled correctly.
-func TestPeriodChangesSkippedEpochsAfterEpochEnd(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
- inflationKeeper := nibiruApp.InflationKeeper
-
- testCases := []struct {
- name string
- currentPeriod uint64
- currentEpochNumber uint64
- epochIdentifier string
- skippedEpochs uint64
- InflationEnabled bool
- periodChanges bool
- }{
- {
- name: "SkippedEpoch set DayEpochID disabledInflation",
- currentPeriod: 0,
- currentEpochNumber: 20, // so it's within range
- epochIdentifier: epochstypes.DayEpochID,
- skippedEpochs: 19,
- InflationEnabled: false,
- periodChanges: false,
- },
- {
- name: "SkippedEpoch set WeekEpochID disabledInflation ",
- currentPeriod: 0,
- currentEpochNumber: 20, // so it's within range
- epochIdentifier: epochstypes.WeekEpochID,
- skippedEpochs: 19,
- InflationEnabled: false,
- periodChanges: false,
- },
- {
- name: "[Period 0] disabledInflation",
- currentPeriod: 0,
- currentEpochNumber: 20, // so it's within range
- epochIdentifier: epochstypes.DayEpochID,
- skippedEpochs: 19,
- InflationEnabled: false,
- periodChanges: false,
- },
- {
- name: "[Period 0] period stays the same under epochs per period",
- currentPeriod: 0,
- currentEpochNumber: 29, // so it's within range
- epochIdentifier: epochstypes.DayEpochID,
- skippedEpochs: 0,
- InflationEnabled: true,
- periodChanges: false,
- },
- {
- name: "[Period 0] period changes once enough epochs have passed",
- currentPeriod: 0,
- currentEpochNumber: 30,
- epochIdentifier: epochstypes.DayEpochID,
- skippedEpochs: 0,
- InflationEnabled: true,
- periodChanges: true,
- },
- {
- name: "[Period 1] period stays the same under the epoch per period",
- currentPeriod: 1,
- currentEpochNumber: 59, // period change is at the end of epoch 59
- epochIdentifier: epochstypes.DayEpochID,
- skippedEpochs: 0,
- InflationEnabled: true,
- periodChanges: false,
- },
- {
- name: "[Period 1] period changes once enough epochs have passed",
- currentPeriod: 1,
- currentEpochNumber: 60,
- epochIdentifier: epochstypes.DayEpochID,
- skippedEpochs: 0,
- InflationEnabled: true,
- periodChanges: true,
- },
- {
- name: "[Period 0] with skipped epochs - period stays the same under epochs per period",
- currentPeriod: 0,
- currentEpochNumber: 30,
- epochIdentifier: epochstypes.DayEpochID,
- skippedEpochs: 1,
- InflationEnabled: true,
- periodChanges: false,
- },
- {
- name: "[Period 0] with skipped epochs - period changes once enough epochs have passed",
- currentPeriod: 0,
- currentEpochNumber: 40,
- epochIdentifier: epochstypes.DayEpochID,
- skippedEpochs: 10,
- InflationEnabled: true,
- periodChanges: true,
- },
- {
- name: "[Period 1] with skipped epochs - period stays the same under epochs per period",
- currentPeriod: 1,
- currentEpochNumber: 69,
- epochIdentifier: epochstypes.DayEpochID,
- skippedEpochs: 10,
- InflationEnabled: true,
- periodChanges: false,
- },
- {
- name: "[Period 1] with skipped epochs - period changes once enough epochs have passed",
- currentPeriod: 1,
- currentEpochNumber: 70,
- epochIdentifier: epochstypes.DayEpochID,
- skippedEpochs: 10,
- InflationEnabled: true,
- periodChanges: true,
- },
- }
- for _, tc := range testCases {
- t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) {
- params := inflationKeeper.GetParams(ctx)
- params.InflationEnabled = tc.InflationEnabled
- params.HasInflationStarted = tc.InflationEnabled
- inflationKeeper.Params.Set(ctx, params)
-
- inflationKeeper.NumSkippedEpochs.Set(ctx, tc.skippedEpochs)
- inflationKeeper.CurrentPeriod.Set(ctx, tc.currentPeriod)
-
- // original values
- prevSkippedEpochs := inflationKeeper.NumSkippedEpochs.Peek(ctx)
- prevPeriod := inflationKeeper.CurrentPeriod.Peek(ctx)
- originalProvision := inflationKeeper.GetEpochMintProvision(ctx)
-
- // Perform Epoch Hooks
- futureCtx := ctx.WithBlockTime(time.Now().Add(time.Minute))
- nibiruApp.EpochsKeeper.BeforeEpochStart(futureCtx, tc.epochIdentifier, tc.currentEpochNumber)
- nibiruApp.EpochsKeeper.AfterEpochEnd(futureCtx, tc.epochIdentifier, tc.currentEpochNumber)
-
- // new values
- newSkippedEpochs := inflationKeeper.NumSkippedEpochs.Peek(ctx)
- newPeriod := inflationKeeper.CurrentPeriod.Peek(ctx)
-
- if tc.periodChanges {
- newProvision := inflationKeeper.GetEpochMintProvision(ctx)
-
- expectedProvision := types.CalculateEpochMintProvision(
- inflationKeeper.GetParams(ctx),
- newPeriod,
- )
-
- require.Equal(t, expectedProvision, newProvision)
- // mint provisions will change
- require.NotEqual(t, newProvision, originalProvision)
- require.Equal(t, prevSkippedEpochs, newSkippedEpochs)
- require.Equal(t, prevPeriod+1, newPeriod)
- } else {
- require.Equal(t, prevPeriod, newPeriod, "period should not change but it did")
- if !tc.InflationEnabled && tc.epochIdentifier == epochstypes.DayEpochID {
- // Check for epochIdentifier for skippedEpoch increment
- require.EqualValues(t, prevSkippedEpochs+1, newSkippedEpochs)
- }
- }
- })
- }
-}
-
-func GetBalanceStaking(ctx sdk.Context, nibiruApp *app.NibiruApp) sdkmath.Int {
- return nibiruApp.BankKeeper.GetBalance(
- ctx,
- nibiruApp.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName),
- denoms.NIBI,
- ).Amount
-}
-
-func TestManual(t *testing.T) {
- // This test is a manual test to check if the inflation is working as expected
- // We turn off inflation, then we turn it on and check if the balance is increasing
- // We turn it off again and check if the balance is not increasing
- // We turn it on again and check if the balance is increasing again with the correct amount
-
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
- inflationKeeper := nibiruApp.InflationKeeper
-
- params := inflationKeeper.GetParams(ctx)
- epochNumber := uint64(1)
-
- params.InflationEnabled = false
- params.HasInflationStarted = false
- params.EpochsPerPeriod = 30
-
- // y = 3 * x + 3 -> 3 nibi per epoch for period 0, 6 nibi per epoch for period 1
- params.PolynomialFactors = []sdk.Dec{math.LegacyNewDec(3), math.LegacyNewDec(3)}
- params.InflationDistribution = types.InflationDistribution{
- CommunityPool: math.LegacyZeroDec(),
- StakingRewards: math.LegacyOneDec(),
- StrategicReserves: math.LegacyZeroDec(),
- }
-
- inflationKeeper.Params.Set(ctx, params)
-
- require.Equal(t, math.ZeroInt(), GetBalanceStaking(ctx, nibiruApp))
-
- for i := 0; i < 42069; i++ {
- inflationKeeper.Hooks().AfterEpochEnd(ctx, epochstypes.DayEpochID, epochNumber)
- epochNumber++
- }
- require.Equal(t, math.ZeroInt(), GetBalanceStaking(ctx, nibiruApp))
- require.EqualValues(t, uint64(0), inflationKeeper.CurrentPeriod.Peek(ctx))
- require.EqualValues(t, uint64(42069), inflationKeeper.NumSkippedEpochs.Peek(ctx))
-
- nibiruApp.EpochsKeeper.Epochs.Insert(ctx, epochstypes.DayEpochID, epochstypes.EpochInfo{
- Identifier: epochstypes.DayEpochID,
- StartTime: time.Now(),
- Duration: 0,
- CurrentEpoch: 42069,
- CurrentEpochStartTime: time.Now(),
- EpochCountingStarted: false,
- CurrentEpochStartHeight: 0,
- },
- )
- err := inflationKeeper.Sudo().ToggleInflation(ctx, true, testapp.DefaultSudoRoot())
- require.NoError(t, err)
-
- // Period 0 - inflate 3M NIBI over 30 epochs or 100k uNIBI per epoch
- for i := 0; i < 30; i++ {
- inflationKeeper.Hooks().AfterEpochEnd(ctx, epochstypes.DayEpochID, epochNumber)
- require.Equal(t, math.NewInt(100_000).Mul(math.NewInt(int64(i+1))), GetBalanceStaking(ctx, nibiruApp))
- epochNumber++
- }
- require.Equal(t, math.NewInt(3_000_000), GetBalanceStaking(ctx, nibiruApp))
- require.EqualValues(t, uint64(1), inflationKeeper.CurrentPeriod.Peek(ctx))
- require.EqualValues(t, uint64(42069), inflationKeeper.NumSkippedEpochs.Peek(ctx))
-
- err = inflationKeeper.Sudo().ToggleInflation(ctx, false, testapp.DefaultSudoRoot())
- require.NoError(t, err)
-
- for i := 0; i < 42069; i++ {
- inflationKeeper.Hooks().AfterEpochEnd(ctx, epochstypes.DayEpochID, epochNumber)
- epochNumber++
- }
- require.Equal(t, math.NewInt(3_000_000), GetBalanceStaking(ctx, nibiruApp))
- require.EqualValues(t, uint64(1), inflationKeeper.CurrentPeriod.Peek(ctx))
- require.EqualValues(t, uint64(84138), inflationKeeper.NumSkippedEpochs.Peek(ctx))
-
- err = inflationKeeper.Sudo().ToggleInflation(ctx, true, testapp.DefaultSudoRoot())
- require.NoError(t, err)
-
- // Period 1 - inflate 6M NIBI over 30 epochs or 200k uNIBI per epoch
- for i := 0; i < 30; i++ {
- inflationKeeper.Hooks().AfterEpochEnd(ctx, epochstypes.DayEpochID, epochNumber)
- require.Equal(t, math.NewInt(3_000_000).Add(math.NewInt(200_000).Mul(math.NewInt(int64(i+1)))), GetBalanceStaking(ctx, nibiruApp))
- epochNumber++
- }
- require.Equal(t, math.NewInt(9_000_000), GetBalanceStaking(ctx, nibiruApp))
- require.EqualValues(t, uint64(2), inflationKeeper.CurrentPeriod.Peek(ctx))
- require.EqualValues(t, uint64(84138), inflationKeeper.NumSkippedEpochs.Peek(ctx))
-
- require.EqualValues(t, uint64(1+2*42069+60), epochNumber)
-}
diff --git a/x/inflation/keeper/inflation.go b/x/inflation/keeper/inflation.go
deleted file mode 100644
index 67f8ab81f..000000000
--- a/x/inflation/keeper/inflation.go
+++ /dev/null
@@ -1,175 +0,0 @@
-package keeper
-
-import (
- "fmt"
-
- "cosmossdk.io/math"
- sdkmath "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// MintAndAllocateInflation mints and allocates tokens based on the polynomial
-// inflation coefficients and current block height.
-//
-// Args:
-// - coins: Tokens to be minted.
-// - params:
-//
-// Returns:
-// - staking: Tokens minted for staking inflation that go to the decentralized
-// validator set and delegators. This is handled by the `auth` module fee
-// collector.
-// - strategic: Tokens minted to the Strategic Reserve, the root account fo the
-// x/sudo module.
-// - community: Tokens minted to the Community Pool, which is managed strictly
-// by on-chain governance.
-func (k Keeper) MintAndAllocateInflation(
- ctx sdk.Context,
- coins sdk.Coin,
- params types.Params,
-) (
- staking, strategic, community sdk.Coin,
- err error,
-) {
- // skip as no coins need to be minted
- if coins.Amount.IsNil() || !coins.Amount.IsPositive() {
- return sdk.Coin{}, sdk.Coin{}, sdk.Coin{}, nil
- }
-
- // Mint coins for distribution
- if err := k.MintCoins(ctx, coins); err != nil {
- return sdk.Coin{}, sdk.Coin{}, sdk.Coin{}, err
- }
-
- // Allocate minted coins according to allocation proportions (staking, strategic, community pool)
- return k.AllocatePolynomialInflation(ctx, coins, params)
-}
-
-// MintCoins calls the underlying [BankKeeper] mints tokens "coin".
-func (k Keeper) MintCoins(ctx sdk.Context, coin sdk.Coin) error {
- coins := sdk.Coins{coin}
- return k.bankKeeper.MintCoins(ctx, types.ModuleName, coins)
-}
-
-// AllocatePolynomialInflation allocates coins from the inflation to external
-// modules according to proportions proportions:
-//
-// Returns:
-// - staking: Tokens minted for staking inflation that go to the decentralized
-// validator set and delegators. This is handled by the `auth` module fee
-// collector.
-// - strategic: Tokens minted to the Strategic Reserve, the root account fo the
-// x/sudo module.
-// - community: Tokens minted to the Community Pool, which is managed strictly
-// by on-chain governance.
-func (k Keeper) AllocatePolynomialInflation(
- ctx sdk.Context,
- mintedCoin sdk.Coin,
- params types.Params,
-) (
- staking, strategic, community sdk.Coin,
- err error,
-) {
- inflationDistribution := params.InflationDistribution
- inflationModuleAddr := k.accountKeeper.GetModuleAddress(types.ModuleName)
-
- // Allocate staking rewards into fee collector account
- staking = k.GetProportions(ctx, mintedCoin, inflationDistribution.StakingRewards)
- if err := k.bankKeeper.SendCoinsFromModuleToModule(
- ctx,
- types.ModuleName,
- k.feeCollectorName,
- sdk.NewCoins(staking),
- ); err != nil {
- return staking, strategic, community, err
- }
-
- // Allocate community pool rewards into community pool
- community = k.GetProportions(ctx, mintedCoin, inflationDistribution.CommunityPool)
- if err = k.distrKeeper.FundCommunityPool(
- ctx,
- sdk.NewCoins(community),
- inflationModuleAddr,
- ); err != nil {
- return staking, strategic, community, err
- }
-
- // Remaining balance is strategic reserve allocation to the root account
- // of the x/sudo module
- strategic = k.bankKeeper.GetBalance(ctx, inflationModuleAddr, denoms.NIBI)
- strategicAccountAddr, err := k.sudoKeeper.GetRootAddr(ctx)
- if err != nil {
- err := fmt.Errorf("inflation error: failed to get sudo root account: %w", err)
- k.Logger(ctx).Error(err.Error())
- return staking, strategic, community, err
- }
-
- if err = k.bankKeeper.SendCoinsFromModuleToAccount(
- ctx, types.ModuleName, strategicAccountAddr, sdk.NewCoins(strategic),
- ); err != nil {
- err := fmt.Errorf("inflation error: failed to send coins to sudo root account: %w", err)
- k.Logger(ctx).Error(err.Error())
- return staking, strategic, community, err
- }
-
- return staking, strategic, community, ctx.EventManager().EmitTypedEvents(
- &types.EventInflationDistribution{
- StakingRewards: staking,
- StrategicReserve: strategic,
- CommunityPool: community,
- })
-}
-
-// GetAllocationProportion calculates the proportion of coins that is to be
-// allocated during inflation for a given distribution.
-func (k Keeper) GetProportions(
- _ sdk.Context,
- coin sdk.Coin,
- proportion sdk.Dec,
-) sdk.Coin {
- return sdk.Coin{
- Denom: coin.Denom,
- Amount: math.LegacyNewDecFromInt(coin.Amount).Mul(proportion).TruncateInt(),
- }
-}
-
-// GetCirculatingSupply returns the bank supply of the mintDenom excluding the
-// team allocation in the first year
-func (k Keeper) GetCirculatingSupply(ctx sdk.Context, mintDenom string) sdkmath.Int {
- return k.bankKeeper.GetSupply(ctx, mintDenom).Amount
-}
-
-// GetInflationRate returns the inflation rate for the current period.
-func (k Keeper) GetInflationRate(ctx sdk.Context, mintDenom string) sdk.Dec {
- epochMintProvision := k.GetEpochMintProvision(ctx)
- if epochMintProvision.IsZero() {
- return math.LegacyZeroDec()
- }
-
- circulatingSupply := k.GetCirculatingSupply(ctx, mintDenom)
- if circulatingSupply.IsZero() {
- return math.LegacyZeroDec()
- }
-
- // EpochMintProvision * 365 / circulatingSupply * 100
- circulatingSupplyToDec := math.LegacyNewDecFromInt(circulatingSupply)
- return epochMintProvision.
- MulInt64(int64(k.GetEpochsPerPeriod(ctx))).
- MulInt64(int64(k.GetPeriodsPerYear(ctx))).
- Quo(circulatingSupplyToDec).
- Mul(math.LegacyNewDec(100))
-}
-
-// GetEpochMintProvision retrieves necessary params KV storage
-// and calculate EpochMintProvision
-func (k Keeper) GetEpochMintProvision(ctx sdk.Context) sdk.Dec {
- peek := k.CurrentPeriod.Peek(ctx)
-
- return types.CalculateEpochMintProvision(
- k.GetParams(ctx),
- peek,
- )
-}
diff --git a/x/inflation/keeper/inflation_test.go b/x/inflation/keeper/inflation_test.go
deleted file mode 100644
index fe09a54a4..000000000
--- a/x/inflation/keeper/inflation_test.go
+++ /dev/null
@@ -1,205 +0,0 @@
-package keeper_test
-
-import (
- "fmt"
- "testing"
-
- "cosmossdk.io/math"
-
- sdkmath "cosmossdk.io/math"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/inflation/types"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
-)
-
-func init() {
- testapp.EnsureNibiruPrefix()
-}
-
-func TestMintAndAllocateInflation(t *testing.T) {
- testCases := []struct {
- name string
- coinsToMint sdk.Coin
- expectedStakingAmt sdk.Coin
- expectedStrategicAmt sdk.Coin
- expectedCommunityAmt sdk.Coin
- expectedStakingRewardsBalance sdk.Coin
- expectedStrategicReservesBalance sdk.Coin
- expectedCommunityPoolBalance sdk.DecCoins
- rootAccount string
- }{
- {
- name: "pass",
- coinsToMint: sdk.NewCoin(denoms.NIBI, math.NewInt(1_000_000)),
- expectedStakingAmt: sdk.NewCoin(denoms.NIBI, math.NewInt(281_250)),
- expectedStrategicAmt: sdk.NewCoin(denoms.NIBI, math.NewInt(363_925)),
- expectedCommunityAmt: sdk.NewCoin(denoms.NIBI, math.NewInt(354_825)),
- expectedStakingRewardsBalance: sdk.NewCoin(denoms.NIBI, math.NewInt(281_250)),
- expectedStrategicReservesBalance: sdk.NewCoin(denoms.NIBI, math.NewInt(363_925)),
- expectedCommunityPoolBalance: sdk.NewDecCoins(sdk.NewDecCoin(denoms.NIBI, math.NewInt(354_825))),
- rootAccount: "nibi1qyqf35fkhn73hjr70442fctpq8prpqr9ysj9sn",
- },
- {
- name: "pass - no coins minted ",
- coinsToMint: sdk.NewCoin(denoms.NIBI, math.ZeroInt()),
- expectedStakingAmt: sdk.Coin{},
- expectedStrategicAmt: sdk.Coin{},
- expectedCommunityAmt: sdk.Coin{},
- expectedStakingRewardsBalance: sdk.NewCoin(denoms.NIBI, math.ZeroInt()),
- expectedStrategicReservesBalance: sdk.NewCoin(denoms.NIBI, math.ZeroInt()),
- expectedCommunityPoolBalance: nil,
- rootAccount: "nibi1qyqf35fkhn73hjr70442fctpq8prpqr9ysj9sn",
- },
- {
- name: "pass - no root account",
- coinsToMint: sdk.NewCoin(denoms.NIBI, math.NewInt(1_000_000)),
- expectedStakingAmt: sdk.NewCoin(denoms.NIBI, math.NewInt(281_250)),
- expectedStrategicAmt: sdk.NewCoin(denoms.NIBI, math.NewInt(363_925)),
- expectedCommunityAmt: sdk.NewCoin(denoms.NIBI, math.NewInt(354_825)),
- expectedStakingRewardsBalance: sdk.NewCoin(denoms.NIBI, math.NewInt(281_250)),
- expectedStrategicReservesBalance: sdk.NewCoin(denoms.NIBI, math.NewInt(363_925)),
- expectedCommunityPoolBalance: sdk.NewDecCoins(sdk.NewDecCoin(denoms.NIBI, math.NewInt(354_825))),
- rootAccount: "",
- },
- }
- for _, tc := range testCases {
- t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
-
- t.Logf("setting root account to %s", tc.rootAccount)
- nibiruApp.SudoKeeper.Sudoers.Set(ctx, sudotypes.Sudoers{
- Root: tc.rootAccount,
- Contracts: []string{},
- })
-
- staking, strategic, community, err := nibiruApp.InflationKeeper.MintAndAllocateInflation(ctx, tc.coinsToMint, types.DefaultParams())
- if tc.rootAccount != "" {
- require.NoError(t, err)
- } else {
- require.Error(t, err)
- return
- }
- assert.Equal(t, tc.expectedStakingAmt, staking)
- assert.Equal(t, tc.expectedStrategicAmt, strategic)
- assert.Equal(t, tc.expectedCommunityAmt, community)
-
- // Get balances
- var balanceStrategicReserve sdk.Coin
- if tc.rootAccount != "" {
- strategicAccount, err := nibiruApp.SudoKeeper.GetRootAddr(ctx)
- require.NoError(t, err)
- balanceStrategicReserve = nibiruApp.BankKeeper.GetBalance(
- ctx,
- strategicAccount,
- denoms.NIBI,
- )
- } else {
- // if no root account is specified, then the strategic reserve remains in the x/inflation module account
- balanceStrategicReserve = nibiruApp.BankKeeper.GetBalance(ctx, nibiruApp.AccountKeeper.GetModuleAddress(types.ModuleName), denoms.NIBI)
- }
-
- balanceStakingRewards := nibiruApp.BankKeeper.GetBalance(
- ctx,
- nibiruApp.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName),
- denoms.NIBI,
- )
-
- balanceCommunityPool := nibiruApp.DistrKeeper.GetFeePoolCommunityCoins(ctx)
-
- require.NoError(t, err, tc.name)
- assert.Equal(t,
- tc.expectedStakingRewardsBalance.String(),
- balanceStakingRewards.String())
- assert.Equal(t,
- tc.expectedStrategicReservesBalance.String(),
- balanceStrategicReserve.String())
- assert.Equal(t,
- tc.expectedCommunityPoolBalance.String(),
- balanceCommunityPool.String())
- })
- }
-}
-
-func TestGetCirculatingSupplyAndInflationRate(t *testing.T) {
- testCases := []struct {
- name string
- supply sdkmath.Int
- malleate func(nibiruApp *app.NibiruApp, ctx sdk.Context)
- expInflationRate sdk.Dec
- }{
- {
- "no epochs per period",
- sdk.TokensFromConsensusPower(400_000_000, sdk.DefaultPowerReduction),
- func(nibiruApp *app.NibiruApp, ctx sdk.Context) {
- nibiruApp.InflationKeeper.Params.Set(ctx, types.Params{
- EpochsPerPeriod: 0,
- InflationEnabled: true,
- PolynomialFactors: types.DefaultPolynomialFactors,
- InflationDistribution: types.DefaultInflationDistribution,
- })
- },
- math.LegacyZeroDec(),
- },
- {
- "high supply",
- sdk.TokensFromConsensusPower(800_000_000, sdk.DefaultPowerReduction),
- func(nibiruApp *app.NibiruApp, ctx sdk.Context) {
- params := nibiruApp.InflationKeeper.GetParams(ctx)
- params.InflationEnabled = true
- nibiruApp.InflationKeeper.Params.Set(ctx, params)
- },
- math.LegacyMustNewDecFromStr("26.741197359810099000"),
- },
- {
- "low supply",
- sdk.TokensFromConsensusPower(400_000_000, sdk.DefaultPowerReduction),
- func(nibiruApp *app.NibiruApp, ctx sdk.Context) {
- params := nibiruApp.InflationKeeper.GetParams(ctx)
- params.InflationEnabled = true
- nibiruApp.InflationKeeper.Params.Set(ctx, params)
- },
- math.LegacyMustNewDecFromStr("53.482394719620198000"),
- },
- }
- for _, tc := range testCases {
- t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
-
- tc.malleate(nibiruApp, ctx)
-
- // Mint coins to increase supply
- coin := sdk.NewCoin(
- denoms.NIBI,
- tc.supply,
- )
- err := nibiruApp.InflationKeeper.MintCoins(ctx, coin)
- require.NoError(t, err)
-
- circulatingSupply := nibiruApp.InflationKeeper.GetCirculatingSupply(ctx, denoms.NIBI)
- require.EqualValues(t, tc.supply, circulatingSupply)
-
- inflationRate := nibiruApp.InflationKeeper.GetInflationRate(ctx, denoms.NIBI)
- require.Equal(t, tc.expInflationRate, inflationRate)
- })
- }
-}
-
-func TestGetters(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
- k := nibiruApp.InflationKeeper
- require.NotPanics(t, func() {
- _ = k.GetPolynomialFactors(ctx)
- _ = k.GetPeriodsPerYear(ctx)
- _ = k.GetInflationDistribution(ctx)
- _ = k.GetInflationEnabled(ctx)
- _ = k.GetEpochsPerPeriod(ctx)
- })
-}
diff --git a/x/inflation/keeper/keeper.go b/x/inflation/keeper/keeper.go
deleted file mode 100644
index 43742b843..000000000
--- a/x/inflation/keeper/keeper.go
+++ /dev/null
@@ -1,101 +0,0 @@
-package keeper
-
-import (
- "github.com/NibiruChain/collections"
- "github.com/cometbft/cometbft/libs/log"
- "github.com/cosmos/cosmos-sdk/codec"
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
-
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// Keeper of the inflation module. Keepers are module-specific "gate keepers"
-// responsible for encapsulating access to the key-value stores (state) of the
-// network. The functions on the Keeper contain all of the business logic for
-// reading and modifying state.
-type Keeper struct {
- cdc codec.BinaryCodec
- storeKey storetypes.StoreKey
- // paramSpace: unused but present for backward compatibility. Removing this
- // breaks the state machine and requires an upgrade.
- paramSpace paramstypes.Subspace
-
- accountKeeper types.AccountKeeper
- bankKeeper types.BankKeeper
- distrKeeper types.DistrKeeper
- stakingKeeper types.StakingKeeper
- sudoKeeper types.SudoKeeper
- // feeCollectorName is the name of of x/auth module's fee collector module
- // account, "fee_collector", which collects transaction fees for distribution
- // to all stakers.
- // By sending staking inflation to the fee collector, the tokens are properly
- // distributed to validator operators and their delegates.
- // See the `[AllocateTokens]` function from x/distribution to learn more.
- // [AllocateTokens]: https://github.com/cosmos/cosmos-sdk/blob/v0.50.3/x/distribution/keeper/allocation.go
- feeCollectorName string
-
- // CurrentPeriod: Strictly increasing counter for the inflation "period".
- CurrentPeriod collections.Sequence
-
- // NumSkippedEpochs: Strictly increasing counter for the number of skipped
- // epochs. Inflation epochs are skipped when [types.Params.InflationEnabled]
- // is false so that gaps in the active status of inflation don't mess up the
- // polynomial computation. It allows inflation to smoothly be toggled on and
- // off.
- NumSkippedEpochs collections.Sequence
-
- // Params stores module-specific parameters that specify the blockchain token
- // economics, token release schedule, maximum supply, and whether or not
- // inflation is enabled on the network.
- Params collections.Item[types.Params]
-}
-
-// NewKeeper creates a new mint Keeper instance
-func NewKeeper(
- cdc codec.BinaryCodec,
- storeKey storetypes.StoreKey,
- paramspace paramstypes.Subspace,
- accountKeeper types.AccountKeeper,
- bankKeeper types.BankKeeper,
- distributionKeeper types.DistrKeeper,
- stakingKeeper types.StakingKeeper,
- sudoKeeper types.SudoKeeper,
- feeCollectorName string,
-) Keeper {
- // ensure mint module account is set
- if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil {
- panic("the inflation module account has not been set")
- }
-
- return Keeper{
- storeKey: storeKey,
- cdc: cdc,
- paramSpace: paramspace,
- accountKeeper: accountKeeper,
- bankKeeper: bankKeeper,
- distrKeeper: distributionKeeper,
- stakingKeeper: stakingKeeper,
- sudoKeeper: sudoKeeper,
- feeCollectorName: feeCollectorName,
- CurrentPeriod: collections.NewSequence(storeKey, 0),
- NumSkippedEpochs: collections.NewSequence(storeKey, 1),
- Params: collections.NewItem(storeKey, 2, collections.ProtoValueEncoder[types.Params](cdc)),
- }
-}
-
-// Logger returns a module-specific logger.
-func (k Keeper) Logger(ctx sdk.Context) log.Logger {
- return ctx.Logger().With("module", "x/"+types.ModuleName)
-}
-
-func (k Keeper) Burn(ctx sdk.Context, coins sdk.Coins, sender sdk.AccAddress) error {
- if err := k.bankKeeper.SendCoinsFromAccountToModule(
- ctx, sender, types.ModuleName, coins,
- ); err != nil {
- return err
- }
-
- return k.bankKeeper.BurnCoins(ctx, types.ModuleName, coins)
-}
diff --git a/x/inflation/keeper/keeper_test.go b/x/inflation/keeper/keeper_test.go
deleted file mode 100644
index 06473700c..000000000
--- a/x/inflation/keeper/keeper_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package keeper_test
-
-import (
- "fmt"
- "testing"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-func init() {
- testapp.EnsureNibiruPrefix()
-}
-
-func TestBurn(t *testing.T) {
- testCases := []struct {
- name string
- sender sdk.AccAddress
- mintCoin sdk.Coin
- burnCoin sdk.Coin
- expectedErr error
- }{
- {
- name: "pass",
- sender: testutil.AccAddress(),
- mintCoin: sdk.NewCoin("unibi", math.NewInt(100)),
- burnCoin: sdk.NewCoin("unibi", math.NewInt(100)),
- expectedErr: nil,
- },
- {
- name: "not enough coins",
- sender: testutil.AccAddress(),
- mintCoin: sdk.NewCoin("unibi", math.NewInt(100)),
- burnCoin: sdk.NewCoin("unibi", math.NewInt(101)),
- expectedErr: fmt.Errorf("spendable balance 100unibi is smaller than 101unibi: insufficient funds"),
- },
- }
-
- for _, tc := range testCases {
- t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) {
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
-
- // mint and send money to the sender
- require.NoError(t,
- nibiruApp.BankKeeper.MintCoins(
- ctx, types.ModuleName, sdk.NewCoins(tc.mintCoin)))
- require.NoError(t,
- nibiruApp.BankKeeper.SendCoinsFromModuleToAccount(
- ctx, types.ModuleName, tc.sender, sdk.NewCoins(tc.mintCoin)),
- )
-
- supply := nibiruApp.BankKeeper.GetSupply(ctx, "unibi")
- require.Equal(t, tc.mintCoin.Amount, supply.Amount)
-
- // Burn coins
- err := nibiruApp.InflationKeeper.Burn(ctx, sdk.NewCoins(tc.burnCoin), tc.sender)
- supply = nibiruApp.BankKeeper.GetSupply(ctx, "unibi")
- if tc.expectedErr != nil {
- require.EqualError(t, err, tc.expectedErr.Error())
- require.Equal(t, tc.mintCoin.Amount, supply.Amount)
- } else {
- require.NoError(t, err)
- require.Equal(t, math.ZeroInt(), supply.Amount)
- }
- })
- }
-}
diff --git a/x/inflation/keeper/msg_server.go b/x/inflation/keeper/msg_server.go
deleted file mode 100644
index b1cc8048a..000000000
--- a/x/inflation/keeper/msg_server.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package keeper
-
-import (
- "context"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-type msgServer struct {
- Keeper
-}
-
-// NewMsgServerImpl returns an implementation of the inflation MsgServer interface
-// for the provided Keeper.
-func NewMsgServerImpl(keeper Keeper) types.MsgServer {
- return &msgServer{Keeper: keeper}
-}
-
-// EditInflationParams: gRPC tx msg for editing the inflation module params.
-// [SUDO] Only callable by sudoers.
-func (ms msgServer) EditInflationParams(
- goCtx context.Context, msg *types.MsgEditInflationParams,
-) (resp *types.MsgEditInflationParamsResponse, err error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
- // Stateless field validation is already performed in msg.ValidateBasic()
- // before the current scope is reached.
- sender, _ := sdk.AccAddressFromBech32(msg.Sender)
- err = ms.Sudo().EditInflationParams(ctx, *msg, sender)
-
- resp = &types.MsgEditInflationParamsResponse{}
- return resp, err
-}
-
-// ToggleInflation: gRPC tx msg for enabling or disabling token inflation.
-// [SUDO] Only callable by sudoers.
-func (ms msgServer) ToggleInflation(
- goCtx context.Context, msg *types.MsgToggleInflation,
-) (resp *types.MsgToggleInflationResponse, err error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
- // Stateless field validation is already performed in msg.ValidateBasic()
- // before the current scope is reached.
- sender, _ := sdk.AccAddressFromBech32(msg.Sender)
- err = ms.Sudo().ToggleInflation(ctx, msg.Enable, sender)
- resp = &types.MsgToggleInflationResponse{}
- return resp, err
-}
diff --git a/x/inflation/keeper/msg_server_test.go b/x/inflation/keeper/msg_server_test.go
deleted file mode 100644
index 1823ce85d..000000000
--- a/x/inflation/keeper/msg_server_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package keeper_test
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/inflation/keeper"
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-func TestMsgToggleInflation(t *testing.T) {
- app, ctx := testapp.NewNibiruTestAppAndContext()
- msgServer := keeper.NewMsgServerImpl(app.InflationKeeper)
-
- params := app.InflationKeeper.GetParams(ctx)
- require.False(t, params.InflationEnabled)
-
- msg := types.MsgToggleInflation{
- Sender: testutil.AccAddress().String(),
- Enable: false,
- }
- _, err := msgServer.ToggleInflation(ctx, &msg)
- require.ErrorContains(t, err, "insufficient permissions on smart contract")
-
- params = app.InflationKeeper.GetParams(ctx)
- require.False(t, params.InflationEnabled)
-
- msg = types.MsgToggleInflation{
- Sender: testapp.DefaultSudoRoot().String(),
- Enable: true,
- }
-
- _, err = msgServer.ToggleInflation(ctx, &msg)
- require.NoError(t, err)
-
- params = app.InflationKeeper.GetParams(ctx)
- require.True(t, params.InflationEnabled)
-}
-
-func TestMsgEditInflationParams(t *testing.T) {
- app, ctx := testapp.NewNibiruTestAppAndContext()
- msgServer := keeper.NewMsgServerImpl(app.InflationKeeper)
-
- params := app.InflationKeeper.GetParams(ctx)
- require.NotEqualValues(t, params.EpochsPerPeriod, 42)
-
- newEpochPerPeriod := math.NewInt(42)
- msg := types.MsgEditInflationParams{
- Sender: testutil.AccAddress().String(),
- EpochsPerPeriod: &newEpochPerPeriod,
- }
- _, err := msgServer.EditInflationParams(ctx, &msg)
- require.ErrorContains(t, err, "insufficient permissions on smart contract")
-
- params = app.InflationKeeper.GetParams(ctx)
- require.NotEqualValues(t, params.EpochsPerPeriod, 42)
-
- msg = types.MsgEditInflationParams{
- Sender: testapp.DefaultSudoRoot().String(),
- EpochsPerPeriod: &newEpochPerPeriod,
- }
-
- _, err = msgServer.EditInflationParams(ctx, &msg)
- require.NoError(t, err)
-
- params = app.InflationKeeper.GetParams(ctx)
- require.EqualValues(t, params.EpochsPerPeriod, 42)
-}
diff --git a/x/inflation/keeper/params.go b/x/inflation/keeper/params.go
deleted file mode 100644
index 3068045de..000000000
--- a/x/inflation/keeper/params.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package keeper
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-func (k Keeper) GetParams(ctx sdk.Context) types.Params {
- params, _ := k.Params.Get(ctx)
- return params
-}
-
-func (k Keeper) GetPolynomialFactors(ctx sdk.Context) (res []sdk.Dec) {
- params, _ := k.Params.Get(ctx)
- return params.PolynomialFactors
-}
-
-func (k Keeper) GetInflationDistribution(ctx sdk.Context) (res types.InflationDistribution) {
- params, _ := k.Params.Get(ctx)
- return params.InflationDistribution
-}
-
-func (k Keeper) GetInflationEnabled(ctx sdk.Context) (res bool) {
- params, _ := k.Params.Get(ctx)
- return params.InflationEnabled
-}
-
-func (k Keeper) GetEpochsPerPeriod(ctx sdk.Context) (res uint64) {
- params, _ := k.Params.Get(ctx)
- return params.EpochsPerPeriod
-}
-
-func (k Keeper) GetPeriodsPerYear(ctx sdk.Context) (res uint64) {
- params, _ := k.Params.Get(ctx)
- return params.PeriodsPerYear
-}
diff --git a/x/inflation/keeper/sudo.go b/x/inflation/keeper/sudo.go
deleted file mode 100644
index aa01e10a8..000000000
--- a/x/inflation/keeper/sudo.go
+++ /dev/null
@@ -1,97 +0,0 @@
-package keeper
-
-import (
- "fmt"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// Sudo extends the Keeper with sudo functions. See [x/sudo].
-//
-// These sudo functions should:
-// 1. Not be called in other methods in the module.
-// 2. Only be callable by the x/sudo root or sudo contracts.
-//
-// The intention behind "[Keeper.Sudo]" is to make it more obvious to the
-// developer that an unsafe function is being used when it's called.
-// [x/sudo]: https://pkg.go.dev/github.com/NibiruChain/nibiru@v1.1.0/x/sudo/keeper
-func (k Keeper) Sudo() sudoExtension { return sudoExtension{k} }
-
-type sudoExtension struct{ Keeper }
-
-// EditInflationParams performs a partial struct update, or struct merge, on the
-// module parameters, given a subset of the params, `newParams`. Only the new
-// params are overwritten.
-func (k sudoExtension) EditInflationParams(
- ctx sdk.Context, newParams inflationtypes.MsgEditInflationParams,
- sender sdk.AccAddress,
-) (err error) {
- if err = k.sudoKeeper.CheckPermissions(sender, ctx); err != nil {
- return
- }
-
- params, err := k.Params.Get(ctx)
- if err != nil {
- return fmt.Errorf("%w: failed to read inflation params", err)
- }
-
- paramsAfter, err := MergeInflationParams(newParams, params)
- if err != nil {
- return
- }
- k.Params.Set(ctx, paramsAfter)
- return paramsAfter.Validate()
-}
-
-// ToggleInflation disables (pauses) or enables (unpauses) inflation.
-func (k sudoExtension) ToggleInflation(
- ctx sdk.Context, enabled bool, sender sdk.AccAddress,
-) (err error) {
- if err = k.sudoKeeper.CheckPermissions(sender, ctx); err != nil {
- return
- }
-
- params, err := k.Params.Get(ctx)
- if err != nil {
- return
- }
-
- params.InflationEnabled = enabled
- if enabled && !params.HasInflationStarted {
- params.HasInflationStarted = true
- }
-
- k.Params.Set(ctx, params)
- return
-}
-
-// MergeInflationParams: Performs a partial struct update using [partial] and
-// merges its params into the existing [inflationParams], keeping any existing
-// values that are not set in the partial. For use with
-// [Keeper.EditInflationParams].
-func MergeInflationParams(
- partial inflationtypes.MsgEditInflationParams,
- inflationParams inflationtypes.Params,
-) (inflationtypes.Params, error) {
- if partial.PolynomialFactors != nil {
- inflationParams.PolynomialFactors = partial.PolynomialFactors
- }
-
- if partial.InflationDistribution != nil {
- inflationParams.InflationDistribution = *partial.InflationDistribution
- }
-
- if partial.EpochsPerPeriod != nil {
- inflationParams.EpochsPerPeriod = partial.EpochsPerPeriod.Uint64()
- }
- if partial.PeriodsPerYear != nil {
- inflationParams.PeriodsPerYear = partial.PeriodsPerYear.Uint64()
- }
- if partial.MaxPeriod != nil {
- inflationParams.MaxPeriod = partial.MaxPeriod.Uint64()
- }
-
- return inflationParams, inflationParams.Validate()
-}
diff --git a/x/inflation/keeper/sudo_test.go b/x/inflation/keeper/sudo_test.go
deleted file mode 100644
index 511719352..000000000
--- a/x/inflation/keeper/sudo_test.go
+++ /dev/null
@@ -1,134 +0,0 @@
-package keeper_test
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- inflationKeeper "github.com/NibiruChain/nibiru/x/inflation/keeper"
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-func TestSuiteInflationSudo(t *testing.T) {
- suite.Run(t, new(SuiteInflationSudo))
-}
-
-type SuiteInflationSudo struct {
- suite.Suite
-}
-
-func (s *SuiteInflationSudo) TestMergeInflationParams() {
- currentParams := types.DefaultParams()
-
- newEpochsPerPeriod := math.NewInt(4)
- paramsChanges := types.MsgEditInflationParams{
- EpochsPerPeriod: &newEpochsPerPeriod,
- }
-
- paramsAfter, err := inflationKeeper.MergeInflationParams(paramsChanges, currentParams)
- s.Require().NoError(err)
- s.Require().EqualValues(4, paramsAfter.EpochsPerPeriod)
-
- // Test that the other params are unchanged.
- s.Require().EqualValues(currentParams.InflationEnabled, paramsAfter.InflationEnabled)
- s.Require().EqualValues(currentParams.PeriodsPerYear, paramsAfter.PeriodsPerYear)
- s.Require().EqualValues(currentParams.MaxPeriod, paramsAfter.MaxPeriod)
- s.Require().EqualValues(currentParams.PolynomialFactors, paramsAfter.PolynomialFactors)
- s.Require().EqualValues(currentParams.InflationDistribution, paramsAfter.InflationDistribution)
-
- // Test a change to all parameters
- newInflationDistribution := types.InflationDistribution{
- CommunityPool: math.LegacyMustNewDecFromStr("0.8"),
- StakingRewards: math.LegacyMustNewDecFromStr("0.1"),
- StrategicReserves: math.LegacyMustNewDecFromStr("0.1"),
- }
-
- paramsChanges = types.MsgEditInflationParams{
- EpochsPerPeriod: &newEpochsPerPeriod,
- PeriodsPerYear: &newEpochsPerPeriod,
- MaxPeriod: &newEpochsPerPeriod,
- PolynomialFactors: []sdk.Dec{
- math.LegacyMustNewDecFromStr("0.1"),
- math.LegacyMustNewDecFromStr("0.2"),
- },
- InflationDistribution: &newInflationDistribution,
- }
-
- paramsAfter, err = inflationKeeper.MergeInflationParams(paramsChanges, currentParams)
- s.Require().NoError(err)
- s.Require().EqualValues(4, paramsAfter.EpochsPerPeriod)
- s.Require().EqualValues(4, paramsAfter.PeriodsPerYear)
- s.Require().EqualValues(4, paramsAfter.MaxPeriod)
- s.Require().EqualValues([]sdk.Dec{
- math.LegacyMustNewDecFromStr("0.1"),
- math.LegacyMustNewDecFromStr("0.2"),
- }, paramsAfter.PolynomialFactors)
- s.Require().EqualValues(newInflationDistribution, paramsAfter.InflationDistribution)
-}
-
-func (s *SuiteInflationSudo) TestEditInflationParams() {
- nibiru, ctx := testapp.NewNibiruTestAppAndContext()
-
- // Change to all non-defaults to test EditInflationParams as a setter .
- epochsPerPeriod := math.NewInt(1_234)
- periodsPerYear := math.NewInt(1_234)
- maxPeriod := math.NewInt(1_234)
- polynomialFactors := []sdk.Dec{
- math.LegacyMustNewDecFromStr("0.1"),
- math.LegacyMustNewDecFromStr("0.2"),
- }
- inflationDistribution := types.InflationDistribution{
- CommunityPool: math.LegacyMustNewDecFromStr("0.8"),
- StakingRewards: math.LegacyMustNewDecFromStr("0.1"),
- StrategicReserves: math.LegacyMustNewDecFromStr("0.1"),
- }
- msgEditParams := types.MsgEditInflationParams{
- EpochsPerPeriod: &epochsPerPeriod,
- PeriodsPerYear: &periodsPerYear,
- MaxPeriod: &maxPeriod,
- PolynomialFactors: polynomialFactors,
- InflationDistribution: &inflationDistribution,
- }
-
- s.T().Log("Params before MUST NOT be equal to default")
- defaultParams := types.DefaultParams()
- currParams, err := nibiru.InflationKeeper.Params.Get(ctx)
- s.Require().NoError(err)
- s.Require().Equal(currParams, defaultParams,
- "Current params should be eqaul to defaults")
- partialParams := msgEditParams
-
- s.T().Log("EditInflationParams should succeed")
- okSender := testapp.DefaultSudoRoot()
- err = nibiru.InflationKeeper.Sudo().EditInflationParams(ctx, partialParams, okSender)
- s.Require().NoError(err)
-
- s.T().Log("Params after MUST be equal to partial params")
- paramsAfter, err := nibiru.InflationKeeper.Params.Get(ctx)
- s.Require().NoError(err)
- s.Require().EqualValues(1234, paramsAfter.EpochsPerPeriod)
- s.Require().EqualValues(1234, paramsAfter.PeriodsPerYear)
- s.Require().EqualValues(1234, paramsAfter.MaxPeriod)
- s.Require().EqualValues(polynomialFactors, paramsAfter.PolynomialFactors)
- s.Require().EqualValues(inflationDistribution, paramsAfter.InflationDistribution)
-}
-
-func (s *SuiteInflationSudo) TestToggleInflation() {
- nibiru, ctx := testapp.NewNibiruTestAppAndContext()
-
- err := nibiru.InflationKeeper.Sudo().ToggleInflation(ctx, true, testapp.DefaultSudoRoot())
- s.Require().NoError(err)
-
- params, err := nibiru.InflationKeeper.Params.Get(ctx)
- s.Require().NoError(err)
- s.Require().True(params.InflationEnabled)
-
- err = nibiru.InflationKeeper.Sudo().ToggleInflation(ctx, false, testapp.DefaultSudoRoot())
- s.Require().NoError(err)
- params, err = nibiru.InflationKeeper.Params.Get(ctx)
- s.Require().NoError(err)
- s.Require().False(params.InflationEnabled)
-}
diff --git a/x/inflation/module.go b/x/inflation/module.go
deleted file mode 100644
index d0ab48ee3..000000000
--- a/x/inflation/module.go
+++ /dev/null
@@ -1,174 +0,0 @@
-package inflation
-
-import (
- "context"
- "encoding/json"
- "fmt"
-
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
- simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
- authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
- stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/inflation/client/cli"
- "github.com/NibiruChain/nibiru/x/inflation/keeper"
- "github.com/NibiruChain/nibiru/x/inflation/simulation"
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// type check to ensure the interface is properly implemented
-var (
- _ module.AppModule = AppModule{}
- _ module.AppModuleBasic = AppModuleBasic{}
- _ module.AppModuleSimulation = AppModule{}
-)
-
-// AppModuleBasic struct
-type AppModuleBasic struct{}
-
-// Name returns the inflation module's name.
-func (AppModuleBasic) Name() string {
- return types.ModuleName
-}
-
-// RegisterLegacyAminoCodec registers the inflation module's types on the given LegacyAmino codec.
-func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- types.RegisterLegacyAminoCodec(cdc)
-}
-
-// ConsensusVersion returns the consensus state-breaking version for the module.
-func (AppModuleBasic) ConsensusVersion() uint64 {
- return 3
-}
-
-// RegisterInterfaces registers the module's interface types
-func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- types.RegisterInterfaces(registry)
-}
-
-// DefaultGenesis returns default genesis state as raw bytes for the inflation
-// module.
-func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
- return cdc.MustMarshalJSON(types.DefaultGenesisState())
-}
-
-// ValidateGenesis performs genesis state validation for the inflation module.
-func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
- var genesisState types.GenesisState
- if err := cdc.UnmarshalJSON(bz, &genesisState); err != nil {
- return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
- }
-
- return genesisState.Validate()
-}
-
-// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the inflation module.
-func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) {
- if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil {
- panic(err)
- }
-}
-
-// GetTxCmd returns the root tx command for the inflation module.
-func (AppModuleBasic) GetTxCmd() *cobra.Command { return cli.GetTxCmd() }
-
-// GetQueryCmd returns no root query command for the inflation module.
-func (AppModuleBasic) GetQueryCmd() *cobra.Command {
- return cli.GetQueryCmd()
-}
-
-// ___________________________________________________________________________
-
-// AppModule implements an application module for the inflation module.
-type AppModule struct {
- AppModuleBasic
- keeper keeper.Keeper
- ak authkeeper.AccountKeeper
- sk stakingkeeper.Keeper
-}
-
-// NewAppModule creates a new AppModule Object
-func NewAppModule(
- k keeper.Keeper,
- ak authkeeper.AccountKeeper,
- sk stakingkeeper.Keeper,
-) AppModule {
- return AppModule{
- AppModuleBasic: AppModuleBasic{},
- keeper: k,
- ak: ak,
- sk: sk,
- }
-}
-
-// Name returns the inflation module's name.
-func (AppModule) Name() string {
- return types.ModuleName
-}
-
-// RegisterInvariants registers the inflation module invariants.
-func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
-
-// RegisterServices registers module services.
-func (am AppModule) RegisterServices(cfg module.Configurator) {
- types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
- querier := keeper.NewQuerier(am.keeper)
- types.RegisterQueryServer(cfg.QueryServer(), querier)
-}
-
-// BeginBlock returns the begin blocker for the inflation module.
-func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {
-}
-
-// EndBlock returns the end blocker for the inflation module. It returns no validator
-// updates.
-func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
- return []abci.ValidatorUpdate{}
-}
-
-// InitGenesis performs genesis initialization for the inflation module. It returns
-// no validator updates.
-func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
- var genesisState types.GenesisState
-
- cdc.MustUnmarshalJSON(data, &genesisState)
- InitGenesis(ctx, am.keeper, am.ak, am.sk, genesisState)
- return []abci.ValidatorUpdate{}
-}
-
-// ExportGenesis returns the exported genesis state as raw bytes for the inflation
-// module.
-func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
- gs := ExportGenesis(ctx, am.keeper)
- return cdc.MustMarshalJSON(gs)
-}
-
-// ___________________________________________________________________________
-
-// AppModuleSimulation functions
-
-// GenerateGenesisState creates a randomized GenState of the inflation module.
-func (am AppModule) GenerateGenesisState(simState *module.SimulationState) {
- simulation.RandomizedGenState(simState)
-}
-
-// ProposalContents doesn't return any content functions for governance proposals.
-func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg {
- return []simtypes.WeightedProposalMsg{}
-}
-
-// RegisterStoreDecoder registers a decoder for inflation module's types.
-func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {
-}
-
-// WeightedOperations doesn't return any inflation module operation.
-func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
- return []simtypes.WeightedOperation{}
-}
diff --git a/x/inflation/simulation/genesis.go b/x/inflation/simulation/genesis.go
deleted file mode 100644
index da5e65c54..000000000
--- a/x/inflation/simulation/genesis.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package simulation
-
-// DONTCOVER
-
-import (
- "encoding/json"
- "fmt"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
-
- "github.com/NibiruChain/nibiru/x/inflation/types"
-)
-
-// RandomizedGenState generates a random GenesisState for distribution
-func RandomizedGenState(simState *module.SimulationState) {
- inflationGenesis := types.GenesisState{
- Params: types.Params{
- InflationEnabled: true,
- PolynomialFactors: []sdk.Dec{
- math.LegacyMustNewDecFromStr("-0.00014851"),
- math.LegacyMustNewDecFromStr("0.07501029"),
- math.LegacyMustNewDecFromStr("-19.04983993"),
- math.LegacyMustNewDecFromStr("3158.89198346"),
- math.LegacyMustNewDecFromStr("-338072.17402939"),
- math.LegacyMustNewDecFromStr("17999834.20786474"),
- },
- InflationDistribution: types.InflationDistribution{
- CommunityPool: math.LegacyNewDecWithPrec(35_142714, 8), // 35.142714%
- StakingRewards: math.LegacyNewDecWithPrec(27_855672, 8), // 27.855672%
- StrategicReserves: math.LegacyNewDecWithPrec(37_001614, 8), // 37.001614%
- },
- EpochsPerPeriod: 30,
- PeriodsPerYear: 12,
- MaxPeriod: 8 * 12,
- },
- Period: 0,
- SkippedEpochs: 0,
- }
-
- bz, err := json.MarshalIndent(&inflationGenesis, "", " ")
- if err != nil {
- panic(err)
- }
- fmt.Printf("Selected randomly generated x/inflation parameters:\n%s\n", bz)
- simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&inflationGenesis)
-}
diff --git a/x/inflation/types/codec.go b/x/inflation/types/codec.go
deleted file mode 100644
index b939b24a9..000000000
--- a/x/inflation/types/codec.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package types
-
-import (
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/msgservice"
-)
-
-// RegisterLegacyAminoCodec registers the necessary x/inflation interfaces and concrete types
-// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
-func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- cdc.RegisterConcrete(&MsgEditInflationParams{}, "inflation/MsgEditInflationParams", nil)
- cdc.RegisterConcrete(&MsgToggleInflation{}, "inflation/MsgToggleInflation", nil)
-}
-
-// RegisterInterfaces registers the x/inflation interfaces types with the interface registry
-func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- registry.RegisterImplementations((*sdk.Msg)(nil),
- &MsgEditInflationParams{},
- &MsgToggleInflation{},
- )
-
- msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
-}
-
-var (
- amino = codec.NewLegacyAmino()
-
- // ModuleCdc references the global x/inflation module codec. Note, the codec should
- // ONLY be used in certain instances of tests and for JSON encoding as Amino is
- // still used for that purpose.
- //
- // The actual codec used for serialization should be provided to x/staking and
- // defined at the application level.
- ModuleCdc = codec.NewAminoCodec(amino)
-)
-
-func init() {
- RegisterLegacyAminoCodec(amino)
- cryptocodec.RegisterCrypto(amino)
- amino.Seal()
-}
diff --git a/x/inflation/types/event.pb.go b/x/inflation/types/event.pb.go
deleted file mode 100644
index c5fd42816..000000000
--- a/x/inflation/types/event.pb.go
+++ /dev/null
@@ -1,437 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/inflation/v1/event.proto
-
-package types
-
-import (
- fmt "fmt"
- types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// EventInflationDistribution: Emitted when NIBI tokens are minted on the
-// network based on Nibiru's inflation schedule.
-type EventInflationDistribution struct {
- StakingRewards types.Coin `protobuf:"bytes,1,opt,name=staking_rewards,json=stakingRewards,proto3" json:"staking_rewards" yaml:"staking_rewards"`
- StrategicReserve types.Coin `protobuf:"bytes,2,opt,name=strategic_reserve,json=strategicReserve,proto3" json:"strategic_reserve" yaml:"strategic_reserve"`
- CommunityPool types.Coin `protobuf:"bytes,3,opt,name=community_pool,json=communityPool,proto3" json:"community_pool" yaml:"community_pool"`
-}
-
-func (m *EventInflationDistribution) Reset() { *m = EventInflationDistribution{} }
-func (m *EventInflationDistribution) String() string { return proto.CompactTextString(m) }
-func (*EventInflationDistribution) ProtoMessage() {}
-func (*EventInflationDistribution) Descriptor() ([]byte, []int) {
- return fileDescriptor_18fa0385facaf5d9, []int{0}
-}
-func (m *EventInflationDistribution) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventInflationDistribution) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventInflationDistribution.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventInflationDistribution) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventInflationDistribution.Merge(m, src)
-}
-func (m *EventInflationDistribution) XXX_Size() int {
- return m.Size()
-}
-func (m *EventInflationDistribution) XXX_DiscardUnknown() {
- xxx_messageInfo_EventInflationDistribution.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventInflationDistribution proto.InternalMessageInfo
-
-func (m *EventInflationDistribution) GetStakingRewards() types.Coin {
- if m != nil {
- return m.StakingRewards
- }
- return types.Coin{}
-}
-
-func (m *EventInflationDistribution) GetStrategicReserve() types.Coin {
- if m != nil {
- return m.StrategicReserve
- }
- return types.Coin{}
-}
-
-func (m *EventInflationDistribution) GetCommunityPool() types.Coin {
- if m != nil {
- return m.CommunityPool
- }
- return types.Coin{}
-}
-
-func init() {
- proto.RegisterType((*EventInflationDistribution)(nil), "nibiru.inflation.v1.EventInflationDistribution")
-}
-
-func init() { proto.RegisterFile("nibiru/inflation/v1/event.proto", fileDescriptor_18fa0385facaf5d9) }
-
-var fileDescriptor_18fa0385facaf5d9 = []byte{
- // 332 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xbd, 0x4e, 0xf3, 0x30,
- 0x14, 0x86, 0x93, 0x7e, 0xd2, 0x37, 0x04, 0x51, 0x20, 0xfc, 0x28, 0x54, 0xc2, 0xad, 0x32, 0x31,
- 0xd9, 0x0a, 0x6c, 0x8c, 0x2d, 0x0c, 0x5d, 0x10, 0xca, 0xc8, 0x12, 0xd9, 0xc1, 0xa4, 0x16, 0x89,
- 0x4f, 0x65, 0x3b, 0x81, 0xde, 0x05, 0x97, 0x55, 0x89, 0xa5, 0x23, 0x53, 0x85, 0xda, 0x3b, 0xe0,
- 0x0a, 0x50, 0xea, 0xb4, 0x82, 0x2e, 0xdd, 0x8e, 0xde, 0x73, 0xce, 0xf3, 0x0c, 0xaf, 0xd7, 0x95,
- 0x82, 0x09, 0x55, 0x12, 0x21, 0x9f, 0x73, 0x6a, 0x04, 0x48, 0x52, 0x45, 0x84, 0x57, 0x5c, 0x1a,
- 0x3c, 0x56, 0x60, 0xc0, 0x3f, 0xb6, 0x07, 0x78, 0x73, 0x80, 0xab, 0xa8, 0x73, 0x92, 0x41, 0x06,
- 0xab, 0x3d, 0xa9, 0x27, 0x7b, 0xda, 0x41, 0x29, 0xe8, 0x02, 0x34, 0x61, 0x54, 0x73, 0x52, 0x45,
- 0x8c, 0x1b, 0x1a, 0x91, 0x14, 0x84, 0xb4, 0xfb, 0xf0, 0xa3, 0xe5, 0x75, 0xee, 0x6a, 0xf4, 0x70,
- 0xcd, 0xba, 0x15, 0xda, 0x28, 0xc1, 0xca, 0x7a, 0xf6, 0x99, 0x77, 0xa0, 0x0d, 0x7d, 0x11, 0x32,
- 0x4b, 0x14, 0x7f, 0xa5, 0xea, 0x49, 0x07, 0x6e, 0xcf, 0xbd, 0xdc, 0xbb, 0x3a, 0xc7, 0x16, 0x8c,
- 0x6b, 0x30, 0x6e, 0xc0, 0x78, 0x00, 0x42, 0xf6, 0xd1, 0x74, 0xde, 0x75, 0xbe, 0xe7, 0xdd, 0xb3,
- 0x09, 0x2d, 0xf2, 0x9b, 0x70, 0xeb, 0x3f, 0x8c, 0xdb, 0x4d, 0x12, 0xdb, 0xc0, 0x1f, 0x79, 0x47,
- 0xda, 0x28, 0x6a, 0x78, 0x26, 0xd2, 0x44, 0x71, 0xcd, 0x55, 0xc5, 0x83, 0xd6, 0x2e, 0x4b, 0xaf,
- 0xb1, 0x04, 0x6b, 0xcb, 0x16, 0x21, 0x8c, 0x0f, 0x37, 0x59, 0x6c, 0x23, 0x3f, 0xf1, 0xda, 0x29,
- 0x14, 0x45, 0x29, 0x85, 0x99, 0x24, 0x63, 0x80, 0x3c, 0xf8, 0xb7, 0x4b, 0x73, 0xd1, 0x68, 0x4e,
- 0xad, 0xe6, 0xef, 0x7b, 0x18, 0xef, 0x6f, 0x82, 0x07, 0x80, 0xbc, 0x3f, 0x9c, 0x2e, 0x90, 0x3b,
- 0x5b, 0x20, 0xf7, 0x6b, 0x81, 0xdc, 0xf7, 0x25, 0x72, 0x66, 0x4b, 0xe4, 0x7c, 0x2e, 0x91, 0xf3,
- 0x48, 0x32, 0x61, 0x46, 0x25, 0xc3, 0x29, 0x14, 0xe4, 0x7e, 0xd5, 0xde, 0x60, 0x44, 0x85, 0x24,
- 0x4d, 0xd5, 0x6f, 0xbf, 0xca, 0x36, 0x93, 0x31, 0xd7, 0xec, 0xff, 0xaa, 0x9f, 0xeb, 0x9f, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0x2c, 0x97, 0xd4, 0x83, 0x0d, 0x02, 0x00, 0x00,
-}
-
-func (m *EventInflationDistribution) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventInflationDistribution) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventInflationDistribution) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.CommunityPool.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvent(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- {
- size, err := m.StrategicReserve.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvent(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- {
- size, err := m.StakingRewards.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvent(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func encodeVarintEvent(dAtA []byte, offset int, v uint64) int {
- offset -= sovEvent(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *EventInflationDistribution) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.StakingRewards.Size()
- n += 1 + l + sovEvent(uint64(l))
- l = m.StrategicReserve.Size()
- n += 1 + l + sovEvent(uint64(l))
- l = m.CommunityPool.Size()
- n += 1 + l + sovEvent(uint64(l))
- return n
-}
-
-func sovEvent(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozEvent(x uint64) (n int) {
- return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *EventInflationDistribution) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventInflationDistribution: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventInflationDistribution: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field StakingRewards", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.StakingRewards.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field StrategicReserve", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.StrategicReserve.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CommunityPool", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.CommunityPool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipEvent(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthEvent
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupEvent
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthEvent
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/inflation/types/events.go b/x/inflation/types/events.go
deleted file mode 100644
index 3a6febaa7..000000000
--- a/x/inflation/types/events.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package types
-
-// Minting module event types
-const (
- EventTypeInflation = ModuleName
-
- AttributeKeyEpochProvisions = "epoch_provisions"
- AttributeEpochNumber = "epoch_number"
-)
diff --git a/x/inflation/types/export.go b/x/inflation/types/export.go
deleted file mode 100644
index fb4b6e3b6..000000000
--- a/x/inflation/types/export.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package types
-
-import (
- grpc "google.golang.org/grpc"
-)
-
-// GrpcQueryServiceDesc represents the query server's RPC service specification.
-// This gives access to the service name and method names needed for stargate
-// queries.
-func GrpcQueryServiceDesc() grpc.ServiceDesc {
- return _Query_serviceDesc
-}
diff --git a/x/inflation/types/genesis.go b/x/inflation/types/genesis.go
deleted file mode 100644
index e85896bfa..000000000
--- a/x/inflation/types/genesis.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package types
-
-// NewGenesisState creates a new GenesisState object
-func NewGenesisState(
- params Params,
- period uint64,
- skippedEpochs uint64,
-) GenesisState {
- return GenesisState{
- Params: params,
- Period: period,
- SkippedEpochs: skippedEpochs,
- }
-}
-
-// DefaultGenesisState creates a default GenesisState object
-func DefaultGenesisState() *GenesisState {
- return &GenesisState{
- Params: DefaultParams(),
- Period: 0,
- SkippedEpochs: 0,
- }
-}
-
-// Validate performs basic genesis state validation returning an error upon any
-// failure.
-func (gs GenesisState) Validate() error {
- if err := validateUint64(gs.SkippedEpochs); err != nil {
- return err
- }
-
- if err := validateUint64(gs.Period); err != nil {
- return err
- }
-
- return gs.Params.Validate()
-}
diff --git a/x/inflation/types/genesis.pb.go b/x/inflation/types/genesis.pb.go
deleted file mode 100644
index 522028269..000000000
--- a/x/inflation/types/genesis.pb.go
+++ /dev/null
@@ -1,842 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/inflation/v1/genesis.proto
-
-package types
-
-import (
- fmt "fmt"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// GenesisState defines the inflation module's genesis state.
-type GenesisState struct {
- // params defines all the parameters of the module.
- Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
- // period is the amount of past periods, based on the epochs per period param
- Period uint64 `protobuf:"varint,2,opt,name=period,proto3" json:"period,omitempty"`
- // skipped_epochs is the number of epochs that have passed while inflation is
- // disabled
- SkippedEpochs uint64 `protobuf:"varint,3,opt,name=skipped_epochs,json=skippedEpochs,proto3" json:"skipped_epochs,omitempty"`
-}
-
-func (m *GenesisState) Reset() { *m = GenesisState{} }
-func (m *GenesisState) String() string { return proto.CompactTextString(m) }
-func (*GenesisState) ProtoMessage() {}
-func (*GenesisState) Descriptor() ([]byte, []int) {
- return fileDescriptor_2d00e2bb98c08f74, []int{0}
-}
-func (m *GenesisState) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *GenesisState) XXX_Merge(src proto.Message) {
- xxx_messageInfo_GenesisState.Merge(m, src)
-}
-func (m *GenesisState) XXX_Size() int {
- return m.Size()
-}
-func (m *GenesisState) XXX_DiscardUnknown() {
- xxx_messageInfo_GenesisState.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_GenesisState proto.InternalMessageInfo
-
-func (m *GenesisState) GetParams() Params {
- if m != nil {
- return m.Params
- }
- return Params{}
-}
-
-func (m *GenesisState) GetPeriod() uint64 {
- if m != nil {
- return m.Period
- }
- return 0
-}
-
-func (m *GenesisState) GetSkippedEpochs() uint64 {
- if m != nil {
- return m.SkippedEpochs
- }
- return 0
-}
-
-// Params holds parameters for the inflation module.
-type Params struct {
- // inflation_enabled is the parameter that enables inflation and halts
- // increasing the skipped_epochs
- InflationEnabled bool `protobuf:"varint,1,opt,name=inflation_enabled,json=inflationEnabled,proto3" json:"inflation_enabled,omitempty"`
- // polynomial_factors takes in the variables to calculate polynomial
- // inflation
- PolynomialFactors []github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,rep,name=polynomial_factors,json=polynomialFactors,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"polynomial_factors"`
- // inflation_distribution of the minted denom
- InflationDistribution InflationDistribution `protobuf:"bytes,3,opt,name=inflation_distribution,json=inflationDistribution,proto3" json:"inflation_distribution"`
- // epochs_per_period is the number of epochs that must pass before a new
- // period is created
- EpochsPerPeriod uint64 `protobuf:"varint,4,opt,name=epochs_per_period,json=epochsPerPeriod,proto3" json:"epochs_per_period,omitempty"`
- // periods_per_year is the number of periods that occur in a year
- PeriodsPerYear uint64 `protobuf:"varint,5,opt,name=periods_per_year,json=periodsPerYear,proto3" json:"periods_per_year,omitempty"`
- // max_period is the maximum number of periods that have inflation being
- // paid off. After this period, inflation will be disabled.
- MaxPeriod uint64 `protobuf:"varint,6,opt,name=max_period,json=maxPeriod,proto3" json:"max_period,omitempty"`
- // has_inflation_started is the parameter that indicates if inflation has
- // started. It's set to false at the starts, and stays at true when we toggle
- // inflation on. It's used to track num skipped epochs
- HasInflationStarted bool `protobuf:"varint,7,opt,name=has_inflation_started,json=hasInflationStarted,proto3" json:"has_inflation_started,omitempty"`
-}
-
-func (m *Params) Reset() { *m = Params{} }
-func (m *Params) String() string { return proto.CompactTextString(m) }
-func (*Params) ProtoMessage() {}
-func (*Params) Descriptor() ([]byte, []int) {
- return fileDescriptor_2d00e2bb98c08f74, []int{1}
-}
-func (m *Params) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_Params.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *Params) XXX_Merge(src proto.Message) {
- xxx_messageInfo_Params.Merge(m, src)
-}
-func (m *Params) XXX_Size() int {
- return m.Size()
-}
-func (m *Params) XXX_DiscardUnknown() {
- xxx_messageInfo_Params.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_Params proto.InternalMessageInfo
-
-func (m *Params) GetInflationEnabled() bool {
- if m != nil {
- return m.InflationEnabled
- }
- return false
-}
-
-func (m *Params) GetInflationDistribution() InflationDistribution {
- if m != nil {
- return m.InflationDistribution
- }
- return InflationDistribution{}
-}
-
-func (m *Params) GetEpochsPerPeriod() uint64 {
- if m != nil {
- return m.EpochsPerPeriod
- }
- return 0
-}
-
-func (m *Params) GetPeriodsPerYear() uint64 {
- if m != nil {
- return m.PeriodsPerYear
- }
- return 0
-}
-
-func (m *Params) GetMaxPeriod() uint64 {
- if m != nil {
- return m.MaxPeriod
- }
- return 0
-}
-
-func (m *Params) GetHasInflationStarted() bool {
- if m != nil {
- return m.HasInflationStarted
- }
- return false
-}
-
-func init() {
- proto.RegisterType((*GenesisState)(nil), "nibiru.inflation.v1.GenesisState")
- proto.RegisterType((*Params)(nil), "nibiru.inflation.v1.Params")
-}
-
-func init() { proto.RegisterFile("nibiru/inflation/v1/genesis.proto", fileDescriptor_2d00e2bb98c08f74) }
-
-var fileDescriptor_2d00e2bb98c08f74 = []byte{
- // 461 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xc1, 0x6e, 0x13, 0x31,
- 0x10, 0xcd, 0x36, 0x61, 0xa1, 0x2e, 0x94, 0xc6, 0xa5, 0xd5, 0xaa, 0x88, 0x6d, 0x28, 0x02, 0x45,
- 0x45, 0xac, 0xd5, 0x70, 0xe2, 0x1a, 0x5a, 0x50, 0x2f, 0x28, 0x4a, 0x4f, 0x20, 0xa1, 0x95, 0x77,
- 0x77, 0xba, 0x6b, 0x35, 0xbb, 0xb6, 0x6c, 0xa7, 0x4a, 0xfe, 0x80, 0x23, 0x5f, 0xc1, 0xb7, 0xf4,
- 0xd8, 0x23, 0xe2, 0x50, 0xa1, 0xe4, 0x47, 0xaa, 0xd8, 0x6e, 0x92, 0xc3, 0x9e, 0xec, 0x99, 0xf7,
- 0xe6, 0xcd, 0xcc, 0xd3, 0xa0, 0xd7, 0x15, 0x4b, 0x98, 0x1c, 0x13, 0x56, 0x5d, 0x8e, 0xa8, 0x66,
- 0xbc, 0x22, 0xd7, 0x27, 0x24, 0x87, 0x0a, 0x14, 0x53, 0x91, 0x90, 0x5c, 0x73, 0xbc, 0x6b, 0x29,
- 0xd1, 0x92, 0x12, 0x5d, 0x9f, 0x1c, 0xbc, 0xc8, 0x79, 0xce, 0x0d, 0x4e, 0x16, 0x3f, 0x4b, 0x3d,
- 0x78, 0x53, 0xa7, 0xb6, 0xaa, 0x33, 0xa4, 0xa3, 0x5f, 0x1e, 0x7a, 0xfa, 0xd5, 0x76, 0xb8, 0xd0,
- 0x54, 0x03, 0xfe, 0x84, 0x7c, 0x41, 0x25, 0x2d, 0x55, 0xe0, 0x75, 0xbc, 0xee, 0x56, 0xef, 0x65,
- 0x54, 0xd3, 0x31, 0x1a, 0x18, 0x4a, 0xbf, 0x75, 0x73, 0x77, 0xd8, 0x18, 0xba, 0x02, 0xbc, 0x8f,
- 0x7c, 0x01, 0x92, 0xf1, 0x2c, 0xd8, 0xe8, 0x78, 0xdd, 0xd6, 0xd0, 0x45, 0xf8, 0x2d, 0xda, 0x56,
- 0x57, 0x4c, 0x08, 0xc8, 0x62, 0x10, 0x3c, 0x2d, 0x54, 0xd0, 0x34, 0xf8, 0x33, 0x97, 0x3d, 0x33,
- 0xc9, 0xa3, 0x3f, 0x4d, 0xe4, 0x5b, 0x5d, 0xfc, 0x1e, 0xb5, 0x97, 0xed, 0x62, 0xa8, 0x68, 0x32,
- 0x82, 0xcc, 0xcc, 0xf3, 0x64, 0xb8, 0xb3, 0x04, 0xce, 0x6c, 0x1e, 0xff, 0x44, 0x58, 0xf0, 0xd1,
- 0xb4, 0xe2, 0x25, 0xa3, 0xa3, 0xf8, 0x92, 0xa6, 0x9a, 0x4b, 0x15, 0x6c, 0x74, 0x9a, 0xdd, 0xcd,
- 0x7e, 0xb4, 0x18, 0xf0, 0xdf, 0xdd, 0xe1, 0xbb, 0x9c, 0xe9, 0x62, 0x9c, 0x44, 0x29, 0x2f, 0x49,
- 0xca, 0x55, 0xc9, 0x95, 0x7b, 0x3e, 0xa8, 0xec, 0x8a, 0xe8, 0xa9, 0x00, 0x15, 0x9d, 0x42, 0x3a,
- 0x6c, 0xaf, 0x94, 0xbe, 0x58, 0x21, 0x9c, 0xa3, 0xfd, 0xd5, 0x2c, 0x19, 0x53, 0x5a, 0xb2, 0x64,
- 0xbc, 0x08, 0xcc, 0x16, 0x5b, 0xbd, 0xe3, 0x5a, 0x83, 0xce, 0x1f, 0x82, 0xd3, 0xb5, 0x0a, 0xe7,
- 0xd7, 0x1e, 0xab, 0x03, 0xf1, 0x31, 0x6a, 0x5b, 0x7b, 0x62, 0x01, 0x32, 0x76, 0x4e, 0xb6, 0x8c,
- 0x53, 0xcf, 0x2d, 0x30, 0x00, 0x39, 0xb0, 0x96, 0x76, 0xd1, 0x8e, 0x25, 0x58, 0xf2, 0x14, 0xa8,
- 0x0c, 0x1e, 0x19, 0xea, 0xb6, 0xcb, 0x0f, 0x40, 0x7e, 0x07, 0x2a, 0xf1, 0x2b, 0x84, 0x4a, 0x3a,
- 0x79, 0x90, 0xf3, 0x0d, 0x67, 0xb3, 0xa4, 0x13, 0x27, 0xd4, 0x43, 0x7b, 0x05, 0x55, 0xf1, 0x6a,
- 0x43, 0xa5, 0xa9, 0xd4, 0x90, 0x05, 0x8f, 0x8d, 0xdb, 0xbb, 0x05, 0x55, 0xcb, 0x55, 0x2e, 0x2c,
- 0xd4, 0x3f, 0xbf, 0x99, 0x85, 0xde, 0xed, 0x2c, 0xf4, 0xfe, 0xcf, 0x42, 0xef, 0xf7, 0x3c, 0x6c,
- 0xdc, 0xce, 0xc3, 0xc6, 0xdf, 0x79, 0xd8, 0xf8, 0x41, 0xd6, 0x6c, 0xfe, 0x66, 0x5c, 0xf9, 0x5c,
- 0x50, 0x56, 0x11, 0x77, 0x89, 0x93, 0xb5, 0x5b, 0x34, 0x9e, 0x27, 0xbe, 0xb9, 0xc2, 0x8f, 0xf7,
- 0x01, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x43, 0x3a, 0xc4, 0xfa, 0x02, 0x00, 0x00,
-}
-
-func (m *GenesisState) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.SkippedEpochs != 0 {
- i = encodeVarintGenesis(dAtA, i, uint64(m.SkippedEpochs))
- i--
- dAtA[i] = 0x18
- }
- if m.Period != 0 {
- i = encodeVarintGenesis(dAtA, i, uint64(m.Period))
- i--
- dAtA[i] = 0x10
- }
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *Params) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Params) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.HasInflationStarted {
- i--
- if m.HasInflationStarted {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x38
- }
- if m.MaxPeriod != 0 {
- i = encodeVarintGenesis(dAtA, i, uint64(m.MaxPeriod))
- i--
- dAtA[i] = 0x30
- }
- if m.PeriodsPerYear != 0 {
- i = encodeVarintGenesis(dAtA, i, uint64(m.PeriodsPerYear))
- i--
- dAtA[i] = 0x28
- }
- if m.EpochsPerPeriod != 0 {
- i = encodeVarintGenesis(dAtA, i, uint64(m.EpochsPerPeriod))
- i--
- dAtA[i] = 0x20
- }
- {
- size, err := m.InflationDistribution.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- if len(m.PolynomialFactors) > 0 {
- for iNdEx := len(m.PolynomialFactors) - 1; iNdEx >= 0; iNdEx-- {
- {
- size := m.PolynomialFactors[iNdEx].Size()
- i -= size
- if _, err := m.PolynomialFactors[iNdEx].MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- }
- if m.InflationEnabled {
- i--
- if m.InflationEnabled {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
- offset -= sovGenesis(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *GenesisState) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Params.Size()
- n += 1 + l + sovGenesis(uint64(l))
- if m.Period != 0 {
- n += 1 + sovGenesis(uint64(m.Period))
- }
- if m.SkippedEpochs != 0 {
- n += 1 + sovGenesis(uint64(m.SkippedEpochs))
- }
- return n
-}
-
-func (m *Params) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.InflationEnabled {
- n += 2
- }
- if len(m.PolynomialFactors) > 0 {
- for _, e := range m.PolynomialFactors {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- l = m.InflationDistribution.Size()
- n += 1 + l + sovGenesis(uint64(l))
- if m.EpochsPerPeriod != 0 {
- n += 1 + sovGenesis(uint64(m.EpochsPerPeriod))
- }
- if m.PeriodsPerYear != 0 {
- n += 1 + sovGenesis(uint64(m.PeriodsPerYear))
- }
- if m.MaxPeriod != 0 {
- n += 1 + sovGenesis(uint64(m.MaxPeriod))
- }
- if m.HasInflationStarted {
- n += 2
- }
- return n
-}
-
-func sovGenesis(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozGenesis(x uint64) (n int) {
- return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *GenesisState) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType)
- }
- m.Period = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Period |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field SkippedEpochs", wireType)
- }
- m.SkippedEpochs = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.SkippedEpochs |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipGenesis(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenesis
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *Params) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: Params: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field InflationEnabled", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.InflationEnabled = bool(v != 0)
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PolynomialFactors", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Dec
- m.PolynomialFactors = append(m.PolynomialFactors, v)
- if err := m.PolynomialFactors[len(m.PolynomialFactors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field InflationDistribution", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.InflationDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EpochsPerPeriod", wireType)
- }
- m.EpochsPerPeriod = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.EpochsPerPeriod |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field PeriodsPerYear", wireType)
- }
- m.PeriodsPerYear = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.PeriodsPerYear |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MaxPeriod", wireType)
- }
- m.MaxPeriod = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MaxPeriod |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 7:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field HasInflationStarted", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.HasInflationStarted = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipGenesis(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenesis
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipGenesis(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthGenesis
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupGenesis
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenesis
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/inflation/types/genesis_test.go b/x/inflation/types/genesis_test.go
deleted file mode 100644
index 1c89d6d15..000000000
--- a/x/inflation/types/genesis_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package types
-
-import (
- "testing"
-
- "github.com/stretchr/testify/require"
-)
-
-func TestValidateGenesis(t *testing.T) {
- // Team Address needs to be set manually at Genesis
- validParams := DefaultParams()
-
- newGen := NewGenesisState(validParams, 0, 0)
-
- testCases := []struct {
- name string
- genState *GenesisState
- expPass bool
- }{
- {
- "empty genesis",
- &GenesisState{},
- false,
- },
- {
- "invalid default genesis",
- DefaultGenesisState(),
- true,
- },
- {
- "valid genesis constructor",
- &newGen,
- true,
- },
- {
- "valid genesis",
- &GenesisState{
- Params: validParams,
- Period: 5,
- SkippedEpochs: 0,
- },
- true,
- },
- }
-
- for _, tc := range testCases {
- tc := tc
- t.Run(tc.name, func(t *testing.T) {
- err := tc.genState.Validate()
- if tc.expPass {
- require.NoError(t, err, tc.name)
- } else {
- require.Error(t, err, tc.name)
- }
- })
- }
-}
diff --git a/x/inflation/types/inflation.pb.go b/x/inflation/types/inflation.pb.go
deleted file mode 100644
index 632c86ebf..000000000
--- a/x/inflation/types/inflation.pb.go
+++ /dev/null
@@ -1,425 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/inflation/v1/inflation.proto
-
-package types
-
-import (
- fmt "fmt"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// InflationDistribution defines the distribution in which inflation is
-// allocated through minting on each epoch (staking, community, strategic). It
-// excludes the team vesting distribution.
-type InflationDistribution struct {
- // staking_rewards defines the proportion of the minted_denom that is
- // to be allocated as staking rewards
- StakingRewards github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=staking_rewards,json=stakingRewards,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"staking_rewards"`
- // community_pool defines the proportion of the minted_denom that is to
- // be allocated to the community pool
- CommunityPool github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=community_pool,json=communityPool,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"community_pool"`
- // strategic_reserves defines the proportion of the minted_denom that
- // is to be allocated to the strategic reserves module address
- StrategicReserves github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=strategic_reserves,json=strategicReserves,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"strategic_reserves"`
-}
-
-func (m *InflationDistribution) Reset() { *m = InflationDistribution{} }
-func (m *InflationDistribution) String() string { return proto.CompactTextString(m) }
-func (*InflationDistribution) ProtoMessage() {}
-func (*InflationDistribution) Descriptor() ([]byte, []int) {
- return fileDescriptor_37da805e9a324a97, []int{0}
-}
-func (m *InflationDistribution) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *InflationDistribution) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_InflationDistribution.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *InflationDistribution) XXX_Merge(src proto.Message) {
- xxx_messageInfo_InflationDistribution.Merge(m, src)
-}
-func (m *InflationDistribution) XXX_Size() int {
- return m.Size()
-}
-func (m *InflationDistribution) XXX_DiscardUnknown() {
- xxx_messageInfo_InflationDistribution.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_InflationDistribution proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*InflationDistribution)(nil), "nibiru.inflation.v1.InflationDistribution")
-}
-
-func init() {
- proto.RegisterFile("nibiru/inflation/v1/inflation.proto", fileDescriptor_37da805e9a324a97)
-}
-
-var fileDescriptor_37da805e9a324a97 = []byte{
- // 284 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xce, 0xcb, 0x4c, 0xca,
- 0x2c, 0x2a, 0xd5, 0xcf, 0xcc, 0x4b, 0xcb, 0x49, 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0x33, 0x44,
- 0x70, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x84, 0x21, 0x8a, 0xf4, 0x10, 0xe2, 0x65, 0x86,
- 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x79, 0x7d, 0x10, 0x0b, 0xa2, 0x54, 0x69, 0x19, 0x13,
- 0x97, 0xa8, 0x27, 0x4c, 0x99, 0x4b, 0x66, 0x71, 0x49, 0x51, 0x66, 0x52, 0x29, 0x88, 0x2d, 0x14,
- 0xce, 0xc5, 0x5f, 0x5c, 0x92, 0x98, 0x9d, 0x99, 0x97, 0x1e, 0x5f, 0x94, 0x5a, 0x9e, 0x58, 0x94,
- 0x52, 0x2c, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xe9, 0xa4, 0x77, 0xe2, 0x9e, 0x3c, 0xc3, 0xad, 0x7b,
- 0xf2, 0x6a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xc9, 0xf9, 0xc5,
- 0xb9, 0xf9, 0xc5, 0x50, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0xa4, 0xb2, 0x20, 0xb5, 0x58, 0xcf,
- 0x25, 0x35, 0x39, 0x88, 0x0f, 0x6a, 0x4c, 0x10, 0xc4, 0x14, 0xa1, 0x50, 0x2e, 0xbe, 0xe4, 0xfc,
- 0xdc, 0xdc, 0xd2, 0xbc, 0xcc, 0x92, 0xca, 0xf8, 0x82, 0xfc, 0xfc, 0x1c, 0x09, 0x26, 0xb2, 0xcc,
- 0xe5, 0x85, 0x9b, 0x12, 0x90, 0x9f, 0x9f, 0x23, 0x14, 0xcb, 0x25, 0x54, 0x5c, 0x52, 0x94, 0x58,
- 0x92, 0x9a, 0x9e, 0x99, 0x1c, 0x5f, 0x94, 0x5a, 0x9c, 0x5a, 0x54, 0x96, 0x5a, 0x2c, 0xc1, 0x4c,
- 0x96, 0xd1, 0x82, 0x70, 0x93, 0x82, 0xa0, 0x06, 0x39, 0x79, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1,
- 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70,
- 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x3e, 0x92, 0xa1, 0x7e, 0xe0, 0x80, 0x77, 0xce, 0x48, 0xcc, 0xcc,
- 0xd3, 0x87, 0xc6, 0x54, 0x05, 0x52, 0x5c, 0x81, 0x6d, 0x48, 0x62, 0x03, 0x07, 0xbd, 0x31, 0x20,
- 0x00, 0x00, 0xff, 0xff, 0x75, 0xbf, 0x6b, 0xae, 0xcc, 0x01, 0x00, 0x00,
-}
-
-func (m *InflationDistribution) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *InflationDistribution) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *InflationDistribution) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size := m.StrategicReserves.Size()
- i -= size
- if _, err := m.StrategicReserves.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintInflation(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- {
- size := m.CommunityPool.Size()
- i -= size
- if _, err := m.CommunityPool.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintInflation(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- {
- size := m.StakingRewards.Size()
- i -= size
- if _, err := m.StakingRewards.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintInflation(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func encodeVarintInflation(dAtA []byte, offset int, v uint64) int {
- offset -= sovInflation(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *InflationDistribution) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.StakingRewards.Size()
- n += 1 + l + sovInflation(uint64(l))
- l = m.CommunityPool.Size()
- n += 1 + l + sovInflation(uint64(l))
- l = m.StrategicReserves.Size()
- n += 1 + l + sovInflation(uint64(l))
- return n
-}
-
-func sovInflation(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozInflation(x uint64) (n int) {
- return sovInflation(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *InflationDistribution) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowInflation
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: InflationDistribution: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: InflationDistribution: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field StakingRewards", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowInflation
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthInflation
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthInflation
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.StakingRewards.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CommunityPool", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowInflation
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthInflation
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthInflation
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.CommunityPool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field StrategicReserves", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowInflation
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthInflation
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthInflation
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.StrategicReserves.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipInflation(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthInflation
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipInflation(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowInflation
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowInflation
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowInflation
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthInflation
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupInflation
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthInflation
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthInflation = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowInflation = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupInflation = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/inflation/types/inflation_calculation.go b/x/inflation/types/inflation_calculation.go
deleted file mode 100644
index b62eeb222..000000000
--- a/x/inflation/types/inflation_calculation.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package types
-
-import (
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// CalculateEpochMintProvision returns mint provision per epoch
-func CalculateEpochMintProvision(
- params Params,
- period uint64,
-) sdk.Dec {
- if params.EpochsPerPeriod == 0 || !params.InflationEnabled || period >= params.MaxPeriod {
- return math.LegacyZeroDec()
- }
-
- // truncating to the nearest integer
- x := period
-
- // Calculate the value of the polynomial at x
- polynomialValue := polynomial(params.PolynomialFactors, math.LegacyNewDec(int64(x)))
-
- if polynomialValue.IsNegative() {
- // Just to make sure nothing weird occur
- return math.LegacyZeroDec()
- }
-
- return polynomialValue.Quo(math.LegacyNewDec(int64(params.EpochsPerPeriod)))
-}
-
-// Compute the value of x given the polynomial factors
-func polynomial(factors []sdk.Dec, x sdk.Dec) sdk.Dec {
- result := math.LegacyZeroDec()
- for i, factor := range factors {
- result = result.Add(factor.Mul(x.Power(uint64(len(factors) - i - 1))))
- }
-
- // Multiply by 1 million to get the value in unibi
- // 1 unibi = 1e6 nibi and the polynomial was fit on nibi token curve.
- return result.Mul(math.LegacyNewDec(1_000_000))
-}
diff --git a/x/inflation/types/inflation_calculation_test.go b/x/inflation/types/inflation_calculation_test.go
deleted file mode 100644
index f8a3d83f1..000000000
--- a/x/inflation/types/inflation_calculation_test.go
+++ /dev/null
@@ -1,105 +0,0 @@
-package types
-
-import (
- fmt "fmt"
- "testing"
-
- "cosmossdk.io/math"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
-)
-
-// These numbers are for year n month 1
-var ExpectedYearlyInflation = []sdk.Dec{
- math.LegacyNewDec(193_333_719e6),
- math.LegacyNewDec(154_304_107e6),
- math.LegacyNewDec(123_153_673e6),
- math.LegacyNewDec(98_291_791e6),
- math.LegacyNewDec(78_448_949e6),
- math.LegacyNewDec(62_611_919e6),
- math.LegacyNewDec(49_972_019e6),
- math.LegacyNewDec(39_883_823e6),
-}
-
-// ExpectedTotalInflation is the total amount of NIBI tokens (in unibi) that
-// should be minted via inflation for the network to reach its target supply.
-// The value 800M is equivalent to:
-// = (Community allocation of total supply) - (Community supply at start)
-// = (60% of the total supply) - (Community supply at start)
-// = (60% of 1.5 billion) - (Community supply at start)
-// = 800 million NIBI
-var ExpectedTotalInflation = math.LegacyNewDec(800_000_000e6)
-
-func TestCalculateEpochMintProvision(t *testing.T) {
- params := DefaultParams()
- params.InflationEnabled = true
-
- period := uint64(0)
- totalInflation := math.LegacyZeroDec()
-
- // Only the first 8 years have inflation with default params but we run
- // for 10 years expecting 0 inflation in the last 2 years.
- for year := uint64(0); year < 10; year++ {
- yearlyInflation := math.LegacyZeroDec()
- for month := uint64(0); month < 12; month++ {
- for day := uint64(0); day < 30; day++ {
- epochMintProvisions := CalculateEpochMintProvision(params, period)
- yearlyInflation = yearlyInflation.Add(epochMintProvisions)
- }
- period++
- }
- // Should be within 0.0098%
- if year < uint64(len(ExpectedYearlyInflation)) {
- require.NoError(t, withinRange(ExpectedYearlyInflation[year], yearlyInflation))
- } else {
- require.Equal(t, yearlyInflation, math.LegacyZeroDec())
- }
- totalInflation = totalInflation.Add(yearlyInflation)
- }
- require.NoError(t, withinRange(ExpectedTotalInflation, totalInflation))
-}
-
-func TestCalculateEpochMintProvisionInflationNotEnabled(t *testing.T) {
- params := DefaultParams()
- params.InflationEnabled = false
-
- epochId := uint64(0)
- totalInflation := math.LegacyZeroDec()
-
- // Only the first 8 years have inflation with default params but we run
- // for 10 years expecting 0 inflation
- for year := uint64(0); year < 10; year++ {
- yearlyInflation := math.LegacyZeroDec()
- for month := uint64(0); month < 12; month++ {
- for day := uint64(0); day < 30; day++ {
- epochMintProvisions := CalculateEpochMintProvision(params, epochId)
- yearlyInflation = yearlyInflation.Add(epochMintProvisions)
- }
- epochId++
- }
-
- require.Equal(t, yearlyInflation, math.LegacyZeroDec())
- totalInflation = totalInflation.Add(yearlyInflation)
- }
- require.Equal(t, totalInflation, math.LegacyZeroDec())
-}
-
-func TestCalculateEpochMintProvision_ZeroEpochs(t *testing.T) {
- params := DefaultParams()
- params.EpochsPerPeriod = 0
-
- epochMintProvisions := CalculateEpochMintProvision(params, 1)
- require.Equal(t, epochMintProvisions, math.LegacyZeroDec())
-}
-
-// withinRange returns an error if the actual value is not within the expected value +/- tolerance
-// tolerance is a percentage set to 0.01% by default
-func withinRange(expected, actual sdk.Dec) error {
- tolerance := math.LegacyNewDecWithPrec(1, 4)
- if expected.Sub(actual).Abs().Quo(expected).GT(tolerance) {
- tolerancePercent := tolerance.Mul(math.LegacyNewDec(100))
- return fmt.Errorf("expected %s to be within %s%% of %s", actual.String(), tolerancePercent.String(), expected.String())
- }
- return nil
-}
diff --git a/x/inflation/types/interfaces.go b/x/inflation/types/interfaces.go
deleted file mode 100644
index 1fccafed4..000000000
--- a/x/inflation/types/interfaces.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package types // noalias
-
-import (
- sdkmath "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/x/auth/types"
-)
-
-// AccountKeeper defines the contract required for account APIs.
-type AccountKeeper interface {
- GetModuleAddress(name string) sdk.AccAddress
- GetModuleAccount(ctx sdk.Context, moduleName string) types.ModuleAccountI
- GetAccount(sdk.Context, sdk.AccAddress) types.AccountI
- SetAccount(sdk.Context, types.AccountI)
-}
-
-// BankKeeper defines the contract needed to be fulfilled for banking and supply
-// dependencies.
-type BankKeeper interface {
- GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
- GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
- SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
- SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
- SendCoinsFromAccountToModule(
- ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins,
- ) error
- MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error
- BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error
- HasSupply(ctx sdk.Context, denom string) bool
- GetSupply(ctx sdk.Context, denom string) sdk.Coin
-}
-
-// DistrKeeper defines the contract needed to be fulfilled for distribution keeper
-type DistrKeeper interface {
- FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
-}
-
-// StakingKeeper expected staking keeper
-type StakingKeeper interface {
- // BondedRatio the fraction of the staking tokens which are currently bonded
- BondedRatio(ctx sdk.Context) sdk.Dec
- StakingTokenSupply(ctx sdk.Context) sdkmath.Int
- TotalBondedTokens(ctx sdk.Context) sdkmath.Int
-}
-
-type SudoKeeper interface {
- GetRootAddr(ctx sdk.Context) (sdk.AccAddress, error)
- CheckPermissions(contract sdk.AccAddress, ctx sdk.Context) error
-}
diff --git a/x/inflation/types/keys.go b/x/inflation/types/keys.go
deleted file mode 100644
index 62bef8202..000000000
--- a/x/inflation/types/keys.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package types
-
-// constants
-const (
- // module name
- ModuleName = "inflation"
-
- // StoreKey to be used when creating the KVStore
- StoreKey = ModuleName
-
- // RouterKey to be used for message routing
- RouterKey = ModuleName
-)
diff --git a/x/inflation/types/msgs.go b/x/inflation/types/msgs.go
deleted file mode 100644
index cbc4da172..000000000
--- a/x/inflation/types/msgs.go
+++ /dev/null
@@ -1,147 +0,0 @@
-package types
-
-import (
- "fmt"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
-)
-
-// ensure Msg interface compliance at compile time
-var (
- _ legacytx.LegacyMsg = &MsgEditInflationParams{}
- _ legacytx.LegacyMsg = &MsgToggleInflation{}
- _ legacytx.LegacyMsg = &MsgBurn{}
-)
-
-// oracle message types
-const (
- TypeMsgEditInflationParams = "edit_inflation_params"
- TypeMsgToggleInflation = "toggle_inflation"
- TypeMsgBurn = "msg_burn"
-)
-
-// Route implements legacytx.LegacyMsg
-func (msg MsgEditInflationParams) Route() string { return RouterKey }
-
-// Type implements legacytx.LegacyMsg
-func (msg MsgEditInflationParams) Type() string { return TypeMsgEditInflationParams }
-
-// GetSignBytes implements legacytx.LegacyMsg
-func (msg MsgEditInflationParams) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
-}
-
-// GetSigners implements sdk.Msg
-func (msg MsgEditInflationParams) GetSigners() []sdk.AccAddress {
- feeder, err := sdk.AccAddressFromBech32(msg.Sender)
- if err != nil {
- panic(err)
- }
-
- return []sdk.AccAddress{feeder}
-}
-
-func (m MsgEditInflationParams) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil {
- return err
- }
-
- if m.InflationDistribution != nil {
- if m.InflationDistribution.CommunityPool.IsNil() {
- return fmt.Errorf("inflation distribution community pool should not be nil")
- }
- if m.InflationDistribution.StakingRewards.IsNil() {
- return fmt.Errorf("inflation distribution staking rewards should not be nil")
- }
- if m.InflationDistribution.StrategicReserves.IsNil() {
- return fmt.Errorf("inflation distribution strategic reserves should not be nil")
- }
-
- sum := math.LegacyNewDec(0)
- sum = sum.Add(m.InflationDistribution.CommunityPool)
- sum = sum.Add(m.InflationDistribution.StakingRewards)
- sum = sum.Add(m.InflationDistribution.StrategicReserves)
- if !sum.Equal(math.LegacyOneDec()) {
- return fmt.Errorf("inflation distribution sum should be 1, got %s", sum)
- }
- }
-
- if m.PolynomialFactors != nil {
- if len(m.PolynomialFactors) != 6 {
- return fmt.Errorf("polynomial factors should have 6 elements, got %d", len(m.PolynomialFactors))
- }
- }
-
- return nil
-}
-
-// -------------------------------------------------
-// MsgToggleInflation
-// Route implements legacytx.LegacyMsg
-func (msg MsgToggleInflation) Route() string { return RouterKey }
-
-// Type implements legacytx.LegacyMsg
-func (msg MsgToggleInflation) Type() string { return TypeMsgToggleInflation }
-
-// GetSignBytes implements legacytx.LegacyMsg
-func (msg MsgToggleInflation) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
-}
-
-// GetSigners implements sdk.Msg
-func (msg MsgToggleInflation) GetSigners() []sdk.AccAddress {
- feeder, err := sdk.AccAddressFromBech32(msg.Sender)
- if err != nil {
- panic(err)
- }
-
- return []sdk.AccAddress{feeder}
-}
-
-func (m MsgToggleInflation) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil {
- return err
- }
- return nil
-}
-
-// -------------------------------------------------
-// MsgBurn
-// Route implements legacytx.LegacyMsg
-func (msg MsgBurn) Route() string { return RouterKey }
-
-// Type implements legacytx.LegacyMsg
-func (msg MsgBurn) Type() string { return TypeMsgBurn }
-
-// GetSignBytes implements legacytx.LegacyMsg
-func (msg MsgBurn) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
-}
-
-// GetSigners implements legacytx.LegacyMsg
-func (msg MsgBurn) GetSigners() []sdk.AccAddress {
- feeder, err := sdk.AccAddressFromBech32(msg.Sender)
- if err != nil {
- panic(err)
- }
-
- return []sdk.AccAddress{feeder}
-}
-
-func (m MsgBurn) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil {
- return err
- }
-
- if err := m.Coin.Validate(); err != nil {
- return err
- }
-
- if m.Coin.Amount.IsZero() {
- return fmt.Errorf("coin amount should not be zero")
- }
-
- return nil
-}
diff --git a/x/inflation/types/params.go b/x/inflation/types/params.go
deleted file mode 100644
index 1ca46623b..000000000
--- a/x/inflation/types/params.go
+++ /dev/null
@@ -1,176 +0,0 @@
-package types
-
-import (
- "errors"
- "fmt"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-var (
- KeyInflationEnabled = []byte("InflationEnabled")
- KeyHasInflationStarted = []byte("HasInflationStarted")
- KeyPolynomialFactors = []byte("PolynomialFactors")
- KeyInflationDistribution = []byte("InflationDistribution")
- KeyEpochsPerPeriod = []byte("EpochsPerPeriod")
- KeyPeriodsPerYear = []byte("PeriodsPerYear")
- KeyMaxPeriod = []byte("MaxPeriod")
-)
-
-var (
- DefaultInflation = false
- DefaultPolynomialFactors = []sdk.Dec{
- math.LegacyMustNewDecFromStr("-0.000147085524"),
- math.LegacyMustNewDecFromStr("0.074291982762"),
- math.LegacyMustNewDecFromStr("-18.867415611180"),
- math.LegacyMustNewDecFromStr("3128.641926954698"),
- math.LegacyMustNewDecFromStr("-334834.740631598223"),
- math.LegacyMustNewDecFromStr("17827464.906540066004"),
- }
- DefaultInflationDistribution = InflationDistribution{
- CommunityPool: math.LegacyNewDecWithPrec(35_4825, 6), // 35.4825%
- StakingRewards: math.LegacyNewDecWithPrec(28_1250, 6), // 28.1250%
- StrategicReserves: math.LegacyNewDecWithPrec(36_3925, 6), // 36.3925%
- }
- DefaultEpochsPerPeriod = uint64(30)
- DefaultPeriodsPerYear = uint64(12)
- DefaultMaxPeriod = uint64(8 * 12) // 8 years with 360 days per year
-)
-
-func NewParams(
- polynomialCalculation []sdk.Dec,
- inflationDistribution InflationDistribution,
- inflationEnabled bool,
- hasInflationStarted bool,
- epochsPerPeriod,
- periodsPerYear,
- maxPeriod uint64,
-) Params {
- return Params{
- PolynomialFactors: polynomialCalculation,
- InflationDistribution: inflationDistribution,
- InflationEnabled: inflationEnabled,
- HasInflationStarted: hasInflationStarted,
- EpochsPerPeriod: epochsPerPeriod,
- PeriodsPerYear: periodsPerYear,
- MaxPeriod: maxPeriod,
- }
-}
-
-// default inflation module parameters
-func DefaultParams() Params {
- return Params{
- PolynomialFactors: DefaultPolynomialFactors,
- InflationDistribution: DefaultInflationDistribution,
- InflationEnabled: DefaultInflation,
- HasInflationStarted: DefaultInflation,
- EpochsPerPeriod: DefaultEpochsPerPeriod,
- PeriodsPerYear: DefaultPeriodsPerYear,
- MaxPeriod: DefaultMaxPeriod,
- }
-}
-
-func validatePolynomialFactors(i interface{}) error {
- v, ok := i.([]sdk.Dec)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
-
- if len(v) == 0 {
- return errors.New("polynomial factors cannot be empty")
- }
- return nil
-}
-
-func validateInflationDistribution(i interface{}) error {
- v, ok := i.(InflationDistribution)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
-
- if v.StakingRewards.IsNegative() {
- return errors.New("staking distribution ratio must not be negative")
- }
-
- if v.CommunityPool.IsNegative() {
- return errors.New("community pool distribution ratio must not be negative")
- }
-
- if v.StrategicReserves.IsNegative() {
- return errors.New("pool incentives distribution ratio must not be negative")
- }
-
- totalProportions := v.StakingRewards.Add(v.StrategicReserves).Add(v.CommunityPool)
- if !totalProportions.Equal(math.LegacyOneDec()) {
- return errors.New("total distributions ratio should be 1")
- }
-
- return nil
-}
-
-func validateBool(i interface{}) error {
- _, ok := i.(bool)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
-
- return nil
-}
-
-func validateUint64(i interface{}) error {
- _, ok := i.(uint64)
- if !ok {
- return fmt.Errorf("invalid genesis state type: %T", i)
- }
- return nil
-}
-
-func validateEpochsPerPeriod(i interface{}) error {
- val, ok := i.(uint64)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
-
- if val <= 0 {
- return fmt.Errorf("epochs per period must be positive: %d", val)
- }
-
- return nil
-}
-
-func validatePeriodsPerYear(i interface{}) error {
- val, ok := i.(uint64)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
-
- if val <= 0 {
- return fmt.Errorf("periods per year must be positive: %d", val)
- }
-
- return nil
-}
-
-func (p Params) Validate() error {
- if err := validateEpochsPerPeriod(p.EpochsPerPeriod); err != nil {
- return err
- }
- if err := validatePeriodsPerYear(p.PeriodsPerYear); err != nil {
- return err
- }
- if err := validatePolynomialFactors(p.PolynomialFactors); err != nil {
- return err
- }
- if err := validateInflationDistribution(p.InflationDistribution); err != nil {
- return err
- }
- if err := validateUint64(p.MaxPeriod); err != nil {
- return err
- }
- if err := validateBool(p.HasInflationStarted); err != nil {
- return err
- }
-
- return validateBool(p.InflationEnabled)
-}
diff --git a/x/inflation/types/params_test.go b/x/inflation/types/params_test.go
deleted file mode 100644
index 054dcc19a..000000000
--- a/x/inflation/types/params_test.go
+++ /dev/null
@@ -1,140 +0,0 @@
-package types_test
-
-import (
- "testing"
-
- "cosmossdk.io/math"
-
- inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
-)
-
-func TestParamsValidate(t *testing.T) {
- testCases := []struct {
- name string
- params inflationtypes.Params
- expError bool
- }{
- {
- "default",
- inflationtypes.DefaultParams(),
- false,
- },
- {
- "valid",
- inflationtypes.NewParams(
- inflationtypes.DefaultPolynomialFactors,
- inflationtypes.DefaultInflationDistribution,
- true,
- true,
- inflationtypes.DefaultEpochsPerPeriod,
- inflationtypes.DefaultPeriodsPerYear,
- inflationtypes.DefaultMaxPeriod,
- ),
- false,
- },
- {
- "valid param literal",
- inflationtypes.Params{
- PolynomialFactors: inflationtypes.DefaultPolynomialFactors,
- InflationDistribution: inflationtypes.DefaultInflationDistribution,
- InflationEnabled: true,
- HasInflationStarted: true,
- EpochsPerPeriod: inflationtypes.DefaultEpochsPerPeriod,
- PeriodsPerYear: inflationtypes.DefaultPeriodsPerYear,
- },
- false,
- },
- {
- "invalid - polynomial calculation - no coefficient",
- inflationtypes.Params{
- PolynomialFactors: []sdk.Dec{},
- InflationDistribution: inflationtypes.DefaultInflationDistribution,
- InflationEnabled: true,
- HasInflationStarted: true,
- EpochsPerPeriod: inflationtypes.DefaultEpochsPerPeriod,
- PeriodsPerYear: inflationtypes.DefaultPeriodsPerYear,
- },
- true,
- },
- {
- "invalid - inflation distribution - negative staking rewards",
- inflationtypes.Params{
- PolynomialFactors: inflationtypes.DefaultPolynomialFactors,
- InflationDistribution: inflationtypes.InflationDistribution{
- StakingRewards: math.LegacyOneDec().Neg(),
- CommunityPool: math.LegacyNewDecWithPrec(133333, 6),
- StrategicReserves: math.LegacyNewDecWithPrec(333333, 6),
- },
- InflationEnabled: true,
- HasInflationStarted: true,
- EpochsPerPeriod: inflationtypes.DefaultEpochsPerPeriod,
- PeriodsPerYear: inflationtypes.DefaultPeriodsPerYear,
- },
- true,
- },
- {
- "invalid - inflation distribution - negative usage incentives",
- inflationtypes.Params{
- PolynomialFactors: inflationtypes.DefaultPolynomialFactors,
- InflationDistribution: inflationtypes.InflationDistribution{
- StakingRewards: math.LegacyNewDecWithPrec(533334, 6),
- CommunityPool: math.LegacyNewDecWithPrec(133333, 6),
- StrategicReserves: math.LegacyOneDec().Neg(),
- },
- InflationEnabled: true,
- HasInflationStarted: true,
- EpochsPerPeriod: inflationtypes.DefaultEpochsPerPeriod,
- PeriodsPerYear: inflationtypes.DefaultPeriodsPerYear,
- },
- true,
- },
- {
- "invalid - inflation distribution - negative community pool rewards",
- inflationtypes.Params{
- PolynomialFactors: inflationtypes.DefaultPolynomialFactors,
- InflationDistribution: inflationtypes.InflationDistribution{
- StakingRewards: math.LegacyNewDecWithPrec(533334, 6),
- CommunityPool: math.LegacyOneDec().Neg(),
- StrategicReserves: math.LegacyNewDecWithPrec(333333, 6),
- },
- InflationEnabled: true,
- HasInflationStarted: true,
- EpochsPerPeriod: inflationtypes.DefaultEpochsPerPeriod,
- PeriodsPerYear: inflationtypes.DefaultPeriodsPerYear,
- },
- true,
- },
- {
- "invalid - inflation distribution - total distribution ratio unequal 1",
- inflationtypes.Params{
- PolynomialFactors: inflationtypes.DefaultPolynomialFactors,
- InflationDistribution: inflationtypes.InflationDistribution{
- StakingRewards: math.LegacyNewDecWithPrec(533333, 6),
- CommunityPool: math.LegacyNewDecWithPrec(133333, 6),
- StrategicReserves: math.LegacyNewDecWithPrec(333333, 6),
- },
- InflationEnabled: true,
- HasInflationStarted: true,
- EpochsPerPeriod: inflationtypes.DefaultEpochsPerPeriod,
- PeriodsPerYear: inflationtypes.DefaultPeriodsPerYear,
- },
- true,
- },
- }
-
- for _, tc := range testCases {
- tc := tc
- t.Run(tc.name, func(t *testing.T) {
- err := tc.params.Validate()
-
- if tc.expError {
- require.Error(t, err, tc.name)
- } else {
- require.NoError(t, err, tc.name)
- }
- })
- }
-}
diff --git a/x/inflation/types/query.pb.go b/x/inflation/types/query.pb.go
deleted file mode 100644
index 4b15226dc..000000000
--- a/x/inflation/types/query.pb.go
+++ /dev/null
@@ -1,2191 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/inflation/v1/query.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// QueryPeriodRequest is the request type for the Query/Period RPC method.
-type QueryPeriodRequest struct {
-}
-
-func (m *QueryPeriodRequest) Reset() { *m = QueryPeriodRequest{} }
-func (m *QueryPeriodRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryPeriodRequest) ProtoMessage() {}
-func (*QueryPeriodRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{0}
-}
-func (m *QueryPeriodRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryPeriodRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryPeriodRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryPeriodRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryPeriodRequest.Merge(m, src)
-}
-func (m *QueryPeriodRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryPeriodRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryPeriodRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryPeriodRequest proto.InternalMessageInfo
-
-// QueryPeriodResponse is the response type for the Query/Period RPC method.
-type QueryPeriodResponse struct {
- // period is the current minting per epoch provision value.
- Period uint64 `protobuf:"varint,1,opt,name=period,proto3" json:"period,omitempty"`
-}
-
-func (m *QueryPeriodResponse) Reset() { *m = QueryPeriodResponse{} }
-func (m *QueryPeriodResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryPeriodResponse) ProtoMessage() {}
-func (*QueryPeriodResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{1}
-}
-func (m *QueryPeriodResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryPeriodResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryPeriodResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryPeriodResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryPeriodResponse.Merge(m, src)
-}
-func (m *QueryPeriodResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryPeriodResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryPeriodResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryPeriodResponse proto.InternalMessageInfo
-
-func (m *QueryPeriodResponse) GetPeriod() uint64 {
- if m != nil {
- return m.Period
- }
- return 0
-}
-
-// QueryEpochMintProvisionRequest is the request type for the
-// Query/EpochMintProvision RPC method.
-type QueryEpochMintProvisionRequest struct {
-}
-
-func (m *QueryEpochMintProvisionRequest) Reset() { *m = QueryEpochMintProvisionRequest{} }
-func (m *QueryEpochMintProvisionRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryEpochMintProvisionRequest) ProtoMessage() {}
-func (*QueryEpochMintProvisionRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{2}
-}
-func (m *QueryEpochMintProvisionRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryEpochMintProvisionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryEpochMintProvisionRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryEpochMintProvisionRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryEpochMintProvisionRequest.Merge(m, src)
-}
-func (m *QueryEpochMintProvisionRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryEpochMintProvisionRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryEpochMintProvisionRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryEpochMintProvisionRequest proto.InternalMessageInfo
-
-// QueryEpochMintProvisionResponse is the response type for the
-// Query/EpochMintProvision RPC method.
-type QueryEpochMintProvisionResponse struct {
- // epoch_mint_provision is the current minting per epoch provision value.
- EpochMintProvision types.DecCoin `protobuf:"bytes,1,opt,name=epoch_mint_provision,json=epochMintProvision,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"epoch_mint_provision"`
-}
-
-func (m *QueryEpochMintProvisionResponse) Reset() { *m = QueryEpochMintProvisionResponse{} }
-func (m *QueryEpochMintProvisionResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryEpochMintProvisionResponse) ProtoMessage() {}
-func (*QueryEpochMintProvisionResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{3}
-}
-func (m *QueryEpochMintProvisionResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryEpochMintProvisionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryEpochMintProvisionResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryEpochMintProvisionResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryEpochMintProvisionResponse.Merge(m, src)
-}
-func (m *QueryEpochMintProvisionResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryEpochMintProvisionResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryEpochMintProvisionResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryEpochMintProvisionResponse proto.InternalMessageInfo
-
-func (m *QueryEpochMintProvisionResponse) GetEpochMintProvision() types.DecCoin {
- if m != nil {
- return m.EpochMintProvision
- }
- return types.DecCoin{}
-}
-
-// QuerySkippedEpochsRequest is the request type for the Query/SkippedEpochs RPC
-// method.
-type QuerySkippedEpochsRequest struct {
-}
-
-func (m *QuerySkippedEpochsRequest) Reset() { *m = QuerySkippedEpochsRequest{} }
-func (m *QuerySkippedEpochsRequest) String() string { return proto.CompactTextString(m) }
-func (*QuerySkippedEpochsRequest) ProtoMessage() {}
-func (*QuerySkippedEpochsRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{4}
-}
-func (m *QuerySkippedEpochsRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QuerySkippedEpochsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QuerySkippedEpochsRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QuerySkippedEpochsRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QuerySkippedEpochsRequest.Merge(m, src)
-}
-func (m *QuerySkippedEpochsRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QuerySkippedEpochsRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QuerySkippedEpochsRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QuerySkippedEpochsRequest proto.InternalMessageInfo
-
-// QuerySkippedEpochsResponse is the response type for the Query/SkippedEpochs
-// RPC method.
-type QuerySkippedEpochsResponse struct {
- // skipped_epochs is the number of epochs that the inflation module has been
- // disabled.
- SkippedEpochs uint64 `protobuf:"varint,1,opt,name=skipped_epochs,json=skippedEpochs,proto3" json:"skipped_epochs,omitempty"`
-}
-
-func (m *QuerySkippedEpochsResponse) Reset() { *m = QuerySkippedEpochsResponse{} }
-func (m *QuerySkippedEpochsResponse) String() string { return proto.CompactTextString(m) }
-func (*QuerySkippedEpochsResponse) ProtoMessage() {}
-func (*QuerySkippedEpochsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{5}
-}
-func (m *QuerySkippedEpochsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QuerySkippedEpochsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QuerySkippedEpochsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QuerySkippedEpochsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QuerySkippedEpochsResponse.Merge(m, src)
-}
-func (m *QuerySkippedEpochsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QuerySkippedEpochsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QuerySkippedEpochsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QuerySkippedEpochsResponse proto.InternalMessageInfo
-
-func (m *QuerySkippedEpochsResponse) GetSkippedEpochs() uint64 {
- if m != nil {
- return m.SkippedEpochs
- }
- return 0
-}
-
-// QueryCirculatingSupplyRequest is the request type for the
-// Query/CirculatingSupply RPC method.
-type QueryCirculatingSupplyRequest struct {
-}
-
-func (m *QueryCirculatingSupplyRequest) Reset() { *m = QueryCirculatingSupplyRequest{} }
-func (m *QueryCirculatingSupplyRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryCirculatingSupplyRequest) ProtoMessage() {}
-func (*QueryCirculatingSupplyRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{6}
-}
-func (m *QueryCirculatingSupplyRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryCirculatingSupplyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryCirculatingSupplyRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryCirculatingSupplyRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryCirculatingSupplyRequest.Merge(m, src)
-}
-func (m *QueryCirculatingSupplyRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryCirculatingSupplyRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryCirculatingSupplyRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryCirculatingSupplyRequest proto.InternalMessageInfo
-
-// QueryCirculatingSupplyResponse is the response type for the
-// Query/CirculatingSupply RPC method.
-type QueryCirculatingSupplyResponse struct {
- // circulating_supply is the total amount of coins in circulation
- CirculatingSupply types.DecCoin `protobuf:"bytes,1,opt,name=circulating_supply,json=circulatingSupply,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"circulating_supply"`
-}
-
-func (m *QueryCirculatingSupplyResponse) Reset() { *m = QueryCirculatingSupplyResponse{} }
-func (m *QueryCirculatingSupplyResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryCirculatingSupplyResponse) ProtoMessage() {}
-func (*QueryCirculatingSupplyResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{7}
-}
-func (m *QueryCirculatingSupplyResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryCirculatingSupplyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryCirculatingSupplyResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryCirculatingSupplyResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryCirculatingSupplyResponse.Merge(m, src)
-}
-func (m *QueryCirculatingSupplyResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryCirculatingSupplyResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryCirculatingSupplyResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryCirculatingSupplyResponse proto.InternalMessageInfo
-
-func (m *QueryCirculatingSupplyResponse) GetCirculatingSupply() types.DecCoin {
- if m != nil {
- return m.CirculatingSupply
- }
- return types.DecCoin{}
-}
-
-// QueryInflationRateRequest is the request type for the Query/InflationRate RPC
-// method.
-type QueryInflationRateRequest struct {
-}
-
-func (m *QueryInflationRateRequest) Reset() { *m = QueryInflationRateRequest{} }
-func (m *QueryInflationRateRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryInflationRateRequest) ProtoMessage() {}
-func (*QueryInflationRateRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{8}
-}
-func (m *QueryInflationRateRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryInflationRateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryInflationRateRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryInflationRateRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryInflationRateRequest.Merge(m, src)
-}
-func (m *QueryInflationRateRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryInflationRateRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryInflationRateRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryInflationRateRequest proto.InternalMessageInfo
-
-// QueryInflationRateResponse is the response type for the Query/InflationRate
-// RPC method.
-type QueryInflationRateResponse struct {
- // inflation_rate by which the total supply increases within one period
- InflationRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=inflation_rate,json=inflationRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation_rate"`
-}
-
-func (m *QueryInflationRateResponse) Reset() { *m = QueryInflationRateResponse{} }
-func (m *QueryInflationRateResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryInflationRateResponse) ProtoMessage() {}
-func (*QueryInflationRateResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{9}
-}
-func (m *QueryInflationRateResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryInflationRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryInflationRateResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryInflationRateResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryInflationRateResponse.Merge(m, src)
-}
-func (m *QueryInflationRateResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryInflationRateResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryInflationRateResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryInflationRateResponse proto.InternalMessageInfo
-
-// QueryParamsRequest is the request type for the Query/Params RPC method.
-type QueryParamsRequest struct {
-}
-
-func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} }
-func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryParamsRequest) ProtoMessage() {}
-func (*QueryParamsRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{10}
-}
-func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryParamsRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryParamsRequest.Merge(m, src)
-}
-func (m *QueryParamsRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryParamsRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo
-
-// QueryParamsResponse is the response type for the Query/Params RPC method.
-type QueryParamsResponse struct {
- // params defines the parameters of the module.
- Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
-}
-
-func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} }
-func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryParamsResponse) ProtoMessage() {}
-func (*QueryParamsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_9cef9ea5e4d20e5e, []int{11}
-}
-func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryParamsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryParamsResponse.Merge(m, src)
-}
-func (m *QueryParamsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryParamsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo
-
-func (m *QueryParamsResponse) GetParams() Params {
- if m != nil {
- return m.Params
- }
- return Params{}
-}
-
-func init() {
- proto.RegisterType((*QueryPeriodRequest)(nil), "nibiru.inflation.v1.QueryPeriodRequest")
- proto.RegisterType((*QueryPeriodResponse)(nil), "nibiru.inflation.v1.QueryPeriodResponse")
- proto.RegisterType((*QueryEpochMintProvisionRequest)(nil), "nibiru.inflation.v1.QueryEpochMintProvisionRequest")
- proto.RegisterType((*QueryEpochMintProvisionResponse)(nil), "nibiru.inflation.v1.QueryEpochMintProvisionResponse")
- proto.RegisterType((*QuerySkippedEpochsRequest)(nil), "nibiru.inflation.v1.QuerySkippedEpochsRequest")
- proto.RegisterType((*QuerySkippedEpochsResponse)(nil), "nibiru.inflation.v1.QuerySkippedEpochsResponse")
- proto.RegisterType((*QueryCirculatingSupplyRequest)(nil), "nibiru.inflation.v1.QueryCirculatingSupplyRequest")
- proto.RegisterType((*QueryCirculatingSupplyResponse)(nil), "nibiru.inflation.v1.QueryCirculatingSupplyResponse")
- proto.RegisterType((*QueryInflationRateRequest)(nil), "nibiru.inflation.v1.QueryInflationRateRequest")
- proto.RegisterType((*QueryInflationRateResponse)(nil), "nibiru.inflation.v1.QueryInflationRateResponse")
- proto.RegisterType((*QueryParamsRequest)(nil), "nibiru.inflation.v1.QueryParamsRequest")
- proto.RegisterType((*QueryParamsResponse)(nil), "nibiru.inflation.v1.QueryParamsResponse")
-}
-
-func init() { proto.RegisterFile("nibiru/inflation/v1/query.proto", fileDescriptor_9cef9ea5e4d20e5e) }
-
-var fileDescriptor_9cef9ea5e4d20e5e = []byte{
- // 686 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x4f, 0x4f, 0x14, 0x3d,
- 0x1c, 0xc7, 0xb7, 0x4f, 0x78, 0xd6, 0x58, 0x03, 0x09, 0x85, 0x18, 0x1d, 0x60, 0x16, 0x97, 0x20,
- 0x10, 0x42, 0x9b, 0x65, 0xbd, 0x78, 0x65, 0xf5, 0xc0, 0x41, 0x83, 0x43, 0xbc, 0x78, 0xd9, 0xcc,
- 0x0e, 0x75, 0x68, 0x60, 0xdb, 0x32, 0x9d, 0xd9, 0xc8, 0xcd, 0xe8, 0x1b, 0x30, 0xf1, 0xec, 0xc9,
- 0x83, 0x89, 0x89, 0x17, 0x5e, 0x05, 0x47, 0x12, 0x2f, 0xc6, 0x03, 0x1a, 0xf0, 0x85, 0x98, 0xe9,
- 0x74, 0x96, 0x1d, 0xb6, 0xb3, 0xc0, 0xc1, 0xd3, 0xce, 0xf6, 0xf7, 0xef, 0xdb, 0x6f, 0xfb, 0x99,
- 0x81, 0x35, 0xce, 0x3a, 0x2c, 0x4a, 0x08, 0xe3, 0xaf, 0xf7, 0xfd, 0x98, 0x09, 0x4e, 0x7a, 0x0d,
- 0x72, 0x90, 0xd0, 0xe8, 0x10, 0xcb, 0x48, 0xc4, 0x02, 0x4d, 0x65, 0x09, 0xb8, 0x9f, 0x80, 0x7b,
- 0x0d, 0xc7, 0x0d, 0x84, 0xea, 0x0a, 0x45, 0x3a, 0xbe, 0xa2, 0xa4, 0xd7, 0xe8, 0xd0, 0xd8, 0x6f,
- 0x90, 0x40, 0x30, 0x9e, 0x15, 0x39, 0x0f, 0x6c, 0x5d, 0x43, 0xca, 0xa9, 0x62, 0xca, 0xa4, 0x4c,
- 0x87, 0x22, 0x14, 0xfa, 0x91, 0xa4, 0x4f, 0x66, 0x75, 0x36, 0x14, 0x22, 0xdc, 0xa7, 0xc4, 0x97,
- 0x8c, 0xf8, 0x9c, 0x8b, 0x58, 0x57, 0x9b, 0x9a, 0xfa, 0x34, 0x44, 0x2f, 0x52, 0x69, 0x5b, 0x34,
- 0x62, 0x62, 0xc7, 0xa3, 0x07, 0x09, 0x55, 0x71, 0x7d, 0x0d, 0x4e, 0x15, 0x56, 0x95, 0x14, 0x5c,
- 0x51, 0x74, 0x17, 0x56, 0xa5, 0x5e, 0xb9, 0x07, 0xe6, 0xc1, 0xf2, 0x98, 0x67, 0xfe, 0xd5, 0xe7,
- 0xa1, 0xab, 0xd3, 0x9f, 0x4a, 0x11, 0xec, 0x3e, 0x63, 0x3c, 0xde, 0x8a, 0x44, 0x8f, 0x29, 0x26,
- 0x78, 0xde, 0xf0, 0x0b, 0x80, 0xb5, 0xd2, 0x14, 0xd3, 0xfd, 0x3d, 0x80, 0xd3, 0x34, 0x0d, 0xb7,
- 0xbb, 0x8c, 0xc7, 0x6d, 0x99, 0x27, 0xe8, 0x61, 0x77, 0xd6, 0x67, 0x71, 0xe6, 0x10, 0x4e, 0x1d,
- 0xc2, 0xc6, 0x21, 0xfc, 0x84, 0x06, 0x2d, 0xc1, 0xf8, 0x46, 0xf3, 0xf8, 0xb4, 0x56, 0xf9, 0xfa,
- 0xab, 0xb6, 0x1a, 0xb2, 0x78, 0x37, 0xe9, 0xe0, 0x40, 0x74, 0x89, 0x71, 0x34, 0xfb, 0x59, 0x53,
- 0x3b, 0x7b, 0x24, 0x3e, 0x94, 0x54, 0xe5, 0x35, 0xca, 0x43, 0x74, 0x48, 0x4d, 0x7d, 0x06, 0xde,
- 0xd7, 0x42, 0xb7, 0xf7, 0x98, 0x94, 0x74, 0x47, 0xeb, 0x55, 0xf9, 0x36, 0x5a, 0xd0, 0xb1, 0x05,
- 0xcd, 0x06, 0x16, 0xe1, 0x84, 0xca, 0x02, 0x6d, 0xdd, 0x58, 0x19, 0x9b, 0xc6, 0xd5, 0x60, 0x7a,
- 0xbd, 0x06, 0xe7, 0x74, 0x93, 0x16, 0x8b, 0x82, 0x24, 0x3d, 0x4b, 0x1e, 0x6e, 0x27, 0x52, 0xee,
- 0x1f, 0xe6, 0x53, 0x3e, 0x03, 0xe3, 0xa7, 0x25, 0xc3, 0x8c, 0x7a, 0x0b, 0x20, 0x0a, 0x2e, 0xa2,
- 0x6d, 0xa5, 0xc3, 0xff, 0xce, 0xa9, 0xc9, 0xe0, 0xb2, 0x94, 0xbe, 0x51, 0x9b, 0xf9, 0x85, 0xf4,
- 0xfc, 0x98, 0xe6, 0x5b, 0x50, 0xc6, 0xa8, 0x4b, 0x41, 0xa3, 0xfe, 0x25, 0x9c, 0xe8, 0x5f, 0xe3,
- 0x76, 0xe4, 0xc7, 0x54, 0x0b, 0xbf, 0xbd, 0x81, 0x53, 0x69, 0x3f, 0x4f, 0x6b, 0x0f, 0xaf, 0x27,
- 0xcd, 0x1b, 0x67, 0x83, 0xed, 0x2f, 0xee, 0xb2, 0x1f, 0xf9, 0xdd, 0xfe, 0x99, 0x6d, 0xe5, 0x77,
- 0xd9, 0xac, 0x1a, 0x0d, 0x8f, 0x61, 0x55, 0xea, 0x15, 0x63, 0xda, 0x0c, 0xb6, 0x50, 0x89, 0xb3,
- 0xa2, 0x8d, 0xb1, 0x54, 0x98, 0x67, 0x0a, 0xd6, 0x8f, 0x6e, 0xc1, 0xff, 0x75, 0xcb, 0xf4, 0x18,
- 0xaa, 0x19, 0x23, 0x68, 0xc9, 0x5a, 0x3f, 0xcc, 0x96, 0xb3, 0x7c, 0x75, 0x62, 0x26, 0xb1, 0xbe,
- 0xf0, 0xee, 0xfb, 0x9f, 0x8f, 0xff, 0xcd, 0xa1, 0x19, 0x62, 0x63, 0x3f, 0x63, 0x0f, 0x1d, 0x01,
- 0x88, 0x86, 0xa1, 0x42, 0xcd, 0xf2, 0x29, 0xa5, 0x94, 0x3a, 0x8f, 0x6e, 0x56, 0x64, 0x64, 0x36,
- 0xb4, 0xcc, 0x55, 0xb4, 0x62, 0x95, 0x69, 0x23, 0x1a, 0x7d, 0x02, 0x70, 0xbc, 0xc0, 0x10, 0xc2,
- 0xe5, 0xa3, 0x6d, 0x24, 0x3a, 0xe4, 0xda, 0xf9, 0x46, 0xe5, 0xaa, 0x56, 0xb9, 0x88, 0x16, 0xac,
- 0x2a, 0x8b, 0xdc, 0xa2, 0x6f, 0x00, 0x4e, 0x0e, 0xc1, 0x87, 0xd6, 0xcb, 0x67, 0x96, 0xb1, 0xec,
- 0x34, 0x6f, 0x54, 0x63, 0xb4, 0x12, 0xad, 0x75, 0x05, 0x2d, 0x59, 0xb5, 0x0e, 0x73, 0xaf, 0xfd,
- 0x2c, 0xa0, 0x36, 0xca, 0x4f, 0x1b, 0xb0, 0xa3, 0xfc, 0xb4, 0x32, 0x7c, 0x85, 0x9f, 0x45, 0xbc,
- 0x33, 0x4e, 0x34, 0x3c, 0x23, 0x39, 0x19, 0xe4, 0x76, 0x24, 0x27, 0x05, 0x94, 0xaf, 0xe2, 0x24,
- 0x43, 0x78, 0xf3, 0xf8, 0xcc, 0x05, 0x27, 0x67, 0x2e, 0xf8, 0x7d, 0xe6, 0x82, 0x0f, 0xe7, 0x6e,
- 0xe5, 0xe4, 0xdc, 0xad, 0xfc, 0x38, 0x77, 0x2b, 0xaf, 0xc8, 0xc0, 0xdb, 0xe6, 0xb9, 0x6e, 0xd0,
- 0xda, 0xf5, 0x19, 0xcf, 0x9b, 0xbd, 0x19, 0x68, 0xa7, 0x5f, 0x3d, 0x9d, 0xaa, 0xfe, 0x74, 0x36,
- 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x40, 0x82, 0x21, 0x19, 0xe9, 0x07, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// QueryClient is the client API for Query service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type QueryClient interface {
- // Period retrieves current period.
- Period(ctx context.Context, in *QueryPeriodRequest, opts ...grpc.CallOption) (*QueryPeriodResponse, error)
- // EpochMintProvision retrieves current minting epoch provision value.
- EpochMintProvision(ctx context.Context, in *QueryEpochMintProvisionRequest, opts ...grpc.CallOption) (*QueryEpochMintProvisionResponse, error)
- // SkippedEpochs retrieves the total number of skipped epochs.
- SkippedEpochs(ctx context.Context, in *QuerySkippedEpochsRequest, opts ...grpc.CallOption) (*QuerySkippedEpochsResponse, error)
- // CirculatingSupply retrieves the total number of tokens that are in
- // circulation (i.e. excluding unvested tokens).
- CirculatingSupply(ctx context.Context, in *QueryCirculatingSupplyRequest, opts ...grpc.CallOption) (*QueryCirculatingSupplyResponse, error)
- // InflationRate retrieves the inflation rate of the current period.
- InflationRate(ctx context.Context, in *QueryInflationRateRequest, opts ...grpc.CallOption) (*QueryInflationRateResponse, error)
- // Params retrieves the total set of minting parameters.
- Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
-}
-
-type queryClient struct {
- cc grpc1.ClientConn
-}
-
-func NewQueryClient(cc grpc1.ClientConn) QueryClient {
- return &queryClient{cc}
-}
-
-func (c *queryClient) Period(ctx context.Context, in *QueryPeriodRequest, opts ...grpc.CallOption) (*QueryPeriodResponse, error) {
- out := new(QueryPeriodResponse)
- err := c.cc.Invoke(ctx, "/nibiru.inflation.v1.Query/Period", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) EpochMintProvision(ctx context.Context, in *QueryEpochMintProvisionRequest, opts ...grpc.CallOption) (*QueryEpochMintProvisionResponse, error) {
- out := new(QueryEpochMintProvisionResponse)
- err := c.cc.Invoke(ctx, "/nibiru.inflation.v1.Query/EpochMintProvision", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) SkippedEpochs(ctx context.Context, in *QuerySkippedEpochsRequest, opts ...grpc.CallOption) (*QuerySkippedEpochsResponse, error) {
- out := new(QuerySkippedEpochsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.inflation.v1.Query/SkippedEpochs", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) CirculatingSupply(ctx context.Context, in *QueryCirculatingSupplyRequest, opts ...grpc.CallOption) (*QueryCirculatingSupplyResponse, error) {
- out := new(QueryCirculatingSupplyResponse)
- err := c.cc.Invoke(ctx, "/nibiru.inflation.v1.Query/CirculatingSupply", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) InflationRate(ctx context.Context, in *QueryInflationRateRequest, opts ...grpc.CallOption) (*QueryInflationRateResponse, error) {
- out := new(QueryInflationRateResponse)
- err := c.cc.Invoke(ctx, "/nibiru.inflation.v1.Query/InflationRate", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) {
- out := new(QueryParamsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.inflation.v1.Query/Params", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// QueryServer is the server API for Query service.
-type QueryServer interface {
- // Period retrieves current period.
- Period(context.Context, *QueryPeriodRequest) (*QueryPeriodResponse, error)
- // EpochMintProvision retrieves current minting epoch provision value.
- EpochMintProvision(context.Context, *QueryEpochMintProvisionRequest) (*QueryEpochMintProvisionResponse, error)
- // SkippedEpochs retrieves the total number of skipped epochs.
- SkippedEpochs(context.Context, *QuerySkippedEpochsRequest) (*QuerySkippedEpochsResponse, error)
- // CirculatingSupply retrieves the total number of tokens that are in
- // circulation (i.e. excluding unvested tokens).
- CirculatingSupply(context.Context, *QueryCirculatingSupplyRequest) (*QueryCirculatingSupplyResponse, error)
- // InflationRate retrieves the inflation rate of the current period.
- InflationRate(context.Context, *QueryInflationRateRequest) (*QueryInflationRateResponse, error)
- // Params retrieves the total set of minting parameters.
- Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
-}
-
-// UnimplementedQueryServer can be embedded to have forward compatible implementations.
-type UnimplementedQueryServer struct {
-}
-
-func (*UnimplementedQueryServer) Period(ctx context.Context, req *QueryPeriodRequest) (*QueryPeriodResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Period not implemented")
-}
-func (*UnimplementedQueryServer) EpochMintProvision(ctx context.Context, req *QueryEpochMintProvisionRequest) (*QueryEpochMintProvisionResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EpochMintProvision not implemented")
-}
-func (*UnimplementedQueryServer) SkippedEpochs(ctx context.Context, req *QuerySkippedEpochsRequest) (*QuerySkippedEpochsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method SkippedEpochs not implemented")
-}
-func (*UnimplementedQueryServer) CirculatingSupply(ctx context.Context, req *QueryCirculatingSupplyRequest) (*QueryCirculatingSupplyResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method CirculatingSupply not implemented")
-}
-func (*UnimplementedQueryServer) InflationRate(ctx context.Context, req *QueryInflationRateRequest) (*QueryInflationRateResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method InflationRate not implemented")
-}
-func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
-}
-
-func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
- s.RegisterService(&_Query_serviceDesc, srv)
-}
-
-func _Query_Period_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryPeriodRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Period(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.inflation.v1.Query/Period",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Period(ctx, req.(*QueryPeriodRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_EpochMintProvision_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryEpochMintProvisionRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).EpochMintProvision(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.inflation.v1.Query/EpochMintProvision",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).EpochMintProvision(ctx, req.(*QueryEpochMintProvisionRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_SkippedEpochs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QuerySkippedEpochsRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).SkippedEpochs(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.inflation.v1.Query/SkippedEpochs",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).SkippedEpochs(ctx, req.(*QuerySkippedEpochsRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_CirculatingSupply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryCirculatingSupplyRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).CirculatingSupply(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.inflation.v1.Query/CirculatingSupply",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).CirculatingSupply(ctx, req.(*QueryCirculatingSupplyRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_InflationRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryInflationRateRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).InflationRate(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.inflation.v1.Query/InflationRate",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).InflationRate(ctx, req.(*QueryInflationRateRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryParamsRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Params(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.inflation.v1.Query/Params",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Query_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.inflation.v1.Query",
- HandlerType: (*QueryServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "Period",
- Handler: _Query_Period_Handler,
- },
- {
- MethodName: "EpochMintProvision",
- Handler: _Query_EpochMintProvision_Handler,
- },
- {
- MethodName: "SkippedEpochs",
- Handler: _Query_SkippedEpochs_Handler,
- },
- {
- MethodName: "CirculatingSupply",
- Handler: _Query_CirculatingSupply_Handler,
- },
- {
- MethodName: "InflationRate",
- Handler: _Query_InflationRate_Handler,
- },
- {
- MethodName: "Params",
- Handler: _Query_Params_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/inflation/v1/query.proto",
-}
-
-func (m *QueryPeriodRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryPeriodRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryPeriodRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryPeriodResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryPeriodResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryPeriodResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.Period != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.Period))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryEpochMintProvisionRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryEpochMintProvisionRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryEpochMintProvisionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryEpochMintProvisionResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryEpochMintProvisionResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryEpochMintProvisionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.EpochMintProvision.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *QuerySkippedEpochsRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QuerySkippedEpochsRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QuerySkippedEpochsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QuerySkippedEpochsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QuerySkippedEpochsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QuerySkippedEpochsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.SkippedEpochs != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.SkippedEpochs))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryCirculatingSupplyRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryCirculatingSupplyRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryCirculatingSupplyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryCirculatingSupplyResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryCirculatingSupplyResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryCirculatingSupplyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.CirculatingSupply.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *QueryInflationRateRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryInflationRateRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryInflationRateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryInflationRateResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryInflationRateResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryInflationRateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size := m.InflationRate.Size()
- i -= size
- if _, err := m.InflationRate.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
- offset -= sovQuery(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *QueryPeriodRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryPeriodResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.Period != 0 {
- n += 1 + sovQuery(uint64(m.Period))
- }
- return n
-}
-
-func (m *QueryEpochMintProvisionRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryEpochMintProvisionResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.EpochMintProvision.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *QuerySkippedEpochsRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QuerySkippedEpochsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.SkippedEpochs != 0 {
- n += 1 + sovQuery(uint64(m.SkippedEpochs))
- }
- return n
-}
-
-func (m *QueryCirculatingSupplyRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryCirculatingSupplyResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.CirculatingSupply.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *QueryInflationRateRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryInflationRateResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.InflationRate.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *QueryParamsRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryParamsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Params.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func sovQuery(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozQuery(x uint64) (n int) {
- return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *QueryPeriodRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryPeriodRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryPeriodRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryPeriodResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryPeriodResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryPeriodResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType)
- }
- m.Period = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Period |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryEpochMintProvisionRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryEpochMintProvisionRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryEpochMintProvisionRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryEpochMintProvisionResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryEpochMintProvisionResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryEpochMintProvisionResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EpochMintProvision", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.EpochMintProvision.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QuerySkippedEpochsRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QuerySkippedEpochsRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QuerySkippedEpochsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QuerySkippedEpochsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QuerySkippedEpochsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QuerySkippedEpochsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field SkippedEpochs", wireType)
- }
- m.SkippedEpochs = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.SkippedEpochs |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryCirculatingSupplyRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryCirculatingSupplyRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryCirculatingSupplyRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryCirculatingSupplyResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryCirculatingSupplyResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryCirculatingSupplyResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CirculatingSupply", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.CirculatingSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryInflationRateRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryInflationRateRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryInflationRateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryInflationRateResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryInflationRateResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryInflationRateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field InflationRate", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.InflationRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipQuery(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthQuery
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupQuery
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthQuery
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/inflation/types/query.pb.gw.go b/x/inflation/types/query.pb.gw.go
deleted file mode 100644
index 5d12e647b..000000000
--- a/x/inflation/types/query.pb.gw.go
+++ /dev/null
@@ -1,478 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: nibiru/inflation/v1/query.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-func request_Query_Period_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryPeriodRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.Period(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Period_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryPeriodRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.Period(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_EpochMintProvision_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryEpochMintProvisionRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.EpochMintProvision(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_EpochMintProvision_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryEpochMintProvisionRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.EpochMintProvision(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_SkippedEpochs_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QuerySkippedEpochsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.SkippedEpochs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_SkippedEpochs_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QuerySkippedEpochsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.SkippedEpochs(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_CirculatingSupply_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryCirculatingSupplyRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.CirculatingSupply(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_CirculatingSupply_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryCirculatingSupplyRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.CirculatingSupply(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_InflationRate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryInflationRateRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.InflationRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_InflationRate_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryInflationRateRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.InflationRate(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryParamsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryParamsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.Params(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
-// UnaryRPC :call QueryServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
-func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
-
- mux.Handle("GET", pattern_Query_Period_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Period_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Period_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_EpochMintProvision_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_EpochMintProvision_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EpochMintProvision_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_SkippedEpochs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_SkippedEpochs_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_SkippedEpochs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_CirculatingSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_CirculatingSupply_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_CirculatingSupply_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_InflationRate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_InflationRate_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_InflationRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterQueryHandler(ctx, mux, conn)
-}
-
-// RegisterQueryHandler registers the http handlers for service Query to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
-}
-
-// RegisterQueryHandlerClient registers the http handlers for service Query
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "QueryClient" to call the correct interceptors.
-func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
-
- mux.Handle("GET", pattern_Query_Period_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Period_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Period_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_EpochMintProvision_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_EpochMintProvision_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EpochMintProvision_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_SkippedEpochs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_SkippedEpochs_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_SkippedEpochs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_CirculatingSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_CirculatingSupply_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_CirculatingSupply_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_InflationRate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_InflationRate_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_InflationRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Query_Period_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "inflation", "v1", "period"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_EpochMintProvision_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "inflation", "v1", "epoch_mint_provision"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_SkippedEpochs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "inflation", "v1", "skipped_epochs"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_CirculatingSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "inflation", "v1", "circulating_supply"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_InflationRate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "inflation", "v1", "inflation_rate"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "inflation", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Query_Period_0 = runtime.ForwardResponseMessage
-
- forward_Query_EpochMintProvision_0 = runtime.ForwardResponseMessage
-
- forward_Query_SkippedEpochs_0 = runtime.ForwardResponseMessage
-
- forward_Query_CirculatingSupply_0 = runtime.ForwardResponseMessage
-
- forward_Query_InflationRate_0 = runtime.ForwardResponseMessage
-
- forward_Query_Params_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/inflation/types/tx.pb.go b/x/inflation/types/tx.pb.go
deleted file mode 100644
index ab332dea7..000000000
--- a/x/inflation/types/tx.pb.go
+++ /dev/null
@@ -1,1550 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/inflation/v1/tx.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// MsgToggleInflation defines a message to enable or disable inflation.
-type MsgToggleInflation struct {
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"`
- Enable bool `protobuf:"varint,2,opt,name=enable,proto3" json:"enable,omitempty" yaml:"enable"`
-}
-
-func (m *MsgToggleInflation) Reset() { *m = MsgToggleInflation{} }
-func (m *MsgToggleInflation) String() string { return proto.CompactTextString(m) }
-func (*MsgToggleInflation) ProtoMessage() {}
-func (*MsgToggleInflation) Descriptor() ([]byte, []int) {
- return fileDescriptor_9f6843f876608d76, []int{0}
-}
-func (m *MsgToggleInflation) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgToggleInflation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgToggleInflation.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgToggleInflation) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgToggleInflation.Merge(m, src)
-}
-func (m *MsgToggleInflation) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgToggleInflation) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgToggleInflation.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgToggleInflation proto.InternalMessageInfo
-
-type MsgEditInflationParams struct {
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"`
- InflationEnabled bool `protobuf:"varint,2,opt,name=inflation_enabled,json=inflationEnabled,proto3" json:"inflation_enabled,omitempty"`
- PolynomialFactors []github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,rep,name=polynomial_factors,json=polynomialFactors,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"polynomial_factors,omitempty"`
- InflationDistribution *InflationDistribution `protobuf:"bytes,4,opt,name=inflation_distribution,json=inflationDistribution,proto3" json:"inflation_distribution,omitempty"`
- EpochsPerPeriod *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=epochs_per_period,json=epochsPerPeriod,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"epochs_per_period,omitempty"`
- PeriodsPerYear *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=periods_per_year,json=periodsPerYear,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"periods_per_year,omitempty"`
- MaxPeriod *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=max_period,json=maxPeriod,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_period,omitempty"`
-}
-
-func (m *MsgEditInflationParams) Reset() { *m = MsgEditInflationParams{} }
-func (m *MsgEditInflationParams) String() string { return proto.CompactTextString(m) }
-func (*MsgEditInflationParams) ProtoMessage() {}
-func (*MsgEditInflationParams) Descriptor() ([]byte, []int) {
- return fileDescriptor_9f6843f876608d76, []int{1}
-}
-func (m *MsgEditInflationParams) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgEditInflationParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgEditInflationParams.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgEditInflationParams) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgEditInflationParams.Merge(m, src)
-}
-func (m *MsgEditInflationParams) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgEditInflationParams) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgEditInflationParams.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgEditInflationParams proto.InternalMessageInfo
-
-type MsgToggleInflationResponse struct {
-}
-
-func (m *MsgToggleInflationResponse) Reset() { *m = MsgToggleInflationResponse{} }
-func (m *MsgToggleInflationResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgToggleInflationResponse) ProtoMessage() {}
-func (*MsgToggleInflationResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_9f6843f876608d76, []int{2}
-}
-func (m *MsgToggleInflationResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgToggleInflationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgToggleInflationResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgToggleInflationResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgToggleInflationResponse.Merge(m, src)
-}
-func (m *MsgToggleInflationResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgToggleInflationResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgToggleInflationResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgToggleInflationResponse proto.InternalMessageInfo
-
-type MsgEditInflationParamsResponse struct {
-}
-
-func (m *MsgEditInflationParamsResponse) Reset() { *m = MsgEditInflationParamsResponse{} }
-func (m *MsgEditInflationParamsResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgEditInflationParamsResponse) ProtoMessage() {}
-func (*MsgEditInflationParamsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_9f6843f876608d76, []int{3}
-}
-func (m *MsgEditInflationParamsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgEditInflationParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgEditInflationParamsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgEditInflationParamsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgEditInflationParamsResponse.Merge(m, src)
-}
-func (m *MsgEditInflationParamsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgEditInflationParamsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgEditInflationParamsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgEditInflationParamsResponse proto.InternalMessageInfo
-
-// MsgBurn: allows burning of any token
-type MsgBurn struct {
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"`
- Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin" yaml:"coin"`
-}
-
-func (m *MsgBurn) Reset() { *m = MsgBurn{} }
-func (m *MsgBurn) String() string { return proto.CompactTextString(m) }
-func (*MsgBurn) ProtoMessage() {}
-func (*MsgBurn) Descriptor() ([]byte, []int) {
- return fileDescriptor_9f6843f876608d76, []int{4}
-}
-func (m *MsgBurn) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgBurn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgBurn.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgBurn) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgBurn.Merge(m, src)
-}
-func (m *MsgBurn) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgBurn) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgBurn.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgBurn proto.InternalMessageInfo
-
-func (m *MsgBurn) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-func (m *MsgBurn) GetCoin() types.Coin {
- if m != nil {
- return m.Coin
- }
- return types.Coin{}
-}
-
-type MsgBurnResponse struct {
-}
-
-func (m *MsgBurnResponse) Reset() { *m = MsgBurnResponse{} }
-func (m *MsgBurnResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgBurnResponse) ProtoMessage() {}
-func (*MsgBurnResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_9f6843f876608d76, []int{5}
-}
-func (m *MsgBurnResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgBurnResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgBurnResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgBurnResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgBurnResponse.Merge(m, src)
-}
-func (m *MsgBurnResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgBurnResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgBurnResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgBurnResponse proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*MsgToggleInflation)(nil), "nibiru.inflation.v1.MsgToggleInflation")
- proto.RegisterType((*MsgEditInflationParams)(nil), "nibiru.inflation.v1.MsgEditInflationParams")
- proto.RegisterType((*MsgToggleInflationResponse)(nil), "nibiru.inflation.v1.MsgToggleInflationResponse")
- proto.RegisterType((*MsgEditInflationParamsResponse)(nil), "nibiru.inflation.v1.MsgEditInflationParamsResponse")
- proto.RegisterType((*MsgBurn)(nil), "nibiru.inflation.v1.MsgBurn")
- proto.RegisterType((*MsgBurnResponse)(nil), "nibiru.inflation.v1.MsgBurnResponse")
-}
-
-func init() { proto.RegisterFile("nibiru/inflation/v1/tx.proto", fileDescriptor_9f6843f876608d76) }
-
-var fileDescriptor_9f6843f876608d76 = []byte{
- // 660 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x31, 0x4f, 0xdb, 0x40,
- 0x14, 0x8e, 0x21, 0x0d, 0x70, 0xa8, 0x85, 0x98, 0x16, 0xa5, 0x29, 0xb5, 0x23, 0x23, 0x95, 0x50,
- 0x84, 0x4f, 0x81, 0x8d, 0xd1, 0x40, 0x25, 0x86, 0x54, 0x91, 0xd5, 0xa1, 0x45, 0xaa, 0xd0, 0x39,
- 0x3e, 0xcc, 0xa9, 0xf6, 0x9d, 0x75, 0x77, 0x41, 0xc9, 0xda, 0xa9, 0x23, 0x52, 0xff, 0x00, 0x63,
- 0x7f, 0x40, 0xff, 0x41, 0x17, 0x46, 0xa4, 0x2e, 0x55, 0x87, 0xa8, 0x82, 0x0e, 0x9d, 0xf9, 0x05,
- 0x95, 0x7d, 0x8e, 0x89, 0x8a, 0x91, 0x0a, 0x83, 0x65, 0xdf, 0xbd, 0xef, 0x7d, 0xef, 0x7b, 0xe7,
- 0xef, 0x1d, 0x58, 0xa2, 0xc4, 0x23, 0xbc, 0x07, 0x09, 0x3d, 0x0c, 0x91, 0x24, 0x8c, 0xc2, 0xe3,
- 0x16, 0x94, 0x7d, 0x3b, 0xe6, 0x4c, 0x32, 0x7d, 0x41, 0x45, 0xed, 0x3c, 0x6a, 0x1f, 0xb7, 0xea,
- 0x8f, 0x03, 0x16, 0xb0, 0x34, 0x0e, 0x93, 0x2f, 0x05, 0xad, 0x2f, 0x05, 0x8c, 0x05, 0x21, 0x86,
- 0x28, 0x26, 0x10, 0x51, 0xca, 0x64, 0x8a, 0x17, 0x59, 0x74, 0xb9, 0xa8, 0xcc, 0x35, 0xab, 0x02,
- 0x19, 0x5d, 0x26, 0x22, 0x26, 0xa0, 0x87, 0x04, 0x86, 0xc7, 0x2d, 0x0f, 0x4b, 0xd4, 0x82, 0x5d,
- 0x46, 0xb2, 0xb8, 0x85, 0x80, 0xde, 0x16, 0xc1, 0x1b, 0x16, 0x04, 0x21, 0xde, 0x1b, 0xe5, 0xea,
- 0x8b, 0xa0, 0x22, 0x30, 0xf5, 0x31, 0xaf, 0x69, 0x0d, 0xad, 0x39, 0xe3, 0x66, 0x2b, 0x7d, 0x15,
- 0x54, 0x30, 0x45, 0x5e, 0x88, 0x6b, 0x13, 0x0d, 0xad, 0x39, 0xed, 0x54, 0xaf, 0x86, 0xe6, 0xc3,
- 0x01, 0x8a, 0xc2, 0x2d, 0x4b, 0xed, 0x5b, 0x6e, 0x06, 0xd8, 0x9a, 0xfe, 0x74, 0x6a, 0x96, 0xfe,
- 0x9c, 0x9a, 0x25, 0xeb, 0x6b, 0x19, 0x2c, 0xb6, 0x45, 0xb0, 0xeb, 0x13, 0x99, 0x57, 0xe8, 0x20,
- 0x8e, 0x22, 0x71, 0x6b, 0x9d, 0x35, 0x50, 0xcd, 0x1b, 0x39, 0x50, 0x84, 0xbe, 0x2a, 0xe9, 0xce,
- 0xe7, 0x81, 0x5d, 0xb5, 0xaf, 0xbf, 0x07, 0x7a, 0xcc, 0xc2, 0x01, 0x65, 0x11, 0x41, 0xe1, 0xc1,
- 0x21, 0xea, 0x4a, 0xc6, 0x45, 0x6d, 0xb2, 0x31, 0xd9, 0x9c, 0x71, 0xec, 0xb3, 0xa1, 0xa9, 0xfd,
- 0x1c, 0x9a, 0x2f, 0x02, 0x22, 0x8f, 0x7a, 0x9e, 0xdd, 0x65, 0x11, 0xcc, 0x4e, 0x44, 0xbd, 0xd6,
- 0x85, 0xff, 0x01, 0xca, 0x41, 0x8c, 0x85, 0xbd, 0x83, 0xbb, 0x6e, 0xf5, 0x9a, 0xe9, 0x95, 0x22,
- 0xd2, 0x03, 0xb0, 0x78, 0xad, 0xc5, 0x27, 0x42, 0x72, 0xe2, 0xf5, 0x92, 0x45, 0xad, 0xdc, 0xd0,
- 0x9a, 0xb3, 0x1b, 0x2f, 0xed, 0x82, 0x1f, 0x6a, 0xe7, 0x9d, 0xee, 0x8c, 0x65, 0x38, 0xe5, 0x44,
- 0x8e, 0xfb, 0x84, 0x14, 0x05, 0xf5, 0x7d, 0x50, 0xc5, 0x31, 0xeb, 0x1e, 0x89, 0x83, 0x18, 0xf3,
- 0xe4, 0x21, 0xcc, 0xaf, 0x3d, 0x48, 0xce, 0xe5, 0x4e, 0x6d, 0xec, 0x51, 0xe9, 0xce, 0x29, 0xa2,
- 0x0e, 0xe6, 0x9d, 0x94, 0x46, 0x7f, 0x0b, 0xe6, 0x15, 0xa1, 0x22, 0x1f, 0x60, 0xc4, 0x6b, 0x95,
- 0x7b, 0x51, 0x3f, 0xca, 0x78, 0x3a, 0x98, 0xbf, 0xc3, 0x88, 0xeb, 0x6d, 0x00, 0x22, 0xd4, 0x1f,
- 0xc9, 0x9d, 0xba, 0x17, 0xe7, 0x4c, 0x84, 0xfa, 0x4a, 0xe8, 0x98, 0x6d, 0x96, 0x40, 0xfd, 0xa6,
- 0x33, 0x5d, 0x2c, 0x62, 0x46, 0x05, 0xb6, 0x1a, 0xc0, 0x28, 0xf6, 0x54, 0x8e, 0xe8, 0x83, 0xa9,
- 0xb6, 0x08, 0x9c, 0x1e, 0xa7, 0x89, 0x6d, 0xc7, 0x6d, 0x36, 0x6e, 0x5b, 0xb5, 0x6f, 0xe5, 0xce,
- 0x73, 0x40, 0x39, 0x99, 0x8e, 0xd4, 0x6c, 0xb3, 0x1b, 0x4f, 0x6d, 0xa5, 0xd7, 0x4e, 0xc6, 0xc7,
- 0xce, 0xc6, 0xc7, 0xde, 0x66, 0x84, 0x3a, 0x0b, 0x67, 0x43, 0xb3, 0x74, 0x35, 0x34, 0x67, 0x15,
- 0x4f, 0x92, 0x64, 0xb9, 0x69, 0xae, 0x55, 0x05, 0x73, 0x59, 0xe5, 0x91, 0x98, 0x8d, 0x6f, 0x13,
- 0x60, 0xb2, 0x2d, 0x02, 0xfd, 0x44, 0x03, 0x73, 0xff, 0x0e, 0xdb, 0x4a, 0xa1, 0x81, 0x6e, 0xf6,
- 0x5e, 0x87, 0xff, 0x09, 0xcc, 0x8f, 0x60, 0xf9, 0xe3, 0xf7, 0xdf, 0x9f, 0x27, 0x9e, 0x5b, 0xcf,
- 0x60, 0xe1, 0x8d, 0x94, 0x66, 0xe9, 0x5f, 0x34, 0xb0, 0x50, 0x34, 0x9b, 0x6b, 0xb7, 0x55, 0x2b,
- 0x00, 0xd7, 0x37, 0xef, 0x00, 0xce, 0xe5, 0xc1, 0x54, 0xde, 0xaa, 0xb5, 0x72, 0x53, 0x1e, 0xf6,
- 0x89, 0x5c, 0xcf, 0x97, 0xeb, 0x71, 0x9a, 0xe8, 0xec, 0x9d, 0x5d, 0x18, 0xda, 0xf9, 0x85, 0xa1,
- 0xfd, 0xba, 0x30, 0xb4, 0x93, 0x4b, 0xa3, 0x74, 0x7e, 0x69, 0x94, 0x7e, 0x5c, 0x1a, 0xa5, 0x7d,
- 0x38, 0xe6, 0xb4, 0xd7, 0x29, 0xd9, 0xf6, 0x11, 0x22, 0x74, 0x44, 0xdc, 0x1f, 0xa3, 0x4e, 0x6d,
- 0xe7, 0x55, 0xd2, 0xeb, 0x6f, 0xf3, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4c, 0x43, 0x97, 0xb5,
- 0xac, 0x05, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// MsgClient is the client API for Msg service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type MsgClient interface {
- // ToggleInflation defines a method to enable or disable inflation.
- ToggleInflation(ctx context.Context, in *MsgToggleInflation, opts ...grpc.CallOption) (*MsgToggleInflationResponse, error)
- // EditInflationParams defines a method to edit the inflation params.
- EditInflationParams(ctx context.Context, in *MsgEditInflationParams, opts ...grpc.CallOption) (*MsgEditInflationParamsResponse, error)
-}
-
-type msgClient struct {
- cc grpc1.ClientConn
-}
-
-func NewMsgClient(cc grpc1.ClientConn) MsgClient {
- return &msgClient{cc}
-}
-
-func (c *msgClient) ToggleInflation(ctx context.Context, in *MsgToggleInflation, opts ...grpc.CallOption) (*MsgToggleInflationResponse, error) {
- out := new(MsgToggleInflationResponse)
- err := c.cc.Invoke(ctx, "/nibiru.inflation.v1.Msg/ToggleInflation", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) EditInflationParams(ctx context.Context, in *MsgEditInflationParams, opts ...grpc.CallOption) (*MsgEditInflationParamsResponse, error) {
- out := new(MsgEditInflationParamsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.inflation.v1.Msg/EditInflationParams", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// MsgServer is the server API for Msg service.
-type MsgServer interface {
- // ToggleInflation defines a method to enable or disable inflation.
- ToggleInflation(context.Context, *MsgToggleInflation) (*MsgToggleInflationResponse, error)
- // EditInflationParams defines a method to edit the inflation params.
- EditInflationParams(context.Context, *MsgEditInflationParams) (*MsgEditInflationParamsResponse, error)
-}
-
-// UnimplementedMsgServer can be embedded to have forward compatible implementations.
-type UnimplementedMsgServer struct {
-}
-
-func (*UnimplementedMsgServer) ToggleInflation(ctx context.Context, req *MsgToggleInflation) (*MsgToggleInflationResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ToggleInflation not implemented")
-}
-func (*UnimplementedMsgServer) EditInflationParams(ctx context.Context, req *MsgEditInflationParams) (*MsgEditInflationParamsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EditInflationParams not implemented")
-}
-
-func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
- s.RegisterService(&_Msg_serviceDesc, srv)
-}
-
-func _Msg_ToggleInflation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgToggleInflation)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).ToggleInflation(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.inflation.v1.Msg/ToggleInflation",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).ToggleInflation(ctx, req.(*MsgToggleInflation))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_EditInflationParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgEditInflationParams)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).EditInflationParams(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.inflation.v1.Msg/EditInflationParams",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).EditInflationParams(ctx, req.(*MsgEditInflationParams))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Msg_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.inflation.v1.Msg",
- HandlerType: (*MsgServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "ToggleInflation",
- Handler: _Msg_ToggleInflation_Handler,
- },
- {
- MethodName: "EditInflationParams",
- Handler: _Msg_EditInflationParams_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/inflation/v1/tx.proto",
-}
-
-func (m *MsgToggleInflation) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgToggleInflation) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgToggleInflation) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.Enable {
- i--
- if m.Enable {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x10
- }
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgEditInflationParams) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgEditInflationParams) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgEditInflationParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.MaxPeriod != nil {
- {
- size := m.MaxPeriod.Size()
- i -= size
- if _, err := m.MaxPeriod.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x3a
- }
- if m.PeriodsPerYear != nil {
- {
- size := m.PeriodsPerYear.Size()
- i -= size
- if _, err := m.PeriodsPerYear.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x32
- }
- if m.EpochsPerPeriod != nil {
- {
- size := m.EpochsPerPeriod.Size()
- i -= size
- if _, err := m.EpochsPerPeriod.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x2a
- }
- if m.InflationDistribution != nil {
- {
- size, err := m.InflationDistribution.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x22
- }
- if len(m.PolynomialFactors) > 0 {
- for iNdEx := len(m.PolynomialFactors) - 1; iNdEx >= 0; iNdEx-- {
- {
- size := m.PolynomialFactors[iNdEx].Size()
- i -= size
- if _, err := m.PolynomialFactors[iNdEx].MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- }
- if m.InflationEnabled {
- i--
- if m.InflationEnabled {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x10
- }
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgToggleInflationResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgToggleInflationResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgToggleInflationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgEditInflationParamsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgEditInflationParamsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgEditInflationParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgBurn) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgBurn) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgBurnResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgBurnResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgBurnResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
- offset -= sovTx(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *MsgToggleInflation) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if m.Enable {
- n += 2
- }
- return n
-}
-
-func (m *MsgEditInflationParams) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if m.InflationEnabled {
- n += 2
- }
- if len(m.PolynomialFactors) > 0 {
- for _, e := range m.PolynomialFactors {
- l = e.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- }
- if m.InflationDistribution != nil {
- l = m.InflationDistribution.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.EpochsPerPeriod != nil {
- l = m.EpochsPerPeriod.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.PeriodsPerYear != nil {
- l = m.PeriodsPerYear.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.MaxPeriod != nil {
- l = m.MaxPeriod.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgToggleInflationResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgEditInflationParamsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgBurn) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = m.Coin.Size()
- n += 1 + l + sovTx(uint64(l))
- return n
-}
-
-func (m *MsgBurnResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func sovTx(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozTx(x uint64) (n int) {
- return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *MsgToggleInflation) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgToggleInflation: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgToggleInflation: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Enable", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Enable = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgEditInflationParams) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgEditInflationParams: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgEditInflationParams: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field InflationEnabled", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.InflationEnabled = bool(v != 0)
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PolynomialFactors", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Dec
- m.PolynomialFactors = append(m.PolynomialFactors, v)
- if err := m.PolynomialFactors[len(m.PolynomialFactors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field InflationDistribution", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.InflationDistribution == nil {
- m.InflationDistribution = &InflationDistribution{}
- }
- if err := m.InflationDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field EpochsPerPeriod", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Int
- m.EpochsPerPeriod = &v
- if err := m.EpochsPerPeriod.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PeriodsPerYear", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Int
- m.PeriodsPerYear = &v
- if err := m.PeriodsPerYear.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field MaxPeriod", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Int
- m.MaxPeriod = &v
- if err := m.MaxPeriod.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgToggleInflationResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgToggleInflationResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgToggleInflationResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgEditInflationParamsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgEditInflationParamsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgEditInflationParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgBurn) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgBurn: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgBurn: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgBurnResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgBurnResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgBurnResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipTx(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthTx
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupTx
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthTx
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowTx = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/inflation/types/tx.pb.gw.go b/x/inflation/types/tx.pb.gw.go
deleted file mode 100644
index 0d122966c..000000000
--- a/x/inflation/types/tx.pb.gw.go
+++ /dev/null
@@ -1,254 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: nibiru/inflation/v1/tx.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-var (
- filter_Msg_ToggleInflation_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_ToggleInflation_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgToggleInflation
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_ToggleInflation_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.ToggleInflation(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_ToggleInflation_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgToggleInflation
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_ToggleInflation_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.ToggleInflation(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Msg_EditInflationParams_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_EditInflationParams_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgEditInflationParams
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_EditInflationParams_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.EditInflationParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_EditInflationParams_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgEditInflationParams
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_EditInflationParams_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.EditInflationParams(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux".
-// UnaryRPC :call MsgServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead.
-func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error {
-
- mux.Handle("POST", pattern_Msg_ToggleInflation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_ToggleInflation_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_ToggleInflation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_EditInflationParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_EditInflationParams_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_EditInflationParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterMsgHandler(ctx, mux, conn)
-}
-
-// RegisterMsgHandler registers the http handlers for service Msg to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn))
-}
-
-// RegisterMsgHandlerClient registers the http handlers for service Msg
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "MsgClient" to call the correct interceptors.
-func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error {
-
- mux.Handle("POST", pattern_Msg_ToggleInflation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_ToggleInflation_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_ToggleInflation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_EditInflationParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_EditInflationParams_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_EditInflationParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Msg_ToggleInflation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "inflation", "v1", "toggle"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Msg_EditInflationParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "inflation", "edit-inflation-params"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Msg_ToggleInflation_0 = runtime.ForwardResponseMessage
-
- forward_Msg_EditInflationParams_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/oracle/README.md b/x/oracle/README.md
deleted file mode 100644
index b92898cd1..000000000
--- a/x/oracle/README.md
+++ /dev/null
@@ -1,330 +0,0 @@
-# Oracle
-
-The Oracle module provides the Nibiru blockchain with an up-to-date and accurate price feed of exchange rates of trading pairs.
-
-As price information is extrinsic to the blockchain, the Nibiru network relies on validators to periodically vote on the current exchange rates, with the protocol tallying up the results once per `VotePeriod` and updating the on-chain exchange rate as the weighted median of the ballot.
-
-> Since the Oracle service is powered by validators, you may find it interesting to look at the [Staking](https://github.com/cosmos/cosmos-sdk/tree/master/x/staking/spec/README.md) module, which covers the logic for staking and validators.
-
-## Contents
-- [Oracle](#oracle)
- - [Concepts](#concepts)
- - [Voting Procedure](#voting-procedure)
- - [Reward Band](#reward-band)
- - [Slashing](#slashing)
- - [Abstaining from Voting](#abstaining-from-voting)
- - [Messages](#messages)
- - [Module Parameters](#module-parameters)
- - [State](#state)
- - [ExchangeRate](#exchangerate)
- - [FeederDelegation](#feederdelegation)
- - [MissCounter](#misscounter)
- - [AggregateExchangeRatePrevote](#aggregateexchangerateprevote)
- - [AggregateExchangeRateVote](#aggregateexchangeratevote)
- - [End Block](#end-block)
- - [Tally Exchange Rate Votes](#tally-exchange-rate-votes)
- - [Messages](#messages-1)
- - [MsgAggregateExchangeRatePrevote](#msgaggregateexchangerateprevote)
- - [MsgAggregateExchangeRateVote](#msgaggregateexchangeratevote)
- - [MsgDelegateFeedConsent](#msgdelegatefeedconsent)
- - [Events](#events)
- - [EndBlocker](#endblocker)
- - [Events for MsgExchangeRatePrevote](#events-for-msgexchangerateprevote)
- - [Events for MsgExchangeRateVote](#events-for-msgexchangeratevote)
- - [Events for MsgDelegateFeedConsent](#events-for-msgdelegatefeedconsent)
- - [Events for MsgAggregateExchangeRatePrevote](#events-for-msgaggregateexchangerateprevote)
- - [Events for MsgAggregateExchangeRateVote](#events-for-msgaggregateexchangeratevote)
-
----
-
-## Concepts
-
-See [docs.nibiru.fi/ecosystem/oracle](https://docs.nibiru.fi/ecosystem/oracle/).
-
-### Voting Procedure
-
-During each `VotePeriod`, the Oracle module obtains consensus on the exchange rate of pairs specified in `Whitelist` by requiring all members of the validator set to submit a vote for exchange rates before the end of the interval.
-
-Validators must first pre-commit to a exchange rate, then in the subsequent `VotePeriod` submit and reveal their exchange rate alongside a proof that they had pre-commited at that price. This scheme forces the voter to commit to a submission before knowing the votes of others and thereby reduces centralization and free-rider risk in the Oracle.
-
-* Prevote and Vote
-
- Let `P_t` be the current time interval of duration defined by `VotePeriod` (currently set to 30 seconds) during which validators must submit two messages:
-
- * A `MsgAggregateExchangeRatePrevote`, containing the SHA256 hash of the exchange rates of pairs. A prevote must be submitted for all pairs.
- * A `MsgAggregateExchangeRateVote`, containing the salt used to create the hash for the aggregate prevote submitted in the previous interval `P_t-1`.
-
-* Vote Tally
-
- At the end of `P_t`, the submitted votes are tallied.
-
- The submitted salt of each vote is used to verify consistency with the prevote submitted by the validator in `P_t-1`. If the validator has not submitted a prevote, or the SHA256 resulting from the salt does not match the hash from the prevote, the vote is dropped.
-
- For each pair, if the total voting power of submitted votes exceeds 50%, the weighted median of the votes is recorded on-chain as the effective exchange rate for the following `VotePeriod` `P_t+1`.
-
- Exchange rates receiving fewer than `VoteThreshold` total voting power have their exchange rates deleted from the store, and no exchange rate will exist for the next VotePeriod `P_t+1`.
-
-* Ballot Rewards
-
- After the votes are tallied, the winners of the ballots are determined with `tally()`.
-
- Voters that have managed to vote within a narrow band around the weighted median, are rewarded with a portion of the collected seigniorage. See `k.RewardBallotWinners()` for more details.
-
-### Reward Band
-
-Let `M` be the weighted median, `𝜎` be the standard deviation of the votes in the ballot, and be the RewardBand parameter. The band around the median is set to be `𝜀 = max(𝜎, R/2)`. All valid (i.e. bonded and non-jailed) validators that submitted an exchange rate vote in the interval `[M - 𝜀, M + 𝜀]` should be included in the set of winners, weighted by their relative vote power.
-
-### Slashing
-
-> Be sure to read this section carefully as it concerns potential loss of funds.
-
-A `VotePeriod` during which either of the following events occur is considered a "miss":
-
-* The validator fails to submits a vote for an exchange rate against **each and every** pair specified in `Whitelist`.
-
-* The validator fails to vote within the `reward band` around the weighted median for one or more pairs.
-
-During every `SlashWindow`, participating validators must maintain a valid vote rate of at least `MinValidPerWindow` (5%), lest they get their stake slashed (currently set to 0.01%). The slashed validator is automatically temporarily "jailed" by the protocol (to protect the funds of delegators), and the operator is expected to fix the discrepancy promptly to resume validator participation.
-
-### Abstaining from Voting
-
-A validator may abstain from voting by submitting a non-positive integer for the `ExchangeRate` field in `MsgAggregateExchangeRateVote`. Doing so will absolve them of any penalties for missing `VotePeriod`s, but also disqualify them from receiving Oracle seigniorage rewards for faithful reporting.
-
-### Messages
-
-> The control flow for vote-tallying, exchange rate updates, ballot rewards and slashing happens at the end of every `VotePeriod`, and is found at the [end-block ABCI](#end-block) function rather than inside message handlers.
-
----
-
-## Module Parameters
-
-The oracle module contains the following parameters:
-
-| Module Param (type) | Description |
-| ------------------------- | ----------- |
-| `VotePeriod` (uint64) | Defines the number of blocks during which voting takes place. Ex. "5". |
-| `VoteThreshold` (Dec) | VoteThreshold specifies the minimum proportion of votes that must be received for a ballot to pass. Ex. "0.5" |
-| `RewardBand` (Dec) | Defines a maxium divergence that a price vote can have from the weighted median in the ballot. If a vote lies within the valid range defined by: `μ := weightedMedian`, `validRange := μ ± (μ * rewardBand / 2)`, then rewards are added to the validator performance. Note that if the reward band is smaller than 1 standard deviation, the band is taken to be 1 standard deviation.a price. Ex. "0.02" |
-| `Whitelist` (set[String]) | The set of whitelisted markets, or asset pairs, for the module. Ex. '["unibi:uusd","ubtc:uusd"]' |
-| `SlashFraction` (Dec) | The proportion of an oracle's stake that gets slashed in the event of slashing. `SlashFraction` specifies the exact penalty for failing a voting period. |
-| `SlashWindow` (uint64) | The number of voting periods that specify a "slash window". After each slash window, all oracles that have missed more than the penalty threshold are slashed. Missing the penalty threshold is synonymous with submitting fewer valid votes than `MinValidPerWindow`. |
-| `MinValidPerWindow` (Dec) | The oracle slashing threshold. Ex. "0.05". |
-| `TwapLookbackWindow` (Duration) | Lookback window for time-weighted average price (TWAP) calculations.
-
----
-
-## State
-
-### ExchangeRate
-
-An `sdk.Dec` that stores the current exchange rate against a given pair.
-
-You can get the active list of pairs (exchange rates with votes past `VoteThreshold`) with `k.GetActivePairs()`.
-
-- ExchangeRate: `0x03 -> amino(sdk.Dec)`
-
-### FeederDelegation
-
-An `sdk.AccAddress` (`nibi-` account) address of `operator`'s delegated price feeder.
-
-- FeederDelegation: `0x04 -> amino(sdk.AccAddress)`
-
-### MissCounter
-
-An `int64` representing the number of `VotePeriods` that validator `operator` missed during the current `SlashWindow`.
-
-- MissCounter: `0x05 -> amino(int64)`
-
-### AggregateExchangeRatePrevote
-
-`AggregateExchangeRatePrevote` containing validator voter's aggregated prevote for all pairs for the current `VotePeriod`.
-
-- AggregateExchangeRatePrevote: `0x06 -> amino(AggregateExchangeRatePrevote)`
-
-```go
-// AggregateVoteHash is hash value to hide vote exchange rates
-// which is formatted as hex string in SHA256("{salt}:({pair},{exchange_rate})|...|({pair},{exchange_rate}):{voter}")
-type AggregateVoteHash []byte
-
-type AggregateExchangeRatePrevote struct {
- Hash AggregateVoteHash // Vote hex hash to protect centralize data source problem
- Voter sdk.ValAddress // Voter val address
- SubmitBlock int64
-}
-```
-
-### AggregateExchangeRateVote
-
-`AggregateExchangeRateVote` containing validator voter's aggregate vote for all pairs for the current `VotePeriod`.
-
-- AggregateExchangeRateVote: `0x07 -> amino(AggregateExchangeRateVote)`
-
-```go
-type ExchangeRateTuple struct {
- Pair string `json:"pair"`
- ExchangeRate sdk.Dec `json:"exchange_rate"`
-}
-
-type ExchangeRateTuples []ExchangeRateTuple
-
-type AggregateExchangeRateVote struct {
- ExchangeRateTuples ExchangeRateTuples // ExchangeRates of pairs
- Voter sdk.ValAddress // voter val address of validator
-}
-```
-
----
-
-## End Block
-
-### Tally Exchange Rate Votes
-
-At the end of every block, the `Oracle` module checks whether it's the last block of the `VotePeriod`. If it is, it runs the [Voting Procedure](#Voting_Procedure):
-
-1. All current active exchange rates are purged from the store
-
-2. Received votes are organized into ballots by pair. Abstained votes, as well as votes by inactive or jailed validators are ignored
-
-3. Pairs not meeting the following requirements will be dropped:
-
- - Must appear in the permitted pairs in `Whitelist`
- - Ballot for pair must have at least `VoteThreshold` total vote power
-
-4. For each remaining `pair` with a passing ballot:
-
- - Tally up votes and find the weighted median exchange rate and winners with `tally()`
- - Iterate through winners of the ballot and add their weight to their running total
- - Set the exchange rate on the blockchain for that pair with `k.SetExchangeRate()`
- - Emit an `exchange_rate_update` event
-
-5. Count up the validators who [missed](#Slashing) the Oracle vote and increase the appropriate miss counters
-
-6. If at the end of a `SlashWindow`, penalize validators who have missed more than the penalty threshold (submitted fewer valid votes than `MinValidPerWindow`)
-
-7. Distribute rewards to ballot winners with `k.RewardBallotWinners()`
-
-8. Clear all prevotes (except ones for the next `VotePeriod`) and votes from the store
-
----
-
-## Messages
-
-### MsgAggregateExchangeRatePrevote
-
-`Hash` is a hex string generated by the leading 20 bytes of the SHA256 hash (hex string) of a string of the format `{salt}:({pair},{exchange_rate})|...|({pair},{exchange_rate}):{voter}`, the metadata of the actual `MsgAggregateExchangeRateVote` to follow in the next `VotePeriod`. You can use the `GetAggregateVoteHash()` function to help encode this hash. Note that since in the subsequent `MsgAggregateExchangeRateVote`, the salt will have to be revealed, the salt used must be regenerated for each prevote submission.
-
-```go
-// MsgAggregateExchangeRatePrevote - struct for aggregate prevoting on the ExchangeRateVote.
-// The purpose of aggregate prevote is to hide vote exchange rates with hash
-// which is formatted as hex string in SHA256("{salt}:({pair},{exchange_rate})|...|({pair},{exchange_rate}):{voter}")
-type MsgAggregateExchangeRatePrevote struct {
- Hash AggregateVoteHash
- Feeder sdk.AccAddress
- Validator sdk.ValAddress
-}
-```
-
-`Feeder` (`nibi-` address) is used if the validator wishes to delegate oracle vote signing to a separate key (who "feeds" the price in lieu of the operator) to de-risk exposing their validator signing key.
-
-`Validator` is the validator address (`nibivaloper-` address) of the original validator.
-
-### MsgAggregateExchangeRateVote
-
-The `MsgAggregateExchangeRateVote` contains the actual exchange rates vote. The `Salt` parameter must match the salt used to create the prevote, otherwise the voter cannot be rewarded.
-
-```go
-// MsgAggregateExchangeRateVote - struct for voting on the exchange rates of pairs.
-type MsgAggregateExchangeRateVote struct {
- Salt string
- ExchangeRates string
- Feeder sdk.AccAddress
- Validator sdk.ValAddress
-}
-```
-
-### MsgDelegateFeedConsent
-
-Validators may also elect to delegate voting rights to another key to prevent the block signing key from being kept online. To do so, they must submit a `MsgDelegateFeedConsent`, delegating their oracle voting rights to a `Delegate` that sign `MsgAggregateExchangeRatePrevote` and `MsgAggregateExchangeRateVote` on behalf of the validator.
-
-> Delegate validators will likely require you to deposit some funds (in NIBI) which they can use to pay fees, sent in a separate MsgSend. This agreement is made off-chain and not enforced by the Nibiru protocol.
-
-The `Operator` field contains the operator address of the validator (prefixed `nibivaloper-`). The `Delegate` field is the account address (prefixed `nibi-`) of the delegate account that will be submitting exchange rate related votes and prevotes on behalf of the `Operator`.
-
-```go
-// MsgDelegateFeedConsent - struct for delegating oracle voting rights to another address.
-type MsgDelegateFeedConsent struct {
- Operator sdk.ValAddress
- Delegate sdk.AccAddress
-}
-```
-
----
-
-## Events
-
-The oracle module emits the following events:
-
-### EndBlocker
-
-| Type | Attribute Key | Attribute Value |
-|----------------------|---------------|-----------------|
-| exchange_rate_update | pair | {pair} |
-| exchange_rate_update | exchange_rate | {exchangeRate} |
-
-
-### Events for MsgExchangeRatePrevote
-
-| Type | Attribute Key | Attribute Value |
-|---------|---------------|---------------------|
-| prevote | pair | {pair} |
-| prevote | voter | {validatorAddress} |
-| prevote | feeder | {feederAddress} |
-| message | module | oracle |
-| message | action | exchangerateprevote |
-| message | sender | {senderAddress} |
-
-### Events for MsgExchangeRateVote
-
-| Type | Attribute Key | Attribute Value |
-|---------|---------------|--------------------|
-| vote | pair | {pair} |
-| vote | voter | {validatorAddress} |
-| vote | exchange_rate | {exchangeRate} |
-| vote | feeder | {feederAddress} |
-| message | module | oracle |
-| message | action | exchangeratevote |
-| message | sender | {senderAddress} |
-
-### Events for MsgDelegateFeedConsent
-
-
-| Type | Attribute Key | Attribute Value |
-|---------------|---------------|--------------------|
-| feed_delegate | operator | {validatorAddress} |
-| feed_delegate | feeder | {feederAddress} |
-| message | module | oracle |
-| message | action | delegatefeeder |
-| message | sender | {senderAddress} |
-
-### Events for MsgAggregateExchangeRatePrevote
-
-| Type | Attribute Key | Attribute Value |
-|-------------------|---------------|------------------------------|
-| aggregate_prevote | voter | {validatorAddress} |
-| aggregate_prevote | feeder | {feederAddress} |
-| message | module | oracle |
-| message | action | aggregateexchangerateprevote |
-| message | sender | {senderAddress} |
-
-### Events for MsgAggregateExchangeRateVote
-
-| Type | Attribute Key | Attribute Value |
-|----------------|----------------|---------------------------|
-| aggregate_vote | voter | {validatorAddress} |
-| aggregate_vote | exchange_rates | {exchangeRates} |
-| aggregate_vote | feeder | {feederAddress} |
-| message | module | oracle |
-| message | action | aggregateexchangeratevote |
-| message | sender | {senderAddress} |
-
----
diff --git a/x/oracle/abci.go b/x/oracle/abci.go
deleted file mode 100644
index be80ea9ac..000000000
--- a/x/oracle/abci.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package oracle
-
-import (
- "time"
-
- "github.com/NibiruChain/nibiru/x/oracle/keeper"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-
- "github.com/cosmos/cosmos-sdk/telemetry"
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// EndBlocker is called at the end of every block
-func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
- defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
-
- params, err := k.Params.Get(ctx)
- if err != nil {
- return
- }
- if types.IsPeriodLastBlock(ctx, params.VotePeriod) {
- k.UpdateExchangeRates(ctx)
- }
-
- // Do slash who did miss voting over threshold and
- // reset miss counters of all validators at the last block of slash window
- if types.IsPeriodLastBlock(ctx, params.SlashWindow) {
- k.SlashAndResetMissCounters(ctx)
- }
-}
diff --git a/x/oracle/abci_test.go b/x/oracle/abci_test.go
deleted file mode 100644
index bb6077c21..000000000
--- a/x/oracle/abci_test.go
+++ /dev/null
@@ -1,96 +0,0 @@
-package oracle
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/oracle/keeper"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestOracleTallyTiming(t *testing.T) {
- input, h := keeper.Setup(t)
-
- // all the Addrs vote for the block ... not last period block yet, so tally fails
- for i := range keeper.Addrs[:4] {
- keeper.MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.BTC, denoms.USD), ExchangeRate: math.LegacyOneDec()},
- }, i)
- }
-
- params, err := input.OracleKeeper.Params.Get(input.Ctx)
- require.NoError(t, err)
-
- params.VotePeriod = 10 // set vote period to 10 for now, for convenience
- params.ExpirationBlocks = 100
- input.OracleKeeper.Params.Set(input.Ctx, params)
- require.Equal(t, 1, int(input.Ctx.BlockHeight()))
-
- EndBlocker(input.Ctx, input.OracleKeeper)
- _, err = input.OracleKeeper.ExchangeRates.Get(input.Ctx, asset.Registry.Pair(denoms.BTC, denoms.USD))
- require.Error(t, err)
-
- input.Ctx = input.Ctx.WithBlockHeight(int64(params.VotePeriod - 1))
-
- EndBlocker(input.Ctx, input.OracleKeeper)
- _, err = input.OracleKeeper.ExchangeRates.Get(input.Ctx, asset.Registry.Pair(denoms.BTC, denoms.USD))
- require.NoError(t, err)
-}
-
-// Set prices for 2 pairs, one that is updated and the other which is updated only once.
-// Ensure that the updated pair is not deleted and the other pair is deleted after a certain time.
-func TestOraclePriceExpiration(t *testing.T) {
- input, h := keeper.Setup(t)
- pair1 := asset.Registry.Pair(denoms.BTC, denoms.USD)
- pair2 := asset.Registry.Pair(denoms.ETH, denoms.USD)
-
- // Set prices for both pairs
- for i := range keeper.Addrs[:4] {
- keeper.MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: pair1, ExchangeRate: math.LegacyOneDec()},
- {Pair: pair2, ExchangeRate: math.LegacyOneDec()},
- }, i)
- }
-
- params, err := input.OracleKeeper.Params.Get(input.Ctx)
- require.NoError(t, err)
-
- params.VotePeriod = 10
- params.ExpirationBlocks = 10
- input.OracleKeeper.Params.Set(input.Ctx, params)
-
- // Wait for prices to set
- input.Ctx = input.Ctx.WithBlockHeight(int64(params.VotePeriod - 1))
- EndBlocker(input.Ctx, input.OracleKeeper)
-
- // Check if both prices are set
- _, err = input.OracleKeeper.ExchangeRates.Get(input.Ctx, pair1)
- require.NoError(t, err)
- _, err = input.OracleKeeper.ExchangeRates.Get(input.Ctx, pair2)
- require.NoError(t, err)
-
- // Set prices for pair 1
- for i := range keeper.Addrs[:4] {
- keeper.MakeAggregatePrevoteAndVote(t, input, h, 19, types.ExchangeRateTuples{
- {Pair: pair1, ExchangeRate: math.LegacyNewDec(2)},
- }, i)
- }
-
- // Set price
- input.Ctx = input.Ctx.WithBlockHeight(19)
- EndBlocker(input.Ctx, input.OracleKeeper)
-
- // Set the block height to 1 block after the expiration
- // End blocker should delete the price of pair2
- input.Ctx = input.Ctx.WithBlockHeight(int64(params.ExpirationBlocks+params.VotePeriod) + 1)
- EndBlocker(input.Ctx, input.OracleKeeper)
-
- _, err = input.OracleKeeper.ExchangeRates.Get(input.Ctx, pair1)
- require.NoError(t, err)
- _, err = input.OracleKeeper.ExchangeRates.Get(input.Ctx, pair2)
- require.Error(t, err)
-}
diff --git a/x/oracle/client/cli/gen_pricefeeder_delegation.go b/x/oracle/client/cli/gen_pricefeeder_delegation.go
deleted file mode 100644
index 1dd5d599d..000000000
--- a/x/oracle/client/cli/gen_pricefeeder_delegation.go
+++ /dev/null
@@ -1,99 +0,0 @@
-package cli
-
-import (
- "encoding/json"
- "fmt"
-
- flag "github.com/spf13/pflag"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/server"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/x/genutil"
- genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-const (
- FlagValidator = "validator"
- FlagPricefeeder = "pricefeeder"
-)
-
-func AddGenesisPricefeederDelegationCmd(defaultNodeHome string) *cobra.Command {
- cmd := &cobra.Command{
- Use: "add-genesis-pricefeeder-delegation",
- Short: "Add a pricefeeder delegation to genesis.json.",
- Long: `Add a pricefeeder delegation to genesis.json.`,
- Args: cobra.ExactArgs(0),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx := client.GetClientContextFromCmd(cmd)
- serverCtx := server.GetServerContextFromCmd(cmd)
- config := serverCtx.Config
- config.SetRoot(clientCtx.HomeDir)
- genFile := config.GenesisFile()
-
- genState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
- if err != nil {
- return err
- }
-
- valAddr, err := cmd.Flags().GetString(FlagValidator)
- if err != nil {
- return err
- }
-
- _, err = sdk.ValAddressFromBech32(valAddr)
- if err != nil {
- return err
- }
-
- pricefeederAddr, err := cmd.Flags().GetString(FlagPricefeeder)
- if err != nil {
- return err
- }
-
- _, err = sdk.AccAddressFromBech32(pricefeederAddr)
- if err != nil {
- return err
- }
-
- oracleGenState := types.GetGenesisStateFromAppState(clientCtx.Codec, genState)
- oracleGenState.FeederDelegations = append(oracleGenState.FeederDelegations, types.FeederDelegation{
- FeederAddress: pricefeederAddr,
- ValidatorAddress: valAddr,
- })
-
- oracleGenStateBz, err := clientCtx.Codec.MarshalJSON(oracleGenState)
- if err != nil {
- return fmt.Errorf("failed to marshal market genesis state: %w", err)
- }
-
- genState[types.ModuleName] = oracleGenStateBz
-
- appStateJSON, err := json.Marshal(genState)
- if err != nil {
- return fmt.Errorf("failed to marshal application genesis state: %w", err)
- }
-
- genDoc.AppState = appStateJSON
- return genutil.ExportGenesisFile(genDoc, genFile)
- },
- }
-
- cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
-
- flagSet := flag.NewFlagSet("flags-add-genesis-pricefeeder-delegation", flag.ContinueOnError)
-
- flagSet.String(FlagValidator, "", "validator address")
- _ = cmd.MarkFlagRequired(FlagValidator)
-
- flagSet.String(FlagPricefeeder, "", "pricefeeder address")
- _ = cmd.MarkFlagRequired(FlagPricefeeder)
-
- cmd.Flags().AddFlagSet(flagSet)
-
- return cmd
-}
diff --git a/x/oracle/client/cli/gen_pricefeeder_delegation_test.go b/x/oracle/client/cli/gen_pricefeeder_delegation_test.go
deleted file mode 100644
index 04dbb081b..000000000
--- a/x/oracle/client/cli/gen_pricefeeder_delegation_test.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package cli_test
-
-import (
- "fmt"
- "testing"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/app/appconst"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/oracle/client/cli"
-
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/stretchr/testify/require"
-)
-
-func TestAddGenesisPricefeederDelegation(t *testing.T) {
- app.SetPrefixes(appconst.AccountAddressPrefix)
-
- tests := []struct {
- name string
- validator string
- pricefeeder string
-
- expectErr bool
- }{
- {
- name: "valid",
- validator: "nibivaloper1zaavvzxez0elundtn32qnk9lkm8kmcszuwx9jz",
- pricefeeder: "nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl",
- expectErr: false,
- },
- {
- name: "invalid pricefeeder",
- validator: "nibivaloper1zaavvzxez0elundtn32qnk9lkm8kmcszuwx9jz",
- pricefeeder: "nibi1foobar",
- expectErr: true,
- },
- {
- name: "empty pricefeeder",
- validator: "nibivaloper1zaavvzxez0elundtn32qnk9lkm8kmcszuwx9jz",
- pricefeeder: "",
- expectErr: true,
- },
- {
- name: "invalid validator",
- validator: "nibivaloper1foobar",
- pricefeeder: "nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl",
- expectErr: true,
- },
- {
- name: "empty validator",
- validator: "",
- pricefeeder: "nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl",
- expectErr: true,
- },
- }
-
- for _, tc := range tests {
- tc := tc
- t.Run(tc.name, func(t *testing.T) {
- ctx := testutil.SetupClientCtx(t)
- cmd := cli.AddGenesisPricefeederDelegationCmd(t.TempDir())
- cmd.SetArgs([]string{
- fmt.Sprintf("--%s=%s", cli.FlagValidator, tc.validator),
- fmt.Sprintf("--%s=%s", cli.FlagPricefeeder, tc.pricefeeder),
- fmt.Sprintf("--%s=home", flags.FlagHome),
- })
-
- if tc.expectErr {
- require.Error(t, cmd.ExecuteContext(ctx))
- } else {
- require.NoError(t, cmd.ExecuteContext(ctx))
- }
- })
- }
-}
diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go
deleted file mode 100644
index e41200c39..000000000
--- a/x/oracle/client/cli/query.go
+++ /dev/null
@@ -1,370 +0,0 @@
-package cli
-
-import (
- "context"
- "strings"
-
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// GetQueryCmd returns the cli query commands for this module
-func GetQueryCmd() *cobra.Command {
- oracleQueryCmd := &cobra.Command{
- Use: types.ModuleName,
- Short: "Querying commands for the oracle module",
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- oracleQueryCmd.AddCommand(
- GetCmdQueryExchangeRates(),
- GetCmdQueryActives(),
- GetCmdQueryParams(),
- GetCmdQueryFeederDelegation(),
- GetCmdQueryMissCounter(),
- GetCmdQueryAggregatePrevote(),
- GetCmdQueryAggregateVote(),
- GetCmdQueryVoteTargets(),
- )
-
- return oracleQueryCmd
-}
-
-// GetCmdQueryExchangeRates implements the query rate command.
-func GetCmdQueryExchangeRates() *cobra.Command {
- cmd := &cobra.Command{
- Use: "exchange-rates [pair]",
- Args: cobra.RangeArgs(0, 1),
- Short: "Query the current exchange rate w.r.t a pair",
- Long: strings.TrimSpace(`
-Query the current exchange rate of a pair.
-You can find the current list of active pairs by running
-
-$ nibid query oracle exchange-rates
-
-Or, can filter with pair
-
-$ nibid query oracle exchange-rates nibi:usd
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- if len(args) == 0 {
- res, err := queryClient.ExchangeRates(context.Background(), &types.QueryExchangeRatesRequest{})
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- }
-
- assetPair, err := asset.TryNewPair(args[0])
- if err != nil {
- return err
- }
-
- res, err := queryClient.ExchangeRate(
- context.Background(),
- &types.QueryExchangeRateRequest{Pair: assetPair},
- )
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
- return cmd
-}
-
-// GetCmdQueryActives implements the query actives command.
-func GetCmdQueryActives() *cobra.Command {
- cmd := &cobra.Command{
- Use: "actives",
- Args: cobra.NoArgs,
- Short: "Query the active list of pairs recognized by the oracle",
- Long: strings.TrimSpace(`
-Query the active list of pairs recognized by the oracles.
-
-$ nibid query oracle actives
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- res, err := queryClient.Actives(context.Background(), &types.QueryActivesRequest{})
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
- return cmd
-}
-
-// GetCmdQueryParams implements the query params command.
-func GetCmdQueryParams() *cobra.Command {
- cmd := &cobra.Command{
- Use: "params",
- Args: cobra.NoArgs,
- Short: "Query the current Oracle params",
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
- return cmd
-}
-
-// GetCmdQueryFeederDelegation implements the query feeder delegation command
-func GetCmdQueryFeederDelegation() *cobra.Command {
- cmd := &cobra.Command{
- Use: "feeder [validator]",
- Args: cobra.ExactArgs(1),
- Short: "Query the oracle feeder delegate account",
- Long: strings.TrimSpace(`
-Query the account the validator's oracle voting right is delegated to.
-
-$ nibid query oracle feeder nibivaloper...
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- valString := args[0]
- validator, err := sdk.ValAddressFromBech32(valString)
- if err != nil {
- return err
- }
-
- res, err := queryClient.FeederDelegation(
- context.Background(),
- &types.QueryFeederDelegationRequest{ValidatorAddr: validator.String()},
- )
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
- return cmd
-}
-
-// GetCmdQueryMissCounter implements the query miss counter of the validator command
-func GetCmdQueryMissCounter() *cobra.Command {
- cmd := &cobra.Command{
- Use: "miss [validator]",
- Args: cobra.ExactArgs(1),
- Short: "Query the # of the miss count",
- Long: strings.TrimSpace(`
-Query the # of vote periods missed in this oracle slash window.
-
-$ nibid query oracle miss nibivaloper...
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- valString := args[0]
- validator, err := sdk.ValAddressFromBech32(valString)
- if err != nil {
- return err
- }
-
- res, err := queryClient.MissCounter(
- context.Background(),
- &types.QueryMissCounterRequest{ValidatorAddr: validator.String()},
- )
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
- return cmd
-}
-
-// GetCmdQueryAggregatePrevote implements the query aggregate prevote of the validator command
-func GetCmdQueryAggregatePrevote() *cobra.Command {
- cmd := &cobra.Command{
- Use: "aggregate-prevotes [validator]",
- Args: cobra.RangeArgs(0, 1),
- Short: "Query outstanding oracle aggregate prevotes.",
- Long: strings.TrimSpace(`
-Query outstanding oracle aggregate prevotes.
-
-$ nibid query oracle aggregate-prevotes
-
-Or, can filter with voter address
-
-$ nibid query oracle aggregate-prevotes nibivaloper...
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- if len(args) == 0 {
- res, err := queryClient.AggregatePrevotes(
- context.Background(),
- &types.QueryAggregatePrevotesRequest{},
- )
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- }
-
- valString := args[0]
- validator, err := sdk.ValAddressFromBech32(valString)
- if err != nil {
- return err
- }
-
- res, err := queryClient.AggregatePrevote(
- context.Background(),
- &types.QueryAggregatePrevoteRequest{ValidatorAddr: validator.String()},
- )
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
- return cmd
-}
-
-// GetCmdQueryAggregateVote implements the query aggregate prevote of the validator command
-func GetCmdQueryAggregateVote() *cobra.Command {
- cmd := &cobra.Command{
- Use: "aggregate-votes [validator]",
- Args: cobra.RangeArgs(0, 1),
- Short: "Query outstanding oracle aggregate votes.",
- Long: strings.TrimSpace(`
-Query outstanding oracle aggregate vote.
-
-$ nibid query oracle aggregate-votes
-
-Or, can filter with voter address
-
-$ nibid query oracle aggregate-votes nibivaloper...
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- if len(args) == 0 {
- res, err := queryClient.AggregateVotes(
- context.Background(),
- &types.QueryAggregateVotesRequest{},
- )
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- }
-
- valString := args[0]
- validator, err := sdk.ValAddressFromBech32(valString)
- if err != nil {
- return err
- }
-
- res, err := queryClient.AggregateVote(
- context.Background(),
- &types.QueryAggregateVoteRequest{ValidatorAddr: validator.String()},
- )
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
- return cmd
-}
-
-// GetCmdQueryVoteTargets implements the query params command.
-func GetCmdQueryVoteTargets() *cobra.Command {
- cmd := &cobra.Command{
- Use: "vote-targets",
- Args: cobra.NoArgs,
- Short: "Query the current Oracle vote targets",
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- res, err := queryClient.VoteTargets(
- context.Background(),
- &types.QueryVoteTargetsRequest{},
- )
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
- return cmd
-}
diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go
deleted file mode 100644
index f52e195dd..000000000
--- a/x/oracle/client/cli/tx.go
+++ /dev/null
@@ -1,207 +0,0 @@
-package cli
-
-import (
- "fmt"
- "strings"
-
- "github.com/pkg/errors"
-
- "github.com/NibiruChain/nibiru/x/oracle/types"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/client/tx"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/spf13/cobra"
-)
-
-// GetTxCmd returns the transaction commands for this module
-func GetTxCmd() *cobra.Command {
- oracleTxCmd := &cobra.Command{
- Use: "oracle",
- Short: "Oracle transaction subcommands",
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- oracleTxCmd.AddCommand(
- GetCmdDelegateFeederPermission(),
- GetCmdAggregateExchangeRatePrevote(),
- GetCmdAggregateExchangeRateVote(),
- )
-
- return oracleTxCmd
-}
-
-// GetCmdDelegateFeederPermission will create a feeder permission delegation tx and sign it with the given key.
-func GetCmdDelegateFeederPermission() *cobra.Command {
- cmd := &cobra.Command{
- Use: "set-feeder [feeder]",
- Args: cobra.ExactArgs(1),
- Short: "Delegate the permission to vote for the oracle to an address",
- Long: strings.TrimSpace(`
-Delegate the permission to submit exchange rate votes for the oracle to an address.
-
-Delegation can keep your validator operator key offline and use a separate replaceable key online.
-
-$ nibid tx oracle set-feeder nibi1...
-
-where "nibi1..." is the address you want to delegate your voting rights to.
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- // Get from address
- voter := clientCtx.GetFromAddress()
-
- // The address the right is being delegated from
- validator := sdk.ValAddress(voter)
-
- feederStr := args[0]
- feeder, err := sdk.AccAddressFromBech32(feederStr)
- if err != nil {
- return err
- }
-
- msg := types.NewMsgDelegateFeedConsent(validator, feeder)
- if err = msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
-
- return cmd
-}
-
-// GetCmdAggregateExchangeRatePrevote will create a aggregateExchangeRatePrevote tx and sign it with the given key.
-func GetCmdAggregateExchangeRatePrevote() *cobra.Command {
- cmd := &cobra.Command{
- Use: "aggregate-prevote [salt] [exchange-rates] [validator]",
- Args: cobra.RangeArgs(2, 3),
- Short: "Submit an oracle aggregate prevote for the exchange rates of Nibiru",
- Long: strings.TrimSpace(`
-Submit an oracle aggregate prevote for the exchange rates of a pair.
-The purpose of aggregate prevote is to hide aggregate exchange rate vote with hash which is formatted
-as hex string in SHA256("{salt}:({pair},{exchange_rate})|...|({pair},{exchange_rate}):{voter}")
-
-# Aggregate Prevote
-$ nibid tx oracle aggregate-prevote 1234 (40000.0,BTC:USD)|(1.243,NIBI:USD)
-
-where "BTC:USD,NIBI:USD" is the pair, and "40000.0, 1.243" is the exchange rates expressed in decimal value.
-
-If voting from a voting delegate, set "validator" to the address of the validator to vote on behalf of:
-$ nibid tx oracle aggregate-prevote 1234 1234 (40000.0,BTC:USD)|(1.243,NIBI:USD) nibivaloper1...
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- salt := args[0]
- exchangeRatesStr := args[1]
- _, err = types.ParseExchangeRateTuples(exchangeRatesStr)
- if err != nil {
- return fmt.Errorf("given exchange_rates {%s} is not a valid format; exchange_rate should be formatted as DecCoins; %s", exchangeRatesStr, err.Error())
- }
-
- // Get from address
- feeder := clientCtx.GetFromAddress()
-
- // By default, the feeder is voting on behalf of itself
- validator := sdk.ValAddress(feeder)
-
- // Override validator if validator is given
- if len(args) == 3 {
- parsedVal, err := sdk.ValAddressFromBech32(args[2])
- if err != nil {
- return errors.Wrap(err, "validator address is invalid")
- }
-
- validator = parsedVal
- }
-
- hash := types.GetAggregateVoteHash(salt, exchangeRatesStr, validator)
-
- msg := types.NewMsgAggregateExchangeRatePrevote(hash, feeder, validator)
- if err = msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
-
- return cmd
-}
-
-// GetCmdAggregateExchangeRateVote will create a aggregateExchangeRateVote tx and sign it with the given key.
-func GetCmdAggregateExchangeRateVote() *cobra.Command {
- cmd := &cobra.Command{
- Use: "aggregate-vote [salt] [exchange-rates] [validator]",
- Args: cobra.RangeArgs(2, 3),
- Short: "Submit an oracle aggregate vote for the exchange_rates of Nibiru",
- Long: strings.TrimSpace(`
-Submit an aggregate vote for the exchange_rates of the proposed pairs. Companion to a prevote submitted in the previous vote period.
-
-$ nibid tx oracle aggregate-vote 1234 (40000.0,BTC:USD)|(1.243,NIBI:USD)
-
-where "BTC:USD, NIBI:USD" is the pairs, and "40000.0,1.243" is the exchange rates as decimal string.
-
-"salt" should match the salt used to generate the SHA256 hex in the aggregated pre-vote.
-
-If voting from a voting delegate, set "validator" to the address of the validator to vote on behalf of:
-$ nibid tx oracle aggregate-vote 1234 (40000.0,BTC:USD)|(1.243,NIBI:USD) nibivaloper1....
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- salt := args[0]
- exchangeRatesStr := args[1]
- _, err = types.ParseExchangeRateTuples(exchangeRatesStr)
- if err != nil {
- return fmt.Errorf("given exchange_rate {%s} is not a valid format; exchange rate should be formatted as DecCoin; %s", exchangeRatesStr, err.Error())
- }
-
- // Get from address
- feeder := clientCtx.GetFromAddress()
-
- // By default, the feeder is voting on behalf of itself
- validator := sdk.ValAddress(feeder)
-
- // Override validator if validator is given
- if len(args) == 3 {
- parsedVal, err := sdk.ValAddressFromBech32(args[2])
- if err != nil {
- return errors.Wrap(err, "validator address is invalid")
- }
- validator = parsedVal
- }
-
- msg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, feeder, validator)
- if err := msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
-
- return cmd
-}
diff --git a/x/oracle/genesis.go b/x/oracle/genesis.go
deleted file mode 100644
index a6635d1eb..000000000
--- a/x/oracle/genesis.go
+++ /dev/null
@@ -1,133 +0,0 @@
-package oracle
-
-import (
- "fmt"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/oracle/keeper"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-// InitGenesis initialize default parameters
-// and the keeper's address to pubkey map
-func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data *types.GenesisState) {
- for _, d := range data.FeederDelegations {
- voter, err := sdk.ValAddressFromBech32(d.ValidatorAddress)
- if err != nil {
- panic(err)
- }
-
- feeder, err := sdk.AccAddressFromBech32(d.FeederAddress)
- if err != nil {
- panic(err)
- }
-
- keeper.FeederDelegations.Insert(ctx, voter, feeder)
- }
-
- for _, ex := range data.ExchangeRates {
- keeper.SetPrice(ctx, ex.Pair, ex.ExchangeRate)
- }
-
- for _, missCounter := range data.MissCounters {
- operator, err := sdk.ValAddressFromBech32(missCounter.ValidatorAddress)
- if err != nil {
- panic(err)
- }
-
- keeper.MissCounters.Insert(ctx, operator, missCounter.MissCounter)
- }
-
- for _, aggregatePrevote := range data.AggregateExchangeRatePrevotes {
- valAddr, err := sdk.ValAddressFromBech32(aggregatePrevote.Voter)
- if err != nil {
- panic(err)
- }
-
- keeper.Prevotes.Insert(ctx, valAddr, aggregatePrevote)
- }
-
- for _, aggregateVote := range data.AggregateExchangeRateVotes {
- valAddr, err := sdk.ValAddressFromBech32(aggregateVote.Voter)
- if err != nil {
- panic(err)
- }
-
- keeper.Votes.Insert(ctx, valAddr, aggregateVote)
- }
-
- if len(data.Pairs) > 0 {
- for _, tt := range data.Pairs {
- keeper.WhitelistedPairs.Insert(ctx, tt)
- }
- } else {
- for _, item := range data.Params.Whitelist {
- keeper.WhitelistedPairs.Insert(ctx, item)
- }
- }
-
- for _, pr := range data.Rewards {
- keeper.Rewards.Insert(ctx, pr.Id, pr)
- }
-
- // set last ID based on the last pair reward
- if len(data.Rewards) != 0 {
- keeper.RewardsID.Set(ctx, data.Rewards[len(data.Rewards)-1].Id)
- }
- keeper.Params.Set(ctx, data.Params)
-
- // check if the module account exists
- moduleAcc := keeper.AccountKeeper.GetModuleAccount(ctx, types.ModuleName)
- if moduleAcc == nil {
- panic(fmt.Sprintf("%s module account has not been set", types.ModuleName))
- }
-}
-
-// ExportGenesis writes the current store values
-// to a genesis file, which can be imported again
-// with InitGenesis
-func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState {
- params, err := keeper.Params.Get(ctx)
- if err != nil {
- panic(err)
- }
-
- feederDelegations := []types.FeederDelegation{}
- for _, kv := range keeper.FeederDelegations.Iterate(ctx, collections.Range[sdk.ValAddress]{}).KeyValues() {
- feederDelegations = append(feederDelegations, types.FeederDelegation{
- FeederAddress: kv.Value.String(),
- ValidatorAddress: kv.Key.String(),
- })
- }
-
- exchangeRates := []types.ExchangeRateTuple{}
- for _, er := range keeper.ExchangeRates.Iterate(ctx, collections.Range[asset.Pair]{}).KeyValues() {
- exchangeRates = append(exchangeRates, types.ExchangeRateTuple{Pair: er.Key, ExchangeRate: er.Value.ExchangeRate})
- }
-
- missCounters := []types.MissCounter{}
- for _, mc := range keeper.MissCounters.Iterate(ctx, collections.Range[sdk.ValAddress]{}).KeyValues() {
- missCounters = append(missCounters, types.MissCounter{
- ValidatorAddress: mc.Key.String(),
- MissCounter: mc.Value,
- })
- }
-
- var pairs []asset.Pair
- pairs = append(pairs, keeper.WhitelistedPairs.Iterate(ctx, collections.Range[asset.Pair]{}).Keys()...)
-
- return types.NewGenesisState(
- params,
- exchangeRates,
- feederDelegations,
- missCounters,
- keeper.Prevotes.Iterate(ctx, collections.Range[sdk.ValAddress]{}).Values(),
- keeper.Votes.Iterate(ctx, collections.Range[sdk.ValAddress]{}).Values(),
- pairs,
- keeper.Rewards.Iterate(ctx, collections.Range[uint64]{}).Values(),
- )
-}
diff --git a/x/oracle/genesis_test.go b/x/oracle/genesis_test.go
deleted file mode 100644
index 9891b5272..000000000
--- a/x/oracle/genesis_test.go
+++ /dev/null
@@ -1,139 +0,0 @@
-package oracle_test
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/oracle"
- "github.com/NibiruChain/nibiru/x/oracle/keeper"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestExportInitGenesis(t *testing.T) {
- input := keeper.CreateTestFixture(t)
-
- input.OracleKeeper.Params.Set(input.Ctx, types.DefaultParams())
- input.OracleKeeper.FeederDelegations.Insert(input.Ctx, keeper.ValAddrs[0], keeper.Addrs[1])
- input.OracleKeeper.ExchangeRates.Insert(input.Ctx, "pair1:pair2", types.DatedPrice{ExchangeRate: math.LegacyNewDec(123), CreatedBlock: 0})
- input.OracleKeeper.Prevotes.Insert(input.Ctx, keeper.ValAddrs[0], types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{123}, keeper.ValAddrs[0], uint64(2)))
- input.OracleKeeper.Votes.Insert(input.Ctx, keeper.ValAddrs[0], types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Pair: "foo", ExchangeRate: math.LegacyNewDec(123)}}, keeper.ValAddrs[0]))
- input.OracleKeeper.WhitelistedPairs.Insert(input.Ctx, "pair1:pair1")
- input.OracleKeeper.WhitelistedPairs.Insert(input.Ctx, "pair2:pair2")
- input.OracleKeeper.MissCounters.Insert(input.Ctx, keeper.ValAddrs[0], 10)
- input.OracleKeeper.Rewards.Insert(input.Ctx, 0, types.Rewards{
- Id: 0,
- VotePeriods: 100,
- Coins: sdk.NewCoins(sdk.NewInt64Coin("test", 1000)),
- })
- genesis := oracle.ExportGenesis(input.Ctx, input.OracleKeeper)
-
- newInput := keeper.CreateTestFixture(t)
- oracle.InitGenesis(newInput.Ctx, newInput.OracleKeeper, genesis)
- newGenesis := oracle.ExportGenesis(newInput.Ctx, newInput.OracleKeeper)
-
- require.Equal(t, genesis, newGenesis)
-}
-
-func TestInitGenesis(t *testing.T) {
- input := keeper.CreateTestFixture(t)
- genesis := types.DefaultGenesisState()
- require.NotPanics(t, func() {
- oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis)
- })
-
- genesis.FeederDelegations = []types.FeederDelegation{{
- FeederAddress: keeper.Addrs[0].String(),
- ValidatorAddress: "invalid",
- }}
-
- require.Panics(t, func() {
- oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis)
- })
-
- genesis.FeederDelegations = []types.FeederDelegation{{
- FeederAddress: "invalid",
- ValidatorAddress: keeper.ValAddrs[0].String(),
- }}
-
- require.Panics(t, func() {
- oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis)
- })
-
- genesis.FeederDelegations = []types.FeederDelegation{{
- FeederAddress: keeper.Addrs[0].String(),
- ValidatorAddress: keeper.ValAddrs[0].String(),
- }}
-
- genesis.MissCounters = []types.MissCounter{
- {
- ValidatorAddress: "invalid",
- MissCounter: 10,
- },
- }
-
- require.Panics(t, func() {
- oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis)
- })
-
- genesis.MissCounters = []types.MissCounter{
- {
- ValidatorAddress: keeper.ValAddrs[0].String(),
- MissCounter: 10,
- },
- }
-
- genesis.AggregateExchangeRatePrevotes = []types.AggregateExchangeRatePrevote{
- {
- Hash: "hash",
- Voter: "invalid",
- SubmitBlock: 100,
- },
- }
-
- require.Panics(t, func() {
- oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis)
- })
-
- genesis.AggregateExchangeRatePrevotes = []types.AggregateExchangeRatePrevote{
- {
- Hash: "hash",
- Voter: keeper.ValAddrs[0].String(),
- SubmitBlock: 100,
- },
- }
-
- genesis.AggregateExchangeRateVotes = []types.AggregateExchangeRateVote{
- {
- ExchangeRateTuples: []types.ExchangeRateTuple{
- {
- Pair: "nibi:usd",
- ExchangeRate: math.LegacyNewDec(10),
- },
- },
- Voter: "invalid",
- },
- }
-
- require.Panics(t, func() {
- oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis)
- })
-
- genesis.AggregateExchangeRateVotes = []types.AggregateExchangeRateVote{
- {
- ExchangeRateTuples: []types.ExchangeRateTuple{
- {
- Pair: "nibi:usd",
- ExchangeRate: math.LegacyNewDec(10),
- },
- },
- Voter: keeper.ValAddrs[0].String(),
- },
- }
-
- require.NotPanics(t, func() {
- oracle.InitGenesis(input.Ctx, input.OracleKeeper, genesis)
- })
-}
diff --git a/x/oracle/integration/action/price.go b/x/oracle/integration/action/price.go
deleted file mode 100644
index 0d80f5e10..000000000
--- a/x/oracle/integration/action/price.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package action
-
-import (
- "time"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/testutil/action"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func SetOraclePrice(pair asset.Pair, price sdk.Dec) action.Action {
- return &setPairPrice{
- Pair: pair,
- Price: price,
- }
-}
-
-type setPairPrice struct {
- Pair asset.Pair
- Price sdk.Dec
-}
-
-func (s setPairPrice) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- app.OracleKeeper.SetPrice(ctx, s.Pair, s.Price)
-
- return ctx, nil
-}
-
-func InsertOraclePriceSnapshot(pair asset.Pair, time time.Time, price sdk.Dec) action.Action {
- return &insertOraclePriceSnapshot{
- Pair: pair,
- Time: time,
- Price: price,
- }
-}
-
-type insertOraclePriceSnapshot struct {
- Pair asset.Pair
- Time time.Time
- Price sdk.Dec
-}
-
-func (s insertOraclePriceSnapshot) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) {
- app.OracleKeeper.PriceSnapshots.Insert(ctx, collections.Join(s.Pair, s.Time), types.PriceSnapshot{
- Pair: s.Pair,
- Price: s.Price,
- TimestampMs: s.Time.UnixMilli(),
- })
-
- return ctx, nil
-}
diff --git a/x/oracle/integration/app_test.go b/x/oracle/integration/app_test.go
deleted file mode 100644
index d8e46a3be..000000000
--- a/x/oracle/integration/app_test.go
+++ /dev/null
@@ -1,179 +0,0 @@
-package integration_test
-
-import (
- "context"
- "testing"
-
- "github.com/cosmos/cosmos-sdk/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
- "github.com/stretchr/testify/suite"
-
- "cosmossdk.io/math"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- testutilcli "github.com/NibiruChain/nibiru/x/common/testutil/cli"
- "github.com/NibiruChain/nibiru/x/common/testutil/genesis"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-type IntegrationTestSuite struct {
- suite.Suite
-
- cfg testutilcli.Config
- network *testutilcli.Network
-}
-
-func (s *IntegrationTestSuite) SetupSuite() {
- testutil.BeforeIntegrationSuite(s.T())
-}
-
-func (s *IntegrationTestSuite) SetupTest() {
- testapp.EnsureNibiruPrefix()
- homeDir := s.T().TempDir()
-
- genesisState := genesis.NewTestGenesisState(app.MakeEncodingConfig())
- s.cfg = testutilcli.BuildNetworkConfig(genesisState)
- s.cfg.NumValidators = 4
- s.cfg.GenesisState[types.ModuleName] = s.cfg.Codec.MustMarshalJSON(func() codec.ProtoMarshaler {
- gs := types.DefaultGenesisState()
- gs.Params.Whitelist = []asset.Pair{
- "nibi:usdc",
- "btc:usdc",
- }
-
- return gs
- }())
-
- network, err := testutilcli.New(
- s.T(),
- homeDir,
- s.cfg,
- )
- s.Require().NoError(err)
- s.network = network
-
- _, err = s.network.WaitForHeight(2)
- require.NoError(s.T(), err)
-}
-
-func (s *IntegrationTestSuite) TestSuccessfulVoting() {
- // assuming validators have equal power
- // we use the weighted median.
- // what happens is that prices are ordered
- // based on exchange rate, from lowest to highest.
- // then the median is picked, based on consensus power
- // so obviously, in this case, since validators have the same power
- // once weight (based on power) >= total power (sum of weights)
- // then the number picked is the one in the middle always.
- prices := []map[asset.Pair]sdk.Dec{
- {
- "nibi:usdc": math.LegacyOneDec(),
- "btc:usdc": math.LegacyMustNewDecFromStr("100203.0"),
- },
- {
- "nibi:usdc": math.LegacyOneDec(),
- "btc:usdc": math.LegacyMustNewDecFromStr("100150.5"),
- },
- {
- "nibi:usdc": math.LegacyOneDec(),
- "btc:usdc": math.LegacyMustNewDecFromStr("100200.9"),
- },
- {
- "nibi:usdc": math.LegacyOneDec(),
- "btc:usdc": math.LegacyMustNewDecFromStr("100300.9"),
- },
- }
- votes := s.sendPrevotes(prices)
-
- s.waitVoteRevealBlock()
-
- s.sendVotes(votes)
-
- s.waitPriceUpdateBlock()
-
- gotPrices := s.currentPrices()
- require.Equal(s.T(),
- map[asset.Pair]sdk.Dec{
- "nibi:usdc": math.LegacyOneDec(),
- "btc:usdc": math.LegacyMustNewDecFromStr("100200.9"),
- },
- gotPrices,
- )
-}
-
-func (s *IntegrationTestSuite) sendPrevotes(prices []map[asset.Pair]sdk.Dec) []string {
- strVotes := make([]string, len(prices))
- for i, val := range s.network.Validators {
- raw := prices[i]
- votes := make(types.ExchangeRateTuples, 0, len(raw))
- for pair, price := range raw {
- votes = append(votes, types.NewExchangeRateTuple(pair, price))
- }
-
- pricesStr, err := votes.ToString()
- require.NoError(s.T(), err)
- _, err = s.network.BroadcastMsgs(val.Address, &types.MsgAggregateExchangeRatePrevote{
- Hash: types.GetAggregateVoteHash("1", pricesStr, val.ValAddress).String(),
- Feeder: val.Address.String(),
- Validator: val.ValAddress.String(),
- })
- require.NoError(s.T(), err)
-
- strVotes[i] = pricesStr
- }
-
- return strVotes
-}
-
-func (s *IntegrationTestSuite) sendVotes(rates []string) {
- for i, val := range s.network.Validators {
- _, err := s.network.BroadcastMsgs(val.Address, &types.MsgAggregateExchangeRateVote{
- Salt: "1",
- ExchangeRates: rates[i],
- Feeder: val.Address.String(),
- Validator: val.ValAddress.String(),
- })
- require.NoError(s.T(), err)
- }
-}
-
-func (s *IntegrationTestSuite) waitVoteRevealBlock() {
- params, err := types.NewQueryClient(s.network.Validators[0].ClientCtx).Params(context.Background(), &types.QueryParamsRequest{})
- require.NoError(s.T(), err)
-
- votePeriod := params.Params.VotePeriod
-
- height, err := s.network.LatestHeight()
- require.NoError(s.T(), err)
-
- waitBlock := (uint64(height)/votePeriod)*votePeriod + votePeriod
-
- _, err = s.network.WaitForHeight(int64(waitBlock + 1))
- require.NoError(s.T(), err)
-}
-
-// it's an alias, but it exists to give better understanding of what we're doing in test cases scenarios
-func (s *IntegrationTestSuite) waitPriceUpdateBlock() {
- s.waitVoteRevealBlock()
-}
-
-func (s *IntegrationTestSuite) currentPrices() map[asset.Pair]sdk.Dec {
- rawRates, err := types.NewQueryClient(s.network.Validators[0].ClientCtx).ExchangeRates(context.Background(), &types.QueryExchangeRatesRequest{})
- require.NoError(s.T(), err)
-
- prices := make(map[asset.Pair]sdk.Dec)
-
- for _, p := range rawRates.ExchangeRates {
- prices[p.Pair] = p.ExchangeRate
- }
-
- return prices
-}
-
-func TestIntegrationTestSuite(t *testing.T) {
- suite.Run(t, new(IntegrationTestSuite))
-}
diff --git a/x/oracle/keeper/ballot.go b/x/oracle/keeper/ballot.go
deleted file mode 100644
index bf873c7c5..000000000
--- a/x/oracle/keeper/ballot.go
+++ /dev/null
@@ -1,185 +0,0 @@
-package keeper
-
-import (
- sdkmath "cosmossdk.io/math"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/collections"
-
- "cosmossdk.io/math"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/omap"
- "github.com/NibiruChain/nibiru/x/common/set"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-// groupVotesByPair takes a collection of votes and groups them by their
-// associated asset pair. This method only considers votes from active validators
-// and disregards votes from validators that are not in the provided validator set.
-//
-// Note that any abstain votes (votes with a non-positive exchange rate) are
-// assigned zero vote power. This function then returns a map where each
-// asset pair is associated with its collection of ExchangeRateVotes.
-func (k Keeper) groupVotesByPair(
- ctx sdk.Context,
- validatorPerformances types.ValidatorPerformances,
-) (pairVotes map[asset.Pair]types.ExchangeRateVotes) {
- pairVotes = map[asset.Pair]types.ExchangeRateVotes{}
-
- for _, value := range k.Votes.Iterate(ctx, collections.Range[sdk.ValAddress]{}).KeyValues() {
- voterAddr, aggregateVote := value.Key, value.Value
-
- // skip votes from inactive validators
- validatorPerformance, exists := validatorPerformances[aggregateVote.Voter]
- if !exists {
- continue
- }
-
- for _, tuple := range aggregateVote.ExchangeRateTuples {
- power := validatorPerformance.Power
- if !tuple.ExchangeRate.IsPositive() {
- // Make the power of abstain vote zero
- power = 0
- }
-
- pairVotes[tuple.Pair] = append(
- pairVotes[tuple.Pair],
- types.NewExchangeRateVote(
- tuple.ExchangeRate,
- tuple.Pair,
- voterAddr,
- power,
- ),
- )
- }
- }
-
- return
-}
-
-// clearVotesAndPrevotes clears all tallied prevotes and votes from the store
-func (k Keeper) clearVotesAndPrevotes(ctx sdk.Context, votePeriod uint64) {
- // Clear all aggregate prevotes
- for _, prevote := range k.Prevotes.Iterate(ctx, collections.Range[sdk.ValAddress]{}).KeyValues() {
- valAddr, aggregatePrevote := prevote.Key, prevote.Value
- if ctx.BlockHeight() >= int64(aggregatePrevote.SubmitBlock+votePeriod) {
- err := k.Prevotes.Delete(ctx, valAddr)
- if err != nil {
- k.Logger(ctx).Error("failed to delete prevote", "error", err)
- }
- }
- }
-
- // Clear all aggregate votes
- for _, valAddr := range k.Votes.Iterate(ctx, collections.Range[sdk.ValAddress]{}).Keys() {
- err := k.Votes.Delete(ctx, valAddr)
- if err != nil {
- k.Logger(ctx).Error("failed to delete vote", "error", err)
- }
- }
-}
-
-// isPassingVoteThreshold votes is passing the threshold amount of voting power
-func isPassingVoteThreshold(
- votes types.ExchangeRateVotes, thresholdVotingPower sdkmath.Int, minVoters uint64,
-) bool {
- totalPower := math.NewInt(votes.Power())
- if totalPower.IsZero() {
- return false
- }
-
- if totalPower.LT(thresholdVotingPower) {
- return false
- }
-
- if votes.NumValidVoters() < minVoters {
- return false
- }
-
- return true
-}
-
-// removeInvalidVotes removes the votes which have not reached the vote
-// threshold or which are not part of the whitelisted pairs anymore: example
-// when params change during a vote period but some votes were already made.
-//
-// ALERT: This function mutates the pairVotes map, it removes the votes for
-// the pair which is not passing the threshold or which is not whitelisted
-// anymore.
-func (k Keeper) removeInvalidVotes(
- ctx sdk.Context,
- pairVotes map[asset.Pair]types.ExchangeRateVotes,
- whitelistedPairs set.Set[asset.Pair],
-) {
- totalBondedPower := sdk.TokensToConsensusPower(
- k.StakingKeeper.TotalBondedTokens(ctx), k.StakingKeeper.PowerReduction(ctx),
- )
-
- // Iterate through sorted keys for deterministic ordering.
- orderedPairVotes := omap.OrderedMap_Pair[types.ExchangeRateVotes](pairVotes)
- for pair := range orderedPairVotes.Range() {
- // If pair is not whitelisted, or the votes for it has failed, then skip
- // and remove it from pairBallotsMap for iteration efficiency
- if !whitelistedPairs.Has(pair) {
- delete(pairVotes, pair)
- }
-
- // If the votes is not passed, remove it from the whitelistedPairs set
- // to prevent slashing validators who did valid vote.
- if !isPassingVoteThreshold(
- pairVotes[pair],
- k.VoteThreshold(ctx).MulInt64(totalBondedPower).RoundInt(),
- k.MinVoters(ctx),
- ) {
- delete(whitelistedPairs, pair)
- delete(pairVotes, pair)
- continue
- }
- }
-}
-
-// Tally calculates the median and returns it. Sets the set of voters to be
-// rewarded, i.e. voted within a reasonable spread from the weighted median to
-// the store.
-//
-// ALERT: This function mutates validatorPerformances slice based on the votes
-// made by the validators.
-func Tally(
- votes types.ExchangeRateVotes,
- rewardBand sdk.Dec,
- validatorPerformances types.ValidatorPerformances,
-) sdk.Dec {
- weightedMedian := votes.WeightedMedianWithAssertion()
- standardDeviation := votes.StandardDeviation(weightedMedian)
- rewardSpread := weightedMedian.Mul(rewardBand.QuoInt64(2))
-
- if standardDeviation.GT(rewardSpread) {
- rewardSpread = standardDeviation
- }
-
- for _, v := range votes {
- // Filter votes winners & abstain voters
- isInsideSpread := v.ExchangeRate.GTE(weightedMedian.Sub(rewardSpread)) &&
- v.ExchangeRate.LTE(weightedMedian.Add(rewardSpread))
- isAbstainVote := !v.ExchangeRate.IsPositive() // strictly less than zero, don't want to include zero
- isMiss := !isInsideSpread && !isAbstainVote
-
- validatorPerformance := validatorPerformances[v.Voter.String()]
-
- switch {
- case isInsideSpread:
- validatorPerformance.RewardWeight += v.Power
- validatorPerformance.WinCount++
- case isMiss:
- validatorPerformance.MissCount++
- case isAbstainVote:
- validatorPerformance.AbstainCount++
- }
-
- validatorPerformances[v.Voter.String()] = validatorPerformance
- }
-
- return weightedMedian
-}
diff --git a/x/oracle/keeper/ballot_test.go b/x/oracle/keeper/ballot_test.go
deleted file mode 100644
index 9245d5dd5..000000000
--- a/x/oracle/keeper/ballot_test.go
+++ /dev/null
@@ -1,360 +0,0 @@
-package keeper
-
-import (
- "sort"
- "testing"
-
- stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
-
- "cosmossdk.io/math"
- "github.com/NibiruChain/collections"
- "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/x/staking"
- fuzz "github.com/google/gofuzz"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/common/set"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestGroupVotesByPair(t *testing.T) {
- fixture := CreateTestFixture(t)
-
- power := int64(100)
- amt := sdk.TokensFromConsensusPower(power, sdk.DefaultPowerReduction)
- sh := stakingkeeper.NewMsgServerImpl(&fixture.StakingKeeper)
-
- // Validator created
- _, err := sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[0], ValPubKeys[0], amt))
- require.NoError(t, err)
- _, err = sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[1], ValPubKeys[1], amt))
- require.NoError(t, err)
- _, err = sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[2], ValPubKeys[2], amt))
- require.NoError(t, err)
- staking.EndBlocker(fixture.Ctx, &fixture.StakingKeeper)
-
- pairBtc := asset.Registry.Pair(denoms.BTC, denoms.NUSD)
- pairEth := asset.Registry.Pair(denoms.ETH, denoms.NUSD)
- btcVotes := types.ExchangeRateVotes{
- {Pair: pairBtc, ExchangeRate: math.LegacyNewDec(17), Voter: ValAddrs[0], Power: power},
- {Pair: pairBtc, ExchangeRate: math.LegacyNewDec(10), Voter: ValAddrs[1], Power: power},
- {Pair: pairBtc, ExchangeRate: math.LegacyNewDec(6), Voter: ValAddrs[2], Power: power},
- }
- ethVotes := types.ExchangeRateVotes{
- {Pair: pairEth, ExchangeRate: math.LegacyNewDec(1_000), Voter: ValAddrs[0], Power: power},
- {Pair: pairEth, ExchangeRate: math.LegacyNewDec(1_300), Voter: ValAddrs[1], Power: power},
- {Pair: pairEth, ExchangeRate: math.LegacyNewDec(2_000), Voter: ValAddrs[2], Power: power},
- }
-
- for i, v := range btcVotes {
- fixture.OracleKeeper.Votes.Insert(
- fixture.Ctx,
- ValAddrs[i],
- types.NewAggregateExchangeRateVote(
- types.ExchangeRateTuples{
- {Pair: v.Pair, ExchangeRate: v.ExchangeRate},
- {Pair: ethVotes[i].Pair, ExchangeRate: ethVotes[i].ExchangeRate},
- },
- ValAddrs[i],
- ),
- )
- }
-
- // organize votes by pair
- pairVotes := fixture.OracleKeeper.groupVotesByPair(fixture.Ctx, types.ValidatorPerformances{
- ValAddrs[0].String(): {
- Power: power,
- WinCount: 0,
- ValAddress: ValAddrs[0],
- },
- ValAddrs[1].String(): {
- Power: power,
- WinCount: 0,
- ValAddress: ValAddrs[1],
- },
- ValAddrs[2].String(): {
- Power: power,
- WinCount: 0,
- ValAddress: ValAddrs[2],
- },
- })
-
- // sort each votes for comparison
- sort.Sort(btcVotes)
- sort.Sort(ethVotes)
- sort.Sort(pairVotes[asset.Registry.Pair(denoms.BTC, denoms.NUSD)])
- sort.Sort(pairVotes[asset.Registry.Pair(denoms.ETH, denoms.NUSD)])
-
- require.Equal(t, btcVotes, pairVotes[asset.Registry.Pair(denoms.BTC, denoms.NUSD)])
- require.Equal(t, ethVotes, pairVotes[asset.Registry.Pair(denoms.ETH, denoms.NUSD)])
-}
-
-func TestClearVotesAndPrevotes(t *testing.T) {
- fixture := CreateTestFixture(t)
-
- power := int64(100)
- amt := sdk.TokensFromConsensusPower(power, sdk.DefaultPowerReduction)
- sh := stakingkeeper.NewMsgServerImpl(&fixture.StakingKeeper)
-
- // Validator created
- _, err := sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[0], ValPubKeys[0], amt))
- require.NoError(t, err)
- _, err = sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[1], ValPubKeys[1], amt))
- require.NoError(t, err)
- _, err = sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[2], ValPubKeys[2], amt))
- require.NoError(t, err)
- staking.EndBlocker(fixture.Ctx, &fixture.StakingKeeper)
-
- btcVotes := types.ExchangeRateVotes{
- types.NewExchangeRateVote(math.LegacyNewDec(17), asset.Registry.Pair(denoms.BTC, denoms.NUSD), ValAddrs[0], power),
- types.NewExchangeRateVote(math.LegacyNewDec(10), asset.Registry.Pair(denoms.BTC, denoms.NUSD), ValAddrs[1], power),
- types.NewExchangeRateVote(math.LegacyNewDec(6), asset.Registry.Pair(denoms.BTC, denoms.NUSD), ValAddrs[2], power),
- }
- ethVotes := types.ExchangeRateVotes{
- types.NewExchangeRateVote(math.LegacyNewDec(1000), asset.Registry.Pair(denoms.ETH, denoms.NUSD), ValAddrs[0], power),
- types.NewExchangeRateVote(math.LegacyNewDec(1300), asset.Registry.Pair(denoms.ETH, denoms.NUSD), ValAddrs[1], power),
- types.NewExchangeRateVote(math.LegacyNewDec(2000), asset.Registry.Pair(denoms.ETH, denoms.NUSD), ValAddrs[2], power),
- }
-
- for i := range btcVotes {
- fixture.OracleKeeper.Prevotes.Insert(fixture.Ctx, ValAddrs[i], types.AggregateExchangeRatePrevote{
- Hash: "",
- Voter: ValAddrs[i].String(),
- SubmitBlock: uint64(fixture.Ctx.BlockHeight()),
- })
-
- fixture.OracleKeeper.Votes.Insert(fixture.Ctx, ValAddrs[i],
- types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{
- {Pair: btcVotes[i].Pair, ExchangeRate: btcVotes[i].ExchangeRate},
- {Pair: ethVotes[i].Pair, ExchangeRate: ethVotes[i].ExchangeRate},
- }, ValAddrs[i]))
- }
-
- fixture.OracleKeeper.clearVotesAndPrevotes(fixture.Ctx, 10)
-
- prevoteCounter := len(fixture.OracleKeeper.Prevotes.Iterate(fixture.Ctx, collections.Range[sdk.ValAddress]{}).Keys())
- voteCounter := len(fixture.OracleKeeper.Votes.Iterate(fixture.Ctx, collections.Range[sdk.ValAddress]{}).Keys())
-
- require.Equal(t, prevoteCounter, 3)
- require.Equal(t, voteCounter, 0)
-
- // vote period starts at b=10, clear the votes at b=0 and below.
- fixture.OracleKeeper.clearVotesAndPrevotes(fixture.Ctx.WithBlockHeight(fixture.Ctx.BlockHeight()+10), 10)
- prevoteCounter = len(fixture.OracleKeeper.Prevotes.Iterate(fixture.Ctx, collections.Range[sdk.ValAddress]{}).Keys())
- require.Equal(t, prevoteCounter, 0)
-}
-
-func TestFuzzTally(t *testing.T) {
- validators := map[string]int64{}
-
- f := fuzz.New().NilChance(0).Funcs(
- func(e *sdk.Dec, c fuzz.Continue) {
- *e = math.LegacyNewDec(c.Int63())
- },
- func(e *map[string]int64, c fuzz.Continue) {
- numValidators := c.Intn(100) + 5
-
- for i := 0; i < numValidators; i++ {
- (*e)[sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address()).String()] = c.Int63n(100)
- }
- },
- func(e *types.ValidatorPerformances, c fuzz.Continue) {
- for validator, power := range validators {
- addr, err := sdk.ValAddressFromBech32(validator)
- require.NoError(t, err)
- (*e)[validator] = types.NewValidatorPerformance(power, addr)
- }
- },
- func(e *types.ExchangeRateVotes, c fuzz.Continue) {
- votes := types.ExchangeRateVotes{}
- for addr, power := range validators {
- addr, _ := sdk.ValAddressFromBech32(addr)
-
- var rate sdk.Dec
- c.Fuzz(&rate)
-
- votes = append(votes, types.NewExchangeRateVote(rate, asset.NewPair(c.RandString(), c.RandString()), addr, power))
- }
-
- *e = votes
- },
- )
-
- // set random pairs and validators
- f.Fuzz(&validators)
-
- claimMap := types.ValidatorPerformances{}
- f.Fuzz(&claimMap)
-
- votes := types.ExchangeRateVotes{}
- f.Fuzz(&votes)
-
- var rewardBand sdk.Dec
- f.Fuzz(&rewardBand)
-
- require.NotPanics(t, func() {
- Tally(votes, rewardBand, claimMap)
- })
-}
-
-type VoteMap = map[asset.Pair]types.ExchangeRateVotes
-
-func TestRemoveInvalidBallots(t *testing.T) {
- testCases := []struct {
- name string
- voteMap VoteMap
- }{
- {
- name: "empty key, empty votes",
- voteMap: VoteMap{
- "": types.ExchangeRateVotes{},
- },
- },
- {
- name: "nonempty key, empty votes",
- voteMap: VoteMap{
- "xxx": types.ExchangeRateVotes{},
- },
- },
- {
- name: "nonempty keys, empty votes",
- voteMap: VoteMap{
- "xxx": types.ExchangeRateVotes{},
- "abc123": types.ExchangeRateVotes{},
- },
- },
- {
- name: "mixed empty keys, empty votes",
- voteMap: VoteMap{
- "xxx": types.ExchangeRateVotes{},
- "": types.ExchangeRateVotes{},
- "abc123": types.ExchangeRateVotes{},
- "0x": types.ExchangeRateVotes{},
- },
- },
- {
- name: "empty key, nonempty votes, not whitelisted",
- voteMap: VoteMap{
- "": types.ExchangeRateVotes{
- {Pair: "", ExchangeRate: math.LegacyZeroDec(), Voter: sdk.ValAddress{}, Power: 0},
- },
- },
- },
- {
- name: "nonempty key, nonempty votes, whitelisted",
- voteMap: VoteMap{
- "x": types.ExchangeRateVotes{
- {Pair: "x", ExchangeRate: sdk.Dec{}, Voter: sdk.ValAddress{123}, Power: 5},
- },
- asset.Registry.Pair(denoms.BTC, denoms.NUSD): types.ExchangeRateVotes{
- {Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD), ExchangeRate: sdk.Dec{}, Voter: sdk.ValAddress{123}, Power: 5},
- },
- asset.Registry.Pair(denoms.ETH, denoms.NUSD): types.ExchangeRateVotes{
- {Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD), ExchangeRate: sdk.Dec{}, Voter: sdk.ValAddress{123}, Power: 5},
- },
- },
- },
- }
-
- for _, testCase := range testCases {
- tc := testCase
- t.Run(tc.name, func(t *testing.T) {
- fixture, _ := Setup(t)
- assert.NotPanics(t, func() {
- fixture.OracleKeeper.removeInvalidVotes(fixture.Ctx, tc.voteMap, set.New[asset.Pair](
- asset.NewPair(denoms.BTC, denoms.NUSD),
- asset.NewPair(denoms.ETH, denoms.NUSD),
- ))
- }, "voteMap: %v", tc.voteMap)
- })
- }
-}
-
-func TestFuzzPickReferencePair(t *testing.T) {
- var pairs []asset.Pair
-
- f := fuzz.New().NilChance(0).Funcs(
- func(e *asset.Pair, c fuzz.Continue) {
- *e = asset.NewPair(testutil.RandLetters(5), testutil.RandLetters(5))
- },
- func(e *[]asset.Pair, c fuzz.Continue) {
- numPairs := c.Intn(100) + 5
-
- for i := 0; i < numPairs; i++ {
- *e = append(*e, asset.NewPair(testutil.RandLetters(5), testutil.RandLetters(5)))
- }
- },
- func(e *sdk.Dec, c fuzz.Continue) {
- *e = math.LegacyNewDec(c.Int63())
- },
- func(e *map[asset.Pair]sdk.Dec, c fuzz.Continue) {
- for _, pair := range pairs {
- var rate sdk.Dec
- c.Fuzz(&rate)
-
- (*e)[pair] = rate
- }
- },
- func(e *map[string]int64, c fuzz.Continue) {
- for i := 0; i < 5+c.Intn(100); i++ {
- (*e)[sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address()).String()] = int64(c.Intn(100) + 1)
- }
- },
- func(e *map[asset.Pair]types.ExchangeRateVotes, c fuzz.Continue) {
- validators := map[string]int64{}
- c.Fuzz(&validators)
-
- for _, pair := range pairs {
- votes := types.ExchangeRateVotes{}
-
- for addr, power := range validators {
- addr, _ := sdk.ValAddressFromBech32(addr)
-
- var rate sdk.Dec
- c.Fuzz(&rate)
-
- votes = append(votes, types.NewExchangeRateVote(rate, pair, addr, power))
- }
-
- (*e)[pair] = votes
- }
- },
- )
-
- // set random pairs
- f.Fuzz(&pairs)
-
- input, _ := Setup(t)
-
- // test OracleKeeper.Pairs.Insert
- voteTargets := set.Set[asset.Pair]{}
- f.Fuzz(&voteTargets)
- whitelistedPairs := make(set.Set[asset.Pair])
-
- for key := range voteTargets {
- whitelistedPairs.Add(key)
- }
-
- // test OracleKeeper.RemoveInvalidBallots
- voteMap := map[asset.Pair]types.ExchangeRateVotes{}
- f.Fuzz(&voteMap)
-
- assert.NotPanics(t, func() {
- input.OracleKeeper.removeInvalidVotes(input.Ctx, voteMap, whitelistedPairs)
- }, "voteMap: %v", voteMap)
-}
-
-func TestZeroBallotPower(t *testing.T) {
- btcVotess := types.ExchangeRateVotes{
- types.NewExchangeRateVote(math.LegacyNewDec(17), asset.Registry.Pair(denoms.BTC, denoms.NUSD), ValAddrs[0], 0),
- types.NewExchangeRateVote(math.LegacyNewDec(10), asset.Registry.Pair(denoms.BTC, denoms.NUSD), ValAddrs[1], 0),
- types.NewExchangeRateVote(math.LegacyNewDec(6), asset.Registry.Pair(denoms.BTC, denoms.NUSD), ValAddrs[2], 0),
- }
-
- assert.False(t, isPassingVoteThreshold(btcVotess, math.ZeroInt(), 0))
-}
diff --git a/x/oracle/keeper/hooks.go b/x/oracle/keeper/hooks.go
deleted file mode 100644
index 077361353..000000000
--- a/x/oracle/keeper/hooks.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package keeper
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/x/auth/keeper"
- bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
-
- "github.com/NibiruChain/nibiru/x/epochs/types"
- oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-var _ types.EpochHooks = Hooks{}
-
-// Return the wrapper struct
-func (k Keeper) Hooks() Hooks {
- return Hooks{
- k,
- k.AccountKeeper,
- k.bankKeeper,
- }
-}
-
-type Hooks struct {
- k Keeper
- accountKeeper oracletypes.AccountKeeper
- bankKeeper oracletypes.BankKeeper
-}
-
-func NewHooks(k Keeper, accountKeeper keeper.AccountKeeper, bankKeeper bankkeeper.Keeper) *Hooks {
- return &Hooks{k: k, accountKeeper: accountKeeper, bankKeeper: bankKeeper}
-}
-
-func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, _ uint64) {
-}
-
-func (h Hooks) BeforeEpochStart(_ sdk.Context, _ string, _ uint64) {}
diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go
deleted file mode 100644
index 9ebd24b43..000000000
--- a/x/oracle/keeper/keeper.go
+++ /dev/null
@@ -1,208 +0,0 @@
-package keeper
-
-import (
- "fmt"
- "time"
-
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
-
- sdkerrors "cosmossdk.io/errors"
- "cosmossdk.io/math"
- "github.com/cometbft/cometbft/libs/log"
- "github.com/cosmos/cosmos-sdk/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-// Keeper of the oracle store
-type Keeper struct {
- cdc codec.BinaryCodec
- storeKey storetypes.StoreKey
-
- AccountKeeper types.AccountKeeper
- bankKeeper types.BankKeeper
- distrKeeper types.DistributionKeeper
- StakingKeeper types.StakingKeeper
- slashingKeeper types.SlashingKeeper
- sudoKeeper types.SudoKeeper
-
- distrModuleName string
-
- // Module parameters
- Params collections.Item[types.Params]
- ExchangeRates collections.Map[asset.Pair, types.DatedPrice]
- FeederDelegations collections.Map[sdk.ValAddress, sdk.AccAddress]
- MissCounters collections.Map[sdk.ValAddress, uint64]
- Prevotes collections.Map[sdk.ValAddress, types.AggregateExchangeRatePrevote]
- Votes collections.Map[sdk.ValAddress, types.AggregateExchangeRateVote]
-
- // PriceSnapshots maps types.PriceSnapshot to the asset.Pair of the snapshot and the creation timestamp as keys.Uint64Key.
- PriceSnapshots collections.Map[
- collections.Pair[asset.Pair, time.Time],
- types.PriceSnapshot]
- WhitelistedPairs collections.KeySet[asset.Pair]
- Rewards collections.Map[uint64, types.Rewards]
- RewardsID collections.Sequence
-}
-
-// NewKeeper constructs a new keeper for oracle
-func NewKeeper(
- cdc codec.BinaryCodec,
- storeKey storetypes.StoreKey,
-
- accountKeeper types.AccountKeeper,
- bankKeeper types.BankKeeper,
- distrKeeper types.DistributionKeeper,
- stakingKeeper types.StakingKeeper,
- slashingKeeper types.SlashingKeeper,
- sudoKeeper types.SudoKeeper,
-
- distrName string,
-) Keeper {
- // ensure oracle module account is set
- if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil {
- panic(fmt.Sprintf("%s module account has not been set", types.ModuleName))
- }
-
- k := Keeper{
- cdc: cdc,
- storeKey: storeKey,
- AccountKeeper: accountKeeper,
- bankKeeper: bankKeeper,
- distrKeeper: distrKeeper,
- StakingKeeper: stakingKeeper,
- slashingKeeper: slashingKeeper,
- sudoKeeper: sudoKeeper,
- distrModuleName: distrName,
- Params: collections.NewItem(storeKey, 11, collections.ProtoValueEncoder[types.Params](cdc)),
- ExchangeRates: collections.NewMap(storeKey, 1, asset.PairKeyEncoder, collections.ProtoValueEncoder[types.DatedPrice](cdc)),
- PriceSnapshots: collections.NewMap(storeKey, 10, collections.PairKeyEncoder(asset.PairKeyEncoder, collections.TimeKeyEncoder), collections.ProtoValueEncoder[types.PriceSnapshot](cdc)),
- FeederDelegations: collections.NewMap(storeKey, 2, collections.ValAddressKeyEncoder, collections.AccAddressValueEncoder),
- MissCounters: collections.NewMap(storeKey, 3, collections.ValAddressKeyEncoder, collections.Uint64ValueEncoder),
- Prevotes: collections.NewMap(storeKey, 4, collections.ValAddressKeyEncoder, collections.ProtoValueEncoder[types.AggregateExchangeRatePrevote](cdc)),
- Votes: collections.NewMap(storeKey, 5, collections.ValAddressKeyEncoder, collections.ProtoValueEncoder[types.AggregateExchangeRateVote](cdc)),
- WhitelistedPairs: collections.NewKeySet(storeKey, 6, asset.PairKeyEncoder),
- Rewards: collections.NewMap(
- storeKey, 7,
- collections.Uint64KeyEncoder, collections.ProtoValueEncoder[types.Rewards](cdc)),
- RewardsID: collections.NewSequence(storeKey, 9),
- }
- return k
-}
-
-// Logger returns a module-specific logger.
-func (k Keeper) Logger(ctx sdk.Context) log.Logger {
- return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
-}
-
-// ValidateFeeder return the given feeder is allowed to feed the message or not
-func (k Keeper) ValidateFeeder(
- ctx sdk.Context, feederAddr sdk.AccAddress, validatorAddr sdk.ValAddress,
-) error {
- // A validator delegates price feeder consent to itself by default.
- // Thus, we only need to verify consent for price feeder addresses that don't
- // match the validator address.
- if !feederAddr.Equals(validatorAddr) {
- delegate := k.FeederDelegations.GetOr(
- ctx, validatorAddr, sdk.AccAddress(validatorAddr))
- if !delegate.Equals(feederAddr) {
- return sdkerrors.Wrapf(
- types.ErrNoVotingPermission,
- "wanted: %s, got: %s", delegate.String(), feederAddr.String())
- }
- }
-
- // Check that the given validator is in the active set for consensus.
- if val := k.StakingKeeper.Validator(ctx, validatorAddr); val == nil || !val.IsBonded() {
- return sdkerrors.Wrapf(
- stakingtypes.ErrNoValidatorFound,
- "validator %s is not active set", validatorAddr.String())
- }
-
- return nil
-}
-
-func (k Keeper) GetExchangeRateTwap(ctx sdk.Context, pair asset.Pair) (price sdk.Dec, err error) {
- params, err := k.Params.Get(ctx)
- if err != nil {
- return math.LegacyOneDec().Neg(), err
- }
-
- snapshots := k.PriceSnapshots.Iterate(
- ctx,
- collections.PairRange[asset.Pair, time.Time]{}.
- Prefix(pair).
- StartInclusive(
- ctx.BlockTime().Add(-1*params.TwapLookbackWindow)).
- EndInclusive(
- ctx.BlockTime()),
- ).Values()
-
- if len(snapshots) == 0 {
- // if there are no snapshots, return -1 for the price
- return math.LegacyOneDec().Neg(), types.ErrNoValidTWAP.Wrapf("no snapshots for pair %s", pair.String())
- }
-
- if len(snapshots) == 1 {
- return snapshots[0].Price, nil
- }
-
- firstTimestampMs := snapshots[0].TimestampMs
- if firstTimestampMs > ctx.BlockTime().UnixMilli() {
- // should never happen, or else we have corrupted state
- return math.LegacyOneDec().Neg(), types.ErrNoValidTWAP.Wrapf(
- "Possible corrupted state. First timestamp %d is after current blocktime %d", firstTimestampMs, ctx.BlockTime().UnixMilli())
- }
-
- if firstTimestampMs == ctx.BlockTime().UnixMilli() {
- // shouldn't happen because we check for len(snapshots) == 1, but if it does, return the first snapshot price
- return snapshots[0].Price, nil
- }
-
- cumulativePrice := math.LegacyZeroDec()
- for i, s := range snapshots {
- var nextTimestampMs int64
- if i == len(snapshots)-1 {
- // if we're at the last snapshot, then consider that price as ongoing until the current blocktime
- nextTimestampMs = ctx.BlockTime().UnixMilli()
- } else {
- nextTimestampMs = snapshots[i+1].TimestampMs
- }
-
- price := s.Price.MulInt64(nextTimestampMs - s.TimestampMs)
- cumulativePrice = cumulativePrice.Add(price)
- }
-
- return cumulativePrice.QuoInt64(ctx.BlockTime().UnixMilli() - firstTimestampMs), nil
-}
-
-func (k Keeper) GetExchangeRate(ctx sdk.Context, pair asset.Pair) (price sdk.Dec, err error) {
- exchangeRate, err := k.ExchangeRates.Get(ctx, pair)
- price = exchangeRate.ExchangeRate
- return
-}
-
-// SetPrice sets the price for a pair as well as the price snapshot.
-func (k Keeper) SetPrice(ctx sdk.Context, pair asset.Pair, price sdk.Dec) {
- k.ExchangeRates.Insert(ctx, pair, types.DatedPrice{ExchangeRate: price, CreatedBlock: uint64(ctx.BlockHeight())})
-
- key := collections.Join(pair, ctx.BlockTime())
- timestampMs := ctx.BlockTime().UnixMilli()
- k.PriceSnapshots.Insert(ctx, key, types.PriceSnapshot{
- Pair: pair,
- Price: price,
- TimestampMs: timestampMs,
- })
- if err := ctx.EventManager().EmitTypedEvent(&types.EventPriceUpdate{
- Pair: pair.String(),
- Price: price,
- TimestampMs: timestampMs,
- }); err != nil {
- ctx.Logger().Error("failed to emit OraclePriceUpdate", "pair", pair, "error", err)
- }
-}
diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go
deleted file mode 100644
index 2aeed42b3..000000000
--- a/x/oracle/keeper/keeper_test.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package keeper
-
-import (
- "testing"
-
- stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/x/staking"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
- "github.com/stretchr/testify/require"
-)
-
-func TestValidateFeeder(t *testing.T) {
- // initial setup
- input := CreateTestFixture(t)
- addr, val := ValAddrs[0], ValPubKeys[0]
- addr1, val1 := ValAddrs[1], ValPubKeys[1]
- amt := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction)
- sh := stakingkeeper.NewMsgServerImpl(&input.StakingKeeper)
- ctx := input.Ctx
-
- // Create 2 validators.
- _, err := sh.CreateValidator(ctx, NewTestMsgCreateValidator(addr, val, amt))
- require.NoError(t, err)
- _, err = sh.CreateValidator(ctx, NewTestMsgCreateValidator(addr1, val1, amt))
- require.NoError(t, err)
- staking.EndBlocker(ctx, &input.StakingKeeper)
-
- require.Equal(
- t, input.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(addr)),
- sdk.NewCoins(sdk.NewCoin(input.StakingKeeper.GetParams(ctx).BondDenom, InitTokens.Sub(amt))),
- )
- require.Equal(t, amt, input.StakingKeeper.Validator(ctx, addr).GetBondedTokens())
- require.Equal(
- t, input.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(addr1)),
- sdk.NewCoins(sdk.NewCoin(input.StakingKeeper.GetParams(ctx).BondDenom, InitTokens.Sub(amt))),
- )
- require.Equal(t, amt, input.StakingKeeper.Validator(ctx, addr1).GetBondedTokens())
-
- require.NoError(t, input.OracleKeeper.ValidateFeeder(input.Ctx, sdk.AccAddress(addr), sdk.ValAddress(addr)))
- require.NoError(t, input.OracleKeeper.ValidateFeeder(input.Ctx, sdk.AccAddress(addr1), sdk.ValAddress(addr1)))
-
- // delegate works
- input.OracleKeeper.FeederDelegations.Insert(input.Ctx, addr, sdk.AccAddress(addr1))
- require.NoError(t, input.OracleKeeper.ValidateFeeder(input.Ctx, sdk.AccAddress(addr1), addr))
- require.Error(t, input.OracleKeeper.ValidateFeeder(input.Ctx, Addrs[2], addr))
-
- // only active validators can do oracle votes
- validator, found := input.StakingKeeper.GetValidator(input.Ctx, addr)
- require.True(t, found)
- validator.Status = stakingtypes.Unbonded
- input.StakingKeeper.SetValidator(input.Ctx, validator)
- require.Error(t, input.OracleKeeper.ValidateFeeder(input.Ctx, sdk.AccAddress(addr1), addr))
-}
diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go
deleted file mode 100644
index c21a8dcd5..000000000
--- a/x/oracle/keeper/msg_server.go
+++ /dev/null
@@ -1,187 +0,0 @@
-package keeper
-
-import (
- "context"
-
- "github.com/cosmos/cosmos-sdk/types/errors"
-
- sdkerrors "cosmossdk.io/errors"
- sdk "github.com/cosmos/cosmos-sdk/types"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
-
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-type msgServer struct {
- Keeper
-}
-
-// NewMsgServerImpl returns an implementation of the oracle MsgServer interface
-// for the provided Keeper.
-func NewMsgServerImpl(keeper Keeper) types.MsgServer {
- return &msgServer{Keeper: keeper}
-}
-
-func (ms msgServer) AggregateExchangeRatePrevote(
- goCtx context.Context,
- msg *types.MsgAggregateExchangeRatePrevote,
-) (*types.MsgAggregateExchangeRatePrevoteResponse, error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- valAddr, err := sdk.ValAddressFromBech32(msg.Validator)
- if err != nil {
- return nil, err
- }
-
- feederAddr, err := sdk.AccAddressFromBech32(msg.Feeder)
- if err != nil {
- return nil, err
- }
-
- if err := ms.ValidateFeeder(ctx, feederAddr, valAddr); err != nil {
- return nil, err
- }
-
- // Convert hex string to votehash
- voteHash, err := types.AggregateVoteHashFromHexString(msg.Hash)
- if err != nil {
- return nil, sdkerrors.Wrap(types.ErrInvalidHash, err.Error())
- }
-
- ms.Keeper.Prevotes.Insert(ctx, valAddr, types.NewAggregateExchangeRatePrevote(voteHash, valAddr, uint64(ctx.BlockHeight())))
-
- err = ctx.EventManager().EmitTypedEvent(&types.EventAggregatePrevote{
- Validator: msg.Validator,
- Feeder: msg.Feeder,
- })
- return &types.MsgAggregateExchangeRatePrevoteResponse{}, err
-}
-
-func (ms msgServer) AggregateExchangeRateVote(
- goCtx context.Context, msg *types.MsgAggregateExchangeRateVote,
-) (msgResp *types.MsgAggregateExchangeRateVoteResponse, err error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- valAddr, err := sdk.ValAddressFromBech32(msg.Validator)
- if err != nil {
- return nil, err
- }
-
- feederAddr, err := sdk.AccAddressFromBech32(msg.Feeder)
- if err != nil {
- return nil, err
- }
-
- if err := ms.ValidateFeeder(ctx, feederAddr, valAddr); err != nil {
- return nil, err
- }
-
- params, err := ms.Keeper.Params.Get(ctx)
- if err != nil {
- return nil, err
- }
-
- // An aggergate prevote is required to get an aggregate vote.
- aggregatePrevote, err := ms.Keeper.Prevotes.Get(ctx, valAddr)
- if err != nil {
- return nil, sdkerrors.Wrap(types.ErrNoAggregatePrevote, msg.Validator)
- }
-
- // Check a msg is submitted proper period
- // This condition necessary for the commit-reveal scheme.
- if (uint64(ctx.BlockHeight())/params.VotePeriod)-(aggregatePrevote.SubmitBlock/params.VotePeriod) != 1 {
- return nil, types.ErrRevealPeriodMissMatch.Wrapf(
- "aggregate prevote block: %d, current block: %d, vote period: %d",
- aggregatePrevote.SubmitBlock, ctx.BlockHeight(), params.VotePeriod,
- )
- }
-
- // Slice of (Pair, ExchangeRate) tuples.
- exchangeRateTuples, err := types.ParseExchangeRateTuples(msg.ExchangeRates)
- if err != nil {
- return nil, sdkerrors.Wrap(errors.ErrInvalidCoins, err.Error())
- }
-
- // Check all pairs are in the vote target
- for _, tuple := range exchangeRateTuples {
- if !ms.IsWhitelistedPair(ctx, tuple.Pair) {
- return nil, sdkerrors.Wrap(types.ErrUnknownPair, tuple.Pair.String())
- }
- }
-
- // Verify an exchange rate with aggregate prevote hash
- hash := types.GetAggregateVoteHash(msg.Salt, msg.ExchangeRates, valAddr)
- if aggregatePrevote.Hash != hash.String() {
- return nil, sdkerrors.Wrapf(
- types.ErrHashVerificationFailed, "must be given %s not %s", aggregatePrevote.Hash, hash,
- )
- }
-
- // Move aggregate prevote to aggregate vote with given exchange rates
- ms.Keeper.Votes.Insert(
- ctx, valAddr, types.NewAggregateExchangeRateVote(exchangeRateTuples, valAddr),
- )
- _ = ms.Keeper.Prevotes.Delete(ctx, valAddr)
-
- priceTuples, err := types.NewExchangeRateTuplesFromString(msg.ExchangeRates)
- if err != nil {
- return
- }
- err = ctx.EventManager().EmitTypedEvent(&types.EventAggregateVote{
- Validator: msg.Validator,
- Feeder: msg.Feeder,
- Prices: priceTuples,
- })
-
- return &types.MsgAggregateExchangeRateVoteResponse{}, err
-}
-
-func (ms msgServer) DelegateFeedConsent(
- goCtx context.Context, msg *types.MsgDelegateFeedConsent,
-) (*types.MsgDelegateFeedConsentResponse, error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- operatorAddr, err := sdk.ValAddressFromBech32(msg.Operator)
- if err != nil {
- return nil, err
- }
-
- delegateAddr, err := sdk.AccAddressFromBech32(msg.Delegate)
- if err != nil {
- return nil, err
- }
-
- // Check the delegator is a validator
- val := ms.StakingKeeper.Validator(ctx, operatorAddr)
- if val == nil {
- return nil, sdkerrors.Wrap(stakingtypes.ErrNoValidatorFound, msg.Operator)
- }
-
- // Set the delegation
- ms.Keeper.FeederDelegations.Insert(ctx, operatorAddr, delegateAddr)
-
- err = ctx.EventManager().EmitTypedEvent(&types.EventDelegateFeederConsent{
- Feeder: msg.Delegate,
- Validator: msg.Operator,
- })
-
- return &types.MsgDelegateFeedConsentResponse{}, err
-}
-
-// EditOracleParams: gRPC tx msg for editing the oracle module params.
-// [SUDO] Only callable by sudoers.
-func (ms msgServer) EditOracleParams(
- goCtx context.Context, msg *types.MsgEditOracleParams,
-) (resp *types.MsgEditOracleParamsResponse, err error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
- // Stateless field validation is already performed in msg.ValidateBasic()
- // before the current scope is reached.
- sender, _ := sdk.AccAddressFromBech32(msg.Sender)
- newParams, err := ms.Sudo().EditOracleParams(
- ctx, *msg, sender,
- )
- resp = &types.MsgEditOracleParamsResponse{
- NewParams: &newParams,
- }
- return resp, err
-}
diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go
deleted file mode 100644
index 0c833dc98..000000000
--- a/x/oracle/keeper/msg_server_test.go
+++ /dev/null
@@ -1,194 +0,0 @@
-package keeper
-
-import (
- "testing"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
-
- "cosmossdk.io/math"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestFeederDelegation(t *testing.T) {
- input, msgServer := Setup(t)
-
- exchangeRates := types.ExchangeRateTuples{
- {
- Pair: asset.Registry.Pair(denoms.BTC, denoms.USD),
- ExchangeRate: testExchangeRate,
- },
- }
-
- exchangeRateStr, err := exchangeRates.ToString()
- require.NoError(t, err)
- salt := "1"
- hash := types.GetAggregateVoteHash(salt, exchangeRateStr, ValAddrs[0])
-
- // Case 1: empty message
- delegateFeedConsentMsg := types.MsgDelegateFeedConsent{}
- _, err = msgServer.DelegateFeedConsent(sdk.WrapSDKContext(input.Ctx), &delegateFeedConsentMsg)
- require.Error(t, err)
-
- // Case 2: Normal Prevote - without delegation
- prevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[0], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(input.Ctx), prevoteMsg)
- require.NoError(t, err)
-
- // Case 2.1: Normal Prevote - with delegation fails
- prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[1], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(input.Ctx), prevoteMsg)
- require.Error(t, err)
-
- // Case 2.2: Normal Vote - without delegation
- voteMsg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, Addrs[0], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx.WithBlockHeight(2)), voteMsg)
- require.NoError(t, err)
-
- // Case 2.3: Normal Vote - with delegation fails
- voteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, Addrs[1], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx.WithBlockHeight(2)), voteMsg)
- require.Error(t, err)
-
- // Case 3: Normal MsgDelegateFeedConsent succeeds
- msg := types.NewMsgDelegateFeedConsent(ValAddrs[0], Addrs[1])
- _, err = msgServer.DelegateFeedConsent(sdk.WrapSDKContext(input.Ctx), msg)
- require.NoError(t, err)
-
- // Case 4.1: Normal Prevote - without delegation fails
- prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[2], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(input.Ctx), prevoteMsg)
- require.Error(t, err)
-
- // Case 4.2: Normal Prevote - with delegation succeeds
- prevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[1], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(input.Ctx), prevoteMsg)
- require.NoError(t, err)
-
- // Case 4.3: Normal Vote - without delegation fails
- voteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, Addrs[2], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx.WithBlockHeight(2)), voteMsg)
- require.Error(t, err)
-
- // Case 4.4: Normal Vote - with delegation succeeds
- voteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, Addrs[1], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx.WithBlockHeight(2)), voteMsg)
- require.NoError(t, err)
-}
-
-func TestAggregatePrevoteVote(t *testing.T) {
- input, msgServer := Setup(t)
-
- salt := "1"
- exchangeRates := types.ExchangeRateTuples{
- {
- Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD),
- ExchangeRate: math.LegacyMustNewDecFromStr("1000.23"),
- },
- {
- Pair: asset.Registry.Pair(denoms.ETH, denoms.USD),
- ExchangeRate: math.LegacyMustNewDecFromStr("0.29"),
- },
-
- {
- Pair: asset.Registry.Pair(denoms.BTC, denoms.USD),
- ExchangeRate: math.LegacyMustNewDecFromStr("0.27"),
- },
- }
-
- otherExchangeRate := types.ExchangeRateTuples{
- {
- Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD),
- ExchangeRate: math.LegacyMustNewDecFromStr("1000.23"),
- },
- {
- Pair: asset.Registry.Pair(denoms.ETH, denoms.USD),
- ExchangeRate: math.LegacyMustNewDecFromStr("0.29"),
- },
-
- {
- Pair: asset.Registry.Pair(denoms.ETH, denoms.USD),
- ExchangeRate: math.LegacyMustNewDecFromStr("0.27"),
- },
- }
-
- unintendedExchangeRateStr := types.ExchangeRateTuples{
- {
- Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD),
- ExchangeRate: math.LegacyMustNewDecFromStr("1000.23"),
- },
- {
- Pair: asset.Registry.Pair(denoms.ETH, denoms.USD),
- ExchangeRate: math.LegacyMustNewDecFromStr("0.29"),
- },
- {
- Pair: "BTC:CNY",
- ExchangeRate: math.LegacyMustNewDecFromStr("0.27"),
- },
- }
- exchangeRatesStr, err := exchangeRates.ToString()
- require.NoError(t, err)
-
- otherExchangeRateStr, err := otherExchangeRate.ToString()
- require.NoError(t, err)
-
- unintendedExchageRateStr, err := unintendedExchangeRateStr.ToString()
- require.NoError(t, err)
-
- hash := types.GetAggregateVoteHash(salt, exchangeRatesStr, ValAddrs[0])
-
- aggregateExchangeRatePrevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[0], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(input.Ctx), aggregateExchangeRatePrevoteMsg)
- require.NoError(t, err)
-
- // Unauthorized feeder
- aggregateExchangeRatePrevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[1], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(input.Ctx), aggregateExchangeRatePrevoteMsg)
- require.Error(t, err)
-
- // Invalid addr
- aggregateExchangeRatePrevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, sdk.AccAddress{}, ValAddrs[0])
- _, err = msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(input.Ctx), aggregateExchangeRatePrevoteMsg)
- require.Error(t, err)
-
- // Invalid validator addr
- aggregateExchangeRatePrevoteMsg = types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[0], sdk.ValAddress{})
- _, err = msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(input.Ctx), aggregateExchangeRatePrevoteMsg)
- require.Error(t, err)
-
- // Invalid reveal period
- aggregateExchangeRateVoteMsg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, Addrs[0], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx), aggregateExchangeRateVoteMsg)
- require.Error(t, err)
-
- // Invalid reveal period
- input.Ctx = input.Ctx.WithBlockHeight(3)
- aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, Addrs[0], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx), aggregateExchangeRateVoteMsg)
- require.Error(t, err)
-
- // Other exchange rate with valid real period
- input.Ctx = input.Ctx.WithBlockHeight(2)
- aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, otherExchangeRateStr, Addrs[0], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx), aggregateExchangeRateVoteMsg)
- require.Error(t, err)
-
- // Unauthorized feeder
- aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, Addrs[1], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx), aggregateExchangeRateVoteMsg)
- require.Error(t, err)
-
- // Unintended denom vote
- aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, unintendedExchageRateStr, Addrs[0], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx), aggregateExchangeRateVoteMsg)
- require.Error(t, err)
-
- // Valid exchange rate reveal submission
- input.Ctx = input.Ctx.WithBlockHeight(2)
- aggregateExchangeRateVoteMsg = types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, Addrs[0], ValAddrs[0])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx), aggregateExchangeRateVoteMsg)
- require.NoError(t, err)
-}
diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go
deleted file mode 100644
index f45f7b3fb..000000000
--- a/x/oracle/keeper/params.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package keeper
-
-import (
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// UpdateParams updates the oracle parameters
-func (k Keeper) UpdateParams(ctx sdk.Context, params types.Params) {
- k.Params.Set(ctx, params)
-}
-
-// VotePeriod returns the number of blocks during which voting takes place.
-func (k Keeper) VotePeriod(ctx sdk.Context) (res uint64) {
- params, _ := k.Params.Get(ctx)
- return params.VotePeriod
-}
-
-// VoteThreshold returns the minimum percentage of votes that must be received for a votes to pass.
-func (k Keeper) VoteThreshold(ctx sdk.Context) (res sdk.Dec) {
- params, _ := k.Params.Get(ctx)
- return params.VoteThreshold
-}
-
-// MinVoters returns the minimum percentage of votes that must be received for a votes to pass.
-func (k Keeper) MinVoters(ctx sdk.Context) (res uint64) {
- params, _ := k.Params.Get(ctx)
- return params.MinVoters
-}
-
-// RewardBand returns a maxium divergence that a price vote can have from the
-// weighted median in the votes. If a vote lies within the valid range
-// defined by:
-//
-// μ := weightedMedian,
-// validRange := μ ± (μ * rewardBand / 2),
-//
-// then rewards are added to the validator performance.
-// Note that if the reward band is smaller than 1 standard
-// deviation, the band is taken to be 1 standard deviation.
-func (k Keeper) RewardBand(ctx sdk.Context) (res sdk.Dec) {
- params, _ := k.Params.Get(ctx)
- return params.RewardBand
-}
-
-// Whitelist returns the pair list that can be activated
-func (k Keeper) Whitelist(ctx sdk.Context) (res []asset.Pair) {
- params, _ := k.Params.Get(ctx)
- return params.Whitelist
-}
-
-// SlashFraction returns oracle voting penalty rate
-func (k Keeper) SlashFraction(ctx sdk.Context) (res sdk.Dec) {
- params, _ := k.Params.Get(ctx)
- return params.SlashFraction
-}
-
-// SlashWindow returns the number of voting periods that specify a "slash window".
-// After each slash window, all oracles that have missed more than the penalty
-// threshold are slashed. Missing the penalty threshold is synonymous with
-// submitting fewer valid votes than `MinValidPerWindow`.
-func (k Keeper) SlashWindow(ctx sdk.Context) (res uint64) {
- params, _ := k.Params.Get(ctx)
- return params.SlashWindow
-}
-
-// MinValidPerWindow returns oracle slashing threshold
-func (k Keeper) MinValidPerWindow(ctx sdk.Context) (res sdk.Dec) {
- params, _ := k.Params.Get(ctx)
- return params.MinValidPerWindow
-}
diff --git a/x/oracle/keeper/params_test.go b/x/oracle/keeper/params_test.go
deleted file mode 100644
index d574440ca..000000000
--- a/x/oracle/keeper/params_test.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package keeper
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestParams(t *testing.T) {
- input := CreateTestFixture(t)
-
- // Test default params setting
- input.OracleKeeper.Params.Set(input.Ctx, types.DefaultParams())
- params, err := input.OracleKeeper.Params.Get(input.Ctx)
- require.NoError(t, err)
- require.NotNil(t, params)
-
- // Test custom params setting
- votePeriod := uint64(10)
- voteThreshold := math.LegacyNewDecWithPrec(33, 2)
- minVoters := uint64(4)
- oracleRewardBand := math.LegacyNewDecWithPrec(1, 2)
- slashFraction := math.LegacyNewDecWithPrec(1, 2)
- slashWindow := uint64(1000)
- minValidPerWindow := math.LegacyNewDecWithPrec(1, 4)
- minFeeRatio := math.LegacyNewDecWithPrec(1, 2)
- whitelist := []asset.Pair{
- asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- asset.Registry.Pair(denoms.ETH, denoms.NUSD),
- }
-
- // Should really test validateParams, but skipping because obvious
- newParams := types.Params{
- VotePeriod: votePeriod,
- VoteThreshold: voteThreshold,
- MinVoters: minVoters,
- RewardBand: oracleRewardBand,
- Whitelist: whitelist,
- SlashFraction: slashFraction,
- SlashWindow: slashWindow,
- MinValidPerWindow: minValidPerWindow,
- ValidatorFeeRatio: minFeeRatio,
- }
- input.OracleKeeper.Params.Set(input.Ctx, newParams)
-
- storedParams, err := input.OracleKeeper.Params.Get(input.Ctx)
- require.NoError(t, err)
- require.NotNil(t, storedParams)
- require.Equal(t, storedParams, newParams)
-}
diff --git a/x/oracle/keeper/querier.go b/x/oracle/keeper/querier.go
deleted file mode 100644
index 7e298c6d4..000000000
--- a/x/oracle/keeper/querier.go
+++ /dev/null
@@ -1,194 +0,0 @@
-package keeper
-
-import (
- "context"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-// querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over q
-type querier struct {
- Keeper
-}
-
-// NewQuerier returns an implementation of the oracle QueryServer interface
-// for the provided Keeper.
-func NewQuerier(keeper Keeper) types.QueryServer {
- return &querier{Keeper: keeper}
-}
-
-var _ types.QueryServer = querier{}
-
-// Params queries params of distribution module
-func (q querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
- var params types.Params
-
- params, err := q.Keeper.Params.Get(ctx)
- if err != nil {
- return nil, err
- }
-
- return &types.QueryParamsResponse{Params: params}, nil
-}
-
-// ExchangeRate queries exchange rate of a pair
-func (q querier) ExchangeRate(c context.Context, req *types.QueryExchangeRateRequest) (*types.QueryExchangeRateResponse, error) {
- if req == nil {
- return nil, status.Error(codes.InvalidArgument, "invalid request")
- }
-
- if len(req.Pair) == 0 {
- return nil, status.Error(codes.InvalidArgument, "empty pair")
- }
-
- ctx := sdk.UnwrapSDKContext(c)
- exchangeRate, err := q.Keeper.GetExchangeRate(ctx, req.Pair)
- if err != nil {
- return nil, err
- }
-
- return &types.QueryExchangeRateResponse{ExchangeRate: exchangeRate}, nil
-}
-
-/*
-Gets the time-weighted average price from ( ctx.BlockTime() - interval, ctx.BlockTime() ]
-Note the open-ended right bracket.
-
-If there's only one snapshot, then this function returns the price from that single snapshot.
-
-Returns -1 if there's no price.
-*/
-func (q querier) ExchangeRateTwap(c context.Context, req *types.QueryExchangeRateRequest) (response *types.QueryExchangeRateResponse, err error) {
- if _, err = q.ExchangeRate(c, req); err != nil {
- return
- }
-
- ctx := sdk.UnwrapSDKContext(c)
- twap, err := q.Keeper.GetExchangeRateTwap(ctx, req.Pair)
- if err != nil {
- return &types.QueryExchangeRateResponse{}, err
- }
- return &types.QueryExchangeRateResponse{ExchangeRate: twap}, nil
-}
-
-// ExchangeRates queries exchange rates of all pairs
-func (q querier) ExchangeRates(c context.Context, _ *types.QueryExchangeRatesRequest) (*types.QueryExchangeRatesResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
-
- var exchangeRates types.ExchangeRateTuples
- for _, er := range q.Keeper.ExchangeRates.Iterate(ctx, collections.Range[asset.Pair]{}).KeyValues() {
- exchangeRates = append(exchangeRates, types.ExchangeRateTuple{
- Pair: er.Key,
- ExchangeRate: er.Value.ExchangeRate,
- })
- }
-
- return &types.QueryExchangeRatesResponse{ExchangeRates: exchangeRates}, nil
-}
-
-// Actives queries all pairs for which exchange rates exist
-func (q querier) Actives(c context.Context, _ *types.QueryActivesRequest) (*types.QueryActivesResponse, error) {
- return &types.QueryActivesResponse{Actives: q.Keeper.ExchangeRates.Iterate(sdk.UnwrapSDKContext(c), collections.Range[asset.Pair]{}).Keys()}, nil
-}
-
-// VoteTargets queries the voting target list on current vote period
-func (q querier) VoteTargets(c context.Context, _ *types.QueryVoteTargetsRequest) (*types.QueryVoteTargetsResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
- return &types.QueryVoteTargetsResponse{VoteTargets: q.GetWhitelistedPairs(ctx)}, nil
-}
-
-// FeederDelegation queries the account address that the validator operator delegated oracle vote rights to
-func (q querier) FeederDelegation(c context.Context, req *types.QueryFeederDelegationRequest) (*types.QueryFeederDelegationResponse, error) {
- if req == nil {
- return nil, status.Error(codes.InvalidArgument, "invalid request")
- }
-
- valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddr)
- if err != nil {
- return nil, status.Error(codes.InvalidArgument, err.Error())
- }
-
- ctx := sdk.UnwrapSDKContext(c)
- return &types.QueryFeederDelegationResponse{
- FeederAddr: q.Keeper.FeederDelegations.GetOr(ctx, valAddr, sdk.AccAddress(valAddr)).String(),
- }, nil
-}
-
-// MissCounter queries oracle miss counter of a validator
-func (q querier) MissCounter(c context.Context, req *types.QueryMissCounterRequest) (*types.QueryMissCounterResponse, error) {
- if req == nil {
- return nil, status.Error(codes.InvalidArgument, "invalid request")
- }
-
- valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddr)
- if err != nil {
- return nil, status.Error(codes.InvalidArgument, err.Error())
- }
-
- ctx := sdk.UnwrapSDKContext(c)
- return &types.QueryMissCounterResponse{
- MissCounter: q.MissCounters.GetOr(ctx, valAddr, 0),
- }, nil
-}
-
-// AggregatePrevote queries an aggregate prevote of a validator
-func (q querier) AggregatePrevote(c context.Context, req *types.QueryAggregatePrevoteRequest) (*types.QueryAggregatePrevoteResponse, error) {
- if req == nil {
- return nil, status.Error(codes.InvalidArgument, "invalid request")
- }
-
- valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddr)
- if err != nil {
- return nil, status.Error(codes.InvalidArgument, err.Error())
- }
-
- ctx := sdk.UnwrapSDKContext(c)
- prevote, err := q.Prevotes.Get(ctx, valAddr)
- if err != nil {
- return nil, err
- }
-
- return &types.QueryAggregatePrevoteResponse{
- AggregatePrevote: prevote,
- }, nil
-}
-
-// AggregatePrevotes queries aggregate prevotes of all validators
-func (q querier) AggregatePrevotes(c context.Context, _ *types.QueryAggregatePrevotesRequest) (*types.QueryAggregatePrevotesResponse, error) {
- return &types.QueryAggregatePrevotesResponse{AggregatePrevotes: q.Prevotes.Iterate(sdk.UnwrapSDKContext(c), collections.Range[sdk.ValAddress]{}).Values()}, nil
-}
-
-// AggregateVote queries an aggregate vote of a validator
-func (q querier) AggregateVote(c context.Context, req *types.QueryAggregateVoteRequest) (*types.QueryAggregateVoteResponse, error) {
- if req == nil {
- return nil, status.Error(codes.InvalidArgument, "invalid request")
- }
-
- valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddr)
- if err != nil {
- return nil, status.Error(codes.InvalidArgument, err.Error())
- }
-
- ctx := sdk.UnwrapSDKContext(c)
- vote, err := q.Keeper.Votes.Get(ctx, valAddr)
- if err != nil {
- return nil, err
- }
-
- return &types.QueryAggregateVoteResponse{
- AggregateVote: vote,
- }, nil
-}
-
-// AggregateVotes queries aggregate votes of all validators
-func (q querier) AggregateVotes(c context.Context, _ *types.QueryAggregateVotesRequest) (*types.QueryAggregateVotesResponse, error) {
- return &types.QueryAggregateVotesResponse{AggregateVotes: q.Keeper.Votes.Iterate(sdk.UnwrapSDKContext(c), collections.Range[sdk.ValAddress]{}).Values()}, nil
-}
diff --git a/x/oracle/keeper/querier_test.go b/x/oracle/keeper/querier_test.go
deleted file mode 100644
index be92c347d..000000000
--- a/x/oracle/keeper/querier_test.go
+++ /dev/null
@@ -1,365 +0,0 @@
-package keeper
-
-import (
- "sort"
- "testing"
- "time"
-
- "cosmossdk.io/math"
- "github.com/NibiruChain/collections"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
-
- testutilevents "github.com/NibiruChain/nibiru/x/common/testutil"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestQueryParams(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
-
- querier := NewQuerier(input.OracleKeeper)
- res, err := querier.Params(ctx, &types.QueryParamsRequest{})
- require.NoError(t, err)
-
- params, err := input.OracleKeeper.Params.Get(input.Ctx)
- require.NoError(t, err)
-
- require.Equal(t, params, res.Params)
-}
-
-func TestQueryExchangeRate(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
- querier := NewQuerier(input.OracleKeeper)
-
- rate := math.LegacyNewDec(1700)
- input.OracleKeeper.ExchangeRates.Insert(input.Ctx, asset.Registry.Pair(denoms.ETH, denoms.NUSD), types.DatedPrice{ExchangeRate: rate, CreatedBlock: uint64(input.Ctx.BlockHeight())})
-
- // empty request
- _, err := querier.ExchangeRate(ctx, nil)
- require.Error(t, err)
-
- // Query to grpc
- res, err := querier.ExchangeRate(ctx, &types.QueryExchangeRateRequest{
- Pair: asset.Registry.Pair(denoms.ETH, denoms.NUSD),
- })
- require.NoError(t, err)
- require.Equal(t, rate, res.ExchangeRate)
-}
-
-func TestQueryMissCounter(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
- querier := NewQuerier(input.OracleKeeper)
-
- missCounter := uint64(1)
- input.OracleKeeper.MissCounters.Insert(input.Ctx, ValAddrs[0], missCounter)
-
- // empty request
- _, err := querier.MissCounter(ctx, nil)
- require.Error(t, err)
-
- // Query to grpc
- res, err := querier.MissCounter(ctx, &types.QueryMissCounterRequest{
- ValidatorAddr: ValAddrs[0].String(),
- })
- require.NoError(t, err)
- require.Equal(t, missCounter, res.MissCounter)
-}
-
-func TestQueryExchangeRates(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
- querier := NewQuerier(input.OracleKeeper)
-
- rate := math.LegacyNewDec(1700)
- input.OracleKeeper.ExchangeRates.Insert(input.Ctx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), types.DatedPrice{ExchangeRate: rate, CreatedBlock: uint64(input.Ctx.BlockHeight())})
- input.OracleKeeper.ExchangeRates.Insert(input.Ctx, asset.Registry.Pair(denoms.ETH, denoms.NUSD), types.DatedPrice{ExchangeRate: rate, CreatedBlock: uint64(input.Ctx.BlockHeight())})
-
- res, err := querier.ExchangeRates(ctx, &types.QueryExchangeRatesRequest{})
- require.NoError(t, err)
-
- require.Equal(t, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD), ExchangeRate: rate},
- {Pair: asset.Registry.Pair(denoms.ETH, denoms.NUSD), ExchangeRate: rate},
- }, res.ExchangeRates)
-}
-
-func TestQueryExchangeRateTwap(t *testing.T) {
- input := CreateTestFixture(t)
- querier := NewQuerier(input.OracleKeeper)
-
- rate := math.LegacyNewDec(1700)
- input.OracleKeeper.SetPrice(input.Ctx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), rate)
- testutilevents.RequireContainsTypedEvent(
- t,
- input.Ctx,
- &types.EventPriceUpdate{
- Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD).String(),
- Price: rate,
- TimestampMs: input.Ctx.BlockTime().UnixMilli(),
- },
- )
-
- ctx := sdk.WrapSDKContext(input.Ctx.
- WithBlockTime(input.Ctx.BlockTime().Add(time.Second)).
- WithBlockHeight(input.Ctx.BlockHeight() + 1),
- )
-
- _, err := querier.ExchangeRateTwap(ctx, &types.QueryExchangeRateRequest{Pair: asset.Registry.Pair(denoms.ETH, denoms.NUSD)})
- require.Error(t, err)
-
- res, err := querier.ExchangeRateTwap(ctx, &types.QueryExchangeRateRequest{Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD)})
- require.NoError(t, err)
- require.Equal(t, math.LegacyMustNewDecFromStr("1700"), res.ExchangeRate)
-}
-
-func TestCalcTwap(t *testing.T) {
- tests := []struct {
- name string
- pair asset.Pair
- priceSnapshots []types.PriceSnapshot
- currentBlockTime time.Time
- currentBlockHeight int64
- lookbackInterval time.Duration
- assetAmount sdk.Dec
- expectedPrice sdk.Dec
- expectedErr error
- }{
- // expected price: (9.5 * (35 - 30) + 8.5 * (30 - 20) + 9.0 * (20 - 5)) / 30 = 8.916666
- {
- name: "spot price twap calc, t=(5,35]",
- pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- priceSnapshots: []types.PriceSnapshot{
- {
- Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- Price: math.LegacyMustNewDecFromStr("90000.0"),
- TimestampMs: time.UnixMilli(1).UnixMilli(),
- },
- {
- Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- Price: math.LegacyMustNewDecFromStr("9.0"),
- TimestampMs: time.UnixMilli(10).UnixMilli(),
- },
- {
- Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- Price: math.LegacyMustNewDecFromStr("8.5"),
- TimestampMs: time.UnixMilli(20).UnixMilli(),
- },
- {
- Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- Price: math.LegacyMustNewDecFromStr("9.5"),
- TimestampMs: time.UnixMilli(30).UnixMilli(),
- },
- },
- currentBlockTime: time.UnixMilli(35),
- currentBlockHeight: 3,
- lookbackInterval: 30 * time.Millisecond,
- expectedPrice: math.LegacyMustNewDecFromStr("8.900000000000000000"),
- },
- }
-
- for _, tc := range tests {
- tc := tc
- t.Run(tc.name, func(t *testing.T) {
- input := CreateTestFixture(t)
- querier := NewQuerier(input.OracleKeeper)
- ctx := input.Ctx
-
- newParams := types.Params{
- VotePeriod: types.DefaultVotePeriod,
- VoteThreshold: types.DefaultVoteThreshold,
- MinVoters: types.DefaultMinVoters,
- RewardBand: types.DefaultRewardBand,
- Whitelist: types.DefaultWhitelist,
- SlashFraction: types.DefaultSlashFraction,
- SlashWindow: types.DefaultSlashWindow,
- MinValidPerWindow: types.DefaultMinValidPerWindow,
- TwapLookbackWindow: tc.lookbackInterval,
- ValidatorFeeRatio: types.DefaultValidatorFeeRatio,
- }
-
- input.OracleKeeper.Params.Set(ctx, newParams)
- ctx = ctx.WithBlockTime(time.UnixMilli(0))
- for _, reserve := range tc.priceSnapshots {
- ctx = ctx.WithBlockTime(time.UnixMilli(reserve.TimestampMs))
- input.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), reserve.Price)
- }
-
- ctx = ctx.WithBlockTime(tc.currentBlockTime).WithBlockHeight(tc.currentBlockHeight)
-
- price, err := querier.ExchangeRateTwap(sdk.WrapSDKContext(ctx), &types.QueryExchangeRateRequest{Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD)})
- require.NoError(t, err)
-
- require.EqualValuesf(t, tc.expectedPrice, price.ExchangeRate,
- "expected %s, got %s", tc.expectedPrice.String(), price.ExchangeRate.String())
- })
- }
-}
-
-func TestQueryActives(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
- queryClient := NewQuerier(input.OracleKeeper)
-
- rate := math.LegacyNewDec(1700)
- input.OracleKeeper.ExchangeRates.Insert(input.Ctx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), types.DatedPrice{ExchangeRate: rate, CreatedBlock: uint64(input.Ctx.BlockHeight())})
- input.OracleKeeper.ExchangeRates.Insert(input.Ctx, asset.Registry.Pair(denoms.NIBI, denoms.NUSD), types.DatedPrice{ExchangeRate: rate, CreatedBlock: uint64(input.Ctx.BlockHeight())})
- input.OracleKeeper.ExchangeRates.Insert(input.Ctx, asset.Registry.Pair(denoms.ETH, denoms.NUSD), types.DatedPrice{ExchangeRate: rate, CreatedBlock: uint64(input.Ctx.BlockHeight())})
-
- res, err := queryClient.Actives(ctx, &types.QueryActivesRequest{})
- require.NoError(t, err)
-
- targetPairs := []asset.Pair{
- asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- asset.Registry.Pair(denoms.ETH, denoms.NUSD),
- asset.Registry.Pair(denoms.NIBI, denoms.NUSD),
- }
-
- require.Equal(t, targetPairs, res.Actives)
-}
-
-func TestQueryFeederDelegation(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
- querier := NewQuerier(input.OracleKeeper)
-
- input.OracleKeeper.FeederDelegations.Insert(input.Ctx, ValAddrs[0], Addrs[1])
-
- // empty request
- _, err := querier.FeederDelegation(ctx, nil)
- require.Error(t, err)
-
- res, err := querier.FeederDelegation(ctx, &types.QueryFeederDelegationRequest{
- ValidatorAddr: ValAddrs[0].String(),
- })
- require.NoError(t, err)
-
- require.Equal(t, Addrs[1].String(), res.FeederAddr)
-}
-
-func TestQueryAggregatePrevote(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
- querier := NewQuerier(input.OracleKeeper)
-
- prevote1 := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{}, ValAddrs[0], 0)
- input.OracleKeeper.Prevotes.Insert(input.Ctx, ValAddrs[0], prevote1)
- prevote2 := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{}, ValAddrs[1], 0)
- input.OracleKeeper.Prevotes.Insert(input.Ctx, ValAddrs[1], prevote2)
-
- // validator 0 address params
- res, err := querier.AggregatePrevote(ctx, &types.QueryAggregatePrevoteRequest{
- ValidatorAddr: ValAddrs[0].String(),
- })
- require.NoError(t, err)
- require.Equal(t, prevote1, res.AggregatePrevote)
-
- // empty request
- _, err = querier.AggregatePrevote(ctx, nil)
- require.Error(t, err)
-
- // validator 1 address params
- res, err = querier.AggregatePrevote(ctx, &types.QueryAggregatePrevoteRequest{
- ValidatorAddr: ValAddrs[1].String(),
- })
- require.NoError(t, err)
- require.Equal(t, prevote2, res.AggregatePrevote)
-}
-
-func TestQueryAggregatePrevotes(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
- querier := NewQuerier(input.OracleKeeper)
-
- prevote1 := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{}, ValAddrs[0], 0)
- input.OracleKeeper.Prevotes.Insert(input.Ctx, ValAddrs[0], prevote1)
- prevote2 := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{}, ValAddrs[1], 0)
- input.OracleKeeper.Prevotes.Insert(input.Ctx, ValAddrs[1], prevote2)
- prevote3 := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash{}, ValAddrs[2], 0)
- input.OracleKeeper.Prevotes.Insert(input.Ctx, ValAddrs[2], prevote3)
-
- expectedPrevotes := []types.AggregateExchangeRatePrevote{prevote1, prevote2, prevote3}
- sort.SliceStable(expectedPrevotes, func(i, j int) bool {
- return expectedPrevotes[i].Voter <= expectedPrevotes[j].Voter
- })
-
- res, err := querier.AggregatePrevotes(ctx, &types.QueryAggregatePrevotesRequest{})
- require.NoError(t, err)
- require.Equal(t, expectedPrevotes, res.AggregatePrevotes)
-}
-
-func TestQueryAggregateVote(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
- querier := NewQuerier(input.OracleKeeper)
-
- vote1 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Pair: "", ExchangeRate: math.LegacyOneDec()}}, ValAddrs[0])
- input.OracleKeeper.Votes.Insert(input.Ctx, ValAddrs[0], vote1)
- vote2 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Pair: "", ExchangeRate: math.LegacyOneDec()}}, ValAddrs[1])
- input.OracleKeeper.Votes.Insert(input.Ctx, ValAddrs[1], vote2)
-
- // empty request
- _, err := querier.AggregateVote(ctx, nil)
- require.Error(t, err)
-
- // validator 0 address params
- res, err := querier.AggregateVote(ctx, &types.QueryAggregateVoteRequest{
- ValidatorAddr: ValAddrs[0].String(),
- })
- require.NoError(t, err)
- require.Equal(t, vote1, res.AggregateVote)
-
- // validator 1 address params
- res, err = querier.AggregateVote(ctx, &types.QueryAggregateVoteRequest{
- ValidatorAddr: ValAddrs[1].String(),
- })
- require.NoError(t, err)
- require.Equal(t, vote2, res.AggregateVote)
-}
-
-func TestQueryAggregateVotes(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
- querier := NewQuerier(input.OracleKeeper)
-
- vote1 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Pair: "", ExchangeRate: math.LegacyOneDec()}}, ValAddrs[0])
- input.OracleKeeper.Votes.Insert(input.Ctx, ValAddrs[0], vote1)
- vote2 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Pair: "", ExchangeRate: math.LegacyOneDec()}}, ValAddrs[1])
- input.OracleKeeper.Votes.Insert(input.Ctx, ValAddrs[1], vote2)
- vote3 := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{{Pair: "", ExchangeRate: math.LegacyOneDec()}}, ValAddrs[2])
- input.OracleKeeper.Votes.Insert(input.Ctx, ValAddrs[2], vote3)
-
- expectedVotes := []types.AggregateExchangeRateVote{vote1, vote2, vote3}
- sort.SliceStable(expectedVotes, func(i, j int) bool {
- return expectedVotes[i].Voter <= expectedVotes[j].Voter
- })
-
- res, err := querier.AggregateVotes(ctx, &types.QueryAggregateVotesRequest{})
- require.NoError(t, err)
- require.Equal(t, expectedVotes, res.AggregateVotes)
-}
-
-func TestQueryVoteTargets(t *testing.T) {
- input := CreateTestFixture(t)
- ctx := sdk.WrapSDKContext(input.Ctx)
- querier := NewQuerier(input.OracleKeeper)
-
- // clear pairs
- for _, p := range input.OracleKeeper.WhitelistedPairs.Iterate(input.Ctx, collections.Range[asset.Pair]{}).Keys() {
- input.OracleKeeper.WhitelistedPairs.Delete(input.Ctx, p)
- }
-
- voteTargets := []asset.Pair{"denom1:denom2", "denom3:denom4", "denom5:denom6"}
- for _, target := range voteTargets {
- input.OracleKeeper.WhitelistedPairs.Insert(input.Ctx, target)
- }
-
- res, err := querier.VoteTargets(ctx, &types.QueryVoteTargetsRequest{})
- require.NoError(t, err)
- require.Equal(t, voteTargets, res.VoteTargets)
-}
diff --git a/x/oracle/keeper/reward.go b/x/oracle/keeper/reward.go
deleted file mode 100644
index 35688c2da..000000000
--- a/x/oracle/keeper/reward.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package keeper
-
-import (
- "github.com/NibiruChain/collections"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func (k Keeper) AllocateRewards(ctx sdk.Context, funderModule string, totalCoins sdk.Coins, votePeriods uint64) error {
- votePeriodCoins := make(sdk.Coins, len(totalCoins))
- for i, coin := range totalCoins {
- newCoin := sdk.NewCoin(coin.Denom, coin.Amount.QuoRaw(int64(votePeriods)))
- votePeriodCoins[i] = newCoin
- }
-
- id := k.RewardsID.Next(ctx)
- k.Rewards.Insert(ctx, id, types.Rewards{
- Id: id,
- VotePeriods: votePeriods,
- Coins: votePeriodCoins,
- })
-
- return k.bankKeeper.SendCoinsFromModuleToModule(ctx, funderModule, types.ModuleName, totalCoins)
-}
-
-// rewardWinners gives out a portion of spread fees collected in the
-// oracle reward pool to the oracle voters that voted faithfully.
-func (k Keeper) rewardWinners(
- ctx sdk.Context,
- validatorPerformances types.ValidatorPerformances,
-) {
- totalRewardWeight := validatorPerformances.TotalRewardWeight()
- if totalRewardWeight == 0 {
- return
- }
-
- var totalRewards sdk.DecCoins
- rewards := k.GatherRewardsForVotePeriod(ctx)
- totalRewards = totalRewards.Add(sdk.NewDecCoinsFromCoins(rewards...)...)
-
- var distributedRewards sdk.Coins
- for _, validatorPerformance := range validatorPerformances {
- validator := k.StakingKeeper.Validator(ctx, validatorPerformance.ValAddress)
- if validator == nil {
- continue
- }
-
- rewardPortion, _ := totalRewards.MulDec(math.LegacyNewDec(validatorPerformance.RewardWeight).QuoInt64(totalRewardWeight)).TruncateDecimal()
- k.distrKeeper.AllocateTokensToValidator(ctx, validator, sdk.NewDecCoinsFromCoins(rewardPortion...))
- distributedRewards = distributedRewards.Add(rewardPortion...)
- }
-
- // Move distributed reward to distribution module
- err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.distrModuleName, distributedRewards)
- if err != nil {
- k.Logger(ctx).Error("Failed to send coins to distribution module", "err", err)
- }
-}
-
-// GatherRewardsForVotePeriod retrieves the pair rewards for the provided pair and current vote period.
-func (k Keeper) GatherRewardsForVotePeriod(ctx sdk.Context) sdk.Coins {
- coins := sdk.NewCoins()
- // iterate over
- for _, rewardId := range k.Rewards.Iterate(ctx, collections.Range[uint64]{}).Keys() {
- pairReward, err := k.Rewards.Get(ctx, rewardId)
- if err != nil {
- k.Logger(ctx).Error("Failed to get reward", "err", err)
- continue
- }
- coins = coins.Add(pairReward.Coins...)
-
- // Decrease the remaining vote periods of the PairReward.
- pairReward.VotePeriods -= 1
- if pairReward.VotePeriods == 0 {
- // If the distribution period count drops to 0: the reward instance is removed.
- err := k.Rewards.Delete(ctx, rewardId)
- if err != nil {
- k.Logger(ctx).Error("Failed to delete pair reward", "err", err)
- }
- } else {
- k.Rewards.Insert(ctx, rewardId, pairReward)
- }
- }
-
- return coins
-}
diff --git a/x/oracle/keeper/reward_test.go b/x/oracle/keeper/reward_test.go
deleted file mode 100644
index 47f3b8f73..000000000
--- a/x/oracle/keeper/reward_test.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package keeper
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- "github.com/NibiruChain/collections"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common"
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestKeeperRewardsDistributionMultiVotePeriods(t *testing.T) {
- // this simulates allocating rewards for the pair atom:usd
- // over 5 voting periods. It simulates rewards are correctly
- // distributed over 5 voting periods to 5 validators.
- // then we simulate that after the 5 voting periods are
- // finished no more rewards distribution happen.
- const periods uint64 = 5
- const validators = 5
-
- fixture, msgServer := Setup(t)
- votePeriod := fixture.OracleKeeper.VotePeriod(fixture.Ctx)
-
- rewards := sdk.NewInt64Coin("reward", 1*common.TO_MICRO)
- valPeriodicRewards := sdk.NewDecCoinsFromCoins(rewards).
- QuoDec(math.LegacyNewDec(int64(periods))).
- QuoDec(math.LegacyNewDec(int64(validators)))
- AllocateRewards(t, fixture, sdk.NewCoins(rewards), periods)
-
- for i := uint64(1); i <= periods; i++ {
- for valIndex := 0; valIndex < validators; valIndex++ {
- // for doc's sake, this function is capable of making prevotes and votes because it
- // passes the current context block height for pre vote
- // then changes the height to current height + vote period for the vote
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, fixture.Ctx.BlockHeight(), types.ExchangeRateTuples{
- {
- Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD),
- ExchangeRate: testExchangeRate,
- },
- }, valIndex)
- }
-
- fixture.OracleKeeper.UpdateExchangeRates(fixture.Ctx)
-
- for valIndex := 0; valIndex < validators; valIndex++ {
- distributionRewards := fixture.DistrKeeper.GetValidatorOutstandingRewards(fixture.Ctx, ValAddrs[0])
- truncatedGot, _ := distributionRewards.Rewards.
- QuoDec(math.LegacyNewDec(int64(i))). // outstanding rewards will count for the previous vote period too, so we divide it by current period
- TruncateDecimal() // NOTE: not applying this on truncatedExpected because of rounding the test fails
- truncatedExpected, _ := valPeriodicRewards.TruncateDecimal()
-
- require.Equalf(t, truncatedExpected, truncatedGot, "period: %d, %s <-> %s", i, truncatedExpected.String(), truncatedGot.String())
- }
- // assert rewards
-
- fixture.Ctx = fixture.Ctx.WithBlockHeight(fixture.Ctx.BlockHeight() + int64(votePeriod))
- }
-
- // assert there are no rewards
- require.True(t, fixture.OracleKeeper.GatherRewardsForVotePeriod(fixture.Ctx).IsZero())
-
- // assert that there are no rewards instances
- require.Empty(t, fixture.OracleKeeper.Rewards.Iterate(fixture.Ctx, collections.Range[uint64]{}).Keys())
-}
diff --git a/x/oracle/keeper/slash.go b/x/oracle/keeper/slash.go
deleted file mode 100644
index 63d3885bd..000000000
--- a/x/oracle/keeper/slash.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package keeper
-
-import (
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/collections"
-)
-
-// SlashAndResetMissCounters do slash any operator who over criteria & clear all operators miss counter to zero
-func (k Keeper) SlashAndResetMissCounters(ctx sdk.Context) {
- height := ctx.BlockHeight()
- distributionHeight := height - sdk.ValidatorUpdateDelay - 1
-
- // slash_window / vote_period
- votePeriodsPerWindow := uint64(
- math.LegacyNewDec(int64(k.SlashWindow(ctx))).
- QuoInt64(int64(k.VotePeriod(ctx))).
- TruncateInt64(),
- )
- minValidPerWindow := k.MinValidPerWindow(ctx)
- slashFraction := k.SlashFraction(ctx)
- powerReduction := k.StakingKeeper.PowerReduction(ctx)
-
- for _, mc := range k.MissCounters.Iterate(ctx, collections.Range[sdk.ValAddress]{}).KeyValues() {
- operator := mc.Key
- missCounter := mc.Value
- // Calculate valid vote rate; (SlashWindow - MissCounter)/SlashWindow
- validVoteRate := math.LegacyNewDecFromInt(
- math.NewInt(int64(votePeriodsPerWindow - missCounter))).
- QuoInt64(int64(votePeriodsPerWindow))
-
- // Penalize the validator whose the valid vote rate is smaller than min threshold
- if validVoteRate.LT(minValidPerWindow) {
- validator := k.StakingKeeper.Validator(ctx, operator)
- if validator.IsBonded() && !validator.IsJailed() {
- consAddr, err := validator.GetConsAddr()
- if err != nil {
- k.Logger(ctx).Error("fail to get consensus address", "validator", validator.GetOperator().String())
- continue
- }
-
- k.slashingKeeper.Slash(
- ctx, consAddr, slashFraction, validator.GetConsensusPower(powerReduction), distributionHeight,
- )
- k.Logger(ctx).Info("oracle slash", "validator", consAddr.String(), "fraction", slashFraction.String())
- k.slashingKeeper.Jail(ctx, consAddr)
- }
- }
-
- err := k.MissCounters.Delete(ctx, operator)
- if err != nil {
- k.Logger(ctx).Error("fail to delete miss counter", "operator", operator.String(), "error", err)
- }
- }
-}
diff --git a/x/oracle/keeper/slash_test.go b/x/oracle/keeper/slash_test.go
deleted file mode 100644
index 51f8d0436..000000000
--- a/x/oracle/keeper/slash_test.go
+++ /dev/null
@@ -1,269 +0,0 @@
-package keeper
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/x/staking"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestSlashAndResetMissCounters(t *testing.T) {
- // initial setup
- input := CreateTestFixture(t)
- addr, val := ValAddrs[0], ValPubKeys[0]
- addr1, val1 := ValAddrs[1], ValPubKeys[1]
- amt := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction)
- sh := stakingkeeper.NewMsgServerImpl(&input.StakingKeeper)
- ctx := input.Ctx
-
- // Validator created
- _, err := sh.CreateValidator(ctx, NewTestMsgCreateValidator(addr, val, amt))
- require.NoError(t, err)
- _, err = sh.CreateValidator(ctx, NewTestMsgCreateValidator(addr1, val1, amt))
- require.NoError(t, err)
- staking.EndBlocker(ctx, &input.StakingKeeper)
-
- require.Equal(
- t, input.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(addr)),
- sdk.NewCoins(sdk.NewCoin(input.StakingKeeper.GetParams(ctx).BondDenom, InitTokens.Sub(amt))),
- )
- require.Equal(t, amt, input.StakingKeeper.Validator(ctx, addr).GetBondedTokens())
- require.Equal(
- t, input.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(addr1)),
- sdk.NewCoins(sdk.NewCoin(input.StakingKeeper.GetParams(ctx).BondDenom, InitTokens.Sub(amt))),
- )
- require.Equal(t, amt, input.StakingKeeper.Validator(ctx, addr1).GetBondedTokens())
-
- votePeriodsPerWindow := math.LegacyNewDec(int64(input.OracleKeeper.SlashWindow(input.Ctx))).QuoInt64(int64(input.OracleKeeper.VotePeriod(input.Ctx))).TruncateInt64()
- slashFraction := input.OracleKeeper.SlashFraction(input.Ctx)
- minValidVotes := input.OracleKeeper.MinValidPerWindow(input.Ctx).MulInt64(votePeriodsPerWindow).Ceil().TruncateInt64()
- // Case 1, no slash
- input.OracleKeeper.MissCounters.Insert(input.Ctx, ValAddrs[0], uint64(votePeriodsPerWindow-minValidVotes))
- input.OracleKeeper.SlashAndResetMissCounters(input.Ctx)
- staking.EndBlocker(input.Ctx, &input.StakingKeeper)
-
- validator, _ := input.StakingKeeper.GetValidator(input.Ctx, ValAddrs[0])
- require.Equal(t, amt, validator.GetBondedTokens())
-
- // Case 2, slash
- input.OracleKeeper.MissCounters.Insert(input.Ctx, ValAddrs[0], uint64(votePeriodsPerWindow-minValidVotes+1))
- input.OracleKeeper.SlashAndResetMissCounters(input.Ctx)
- validator, _ = input.StakingKeeper.GetValidator(input.Ctx, ValAddrs[0])
- require.Equal(t, amt.Sub(slashFraction.MulInt(amt).TruncateInt()), validator.GetBondedTokens())
- require.True(t, validator.IsJailed())
-
- // Case 3, slash unbonded validator
- validator, _ = input.StakingKeeper.GetValidator(input.Ctx, ValAddrs[0])
- validator.Status = stakingtypes.Unbonded
- validator.Jailed = false
- validator.Tokens = amt
- input.StakingKeeper.SetValidator(input.Ctx, validator)
-
- input.OracleKeeper.MissCounters.Insert(input.Ctx, ValAddrs[0], uint64(votePeriodsPerWindow-minValidVotes+1))
- input.OracleKeeper.SlashAndResetMissCounters(input.Ctx)
- validator, _ = input.StakingKeeper.GetValidator(input.Ctx, ValAddrs[0])
- require.Equal(t, amt, validator.Tokens)
- require.False(t, validator.IsJailed())
-
- // Case 4, slash jailed validator
- validator, _ = input.StakingKeeper.GetValidator(input.Ctx, ValAddrs[0])
- validator.Status = stakingtypes.Bonded
- validator.Jailed = true
- validator.Tokens = amt
- input.StakingKeeper.SetValidator(input.Ctx, validator)
-
- input.OracleKeeper.MissCounters.Insert(input.Ctx, ValAddrs[0], uint64(votePeriodsPerWindow-minValidVotes+1))
- input.OracleKeeper.SlashAndResetMissCounters(input.Ctx)
- validator, _ = input.StakingKeeper.GetValidator(input.Ctx, ValAddrs[0])
- require.Equal(t, amt, validator.Tokens)
-}
-
-func TestInvalidVotesSlashing(t *testing.T) {
- input, h := Setup(t)
- params, err := input.OracleKeeper.Params.Get(input.Ctx)
- require.NoError(t, err)
- params.Whitelist = []asset.Pair{asset.Registry.Pair(denoms.ATOM, denoms.USD)}
- input.OracleKeeper.Params.Set(input.Ctx, params)
- input.OracleKeeper.WhitelistedPairs.Insert(input.Ctx, asset.Registry.Pair(denoms.ATOM, denoms.USD))
-
- votePeriodsPerWindow := math.LegacyNewDec(int64(input.OracleKeeper.SlashWindow(input.Ctx))).QuoInt64(int64(input.OracleKeeper.VotePeriod(input.Ctx))).TruncateInt64()
- slashFraction := input.OracleKeeper.SlashFraction(input.Ctx)
- minValidPerWindow := input.OracleKeeper.MinValidPerWindow(input.Ctx)
-
- for i := uint64(0); i < uint64(math.LegacyOneDec().Sub(minValidPerWindow).MulInt64(votePeriodsPerWindow).TruncateInt64()); i++ {
- input.Ctx = input.Ctx.WithBlockHeight(input.Ctx.BlockHeight() + 1)
-
- // Account 1, govstable
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate},
- }, 0)
-
- // Account 2, govstable, miss vote
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate.Add(math.LegacyNewDec(100000000000000))},
- }, 1)
-
- // Account 3, govstable
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate},
- }, 2)
-
- // Account 4, govstable
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate},
- }, 3)
-
- input.OracleKeeper.UpdateExchangeRates(input.Ctx)
- // input.OracleKeeper.SlashAndResetMissCounters(input.Ctx)
- // input.OracleKeeper.UpdateExchangeRates(input.Ctx)
-
- require.Equal(t, i+1, input.OracleKeeper.MissCounters.GetOr(input.Ctx, ValAddrs[1], 0))
- }
-
- validator := input.StakingKeeper.Validator(input.Ctx, ValAddrs[1])
- require.Equal(t, testStakingAmt, validator.GetBondedTokens())
-
- // one more miss vote will inccur ValAddrs[1] slashing
- // Account 1, govstable
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate},
- }, 0)
-
- // Account 2, govstable, miss vote
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate.Add(math.LegacyNewDec(100000000000000))},
- }, 1)
-
- // Account 3, govstable
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate},
- }, 2)
-
- // Account 4, govstable
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate},
- }, 3)
-
- input.Ctx = input.Ctx.WithBlockHeight(votePeriodsPerWindow - 1)
- input.OracleKeeper.UpdateExchangeRates(input.Ctx)
- input.OracleKeeper.SlashAndResetMissCounters(input.Ctx)
- // input.OracleKeeper.UpdateExchangeRates(input.Ctx)
-
- validator = input.StakingKeeper.Validator(input.Ctx, ValAddrs[1])
- require.Equal(t, math.LegacyOneDec().Sub(slashFraction).MulInt(testStakingAmt).TruncateInt(), validator.GetBondedTokens())
-}
-
-// TestWhitelistSlashing: Creates a scenario where one valoper (valIdx 0) does
-// not vote throughout an entire vote window, while valopers 1 and 2 do.
-func TestWhitelistSlashing(t *testing.T) {
- input, msgServer := Setup(t)
-
- votePeriodsPerSlashWindow := math.LegacyNewDec(int64(input.OracleKeeper.SlashWindow(input.Ctx))).QuoInt64(int64(input.OracleKeeper.VotePeriod(input.Ctx))).TruncateInt64()
- minValidVotePeriodsPerWindow := input.OracleKeeper.MinValidPerWindow(input.Ctx)
-
- pair := asset.Registry.Pair(denoms.ATOM, denoms.USD)
- priceVoteFromVal := func(valIdx int, block int64, erate sdk.Dec) {
- MakeAggregatePrevoteAndVote(t, input, msgServer, block,
- types.ExchangeRateTuples{{Pair: pair, ExchangeRate: erate}},
- valIdx)
- }
- input.OracleKeeper.WhitelistedPairs.Insert(input.Ctx, pair)
- perfs := input.OracleKeeper.UpdateExchangeRates(input.Ctx)
- require.EqualValues(t, 0, perfs.TotalRewardWeight())
-
- allowedMissPct := math.LegacyOneDec().Sub(minValidVotePeriodsPerWindow)
- allowedMissVotePeriods := allowedMissPct.MulInt64(votePeriodsPerSlashWindow).
- TruncateInt64()
- t.Logf("For %v blocks, valoper0 does not vote, while 1 and 2 do.", allowedMissVotePeriods)
- for idxMissPeriod := uint64(0); idxMissPeriod < uint64(allowedMissVotePeriods); idxMissPeriod++ {
- block := input.Ctx.BlockHeight() + 1
- input.Ctx = input.Ctx.WithBlockHeight(block)
-
- valIdx := 0 // Valoper doesn't vote (abstain)
- priceVoteFromVal(valIdx+1, block, testExchangeRate)
- priceVoteFromVal(valIdx+2, block, testExchangeRate)
-
- perfs := input.OracleKeeper.UpdateExchangeRates(input.Ctx)
- missCount := input.OracleKeeper.MissCounters.GetOr(input.Ctx, ValAddrs[0], 0)
- require.EqualValues(t, 0, missCount, perfs.String())
- }
-
- t.Log("valoper0 should not be slashed")
- validator := input.StakingKeeper.Validator(input.Ctx, ValAddrs[0])
- require.Equal(t, testStakingAmt, validator.GetBondedTokens())
-}
-
-func TestNotPassedBallotSlashing(t *testing.T) {
- input, h := Setup(t)
- params, err := input.OracleKeeper.Params.Get(input.Ctx)
- require.NoError(t, err)
- params.Whitelist = []asset.Pair{asset.Registry.Pair(denoms.ATOM, denoms.USD)}
- input.OracleKeeper.Params.Set(input.Ctx, params)
-
- // clear tobin tax to reset vote targets
- for _, p := range input.OracleKeeper.WhitelistedPairs.Iterate(input.Ctx, collections.Range[asset.Pair]{}).Keys() {
- input.OracleKeeper.WhitelistedPairs.Delete(input.Ctx, p)
- }
- input.OracleKeeper.WhitelistedPairs.Insert(input.Ctx, asset.Registry.Pair(denoms.ATOM, denoms.USD))
-
- input.Ctx = input.Ctx.WithBlockHeight(input.Ctx.BlockHeight() + 1)
-
- // Account 1, govstable
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{{Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate}}, 0)
-
- input.OracleKeeper.UpdateExchangeRates(input.Ctx)
- input.OracleKeeper.SlashAndResetMissCounters(input.Ctx)
- // input.OracleKeeper.UpdateExchangeRates(input.Ctx)
- require.Equal(t, uint64(0), input.OracleKeeper.MissCounters.GetOr(input.Ctx, ValAddrs[0], 0))
- require.Equal(t, uint64(0), input.OracleKeeper.MissCounters.GetOr(input.Ctx, ValAddrs[1], 0))
- require.Equal(t, uint64(0), input.OracleKeeper.MissCounters.GetOr(input.Ctx, ValAddrs[2], 0))
-}
-
-func TestAbstainSlashing(t *testing.T) {
- input, h := Setup(t)
-
- // reset whitelisted pairs
- params, err := input.OracleKeeper.Params.Get(input.Ctx)
- require.NoError(t, err)
- params.Whitelist = []asset.Pair{asset.Registry.Pair(denoms.ATOM, denoms.USD)}
- input.OracleKeeper.Params.Set(input.Ctx, params)
- for _, p := range input.OracleKeeper.WhitelistedPairs.Iterate(input.Ctx, collections.Range[asset.Pair]{}).Keys() {
- input.OracleKeeper.WhitelistedPairs.Delete(input.Ctx, p)
- }
- input.OracleKeeper.WhitelistedPairs.Insert(input.Ctx, asset.Registry.Pair(denoms.ATOM, denoms.USD))
-
- votePeriodsPerWindow := math.LegacyNewDec(int64(input.OracleKeeper.SlashWindow(input.Ctx))).QuoInt64(int64(input.OracleKeeper.VotePeriod(input.Ctx))).TruncateInt64()
- minValidPerWindow := input.OracleKeeper.MinValidPerWindow(input.Ctx)
-
- for i := uint64(0); i <= uint64(math.LegacyOneDec().Sub(minValidPerWindow).MulInt64(votePeriodsPerWindow).TruncateInt64()); i++ {
- input.Ctx = input.Ctx.WithBlockHeight(input.Ctx.BlockHeight() + 1)
-
- // Account 1, ATOM/USD
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{{Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate}}, 0)
-
- // Account 2, ATOM/USD, abstain vote
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{{Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: math.LegacyOneDec().Neg()}}, 1)
-
- // Account 3, ATOM/USD
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{{Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate}}, 2)
-
- input.OracleKeeper.UpdateExchangeRates(input.Ctx)
- input.OracleKeeper.SlashAndResetMissCounters(input.Ctx)
- // input.OracleKeeper.UpdateExchangeRates(input.Ctx)
- require.Equal(t, uint64(0), input.OracleKeeper.MissCounters.GetOr(input.Ctx, ValAddrs[1], 0))
- }
-
- validator := input.StakingKeeper.Validator(input.Ctx, ValAddrs[1])
- require.Equal(t, testStakingAmt, validator.GetBondedTokens())
-}
diff --git a/x/oracle/keeper/sudo.go b/x/oracle/keeper/sudo.go
deleted file mode 100644
index 0843ae882..000000000
--- a/x/oracle/keeper/sudo.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package keeper
-
-import (
- "fmt"
- "time"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-// Sudo extends the Keeper with sudo functions. See sudo.go. Sudo is syntactic
-// sugar to separate admin calls off from the other Keeper methods.
-//
-// These Sudo functions should:
-// 1. Not be called in other methods in the x/perp module.
-// 2. Only be callable by the x/sudo root or sudo contracts.
-//
-// The intention behind "Keeper.Sudo()" is to make it more obvious to the
-// developer that an unsafe function is being used when it's called.
-func (k Keeper) Sudo() sudoExtension { return sudoExtension{k} }
-
-type sudoExtension struct{ Keeper }
-
-// ------------------------------------------------------------------
-// Admin.EditOracleParams
-
-func (k sudoExtension) EditOracleParams(
- ctx sdk.Context, newParams oracletypes.MsgEditOracleParams,
- sender sdk.AccAddress,
-) (paramsAfter oracletypes.Params, err error) {
- if err := k.sudoKeeper.CheckPermissions(sender, ctx); err != nil {
- return paramsAfter, err
- }
-
- params, err := k.Params.Get(ctx)
- if err != nil {
- return paramsAfter, fmt.Errorf("%w: failed to read oracle params", err)
- }
-
- paramsAfter = MergeOracleParams(newParams, params)
- k.UpdateParams(ctx, paramsAfter)
- return paramsAfter, paramsAfter.Validate()
-}
-
-// MergeOracleParams: Takes the given oracle params and merges them into the
-// existing partial params, keeping any existing values that are not set in the
-// partial.
-func MergeOracleParams(
- partial oracletypes.MsgEditOracleParams,
- oracleParams oracletypes.Params,
-) oracletypes.Params {
- if partial.VotePeriod != nil {
- oracleParams.VotePeriod = partial.VotePeriod.Uint64()
- }
-
- if partial.VoteThreshold != nil {
- oracleParams.VoteThreshold = *partial.VoteThreshold
- }
-
- if partial.RewardBand != nil {
- oracleParams.RewardBand = *partial.RewardBand
- }
-
- if partial.Whitelist != nil {
- whitelist := make([]asset.Pair, len(partial.Whitelist))
- for i, pair := range partial.Whitelist {
- whitelist[i] = asset.MustNewPair(pair)
- }
-
- oracleParams.Whitelist = whitelist
- }
-
- if partial.SlashFraction != nil {
- oracleParams.SlashFraction = *partial.SlashFraction
- }
-
- if partial.SlashWindow != nil {
- oracleParams.SlashWindow = partial.SlashWindow.Uint64()
- }
-
- if partial.MinValidPerWindow != nil {
- oracleParams.MinValidPerWindow = *partial.MinValidPerWindow
- }
-
- if partial.TwapLookbackWindow != nil {
- oracleParams.TwapLookbackWindow = time.Duration(partial.TwapLookbackWindow.Int64())
- }
-
- if partial.MinVoters != nil {
- oracleParams.MinVoters = partial.MinVoters.Uint64()
- }
-
- if partial.ValidatorFeeRatio != nil {
- oracleParams.ValidatorFeeRatio = *partial.ValidatorFeeRatio
- }
-
- return oracleParams
-}
diff --git a/x/oracle/keeper/sudo_test.go b/x/oracle/keeper/sudo_test.go
deleted file mode 100644
index 36cc88a92..000000000
--- a/x/oracle/keeper/sudo_test.go
+++ /dev/null
@@ -1,95 +0,0 @@
-package keeper_test
-
-import (
- "testing"
- "time"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- oraclekeeper "github.com/NibiruChain/nibiru/x/oracle/keeper"
- oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-// TestSuiteOracleSudo tests sudo-only functions in the oracle module.
-func TestSuiteOracleSudo(t *testing.T) {
- suite.Run(t, new(SuiteOracleSudo))
-}
-
-type SuiteOracleSudo struct {
- suite.Suite
-}
-
-// TestEditOracleParams tests the business logic for
-// "oraclekeeper.Keeper.Sudo().EditOracleParams"
-func (s *SuiteOracleSudo) TestEditOracleParams() {
- nibiru, ctx := testapp.NewNibiruTestAppAndContext()
-
- // Change to all non-defaults to test EditOracleParams as a setter .
- votePeriod := math.NewInt(1_234)
- voteThreshold := math.LegacyMustNewDecFromStr("0.4")
- rewardBand := math.LegacyMustNewDecFromStr("0.5")
- whitelist := []string{"aave:usdc", "sol:usdc"}
- slashFraction := math.LegacyMustNewDecFromStr("0.5")
- slashWindow := math.NewInt(2_000)
- minValidPerWindow := math.LegacyMustNewDecFromStr("0.5")
- twapLookbackWindow := math.NewInt(int64(time.Second * 30))
- minVoters := math.NewInt(2)
- validatorFeeRatio := math.LegacyMustNewDecFromStr("0.7")
- msgEditParams := oracletypes.MsgEditOracleParams{
- VotePeriod: &votePeriod,
- VoteThreshold: &voteThreshold,
- RewardBand: &rewardBand,
- Whitelist: whitelist,
- SlashFraction: &slashFraction,
- SlashWindow: &slashWindow,
- MinValidPerWindow: &minValidPerWindow,
- TwapLookbackWindow: &twapLookbackWindow,
- MinVoters: &minVoters,
- ValidatorFeeRatio: &validatorFeeRatio,
- }
-
- s.T().Log("Params before MUST NOT be equal to default")
- defaultParams := oracletypes.DefaultParams()
- currParams, err := nibiru.OracleKeeper.Params.Get(ctx)
- s.NoError(err)
- s.Equal(currParams, defaultParams,
- "Current params should be eqaul to defaults")
- partialParams := msgEditParams
- fullParams := oraclekeeper.MergeOracleParams(partialParams, defaultParams)
- s.NotEqual(defaultParams, fullParams,
- "new params after merge should not be defaults")
-
- invalidSender := testutil.AccAddress()
- oracleMsgServer := oraclekeeper.NewMsgServerImpl(nibiru.OracleKeeper)
- goCtx := sdk.WrapSDKContext(ctx)
- msgEditParams.Sender = invalidSender.String()
- _, err = oracleMsgServer.EditOracleParams(
- goCtx, &msgEditParams,
- )
- s.Error(err)
-
- s.T().Log("Params after MUST be equal to new ones with partialParams")
- okSender := testapp.DefaultSudoRoot()
- msgEditParams.Sender = okSender.String()
- resp, err := oracleMsgServer.EditOracleParams(
- goCtx, &msgEditParams,
- )
- s.Require().NoError(err)
- s.EqualValues(resp.NewParams.String(), fullParams.String())
-
- s.T().Log("Changing to invalid params MUST fail")
- slashWindow = math.NewInt(1_233) // slashWindow < vote period is not allowed.
- msgEditParams = oracletypes.MsgEditOracleParams{
- Sender: okSender.String(),
- SlashWindow: &slashWindow,
- }
- _, err = oracleMsgServer.EditOracleParams(
- goCtx, &msgEditParams,
- )
- s.Require().Error(err)
- s.ErrorContains(err, "oracle parameter SlashWindow must be greater")
-}
diff --git a/x/oracle/keeper/test_utils.go b/x/oracle/keeper/test_utils.go
deleted file mode 100644
index 72f91aada..000000000
--- a/x/oracle/keeper/test_utils.go
+++ /dev/null
@@ -1,368 +0,0 @@
-// nolint
-package keeper
-
-import (
- "testing"
- "time"
-
- "cosmossdk.io/math"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/oracle/types"
- "github.com/NibiruChain/nibiru/x/sudo"
- sudokeeper "github.com/NibiruChain/nibiru/x/sudo/keeper"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
- dbm "github.com/cometbft/cometbft-db"
- "github.com/cometbft/cometbft/crypto"
- "github.com/cometbft/cometbft/crypto/secp256k1"
- "github.com/cometbft/cometbft/libs/log"
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
- "github.com/cosmos/cosmos-sdk/std"
- "github.com/cosmos/cosmos-sdk/store"
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
- "github.com/cosmos/cosmos-sdk/testutil/sims"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
- "github.com/cosmos/cosmos-sdk/types/module/testutil"
- "github.com/cosmos/cosmos-sdk/x/auth"
- authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
- "github.com/cosmos/cosmos-sdk/x/auth/tx"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- "github.com/cosmos/cosmos-sdk/x/bank"
- bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
- distr "github.com/cosmos/cosmos-sdk/x/distribution"
- distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
- distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
- "github.com/cosmos/cosmos-sdk/x/params"
- paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
- slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
- slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
- "github.com/cosmos/cosmos-sdk/x/staking"
- stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
- "github.com/stretchr/testify/require"
-)
-
-const faucetAccountName = "faucet"
-
-// ModuleBasics nolint
-var ModuleBasics = module.NewBasicManager(
- auth.AppModuleBasic{},
- bank.AppModuleBasic{},
- distr.AppModuleBasic{},
- staking.AppModuleBasic{},
- params.AppModuleBasic{},
- sudo.AppModuleBasic{},
-)
-
-// MakeTestCodec nolint
-func MakeTestCodec(t *testing.T) codec.Codec {
- return MakeEncodingConfig(t).Codec
-}
-
-// MakeEncodingConfig nolint
-func MakeEncodingConfig(_ *testing.T) testutil.TestEncodingConfig {
- amino := codec.NewLegacyAmino()
- interfaceRegistry := codectypes.NewInterfaceRegistry()
- codec := codec.NewProtoCodec(interfaceRegistry)
- txCfg := tx.NewTxConfig(codec, tx.DefaultSignModes)
-
- std.RegisterInterfaces(interfaceRegistry)
- std.RegisterLegacyAminoCodec(amino)
-
- ModuleBasics.RegisterLegacyAminoCodec(amino)
- ModuleBasics.RegisterInterfaces(interfaceRegistry)
- types.RegisterLegacyAminoCodec(amino)
- types.RegisterInterfaces(interfaceRegistry)
- return testutil.TestEncodingConfig{
- InterfaceRegistry: interfaceRegistry,
- Codec: codec,
- TxConfig: txCfg,
- Amino: amino,
- }
-}
-
-// Test addresses
-var (
- ValPubKeys = sims.CreateTestPubKeys(5)
-
- pubKeys = []crypto.PubKey{
- secp256k1.GenPrivKey().PubKey(),
- secp256k1.GenPrivKey().PubKey(),
- secp256k1.GenPrivKey().PubKey(),
- secp256k1.GenPrivKey().PubKey(),
- secp256k1.GenPrivKey().PubKey(),
- }
-
- Addrs = []sdk.AccAddress{
- sdk.AccAddress(pubKeys[0].Address()),
- sdk.AccAddress(pubKeys[1].Address()),
- sdk.AccAddress(pubKeys[2].Address()),
- sdk.AccAddress(pubKeys[3].Address()),
- sdk.AccAddress(pubKeys[4].Address()),
- }
-
- ValAddrs = []sdk.ValAddress{
- sdk.ValAddress(pubKeys[0].Address()),
- sdk.ValAddress(pubKeys[1].Address()),
- sdk.ValAddress(pubKeys[2].Address()),
- sdk.ValAddress(pubKeys[3].Address()),
- sdk.ValAddress(pubKeys[4].Address()),
- }
-
- InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction)
- InitCoins = sdk.NewCoins(sdk.NewCoin(denoms.NIBI, InitTokens))
-
- OracleDecPrecision = 8
-)
-
-// TestFixture nolint
-type TestFixture struct {
- Ctx sdk.Context
- Cdc *codec.LegacyAmino
- AccountKeeper authkeeper.AccountKeeper
- BankKeeper bankkeeper.Keeper
- OracleKeeper Keeper
- StakingKeeper stakingkeeper.Keeper
- DistrKeeper distrkeeper.Keeper
- SudoKeeper types.SudoKeeper
-}
-
-// CreateTestFixture nolint
-// Creates a base app, with 5 accounts,
-func CreateTestFixture(t *testing.T) TestFixture {
- keyAcc := sdk.NewKVStoreKey(authtypes.StoreKey)
- keyBank := sdk.NewKVStoreKey(banktypes.StoreKey)
- keyParams := sdk.NewKVStoreKey(paramstypes.StoreKey)
- tKeyParams := sdk.NewTransientStoreKey(paramstypes.TStoreKey)
- keyOracle := sdk.NewKVStoreKey(types.StoreKey)
- keyStaking := sdk.NewKVStoreKey(stakingtypes.StoreKey)
- keySlashing := sdk.NewKVStoreKey(slashingtypes.StoreKey)
- keyDistr := sdk.NewKVStoreKey(distrtypes.StoreKey)
- keySudo := sdk.NewKVStoreKey(sudotypes.StoreKey)
-
- govModuleAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
-
- db := dbm.NewMemDB()
- ms := store.NewCommitMultiStore(db)
- ctx := sdk.NewContext(ms, tmproto.Header{Time: time.Now().UTC(), Height: 1}, false, log.NewNopLogger())
- encodingConfig := MakeEncodingConfig(t)
- appCodec, legacyAmino := encodingConfig.Codec, encodingConfig.Amino
-
- ms.MountStoreWithDB(keyAcc, storetypes.StoreTypeIAVL, db)
- ms.MountStoreWithDB(keyBank, storetypes.StoreTypeIAVL, db)
- ms.MountStoreWithDB(tKeyParams, storetypes.StoreTypeTransient, db)
- ms.MountStoreWithDB(keyParams, storetypes.StoreTypeIAVL, db)
- ms.MountStoreWithDB(keyOracle, storetypes.StoreTypeIAVL, db)
- ms.MountStoreWithDB(keyStaking, storetypes.StoreTypeIAVL, db)
- ms.MountStoreWithDB(keyDistr, storetypes.StoreTypeIAVL, db)
-
- require.NoError(t, ms.LoadLatestVersion())
-
- blackListAddrs := map[string]bool{
- authtypes.FeeCollectorName: true,
- stakingtypes.NotBondedPoolName: true,
- stakingtypes.BondedPoolName: true,
- distrtypes.ModuleName: true,
- faucetAccountName: true,
- }
-
- maccPerms := map[string][]string{
- faucetAccountName: {authtypes.Minter},
- authtypes.FeeCollectorName: nil,
- stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
- stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
- distrtypes.ModuleName: nil,
- types.ModuleName: nil,
- }
-
- accountKeeper := authkeeper.NewAccountKeeper(
- appCodec,
- keyAcc,
- authtypes.ProtoBaseAccount,
- maccPerms,
- sdk.GetConfig().GetBech32AccountAddrPrefix(),
- authtypes.NewModuleAddress(govtypes.ModuleName).String(),
- )
- bankKeeper := bankkeeper.NewBaseKeeper(
- appCodec,
- keyBank,
- accountKeeper,
- blackListAddrs,
- authtypes.NewModuleAddress(govtypes.ModuleName).String(),
- )
-
- totalSupply := sdk.NewCoins(sdk.NewCoin(denoms.NIBI, InitTokens.MulRaw(int64(len(Addrs)*10))))
- bankKeeper.MintCoins(ctx, faucetAccountName, totalSupply)
-
- stakingKeeper := stakingkeeper.NewKeeper(
- appCodec,
- keyStaking,
- accountKeeper,
- bankKeeper,
- authtypes.NewModuleAddress(govtypes.ModuleName).String(),
- )
- stakingParams := stakingtypes.DefaultParams()
- stakingParams.BondDenom = denoms.NIBI
- stakingKeeper.SetParams(ctx, stakingParams)
-
- slashingKeeper := slashingkeeper.NewKeeper(appCodec, legacyAmino, keySlashing, stakingKeeper, govModuleAddr)
-
- distrKeeper := distrkeeper.NewKeeper(
- appCodec,
- keyDistr,
- accountKeeper, bankKeeper, stakingKeeper,
- authtypes.FeeCollectorName,
- authtypes.NewModuleAddress(govtypes.ModuleName).String(),
- )
-
- distrKeeper.SetFeePool(ctx, distrtypes.InitialFeePool())
- distrParams := distrtypes.DefaultParams()
- distrParams.CommunityTax = math.LegacyNewDecWithPrec(2, 2)
- distrParams.BaseProposerReward = math.LegacyNewDecWithPrec(1, 2)
- distrParams.BonusProposerReward = math.LegacyNewDecWithPrec(4, 2)
- distrKeeper.SetParams(ctx, distrParams)
- stakingKeeper.SetHooks(stakingtypes.NewMultiStakingHooks(distrKeeper.Hooks()))
-
- feeCollectorAcc := authtypes.NewEmptyModuleAccount(authtypes.FeeCollectorName)
- notBondedPool := authtypes.NewEmptyModuleAccount(stakingtypes.NotBondedPoolName, authtypes.Burner, authtypes.Staking)
- bondPool := authtypes.NewEmptyModuleAccount(stakingtypes.BondedPoolName, authtypes.Burner, authtypes.Staking)
- distrAcc := authtypes.NewEmptyModuleAccount(distrtypes.ModuleName)
- oracleAcc := authtypes.NewEmptyModuleAccount(types.ModuleName, authtypes.Minter)
-
- bankKeeper.SendCoinsFromModuleToModule(ctx, faucetAccountName, stakingtypes.NotBondedPoolName, sdk.NewCoins(sdk.NewCoin(denoms.NIBI, InitTokens.MulRaw(int64(len(Addrs))))))
-
- sudoKeeper := sudokeeper.NewKeeper(appCodec, keySudo)
- sudoAcc := authtypes.NewEmptyModuleAccount(sudotypes.ModuleName)
-
- accountKeeper.SetModuleAccount(ctx, feeCollectorAcc)
- accountKeeper.SetModuleAccount(ctx, bondPool)
- accountKeeper.SetModuleAccount(ctx, notBondedPool)
- accountKeeper.SetModuleAccount(ctx, distrAcc)
- accountKeeper.SetModuleAccount(ctx, oracleAcc)
- accountKeeper.SetModuleAccount(ctx, sudoAcc)
-
- for _, addr := range Addrs {
- accountKeeper.SetAccount(ctx, authtypes.NewBaseAccountWithAddress(addr))
- err := bankKeeper.SendCoinsFromModuleToAccount(ctx, faucetAccountName, addr, InitCoins)
- require.NoError(t, err)
- }
-
- keeper := NewKeeper(
- appCodec,
- keyOracle,
- accountKeeper,
- bankKeeper,
- distrKeeper,
- stakingKeeper,
- slashingKeeper,
- sudoKeeper,
- distrtypes.ModuleName,
- )
-
- defaults := types.DefaultParams()
-
- for _, pair := range defaults.Whitelist {
- keeper.WhitelistedPairs.Insert(ctx, pair)
- }
-
- keeper.Params.Set(ctx, defaults)
-
- return TestFixture{
- ctx, legacyAmino, accountKeeper, bankKeeper,
- keeper,
- *stakingKeeper,
- distrKeeper,
- sudoKeeper,
- }
-}
-
-// NewTestMsgCreateValidator test msg creator
-func NewTestMsgCreateValidator(
- address sdk.ValAddress, pubKey cryptotypes.PubKey, amt sdk.Int,
-) *stakingtypes.MsgCreateValidator {
- commission := stakingtypes.NewCommissionRates(math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec())
- msg, _ := stakingtypes.NewMsgCreateValidator(
- address, pubKey, sdk.NewCoin(denoms.NIBI, amt),
- stakingtypes.Description{}, commission, math.OneInt(),
- )
-
- return msg
-}
-
-// FundAccount is a utility function that funds an account by minting and
-// sending the coins to the address. This should be used for testing purposes
-// only!
-func FundAccount(input TestFixture, addr sdk.AccAddress, amounts sdk.Coins) error {
- if err := input.BankKeeper.MintCoins(input.Ctx, faucetAccountName, amounts); err != nil {
- return err
- }
-
- return input.BankKeeper.SendCoinsFromModuleToAccount(input.Ctx, faucetAccountName, addr, amounts)
-}
-
-func AllocateRewards(t *testing.T, input TestFixture, rewards sdk.Coins, votePeriods uint64) {
- require.NoError(t, input.BankKeeper.MintCoins(input.Ctx, faucetAccountName, rewards))
- require.NoError(t, input.OracleKeeper.AllocateRewards(input.Ctx, faucetAccountName, rewards, votePeriods))
-}
-
-var (
- testStakingAmt = sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)
- testExchangeRate = math.LegacyNewDec(1700)
-)
-
-func Setup(t *testing.T) (TestFixture, types.MsgServer) {
- fixture := CreateTestFixture(t)
-
- params, _ := fixture.OracleKeeper.Params.Get(fixture.Ctx)
-
- params.VotePeriod = 1
- params.SlashWindow = 100
- fixture.OracleKeeper.Params.Set(fixture.Ctx, params)
-
- params, _ = fixture.OracleKeeper.Params.Get(fixture.Ctx)
-
- h := NewMsgServerImpl(fixture.OracleKeeper)
- sh := stakingkeeper.NewMsgServerImpl(&fixture.StakingKeeper)
-
- // Validator created
- _, err := sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[0], ValPubKeys[0], testStakingAmt))
- require.NoError(t, err)
- _, err = sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[1], ValPubKeys[1], testStakingAmt))
- require.NoError(t, err)
- _, err = sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[2], ValPubKeys[2], testStakingAmt))
- require.NoError(t, err)
- _, err = sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[3], ValPubKeys[3], testStakingAmt))
- require.NoError(t, err)
- _, err = sh.CreateValidator(fixture.Ctx, NewTestMsgCreateValidator(ValAddrs[4], ValPubKeys[4], testStakingAmt))
- require.NoError(t, err)
- staking.EndBlocker(fixture.Ctx, &fixture.StakingKeeper)
-
- return fixture, h
-}
-
-func MakeAggregatePrevoteAndVote(
- t *testing.T,
- input TestFixture,
- msgServer types.MsgServer,
- height int64,
- rates types.ExchangeRateTuples,
- valIdx int,
-) {
- salt := "1"
- ratesStr, err := rates.ToString()
- require.NoError(t, err)
- hash := types.GetAggregateVoteHash(salt, ratesStr, ValAddrs[valIdx])
-
- prevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[valIdx], ValAddrs[valIdx])
- _, err = msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(input.Ctx.WithBlockHeight(height)), prevoteMsg)
- require.NoError(t, err)
-
- voteMsg := types.NewMsgAggregateExchangeRateVote(salt, ratesStr, Addrs[valIdx], ValAddrs[valIdx])
- _, err = msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(input.Ctx.WithBlockHeight(height+1)), voteMsg)
- require.NoError(t, err)
-}
diff --git a/x/oracle/keeper/update_exchange_rates.go b/x/oracle/keeper/update_exchange_rates.go
deleted file mode 100644
index dff65f9dc..000000000
--- a/x/oracle/keeper/update_exchange_rates.go
+++ /dev/null
@@ -1,155 +0,0 @@
-package keeper
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/omap"
- "github.com/NibiruChain/nibiru/x/common/set"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-// UpdateExchangeRates updates the ExchangeRates, this is supposed to be executed on EndBlock.
-func (k Keeper) UpdateExchangeRates(ctx sdk.Context) types.ValidatorPerformances {
- k.Logger(ctx).Info("processing validator price votes")
- validatorPerformances := k.newValidatorPerformances(ctx)
- whitelistedPairs := set.New[asset.Pair](k.GetWhitelistedPairs(ctx)...)
-
- pairVotes := k.getPairVotes(ctx, validatorPerformances, whitelistedPairs)
-
- k.clearExchangeRates(ctx, pairVotes)
- k.tallyVotesAndUpdatePrices(ctx, pairVotes, validatorPerformances)
-
- k.incrementMissCounters(ctx, whitelistedPairs, validatorPerformances)
- k.incrementAbstainsByOmission(ctx, len(whitelistedPairs), validatorPerformances)
-
- k.rewardWinners(ctx, validatorPerformances)
-
- params, _ := k.Params.Get(ctx)
- k.clearVotesAndPrevotes(ctx, params.VotePeriod)
- k.refreshWhitelist(ctx, params.Whitelist, whitelistedPairs)
-
- for _, validatorPerformance := range validatorPerformances {
- _ = ctx.EventManager().EmitTypedEvent(&types.EventValidatorPerformance{
- Validator: validatorPerformance.ValAddress.String(),
- VotingPower: validatorPerformance.Power,
- RewardWeight: validatorPerformance.RewardWeight,
- WinCount: validatorPerformance.WinCount,
- AbstainCount: validatorPerformance.AbstainCount,
- MissCount: validatorPerformance.MissCount,
- })
- }
-
- return validatorPerformances
-}
-
-// incrementMissCounters it parses all validators performance and increases the
-// missed vote of those that did not vote.
-func (k Keeper) incrementMissCounters(
- ctx sdk.Context,
- whitelistedPairs set.Set[asset.Pair],
- validatorPerformances types.ValidatorPerformances,
-) {
- for _, validatorPerformance := range validatorPerformances {
- if int(validatorPerformance.MissCount) > 0 {
- k.MissCounters.Insert(
- ctx, validatorPerformance.ValAddress,
- k.MissCounters.GetOr(ctx, validatorPerformance.ValAddress, 0)+uint64(validatorPerformance.MissCount),
- )
-
- k.Logger(ctx).Info("vote miss", "validator", validatorPerformance.ValAddress.String())
- }
- }
-}
-
-func (k Keeper) incrementAbstainsByOmission(
- ctx sdk.Context,
- numPairs int,
- validatorPerformances types.ValidatorPerformances,
-) {
- for valAddr, performance := range validatorPerformances {
- omitCount := int64(numPairs) - (performance.WinCount + performance.AbstainCount + performance.MissCount)
- if omitCount > 0 {
- performance.AbstainCount += omitCount
- validatorPerformances[valAddr] = performance
- }
- }
-}
-
-// tallyVotesAndUpdatePrices processes the votes and updates the ExchangeRates based on the results.
-func (k Keeper) tallyVotesAndUpdatePrices(
- ctx sdk.Context,
- pairVotes map[asset.Pair]types.ExchangeRateVotes,
- validatorPerformances types.ValidatorPerformances,
-) {
- rewardBand := k.RewardBand(ctx)
- // Iterate through sorted keys for deterministic ordering.
- orderedPairVotes := omap.OrderedMap_Pair[types.ExchangeRateVotes](pairVotes)
- for pair := range orderedPairVotes.Range() {
- exchangeRate := Tally(pairVotes[pair], rewardBand, validatorPerformances)
- k.SetPrice(ctx, pair, exchangeRate)
- }
-}
-
-// getPairVotes returns a map of pairs and votes excluding abstained votes and votes that don't meet the threshold criteria
-func (k Keeper) getPairVotes(
- ctx sdk.Context,
- validatorPerformances types.ValidatorPerformances,
- whitelistedPairs set.Set[asset.Pair],
-) (pairVotes map[asset.Pair]types.ExchangeRateVotes) {
- pairVotes = k.groupVotesByPair(ctx, validatorPerformances)
-
- k.removeInvalidVotes(ctx, pairVotes, whitelistedPairs)
-
- return pairVotes
-}
-
-// clearExchangeRates removes all exchange rates from the state
-// We remove the price for pair with expired prices or valid votes
-func (k Keeper) clearExchangeRates(ctx sdk.Context, pairVotes map[asset.Pair]types.ExchangeRateVotes) {
- params, _ := k.Params.Get(ctx)
-
- for _, key := range k.ExchangeRates.Iterate(ctx, collections.Range[asset.Pair]{}).Keys() {
- _, isValid := pairVotes[key]
- previousExchangeRate, _ := k.ExchangeRates.Get(ctx, key)
- isExpired := previousExchangeRate.CreatedBlock+params.ExpirationBlocks <= uint64(ctx.BlockHeight())
-
- if isValid || isExpired {
- err := k.ExchangeRates.Delete(ctx, key)
- if err != nil {
- k.Logger(ctx).Error("failed to delete exchange rate", "pair", key.String(), "error", err)
- }
- }
- }
-}
-
-// newValidatorPerformances creates a new map of validators and their performance, excluding validators that are
-// not bonded.
-func (k Keeper) newValidatorPerformances(ctx sdk.Context) types.ValidatorPerformances {
- validatorPerformances := make(map[string]types.ValidatorPerformance)
-
- maxValidators := k.StakingKeeper.MaxValidators(ctx)
- powerReduction := k.StakingKeeper.PowerReduction(ctx)
-
- iterator := k.StakingKeeper.ValidatorsPowerStoreIterator(ctx)
- defer iterator.Close()
-
- for i := 0; iterator.Valid() && i < int(maxValidators); iterator.Next() {
- validator := k.StakingKeeper.Validator(ctx, iterator.Value())
-
- // exclude not bonded
- if !validator.IsBonded() {
- continue
- }
-
- valAddr := validator.GetOperator()
- validatorPerformances[valAddr.String()] = types.NewValidatorPerformance(
- validator.GetConsensusPower(powerReduction), valAddr,
- )
- i++
- }
-
- return validatorPerformances
-}
diff --git a/x/oracle/keeper/update_exchange_rates_test.go b/x/oracle/keeper/update_exchange_rates_test.go
deleted file mode 100644
index 80e5b877f..000000000
--- a/x/oracle/keeper/update_exchange_rates_test.go
+++ /dev/null
@@ -1,491 +0,0 @@
-package keeper
-
-import (
- "fmt"
- "math"
- "sort"
- "testing"
-
- "github.com/cometbft/cometbft/libs/rand"
- sdk "github.com/cosmos/cosmos-sdk/types"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- sdkmath "cosmossdk.io/math"
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/common"
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestOracleThreshold(t *testing.T) {
- exchangeRates := types.ExchangeRateTuples{
- {
- Pair: asset.Registry.Pair(denoms.BTC, denoms.USD),
- ExchangeRate: testExchangeRate,
- },
- }
- exchangeRateStr, err := exchangeRates.ToString()
- require.NoError(t, err)
-
- fixture, msgServer := Setup(t)
- params, _ := fixture.OracleKeeper.Params.Get(fixture.Ctx)
- params.ExpirationBlocks = 0
- fixture.OracleKeeper.Params.Set(fixture.Ctx, params)
-
- // Case 1.
- // Less than the threshold signs, exchange rate consensus fails
- for i := 0; i < 1; i++ {
- salt := fmt.Sprintf("%d", i)
- hash := types.GetAggregateVoteHash(salt, exchangeRateStr, ValAddrs[i])
- prevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[i], ValAddrs[i])
- voteMsg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, Addrs[i], ValAddrs[i])
-
- _, err1 := msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(fixture.Ctx.WithBlockHeight(0)), prevoteMsg)
- _, err2 := msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(fixture.Ctx.WithBlockHeight(1)), voteMsg)
- require.NoError(t, err1)
- require.NoError(t, err2)
- }
- fixture.OracleKeeper.UpdateExchangeRates(fixture.Ctx)
- _, err = fixture.OracleKeeper.ExchangeRates.Get(fixture.Ctx.WithBlockHeight(1), exchangeRates[0].Pair)
- assert.Error(t, err)
-
- // Case 2.
- // More than the threshold signs, exchange rate consensus succeeds
- for i := 0; i < 4; i++ {
- salt := fmt.Sprintf("%d", i)
- hash := types.GetAggregateVoteHash(salt, exchangeRateStr, ValAddrs[i])
- prevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[i], ValAddrs[i])
- voteMsg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, Addrs[i], ValAddrs[i])
-
- _, err1 := msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(fixture.Ctx.WithBlockHeight(0)), prevoteMsg)
- _, err2 := msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(fixture.Ctx.WithBlockHeight(1)), voteMsg)
- require.NoError(t, err1)
- require.NoError(t, err2)
- }
- fixture.OracleKeeper.UpdateExchangeRates(fixture.Ctx)
- rate, err := fixture.OracleKeeper.ExchangeRates.Get(fixture.Ctx, exchangeRates[0].Pair)
- require.NoError(t, err)
- assert.Equal(t, testExchangeRate, rate.ExchangeRate)
-
- // Case 3.
- // Increase voting power of absent validator, exchange rate consensus fails
- val, _ := fixture.StakingKeeper.GetValidator(fixture.Ctx, ValAddrs[4])
- _, _ = fixture.StakingKeeper.Delegate(fixture.Ctx.WithBlockHeight(0), Addrs[4], testStakingAmt.MulRaw(8), stakingtypes.Unbonded, val, false)
-
- for i := 0; i < 4; i++ {
- salt := fmt.Sprintf("%d", i)
- hash := types.GetAggregateVoteHash(salt, exchangeRateStr, ValAddrs[i])
- prevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, Addrs[i], ValAddrs[i])
- voteMsg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, Addrs[i], ValAddrs[i])
-
- _, err1 := msgServer.AggregateExchangeRatePrevote(sdk.WrapSDKContext(fixture.Ctx.WithBlockHeight(0)), prevoteMsg)
- _, err2 := msgServer.AggregateExchangeRateVote(sdk.WrapSDKContext(fixture.Ctx.WithBlockHeight(1)), voteMsg)
- require.NoError(t, err1)
- require.NoError(t, err2)
- }
- fixture.OracleKeeper.UpdateExchangeRates(fixture.Ctx)
- _, err = fixture.OracleKeeper.ExchangeRates.Get(fixture.Ctx, exchangeRates[0].Pair)
- assert.Error(t, err)
-}
-
-func TestResetExchangeRates(t *testing.T) {
- pair := asset.Registry.Pair(denoms.BTC, denoms.USD)
- fixture, _ := Setup(t)
-
- emptyVotes := map[asset.Pair]types.ExchangeRateVotes{}
- validVotes := map[asset.Pair]types.ExchangeRateVotes{pair: {}}
-
- // Set expiration blocks to 10
- params, _ := fixture.OracleKeeper.Params.Get(fixture.Ctx)
- params.ExpirationBlocks = 10
- fixture.OracleKeeper.Params.Set(fixture.Ctx, params)
-
- // Post a price at block 1
- fixture.OracleKeeper.SetPrice(fixture.Ctx.WithBlockHeight(1), pair, testExchangeRate)
-
- // reset exchange rates at block 2
- // Price should still be there because not expired yet
- fixture.OracleKeeper.clearExchangeRates(fixture.Ctx.WithBlockHeight(2), emptyVotes)
- _, err := fixture.OracleKeeper.ExchangeRates.Get(fixture.Ctx, pair)
- assert.NoError(t, err)
-
- // reset exchange rates at block 3 but pair is in votes
- // Price should be removed there because there was a valid votes
- fixture.OracleKeeper.clearExchangeRates(fixture.Ctx.WithBlockHeight(3), validVotes)
- _, err = fixture.OracleKeeper.ExchangeRates.Get(fixture.Ctx, pair)
- assert.Error(t, err)
-
- // Post a price at block 69
- // reset exchange rates at block 79
- // Price should not be there anymore because expired
- fixture.OracleKeeper.SetPrice(fixture.Ctx.WithBlockHeight(69), pair, testExchangeRate)
- fixture.OracleKeeper.clearExchangeRates(fixture.Ctx.WithBlockHeight(79), emptyVotes)
-
- _, err = fixture.OracleKeeper.ExchangeRates.Get(fixture.Ctx, pair)
- assert.Error(t, err)
-}
-
-func TestOracleTally(t *testing.T) {
- fixture, _ := Setup(t)
-
- votes := types.ExchangeRateVotes{}
- rates, valAddrs, stakingKeeper := types.GenerateRandomTestCase()
- fixture.OracleKeeper.StakingKeeper = stakingKeeper
- h := NewMsgServerImpl(fixture.OracleKeeper)
-
- for i, rate := range rates {
- decExchangeRate := sdkmath.LegacyNewDecWithPrec(int64(rate*math.Pow10(OracleDecPrecision)), int64(OracleDecPrecision))
- exchangeRateStr, err := types.ExchangeRateTuples{
- {ExchangeRate: decExchangeRate, Pair: asset.Registry.Pair(denoms.BTC, denoms.USD)},
- }.ToString()
- require.NoError(t, err)
-
- salt := fmt.Sprintf("%d", i)
- hash := types.GetAggregateVoteHash(salt, exchangeRateStr, valAddrs[i])
- prevoteMsg := types.NewMsgAggregateExchangeRatePrevote(hash, sdk.AccAddress(valAddrs[i]), valAddrs[i])
- voteMsg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRateStr, sdk.AccAddress(valAddrs[i]), valAddrs[i])
-
- _, err1 := h.AggregateExchangeRatePrevote(sdk.WrapSDKContext(fixture.Ctx.WithBlockHeight(0)), prevoteMsg)
- _, err2 := h.AggregateExchangeRateVote(sdk.WrapSDKContext(fixture.Ctx.WithBlockHeight(1)), voteMsg)
- require.NoError(t, err1)
- require.NoError(t, err2)
-
- power := testStakingAmt.QuoRaw(int64(6)).Int64()
- if decExchangeRate.IsZero() {
- power = int64(0)
- }
-
- vote := types.NewExchangeRateVote(
- decExchangeRate, asset.Registry.Pair(denoms.BTC, denoms.USD), valAddrs[i], power)
- votes = append(votes, vote)
-
- // change power of every three validator
- if i%3 == 0 {
- stakingKeeper.Validators()[i].SetConsensusPower(int64(i + 1))
- }
- }
-
- validatorPerformances := make(types.ValidatorPerformances)
- for _, valAddr := range valAddrs {
- validatorPerformances[valAddr.String()] = types.NewValidatorPerformance(
- stakingKeeper.Validator(fixture.Ctx, valAddr).GetConsensusPower(sdk.DefaultPowerReduction),
- valAddr,
- )
- }
- sort.Sort(votes)
- weightedMedian := votes.WeightedMedianWithAssertion()
- standardDeviation := votes.StandardDeviation(weightedMedian)
- maxSpread := weightedMedian.Mul(fixture.OracleKeeper.RewardBand(fixture.Ctx).QuoInt64(2))
-
- if standardDeviation.GT(maxSpread) {
- maxSpread = standardDeviation
- }
-
- expectedValidatorPerformances := make(types.ValidatorPerformances)
- for _, valAddr := range valAddrs {
- expectedValidatorPerformances[valAddr.String()] = types.NewValidatorPerformance(
- stakingKeeper.Validator(fixture.Ctx, valAddr).GetConsensusPower(sdk.DefaultPowerReduction),
- valAddr,
- )
- }
-
- for _, vote := range votes {
- key := vote.Voter.String()
- validatorPerformance := expectedValidatorPerformances[key]
- if vote.ExchangeRate.GTE(weightedMedian.Sub(maxSpread)) &&
- vote.ExchangeRate.LTE(weightedMedian.Add(maxSpread)) {
- validatorPerformance.RewardWeight += vote.Power
- validatorPerformance.WinCount++
- } else if !vote.ExchangeRate.IsPositive() {
- validatorPerformance.AbstainCount++
- } else {
- validatorPerformance.MissCount++
- }
- expectedValidatorPerformances[key] = validatorPerformance
- }
-
- tallyMedian := Tally(
- votes, fixture.OracleKeeper.RewardBand(fixture.Ctx), validatorPerformances)
-
- assert.Equal(t, expectedValidatorPerformances, validatorPerformances)
- assert.Equal(t, tallyMedian.MulInt64(100).TruncateInt(), weightedMedian.MulInt64(100).TruncateInt())
- assert.NotEqualValues(t, 0, validatorPerformances.TotalRewardWeight(), validatorPerformances.String())
-}
-
-func TestOracleRewardBand(t *testing.T) {
- fixture, msgServer := Setup(t)
- params, err := fixture.OracleKeeper.Params.Get(fixture.Ctx)
- require.NoError(t, err)
-
- params.Whitelist = []asset.Pair{asset.Registry.Pair(denoms.ATOM, denoms.USD)}
- fixture.OracleKeeper.Params.Set(fixture.Ctx, params)
-
- // clear pairs to reset vote targets
- for _, p := range fixture.OracleKeeper.WhitelistedPairs.Iterate(fixture.Ctx, collections.Range[asset.Pair]{}).Keys() {
- fixture.OracleKeeper.WhitelistedPairs.Delete(fixture.Ctx, p)
- }
- fixture.OracleKeeper.WhitelistedPairs.Insert(fixture.Ctx, asset.Registry.Pair(denoms.ATOM, denoms.USD))
-
- rewardSpread := testExchangeRate.Mul(fixture.OracleKeeper.RewardBand(fixture.Ctx).QuoInt64(2))
-
- // Account 1, atom:usd
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate.Sub(rewardSpread)},
- }, 0)
-
- // Account 2, atom:usd
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate},
- }, 1)
-
- // Account 3, atom:usd
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate},
- }, 2)
-
- // Account 4, atom:usd
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate.Add(rewardSpread)},
- }, 3)
-
- fixture.OracleKeeper.UpdateExchangeRates(fixture.Ctx)
-
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[0], 0))
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[1], 0))
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[2], 0))
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[3], 0))
-
- // Account 1 will miss the vote due to raward band condition
- // Account 1, atom:usd
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate.Sub(rewardSpread.Add(sdkmath.LegacyOneDec()))},
- }, 0)
-
- // Account 2, atom:usd
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate},
- }, 1)
-
- // Account 3, atom:usd
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate},
- }, 2)
-
- // Account 4, atom:usd
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate.Add(rewardSpread)},
- }, 3)
-
- fixture.OracleKeeper.UpdateExchangeRates(fixture.Ctx)
-
- assert.Equal(t, uint64(1), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[0], 0))
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[1], 0))
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[2], 0))
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[3], 0))
-}
-
-/* TODO(Mercilex): not appliable right now: https://github.com/NibiruChain/nibiru/issues/805
-func TestOracleMultiRewardDistribution(t *testing.T) {
- input, h := setup(t)
-
- // SDR and KRW have the same voting power, but KRW has been chosen as referencepair by alphabetical order.
- // Account 1, SDR, KRW
- makeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{{Pair: common.Pairbtc:usd.String(), ExchangeRate: randomExchangeRate}, {Pair: common.Pairatom:usd.String(), ExchangeRate: randomExchangeRate}}, 0)
-
- // Account 2, SDR
- makeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{{Pair: common.Pairbtc:usd.String(), ExchangeRate: randomExchangeRate}}, 1)
-
- // Account 3, KRW
- makeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{{Pair: common.Pairbtc:usd.String(), ExchangeRate: randomExchangeRate}}, 2)
-
- rewardAmt := math.NewInt(1e6)
- err := input.BankKeeper.MintCoins(input.Ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(denoms.Gov, rewardAmt)))
- require.NoError(t, err)
-
- input.OracleKeeper.UpdateExchangeRates(input.Ctx)
-
- rewardDistributedWindow := input.OracleKeeper.RewardDistributionWindow(input.Ctx)
-
- expectedRewardAmt := math.LegacyNewDecFromInt(rewardAmt.QuoRaw(3).MulRaw(2)).QuoInt64(int64(rewardDistributedWindow)).TruncateInt()
- expectedRewardAmt2 := math.ZeroInt() // even vote power is same KRW with SDR, KRW chosen referenceTerra because alphabetical order
- expectedRewardAmt3 := math.LegacyNewDecFromInt(rewardAmt.QuoRaw(3)).QuoInt64(int64(rewardDistributedWindow)).TruncateInt()
-
- rewards := input.DistrKeeper.GetValidatorOutstandingRewards(input.Ctx.WithBlockHeight(2), ValAddrs[0])
- assert.Equal(t, expectedRewardAmt, rewards.Rewards.AmountOf(denoms.Gov).TruncateInt())
- rewards = input.DistrKeeper.GetValidatorOutstandingRewards(input.Ctx.WithBlockHeight(2), ValAddrs[1])
- assert.Equal(t, expectedRewardAmt2, rewards.Rewards.AmountOf(denoms.Gov).TruncateInt())
- rewards = input.DistrKeeper.GetValidatorOutstandingRewards(input.Ctx.WithBlockHeight(2), ValAddrs[2])
- assert.Equal(t, expectedRewardAmt3, rewards.Rewards.AmountOf(denoms.Gov).TruncateInt())
-}
-*/
-
-func TestOracleExchangeRate(t *testing.T) {
- // The following scenario tests four validators providing prices for eth:usd, atom:usd, and btc:usd.
- // eth:usd and atom:usd pass, but btc:usd fails due to not enough validators voting.
- input, h := Setup(t)
-
- atomUsdExchangeRate := sdkmath.LegacyNewDec(1000000)
- ethUsdExchangeRate := sdkmath.LegacyNewDec(1000000)
- btcusdExchangeRate := sdkmath.LegacyNewDec(1e6)
-
- // Account 1, eth:usd, atom:usd, btc:usd
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ETH, denoms.USD), ExchangeRate: ethUsdExchangeRate},
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: atomUsdExchangeRate},
- {Pair: asset.Registry.Pair(denoms.BTC, denoms.USD), ExchangeRate: btcusdExchangeRate},
- }, 0)
-
- // Account 2, eth:usd, atom:usd
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ETH, denoms.USD), ExchangeRate: ethUsdExchangeRate},
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: atomUsdExchangeRate},
- }, 1)
-
- // Account 3, eth:usd, atom:usd, btc:usd(abstain)
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ETH, denoms.USD), ExchangeRate: ethUsdExchangeRate},
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: atomUsdExchangeRate},
- {Pair: asset.Registry.Pair(denoms.BTC, denoms.USD), ExchangeRate: sdkmath.LegacyZeroDec()},
- }, 2)
-
- // Account 4, eth:usd, atom:usd, btc:usd
- MakeAggregatePrevoteAndVote(t, input, h, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ETH, denoms.USD), ExchangeRate: ethUsdExchangeRate},
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: atomUsdExchangeRate},
- {Pair: asset.Registry.Pair(denoms.BTC, denoms.USD), ExchangeRate: sdkmath.LegacyZeroDec()},
- }, 3)
-
- ethUsdRewards := sdk.NewInt64Coin("ETHREWARD", 1*common.TO_MICRO)
- atomUsdRewards := sdk.NewInt64Coin("ATOMREWARD", 1*common.TO_MICRO)
-
- AllocateRewards(t, input, sdk.NewCoins(ethUsdRewards), 1)
- AllocateRewards(t, input, sdk.NewCoins(atomUsdRewards), 1)
-
- input.OracleKeeper.UpdateExchangeRates(input.Ctx)
-
- // total reward pool for the current vote period is 1* common.TO_MICRO for eth:usd and 1* common.TO_MICRO for atom:usd
- // val 1,2,3,4 all won on 2 pairs
- // so total votes are 2 * 2 + 2 + 2 = 8
- expectedRewardAmt := sdk.NewDecCoinsFromCoins(ethUsdRewards, atomUsdRewards).
- QuoDec(sdkmath.LegacyNewDec(8)). // total votes
- MulDec(sdkmath.LegacyNewDec(2)) // votes won by val1 and val2
- rewards := input.DistrKeeper.GetValidatorOutstandingRewards(input.Ctx.WithBlockHeight(2), ValAddrs[0])
- assert.Equalf(t, expectedRewardAmt, rewards.Rewards, "%s <-> %s", expectedRewardAmt, rewards.Rewards)
- rewards = input.DistrKeeper.GetValidatorOutstandingRewards(input.Ctx.WithBlockHeight(2), ValAddrs[1])
- assert.Equalf(t, expectedRewardAmt, rewards.Rewards, "%s <-> %s", expectedRewardAmt, rewards.Rewards)
- rewards = input.DistrKeeper.GetValidatorOutstandingRewards(input.Ctx.WithBlockHeight(2), ValAddrs[2])
- assert.Equalf(t, expectedRewardAmt, rewards.Rewards, "%s <-> %s", expectedRewardAmt, rewards.Rewards)
- rewards = input.DistrKeeper.GetValidatorOutstandingRewards(input.Ctx.WithBlockHeight(2), ValAddrs[3])
- assert.Equalf(t, expectedRewardAmt, rewards.Rewards, "%s <-> %s", expectedRewardAmt, rewards.Rewards)
-}
-
-func TestOracleRandomPrices(t *testing.T) {
- fixture, msgServer := Setup(t)
-
- for i := 0; i < 100; i++ {
- for val := 0; val < 4; val++ {
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, 0, types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.ETH, denoms.USD), ExchangeRate: sdkmath.LegacyNewDec(int64(rand.Uint64() % 1e6))},
- {Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: sdkmath.LegacyNewDec(int64(rand.Uint64() % 1e6))},
- }, val)
- }
-
- require.NotPanics(t, func() {
- fixture.OracleKeeper.UpdateExchangeRates(fixture.Ctx)
- })
- }
-}
-
-func TestWhitelistedPairs(t *testing.T) {
- fixture, msgServer := Setup(t)
- params, err := fixture.OracleKeeper.Params.Get(fixture.Ctx)
- require.NoError(t, err)
-
- t.Log("whitelist ONLY atom:usd")
- for _, p := range fixture.OracleKeeper.WhitelistedPairs.Iterate(fixture.Ctx, collections.Range[asset.Pair]{}).Keys() {
- fixture.OracleKeeper.WhitelistedPairs.Delete(fixture.Ctx, p)
- }
- fixture.OracleKeeper.WhitelistedPairs.Insert(fixture.Ctx, asset.Registry.Pair(denoms.ATOM, denoms.USD))
-
- t.Log("vote and prevote from all vals on atom:usd")
- priceVoteFromVal := func(valIdx int, block int64) {
- MakeAggregatePrevoteAndVote(t, fixture, msgServer, block, types.ExchangeRateTuples{{Pair: asset.Registry.Pair(denoms.ATOM, denoms.USD), ExchangeRate: testExchangeRate}}, valIdx)
- }
- block := int64(0)
- priceVoteFromVal(0, block)
- priceVoteFromVal(1, block)
- priceVoteFromVal(2, block)
- priceVoteFromVal(3, block)
-
- t.Log("whitelist btc:usd for next vote period")
- params.Whitelist = []asset.Pair{asset.Registry.Pair(denoms.ATOM, denoms.USD), asset.Registry.Pair(denoms.BTC, denoms.USD)}
- fixture.OracleKeeper.Params.Set(fixture.Ctx, params)
- fixture.OracleKeeper.UpdateExchangeRates(fixture.Ctx)
-
- t.Log("assert: no miss counts for all vals")
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[0], 0))
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[1], 0))
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[2], 0))
- assert.Equal(t, uint64(0), fixture.OracleKeeper.MissCounters.GetOr(fixture.Ctx, ValAddrs[3], 0))
-
- t.Log("whitelisted pairs are {atom:usd, btc:usd}")
- assert.Equal(t,
- []asset.Pair{
- asset.Registry.Pair(denoms.ATOM, denoms.USD),
- asset.Registry.Pair(denoms.BTC, denoms.USD),
- },
- fixture.OracleKeeper.GetWhitelistedPairs(fixture.Ctx))
-
- t.Log("vote from vals 0-3 on atom:usd (but not btc:usd)")
- priceVoteFromVal(0, block)
- priceVoteFromVal(1, block)
- priceVoteFromVal(2, block)
- priceVoteFromVal(3, block)
-
- t.Log("delete btc:usd for next vote period")
- params.Whitelist = []asset.Pair{asset.Registry.Pair(denoms.ATOM, denoms.USD)}
- fixture.OracleKeeper.Params.Set(fixture.Ctx, params)
- perfs := fixture.OracleKeeper.UpdateExchangeRates(fixture.Ctx)
-
- t.Log("validators 0-3 all voted -> expect win")
- for valIdx := 0; valIdx < 4; valIdx++ {
- perf := perfs[ValAddrs[valIdx].String()]
- assert.EqualValues(t, 1, perf.WinCount)
- assert.EqualValues(t, 1, perf.AbstainCount)
- assert.EqualValues(t, 0, perf.MissCount)
- }
- t.Log("validators 4 didn't vote -> expect abstain")
- perf := perfs[ValAddrs[4].String()]
- assert.EqualValues(t, 0, perf.WinCount)
- assert.EqualValues(t, 2, perf.AbstainCount)
- assert.EqualValues(t, 0, perf.MissCount)
-
- t.Log("btc:usd must be deleted")
- assert.Equal(t, []asset.Pair{asset.Registry.Pair(denoms.ATOM, denoms.USD)},
- fixture.OracleKeeper.GetWhitelistedPairs(fixture.Ctx))
- require.False(t, fixture.OracleKeeper.WhitelistedPairs.Has(
- fixture.Ctx, asset.Registry.Pair(denoms.BTC, denoms.USD)))
-
- t.Log("vote from vals 0-3 on atom:usd")
- priceVoteFromVal(0, block)
- priceVoteFromVal(1, block)
- priceVoteFromVal(2, block)
- priceVoteFromVal(3, block)
- perfs = fixture.OracleKeeper.UpdateExchangeRates(fixture.Ctx)
-
- t.Log("Although validators 0-2 voted, it's for the same period -> expect abstains for everyone")
- for valIdx := 0; valIdx < 4; valIdx++ {
- perf := perfs[ValAddrs[valIdx].String()]
- assert.EqualValues(t, 1, perf.WinCount)
- assert.EqualValues(t, 0, perf.AbstainCount)
- assert.EqualValues(t, 0, perf.MissCount)
- }
- perf = perfs[ValAddrs[4].String()]
- assert.EqualValues(t, 0, perf.WinCount)
- assert.EqualValues(t, 1, perf.AbstainCount)
- assert.EqualValues(t, 0, perf.MissCount)
-}
diff --git a/x/oracle/keeper/whitelist.go b/x/oracle/keeper/whitelist.go
deleted file mode 100644
index f1662c19e..000000000
--- a/x/oracle/keeper/whitelist.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package keeper
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/set"
-)
-
-// IsWhitelistedPair returns existence of a pair in the voting target list
-func (k Keeper) IsWhitelistedPair(ctx sdk.Context, pair asset.Pair) bool {
- return k.WhitelistedPairs.Has(ctx, pair)
-}
-
-// GetWhitelistedPairs returns the whitelisted pairs list on current vote period
-func (k Keeper) GetWhitelistedPairs(ctx sdk.Context) []asset.Pair {
- return k.WhitelistedPairs.Iterate(ctx, collections.Range[asset.Pair]{}).Keys()
-}
-
-// refreshWhitelist updates the whitelist by detecting possible changes between
-// the current vote targets and the current updated whitelist.
-func (k Keeper) refreshWhitelist(ctx sdk.Context, nextWhitelist []asset.Pair, currentWhitelist set.Set[asset.Pair]) {
- updateRequired := false
-
- if len(currentWhitelist) != len(nextWhitelist) {
- updateRequired = true
- } else {
- for _, pair := range nextWhitelist {
- _, exists := currentWhitelist[pair]
- if !exists {
- updateRequired = true
- break
- }
- }
- }
-
- if updateRequired {
- for _, p := range k.WhitelistedPairs.Iterate(ctx, collections.Range[asset.Pair]{}).Keys() {
- k.WhitelistedPairs.Delete(ctx, p)
- }
- for _, pair := range nextWhitelist {
- k.WhitelistedPairs.Insert(ctx, pair)
- }
- }
-}
diff --git a/x/oracle/keeper/whitelist_test.go b/x/oracle/keeper/whitelist_test.go
deleted file mode 100644
index 6061d73e3..000000000
--- a/x/oracle/keeper/whitelist_test.go
+++ /dev/null
@@ -1,129 +0,0 @@
-package keeper
-
-import (
- "sort"
- "testing"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/common/set"
-)
-
-func TestKeeper_GetVoteTargets(t *testing.T) {
- type TestCase struct {
- name string
- in []asset.Pair
- panic bool
- }
-
- panicCases := []TestCase{
- {name: "blank pair", in: []asset.Pair{""}, panic: true},
- {name: "blank pair and others", in: []asset.Pair{"", "x", "abc", "defafask"}, panic: true},
- {name: "denom len too short", in: []asset.Pair{"x:y", "xx:yy"}, panic: true},
- }
- happyCases := []TestCase{
- {name: "happy", in: []asset.Pair{"foo:bar", "whoo:whoo"}},
- }
-
- for _, testCase := range append(panicCases, happyCases...) {
- tc := testCase
- t.Run(tc.name, func(t *testing.T) {
- input := CreateTestFixture(t)
-
- for _, p := range input.OracleKeeper.WhitelistedPairs.Iterate(input.Ctx, collections.Range[asset.Pair]{}).Keys() {
- input.OracleKeeper.WhitelistedPairs.Delete(input.Ctx, p)
- }
-
- expectedTargets := tc.in
- for _, target := range expectedTargets {
- input.OracleKeeper.WhitelistedPairs.Insert(input.Ctx, target)
- }
-
- var panicAssertFn func(t assert.TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool
- switch tc.panic {
- case true:
- panicAssertFn = assert.Panics
- default:
- panicAssertFn = assert.NotPanics
- }
- panicAssertFn(t, func() {
- targets := input.OracleKeeper.GetWhitelistedPairs(input.Ctx)
- assert.Equal(t, expectedTargets, targets)
- })
- })
- }
-
- input := CreateTestFixture(t)
-
- for _, p := range input.OracleKeeper.WhitelistedPairs.Iterate(input.Ctx, collections.Range[asset.Pair]{}).Keys() {
- input.OracleKeeper.WhitelistedPairs.Delete(input.Ctx, p)
- }
-
- expectedTargets := []asset.Pair{"foo:bar", "whoo:whoo"}
- for _, target := range expectedTargets {
- input.OracleKeeper.WhitelistedPairs.Insert(input.Ctx, target)
- }
-
- targets := input.OracleKeeper.GetWhitelistedPairs(input.Ctx)
- require.Equal(t, expectedTargets, targets)
-}
-
-func TestIsWhitelistedPair(t *testing.T) {
- input := CreateTestFixture(t)
-
- for _, p := range input.OracleKeeper.WhitelistedPairs.Iterate(input.Ctx, collections.Range[asset.Pair]{}).Keys() {
- input.OracleKeeper.WhitelistedPairs.Delete(input.Ctx, p)
- }
-
- validPairs := []asset.Pair{"foo:bar", "xxx:yyy", "whoo:whoo"}
- for _, target := range validPairs {
- input.OracleKeeper.WhitelistedPairs.Insert(input.Ctx, target)
- require.True(t, input.OracleKeeper.IsWhitelistedPair(input.Ctx, target))
- }
-}
-
-func TestUpdateWhitelist(t *testing.T) {
- fixture := CreateTestFixture(t)
- // prepare test by resetting the genesis pairs
- for _, p := range fixture.OracleKeeper.WhitelistedPairs.Iterate(fixture.Ctx, collections.Range[asset.Pair]{}).Keys() {
- fixture.OracleKeeper.WhitelistedPairs.Delete(fixture.Ctx, p)
- }
-
- currentWhitelist := set.New(asset.NewPair(denoms.NIBI, denoms.USD), asset.NewPair(denoms.BTC, denoms.USD))
- for p := range currentWhitelist {
- fixture.OracleKeeper.WhitelistedPairs.Insert(fixture.Ctx, p)
- }
-
- nextWhitelist := set.New(asset.NewPair(denoms.NIBI, denoms.USD), asset.NewPair(denoms.BTC, denoms.USD))
-
- // no updates case
- whitelistSlice := nextWhitelist.ToSlice()
- sort.Slice(whitelistSlice, func(i, j int) bool {
- return whitelistSlice[i].String() < whitelistSlice[j].String()
- })
- fixture.OracleKeeper.refreshWhitelist(fixture.Ctx, whitelistSlice, currentWhitelist)
- assert.Equal(t, whitelistSlice, fixture.OracleKeeper.GetWhitelistedPairs(fixture.Ctx))
-
- // len update (fast path)
- nextWhitelist.Add(asset.NewPair(denoms.NIBI, denoms.ETH))
- whitelistSlice = nextWhitelist.ToSlice()
- sort.Slice(whitelistSlice, func(i, j int) bool {
- return whitelistSlice[i].String() < whitelistSlice[j].String()
- })
- fixture.OracleKeeper.refreshWhitelist(fixture.Ctx, whitelistSlice, currentWhitelist)
- assert.Equal(t, whitelistSlice, fixture.OracleKeeper.GetWhitelistedPairs(fixture.Ctx))
-
- // diff update (slow path)
- currentWhitelist.Add(asset.NewPair(denoms.NIBI, denoms.ATOM))
- whitelistSlice = nextWhitelist.ToSlice()
- sort.Slice(whitelistSlice, func(i, j int) bool {
- return whitelistSlice[i].String() < whitelistSlice[j].String()
- })
- fixture.OracleKeeper.refreshWhitelist(fixture.Ctx, whitelistSlice, currentWhitelist)
- assert.Equal(t, whitelistSlice, fixture.OracleKeeper.GetWhitelistedPairs(fixture.Ctx))
-}
diff --git a/x/oracle/module.go b/x/oracle/module.go
deleted file mode 100644
index d69df8fdc..000000000
--- a/x/oracle/module.go
+++ /dev/null
@@ -1,181 +0,0 @@
-package oracle
-
-import (
- "context"
- "encoding/json"
- "fmt"
-
- "github.com/gorilla/mux"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/spf13/cobra"
-
- abci "github.com/cometbft/cometbft/abci/types"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
- simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
-
- "github.com/NibiruChain/nibiru/x/oracle/client/cli"
- "github.com/NibiruChain/nibiru/x/oracle/keeper"
- "github.com/NibiruChain/nibiru/x/oracle/simulation"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-var (
- _ module.AppModule = AppModule{}
- _ module.AppModuleBasic = AppModuleBasic{}
- _ module.AppModuleSimulation = AppModule{}
-)
-
-// AppModuleBasic defines the basic application module used by the oracle module.
-type AppModuleBasic struct {
- cdc codec.Codec
-}
-
-// Name returns the module's name
-func (AppModuleBasic) Name() string {
- return types.ModuleName
-}
-
-// RegisterLegacyAminoCodec registers the module's types on the given LegacyAmino codec.
-func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- types.RegisterLegacyAminoCodec(cdc)
-}
-
-// RegisterInterfaces registers the module's interface types
-func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- types.RegisterInterfaces(registry)
-}
-
-// DefaultGenesis returns default genesis state as raw bytes for the staking
-// module.
-func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
- return cdc.MustMarshalJSON(types.DefaultGenesisState())
-}
-
-// ValidateGenesis performs genesis state validation for the oracle module.
-func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
- var data types.GenesisState
- if err := cdc.UnmarshalJSON(bz, &data); err != nil {
- return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
- }
-
- return types.ValidateGenesis(&data)
-}
-
-// RegisterRESTRoutes registers the REST routes for the oracle module.
-func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {
-}
-
-// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the oracle module.
-func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
- _ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
-}
-
-// GetTxCmd returns the root tx command for the oracle module.
-func (AppModuleBasic) GetTxCmd() *cobra.Command {
- return cli.GetTxCmd()
-}
-
-// GetQueryCmd returns no root query command for the oracle module.
-func (AppModuleBasic) GetQueryCmd() *cobra.Command {
- return cli.GetQueryCmd()
-}
-
-//___________________________
-
-// AppModule implements an application module for the oracle module.
-type AppModule struct {
- AppModuleBasic
- keeper keeper.Keeper
- accountKeeper types.AccountKeeper
- bankKeeper types.BankKeeper
-}
-
-// NewAppModule creates a new AppModule object
-func NewAppModule(
- cdc codec.Codec,
- keeper keeper.Keeper,
- accountKeeper types.AccountKeeper,
- bankKeeper types.BankKeeper,
-) AppModule {
- return AppModule{
- AppModuleBasic: AppModuleBasic{cdc},
- keeper: keeper,
- accountKeeper: accountKeeper,
- bankKeeper: bankKeeper,
- }
-}
-
-// Name returns the oracle module's name.
-func (AppModule) Name() string { return types.ModuleName }
-
-// RegisterInvariants performs a no-op.
-func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
-
-// RegisterServices registers module services.
-func (am AppModule) RegisterServices(cfg module.Configurator) {
- types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
- querier := keeper.NewQuerier(am.keeper)
- types.RegisterQueryServer(cfg.QueryServer(), querier)
-}
-
-// InitGenesis performs genesis initialization for the oracle module. It returns
-// no validator updates.
-func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
- var genesisState types.GenesisState
- cdc.MustUnmarshalJSON(data, &genesisState)
- InitGenesis(ctx, am.keeper, &genesisState)
-
- return nil
-}
-
-// ExportGenesis returns the exported genesis state as raw bytes for the oracle
-// module.
-func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
- gs := ExportGenesis(ctx, am.keeper)
- return cdc.MustMarshalJSON(gs)
-}
-
-// ConsensusVersion implements AppModule/ConsensusVersion.
-func (AppModule) ConsensusVersion() uint64 { return 1 }
-
-// BeginBlock returns the begin blocker for the oracle module.
-func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
-
-// EndBlock returns the end blocker for the oracle module.
-func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
- EndBlocker(ctx, am.keeper)
- return []abci.ValidatorUpdate{}
-}
-
-//____________________________________________________________________________
-
-// AppModuleSimulation functions
-
-// GenerateGenesisState creates a randomized GenState of the oracle module.
-func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
- simulation.RandomizedGenState(simState)
-}
-
-// ProposalContents returns all the oracle content functions used to
-// simulate governance proposals.
-func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg {
- return nil
-}
-
-// RegisterStoreDecoder registers a decoder for oracle module's types
-func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
- sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
-}
-
-// WeightedOperations returns the all the oracle module operations with their respective weights.
-func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
- return simulation.WeightedOperations(
- simState.AppParams, simState.Cdc,
- am.accountKeeper, am.bankKeeper, am.keeper,
- )
-}
diff --git a/x/oracle/simulation/decoder.go b/x/oracle/simulation/decoder.go
deleted file mode 100644
index 25935f631..000000000
--- a/x/oracle/simulation/decoder.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package simulation
-
-import (
- "fmt"
-
- "github.com/cosmos/cosmos-sdk/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/kv"
- gogotypes "github.com/cosmos/gogoproto/types"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's
-// Value to the corresponding oracle type.
-func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
- return func(kvA, kvB kv.Pair) string {
- switch kvA.Key[0] {
- case 1:
- return fmt.Sprintf("%v\n%v", collections.DecValueEncoder.Decode(kvA.Value), collections.DecValueEncoder.Decode(kvB.Value))
- case 2:
- return fmt.Sprintf("%v\n%v", sdk.AccAddress(kvA.Value), sdk.AccAddress(kvB.Value))
- case 3:
- var counterA, counterB gogotypes.UInt64Value
- cdc.MustUnmarshal(kvA.Value, &counterA)
- cdc.MustUnmarshal(kvB.Value, &counterB)
- return fmt.Sprintf("%v\n%v", counterA.Value, counterB.Value)
- case 4:
- var prevoteA, prevoteB types.AggregateExchangeRatePrevote
- cdc.MustUnmarshal(kvA.Value, &prevoteA)
- cdc.MustUnmarshal(kvB.Value, &prevoteB)
- return fmt.Sprintf("%v\n%v", prevoteA, prevoteB)
- case 5:
- var voteA, voteB types.AggregateExchangeRateVote
- cdc.MustUnmarshal(kvA.Value, &voteA)
- cdc.MustUnmarshal(kvB.Value, &voteB)
- return fmt.Sprintf("%v\n%v", voteA, voteB)
- case 6:
- _, a := collections.StringKeyEncoder.Decode(kvA.Key[1:])
- _, b := collections.StringKeyEncoder.Decode(kvB.Key[1:])
- return fmt.Sprintf("%s\n%s", a, b)
- default:
- panic(fmt.Sprintf("invalid oracle key prefix %X", kvA.Key[:1]))
- }
- }
-}
diff --git a/x/oracle/simulation/decoder_test.go b/x/oracle/simulation/decoder_test.go
deleted file mode 100644
index f1d5c7702..000000000
--- a/x/oracle/simulation/decoder_test.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package simulation_test
-
-import (
- "fmt"
- "testing"
-
- "cosmossdk.io/math"
- "github.com/cometbft/cometbft/crypto/ed25519"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/kv"
- gogotypes "github.com/cosmos/gogoproto/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/oracle/keeper"
- sim "github.com/NibiruChain/nibiru/x/oracle/simulation"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-var (
- delPk = ed25519.GenPrivKey().PubKey()
- feederAddr = sdk.AccAddress(delPk.Address())
- valAddr = sdk.ValAddress(delPk.Address())
-)
-
-func TestDecodeDistributionStore(t *testing.T) {
- cdc := keeper.MakeTestCodec(t)
- dec := sim.NewDecodeStore(cdc)
-
- exchangeRate := math.LegacyNewDecWithPrec(1234, 1)
- missCounter := uint64(23)
-
- aggregatePrevote := types.NewAggregateExchangeRatePrevote(types.AggregateVoteHash([]byte("12345")), valAddr, 123)
- aggregateVote := types.NewAggregateExchangeRateVote(types.ExchangeRateTuples{
- {Pair: asset.Registry.Pair(denoms.NIBI, denoms.NUSD), ExchangeRate: math.LegacyNewDecWithPrec(1234, 1)},
- {Pair: asset.Registry.Pair(denoms.ETH, denoms.NUSD), ExchangeRate: math.LegacyNewDecWithPrec(4321, 1)},
- }, valAddr)
-
- pair := "btc:usd"
-
- erBytes, err := exchangeRate.Marshal()
- require.NoError(t, err)
-
- kvPairs := kv.Pairs{
- Pairs: []kv.Pair{
- {Key: []byte{0x1, 0x2, 0x3, 0x4, 0x5}, Value: erBytes},
- {Key: []byte{0x2, 0x3, 0x4, 0x5, 0x6}, Value: feederAddr.Bytes()},
- {Key: []byte{0x3, 0x4, 0x5, 0x6, 0x7}, Value: cdc.MustMarshal(&gogotypes.UInt64Value{Value: missCounter})},
- {Key: []byte{0x4, 0x3, 0x5, 0x7, 0x8}, Value: cdc.MustMarshal(&aggregatePrevote)},
- {Key: []byte{0x5, 0x6, 0x7, 0x8, 0x9}, Value: cdc.MustMarshal(&aggregateVote)},
- {Key: append([]byte{0x6}, append([]byte(pair), 0x0)...), Value: []byte{}},
- {Key: []byte{0x99}, Value: []byte{0x99}},
- },
- }
-
- tests := []struct {
- name string
- expectedLog string
- }{
- {"ExchangeRate", fmt.Sprintf("%v\n%v", exchangeRate, exchangeRate)},
- {"FeederDelegation", fmt.Sprintf("%v\n%v", feederAddr, feederAddr)},
- {"MissCounter", fmt.Sprintf("%v\n%v", missCounter, missCounter)},
- {"AggregatePrevote", fmt.Sprintf("%v\n%v", aggregatePrevote, aggregatePrevote)},
- {"AggregateVote", fmt.Sprintf("%v\n%v", aggregateVote, aggregateVote)},
- {"Pairs", fmt.Sprintf("%s\n%s", pair, pair)},
- {"other", ""},
- }
-
- for i, tt := range tests {
- i, tt := i, tt
- t.Run(tt.name, func(t *testing.T) {
- switch i {
- case len(tests) - 1:
- require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name)
- default:
- require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i]), tt.name)
- }
- })
- }
-}
diff --git a/x/oracle/simulation/genesis.go b/x/oracle/simulation/genesis.go
deleted file mode 100644
index 3bae9471b..000000000
--- a/x/oracle/simulation/genesis.go
+++ /dev/null
@@ -1,128 +0,0 @@
-package simulation
-
-// DONTCOVER
-
-import (
- "encoding/json"
- "fmt"
- "math/rand"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
-
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-// Simulation parameter constants
-const (
- voteThresholdKey = "vote_threshold"
- rewardBandKey = "reward_band"
- slashFractionKey = "slash_fraction"
- slashWindowKey = "slash_window"
- minValidPerWindowKey = "min_valid_per_window"
-)
-
-// GenVotePeriod randomized VotePeriod
-func GenVotePeriod(r *rand.Rand) uint64 {
- return uint64(1 + r.Intn(100))
-}
-
-// GenVoteThreshold randomized VoteThreshold
-func GenVoteThreshold(r *rand.Rand) sdk.Dec {
- return math.LegacyNewDecWithPrec(333, 3).Add(math.LegacyNewDecWithPrec(int64(r.Intn(333)), 3))
-}
-
-// GenRewardBand randomized RewardBand
-func GenRewardBand(r *rand.Rand) sdk.Dec {
- return math.LegacyZeroDec().Add(math.LegacyNewDecWithPrec(int64(r.Intn(100)), 3))
-}
-
-// GenRewardDistributionWindow randomized RewardDistributionWindow
-func GenRewardDistributionWindow(r *rand.Rand) uint64 {
- return uint64(100 + r.Intn(100000))
-}
-
-// GenSlashFraction randomized SlashFraction
-func GenSlashFraction(r *rand.Rand) sdk.Dec {
- return math.LegacyZeroDec().Add(math.LegacyNewDecWithPrec(int64(r.Intn(100)), 3))
-}
-
-// GenSlashWindow randomized SlashWindow
-func GenSlashWindow(r *rand.Rand) uint64 {
- return uint64(100 + r.Intn(100000))
-}
-
-// GenMinValidPerWindow randomized MinValidPerWindow
-func GenMinValidPerWindow(r *rand.Rand) sdk.Dec {
- return math.LegacyZeroDec().Add(math.LegacyNewDecWithPrec(int64(r.Intn(500)), 3))
-}
-
-// RandomizedGenState generates a random GenesisState for oracle
-func RandomizedGenState(simState *module.SimulationState) {
- var voteThreshold sdk.Dec
- simState.AppParams.GetOrGenerate(
- simState.Cdc, voteThresholdKey, &voteThreshold, simState.Rand,
- func(r *rand.Rand) { voteThreshold = GenVoteThreshold(r) },
- )
-
- var rewardBand sdk.Dec
- simState.AppParams.GetOrGenerate(
- simState.Cdc, rewardBandKey, &rewardBand, simState.Rand,
- func(r *rand.Rand) { rewardBand = GenRewardBand(r) },
- )
-
- var slashFraction sdk.Dec
- simState.AppParams.GetOrGenerate(
- simState.Cdc, slashFractionKey, &slashFraction, simState.Rand,
- func(r *rand.Rand) { slashFraction = GenSlashFraction(r) },
- )
-
- var slashWindow uint64
- simState.AppParams.GetOrGenerate(
- simState.Cdc, slashWindowKey, &slashWindow, simState.Rand,
- func(r *rand.Rand) { slashWindow = GenSlashWindow(r) },
- )
-
- var minValidPerWindow sdk.Dec
- simState.AppParams.GetOrGenerate(
- simState.Cdc, minValidPerWindowKey, &minValidPerWindow, simState.Rand,
- func(r *rand.Rand) { minValidPerWindow = GenMinValidPerWindow(r) },
- )
-
- oracleGenesis := types.NewGenesisState(
- types.Params{
- VotePeriod: uint64(10_000),
- VoteThreshold: voteThreshold,
- RewardBand: rewardBand,
- Whitelist: []asset.Pair{
- asset.Registry.Pair(denoms.ETH, denoms.NUSD),
- asset.Registry.Pair(denoms.USDC, denoms.NUSD),
- asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- asset.Registry.Pair(denoms.NIBI, denoms.NUSD),
- },
- SlashFraction: slashFraction,
- SlashWindow: slashWindow,
- MinValidPerWindow: minValidPerWindow,
- },
- []types.ExchangeRateTuple{
- {Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD), ExchangeRate: math.LegacyNewDec(20_000)},
- },
- []types.FeederDelegation{},
- []types.MissCounter{},
- []types.AggregateExchangeRatePrevote{},
- []types.AggregateExchangeRateVote{},
- []asset.Pair{},
- []types.Rewards{},
- )
-
- bz, err := json.MarshalIndent(&oracleGenesis, "", " ")
- if err != nil {
- panic(err)
- }
- fmt.Printf("Selected randomly generated oracle parameters:\n%s\n", bz)
- simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(oracleGenesis)
-}
diff --git a/x/oracle/simulation/operations.go b/x/oracle/simulation/operations.go
deleted file mode 100644
index 16a105010..000000000
--- a/x/oracle/simulation/operations.go
+++ /dev/null
@@ -1,277 +0,0 @@
-package simulation
-
-// DONTCOVER
-
-import (
- "math/rand"
- "strings"
-
- "cosmossdk.io/math"
- "github.com/CosmWasm/wasmd/app/params"
- "github.com/cosmos/cosmos-sdk/types/module/testutil"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
-
- helpers "github.com/cosmos/cosmos-sdk/testutil/sims"
-
- "github.com/cosmos/cosmos-sdk/baseapp"
- "github.com/cosmos/cosmos-sdk/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
- simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
- "github.com/cosmos/cosmos-sdk/x/simulation"
-
- "github.com/NibiruChain/nibiru/x/oracle/keeper"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-// Simulation operation weights constants
-const (
- OpWeightMsgAggregateExchangeRatePrevote = "op_weight_msg_exchange_rate_aggregate_prevote"
- OpWeightMsgAggregateExchangeRateVote = "op_weight_msg_exchange_rate_aggregate_vote"
- OpWeightMsgDelegateFeedConsent = "op_weight_msg_exchange_feed_consent"
-
- salt = "1234"
-)
-
-var (
- whitelist = []asset.Pair{asset.Registry.Pair(denoms.BTC, denoms.NUSD), asset.Registry.Pair(denoms.ETH, denoms.NUSD), asset.Registry.Pair(denoms.NIBI, denoms.NUSD)}
- voteHashMap map[string]string = make(map[string]string)
-)
-
-// WeightedOperations returns all the operations from the module with their respective weights
-func WeightedOperations(
- appParams simtypes.AppParams,
- cdc codec.JSONCodec,
- ak types.AccountKeeper,
- bk types.BankKeeper,
- k keeper.Keeper,
-) simulation.WeightedOperations {
- var (
- weightMsgAggregateExchangeRatePrevote int
- weightMsgAggregateExchangeRateVote int
- weightMsgDelegateFeedConsent int
- )
- appParams.GetOrGenerate(cdc, OpWeightMsgAggregateExchangeRatePrevote, &weightMsgAggregateExchangeRatePrevote, nil,
- func(_ *rand.Rand) {
- weightMsgAggregateExchangeRatePrevote = params.DefaultWeightMsgSend * 2
- },
- )
-
- appParams.GetOrGenerate(cdc, OpWeightMsgAggregateExchangeRateVote, &weightMsgAggregateExchangeRateVote, nil,
- func(_ *rand.Rand) {
- weightMsgAggregateExchangeRateVote = params.DefaultWeightMsgSend * 2
- },
- )
-
- appParams.GetOrGenerate(cdc, OpWeightMsgDelegateFeedConsent, &weightMsgDelegateFeedConsent, nil,
- func(_ *rand.Rand) {
- weightMsgDelegateFeedConsent = params.DefaultWeightMsgDelegate // TODO: temp fix
- },
- )
-
- return simulation.WeightedOperations{
- simulation.NewWeightedOperation(
- weightMsgAggregateExchangeRatePrevote,
- SimulateMsgAggregateExchangeRatePrevote(ak, bk, k),
- ),
- simulation.NewWeightedOperation(
- weightMsgAggregateExchangeRateVote,
- SimulateMsgAggregateExchangeRateVote(ak, bk, k),
- ),
- simulation.NewWeightedOperation(
- weightMsgDelegateFeedConsent,
- SimulateMsgDelegateFeedConsent(ak, bk, k),
- ),
- }
-}
-
-// SimulateMsgAggregateExchangeRatePrevote generates a MsgAggregateExchangeRatePrevote with random values.
-// nolint: funlen
-func SimulateMsgAggregateExchangeRatePrevote(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation {
- return func(
- r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
- ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
- simAccount, _ := simtypes.RandomAcc(r, accs)
- address := sdk.ValAddress(simAccount.Address)
-
- // ensure the validator exists
- val := k.StakingKeeper.Validator(ctx, address)
- if val == nil || !val.IsBonded() {
- return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRatePrevote, "unable to find validator"), nil, nil
- }
-
- exchangeRatesStr := ""
- for _, pair := range whitelist {
- price := math.LegacyNewDecWithPrec(int64(simtypes.RandIntBetween(r, 1, 10000)), int64(1))
- exchangeRatesStr += price.String() + pair.String() + ","
- }
-
- exchangeRatesStr = strings.TrimRight(exchangeRatesStr, ",")
- voteHash := types.GetAggregateVoteHash(salt, exchangeRatesStr, address)
-
- feederAddr := k.FeederDelegations.GetOr(ctx, address, sdk.AccAddress(address))
- feederSimAccount, _ := simtypes.FindAccount(accs, feederAddr)
-
- feederAccount := ak.GetAccount(ctx, feederAddr)
- spendable := bk.SpendableCoins(ctx, feederAccount.GetAddress())
-
- fees, err := simtypes.RandomFees(r, ctx, spendable)
- if err != nil {
- return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRatePrevote, "unable to generate fees"), nil, err
- }
-
- msg := types.NewMsgAggregateExchangeRatePrevote(voteHash, feederAddr, address)
-
- txGen := testutil.MakeTestEncodingConfig().TxConfig
- tx, err := helpers.GenSignedMockTx(
- r,
- txGen,
- []sdk.Msg{msg},
- fees,
- helpers.DefaultGenTxGas,
- chainID,
- []uint64{feederAccount.GetAccountNumber()},
- []uint64{feederAccount.GetSequence()},
- feederSimAccount.PrivKey,
- )
- if err != nil {
- return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err
- }
-
- _, _, err = app.SimDeliver(txGen.TxEncoder(), tx)
- if err != nil {
- return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err
- }
-
- voteHashMap[address.String()] = exchangeRatesStr
-
- return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil
- }
-}
-
-// SimulateMsgAggregateExchangeRateVote generates a MsgAggregateExchangeRateVote with random values.
-// nolint: funlen
-func SimulateMsgAggregateExchangeRateVote(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation {
- return func(
- r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
- ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
- simAccount, _ := simtypes.RandomAcc(r, accs)
- address := sdk.ValAddress(simAccount.Address)
-
- // ensure the validator exists
- val := k.StakingKeeper.Validator(ctx, address)
- if val == nil || !val.IsBonded() {
- return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "unable to find validator"), nil, nil
- }
-
- // ensure vote hash exists
- exchangeRatesStr, ok := voteHashMap[address.String()]
- if !ok {
- return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "vote hash not exists"), nil, nil
- }
-
- // get prevote
- prevote, err := k.Prevotes.Get(ctx, address)
- if err != nil {
- return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "prevote not found"), nil, nil
- }
-
- params, _ := k.Params.Get(ctx)
- if (uint64(ctx.BlockHeight())/params.VotePeriod)-(prevote.SubmitBlock/params.VotePeriod) != 1 {
- return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "reveal period of submitted vote do not match with registered prevote"), nil, nil
- }
-
- feederAddr := k.FeederDelegations.GetOr(ctx, address, sdk.AccAddress(address))
- feederSimAccount, _ := simtypes.FindAccount(accs, feederAddr)
- feederAccount := ak.GetAccount(ctx, feederAddr)
- spendableCoins := bk.SpendableCoins(ctx, feederAddr)
-
- fees, err := simtypes.RandomFees(r, ctx, spendableCoins)
- if err != nil {
- return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "unable to generate fees"), nil, err
- }
-
- msg := types.NewMsgAggregateExchangeRateVote(salt, exchangeRatesStr, feederAddr, address)
-
- txGen := testutil.MakeTestEncodingConfig().TxConfig
- tx, err := helpers.GenSignedMockTx(
- r,
- txGen,
- []sdk.Msg{msg},
- fees,
- helpers.DefaultGenTxGas,
- chainID,
- []uint64{feederAccount.GetAccountNumber()},
- []uint64{feederAccount.GetSequence()},
- feederSimAccount.PrivKey,
- )
- if err != nil {
- return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err
- }
-
- _, _, err = app.SimDeliver(txGen.TxEncoder(), tx)
- if err != nil {
- return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err
- }
-
- return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil
- }
-}
-
-// SimulateMsgDelegateFeedConsent generates a MsgDelegateFeedConsent with random values.
-// nolint: funlen
-func SimulateMsgDelegateFeedConsent(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation {
- return func(
- r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
- ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
- simAccount, _ := simtypes.RandomAcc(r, accs)
- delegateAccount, _ := simtypes.RandomAcc(r, accs)
- valAddress := sdk.ValAddress(simAccount.Address)
- delegateValAddress := sdk.ValAddress(delegateAccount.Address)
- account := ak.GetAccount(ctx, simAccount.Address)
-
- // ensure the validator exists
- val := k.StakingKeeper.Validator(ctx, valAddress)
- if val == nil {
- return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgDelegateFeedConsent, "unable to find validator"), nil, nil
- }
-
- // ensure the target address is not a validator
- val2 := k.StakingKeeper.Validator(ctx, delegateValAddress)
- if val2 != nil {
- return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgDelegateFeedConsent, "unable to delegate to validator"), nil, nil
- }
-
- spendableCoins := bk.SpendableCoins(ctx, account.GetAddress())
- fees, err := simtypes.RandomFees(r, ctx, spendableCoins)
- if err != nil {
- return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAggregateExchangeRateVote, "unable to generate fees"), nil, err
- }
-
- msg := types.NewMsgDelegateFeedConsent(valAddress, delegateAccount.Address)
-
- txGen := testutil.MakeTestEncodingConfig().TxConfig
- tx, err := helpers.GenSignedMockTx(
- r,
- txGen,
- []sdk.Msg{msg},
- fees,
- helpers.DefaultGenTxGas,
- chainID,
- []uint64{account.GetAccountNumber()},
- []uint64{account.GetSequence()},
- simAccount.PrivKey,
- )
- if err != nil {
- return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err
- }
-
- _, _, err = app.SimDeliver(txGen.TxEncoder(), tx)
- if err != nil {
- return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err
- }
-
- return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil
- }
-}
diff --git a/x/oracle/types/ballot.go b/x/oracle/types/ballot.go
deleted file mode 100644
index 4311db6fc..000000000
--- a/x/oracle/types/ballot.go
+++ /dev/null
@@ -1,220 +0,0 @@
-package types
-
-import (
- "encoding/json"
- "sort"
-
- "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/common"
- "github.com/NibiruChain/nibiru/x/common/asset"
-)
-
-// NOTE: we don't need to implement proto interface on this file
-// these are not used in store or rpc response
-
-// ExchangeRateVote is a convenience wrapper to reduce redundant lookup cost
-type ExchangeRateVote struct {
- Pair asset.Pair
- ExchangeRate sdk.Dec // aka price
- Voter sdk.ValAddress
- Power int64 // how much tendermint consensus power this vote should have
-}
-
-// NewExchangeRateVote returns a new ExchangeRateVote instance
-func NewExchangeRateVote(rate sdk.Dec, pair asset.Pair, voter sdk.ValAddress, power int64) ExchangeRateVote {
- return ExchangeRateVote{
- ExchangeRate: rate,
- Pair: pair,
- Voter: voter,
- Power: power,
- }
-}
-
-// ExchangeRateVotes is a convenience wrapper around a ExchangeRateVote slice
-type ExchangeRateVotes []ExchangeRateVote
-
-// ToMap return organized exchange rate map by validator
-func (pb ExchangeRateVotes) ToMap() map[string]sdk.Dec {
- validatorExchangeRateMap := make(map[string]sdk.Dec)
- for _, vote := range pb {
- if vote.ExchangeRate.IsPositive() {
- validatorExchangeRateMap[string(vote.Voter)] = vote.ExchangeRate
- }
- }
-
- return validatorExchangeRateMap
-}
-
-// ToCrossRate return cross_rate(base/exchange_rate) votes
-func (pb ExchangeRateVotes) ToCrossRate(bases map[string]sdk.Dec) (cb ExchangeRateVotes) {
- for i := range pb {
- vote := pb[i]
-
- if exchangeRateRT, ok := bases[string(vote.Voter)]; ok && vote.ExchangeRate.IsPositive() {
- vote.ExchangeRate = exchangeRateRT.Quo(vote.ExchangeRate)
- } else {
- // If we can't get reference exchange rate, we just convert the vote as abstain vote
- vote.ExchangeRate = math.LegacyZeroDec()
- vote.Power = 0
- }
-
- cb = append(cb, vote)
- }
-
- return
-}
-
-// NumValidVoters returns the number of voters who actually voted (i.e. did not abstain from voting for a pair).
-func (v ExchangeRateVotes) NumValidVoters() uint64 {
- count := 0
- for _, vote := range v {
- if vote.ExchangeRate.IsPositive() {
- count++
- }
- }
- return uint64(count)
-}
-
-// Power returns the total amount of voting power in the votes
-func (v ExchangeRateVotes) Power() int64 {
- totalPower := int64(0)
- for _, vote := range v {
- totalPower += vote.Power
- }
-
- return totalPower
-}
-
-// WeightedMedian returns the median weighted by the power of the ExchangeRateVote.
-// CONTRACT: votes must be sorted
-func (votes ExchangeRateVotes) WeightedMedian() sdk.Dec {
- totalPower := votes.Power()
- if votes.Len() > 0 {
- pivot := int64(0)
- for _, v := range votes {
- votePower := v.Power
-
- pivot += votePower
- if pivot >= (totalPower / 2) {
- return v.ExchangeRate
- }
- }
- }
- return math.LegacyZeroDec()
-}
-
-// WeightedMedianWithAssertion returns the median weighted by the power of the ExchangeRateVote.
-func (pb ExchangeRateVotes) WeightedMedianWithAssertion() sdk.Dec {
- sort.Sort(pb)
- totalPower := pb.Power()
- if pb.Len() > 0 {
- pivot := int64(0)
- for _, v := range pb {
- votePower := v.Power
-
- pivot += votePower
- if pivot >= (totalPower / 2) {
- return v.ExchangeRate
- }
- }
- }
- return math.LegacyZeroDec()
-}
-
-// StandardDeviation returns the standard deviation by the power of the ExchangeRateVote.
-func (pb ExchangeRateVotes) StandardDeviation(median sdk.Dec) (standardDeviation sdk.Dec) {
- if len(pb) == 0 {
- return math.LegacyZeroDec()
- }
-
- defer func() {
- if e := recover(); e != nil {
- standardDeviation = math.LegacyZeroDec()
- }
- }()
-
- sum := math.LegacyZeroDec()
- n := 0
- for _, v := range pb {
- // ignore abstain votes in std dev calculation
- if v.ExchangeRate.IsPositive() {
- deviation := v.ExchangeRate.Sub(median)
- sum = sum.Add(deviation.Mul(deviation))
- n += 1
- }
- }
-
- variance := sum.QuoInt64(int64(n))
-
- standardDeviation, err := common.SqrtDec(variance)
- if err != nil {
- return math.LegacyZeroDec()
- }
-
- return
-}
-
-// Len implements sort.Interface
-func (pb ExchangeRateVotes) Len() int {
- return len(pb)
-}
-
-// Less reports whether the element with
-// index i should sort before the element with index j.
-func (pb ExchangeRateVotes) Less(i, j int) bool {
- return pb[i].ExchangeRate.LT(pb[j].ExchangeRate)
-}
-
-// Swap implements sort.Interface.
-func (pb ExchangeRateVotes) Swap(i, j int) {
- pb[i], pb[j] = pb[j], pb[i]
-}
-
-// ValidatorPerformance keeps track of a validator performance in the voting period.
-type ValidatorPerformance struct {
- // Tendermint consensus voting power
- Power int64
- // RewardWeight: Weight of rewards the validator should receive in units of
- // consensus power.
- RewardWeight int64
- WinCount int64 // Number of valid votes for which the validator will be rewarded
- AbstainCount int64 // Number of abstained votes for which there will be no reward or punishment
- MissCount int64 // Number of invalid/punishable votes
- ValAddress sdk.ValAddress
-}
-
-// NewValidatorPerformance generates a ValidatorPerformance instance.
-func NewValidatorPerformance(power int64, recipient sdk.ValAddress) ValidatorPerformance {
- return ValidatorPerformance{
- Power: power,
- RewardWeight: 0,
- WinCount: 0,
- AbstainCount: 0,
- MissCount: 0,
- ValAddress: recipient,
- }
-}
-
-type ValidatorPerformances map[string]ValidatorPerformance
-
-// TotalRewardWeight returns the sum of the reward weight of all the validators included in the map
-func (vp ValidatorPerformances) TotalRewardWeight() int64 {
- totalRewardWeight := int64(0)
- for _, validator := range vp {
- totalRewardWeight += validator.RewardWeight
- }
-
- return totalRewardWeight
-}
-
-func (vp ValidatorPerformances) String() string {
- jsonBz, _ := json.MarshalIndent(vp, "", " ")
- return string(jsonBz)
-}
-
-func (vp ValidatorPerformance) String() string {
- jsonBz, _ := json.MarshalIndent(vp, "", " ")
- return string(jsonBz)
-}
diff --git a/x/oracle/types/ballot_test.go b/x/oracle/types/ballot_test.go
deleted file mode 100644
index 317a6ff2c..000000000
--- a/x/oracle/types/ballot_test.go
+++ /dev/null
@@ -1,364 +0,0 @@
-package types_test
-
-import (
- "fmt"
- basicmath "math"
- "sort"
- "strconv"
- "testing"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
-
- "github.com/stretchr/testify/require"
-
- "github.com/cometbft/cometbft/crypto/secp256k1"
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
-
- "cosmossdk.io/math"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestExchangeRateVotesToMap(t *testing.T) {
- tests := struct {
- votes []types.ExchangeRateVote
- isValid []bool
- }{
- []types.ExchangeRateVote{
- {
- Voter: sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address()),
- Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- ExchangeRate: math.LegacyNewDec(1600),
- Power: 100,
- },
- {
- Voter: sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address()),
- Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- ExchangeRate: math.LegacyZeroDec(),
- Power: 100,
- },
- {
- Voter: sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address()),
- Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD),
- ExchangeRate: math.LegacyNewDec(1500),
- Power: 100,
- },
- },
- []bool{true, false, true},
- }
-
- pb := types.ExchangeRateVotes(tests.votes)
- mapData := pb.ToMap()
- for i, vote := range tests.votes {
- exchangeRate, ok := mapData[string(vote.Voter)]
- if tests.isValid[i] {
- require.True(t, ok)
- require.Equal(t, exchangeRate, vote.ExchangeRate)
- } else {
- require.False(t, ok)
- }
- }
- require.NotPanics(t, func() {
- types.ExchangeRateVotes(tests.votes).NumValidVoters()
- })
-}
-
-func TestToCrossRate(t *testing.T) {
- data := []struct {
- base sdk.Dec
- quote sdk.Dec
- expected sdk.Dec
- }{
- {
- base: math.LegacyNewDec(1600),
- quote: math.LegacyNewDec(100),
- expected: math.LegacyNewDec(16),
- },
- {
- base: math.LegacyZeroDec(),
- quote: math.LegacyNewDec(100),
- expected: math.LegacyNewDec(16),
- },
- {
- base: math.LegacyNewDec(1600),
- quote: math.LegacyZeroDec(),
- expected: math.LegacyNewDec(16),
- },
- }
-
- pbBase := types.ExchangeRateVotes{}
- pbQuote := types.ExchangeRateVotes{}
- cb := types.ExchangeRateVotes{}
- for _, data := range data {
- valAddr := sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address())
- if !data.base.IsZero() {
- pbBase = append(pbBase, types.NewExchangeRateVote(data.base, asset.Registry.Pair(denoms.BTC, denoms.NUSD), valAddr, 100))
- }
-
- pbQuote = append(pbQuote, types.NewExchangeRateVote(data.quote, asset.Registry.Pair(denoms.BTC, denoms.NUSD), valAddr, 100))
-
- if !data.base.IsZero() && !data.quote.IsZero() {
- cb = append(cb, types.NewExchangeRateVote(data.base.Quo(data.quote), asset.Registry.Pair(denoms.BTC, denoms.NUSD), valAddr, 100))
- } else {
- cb = append(cb, types.NewExchangeRateVote(math.LegacyZeroDec(), asset.Registry.Pair(denoms.BTC, denoms.NUSD), valAddr, 0))
- }
- }
-
- basePairPrices := pbBase.ToMap()
- require.Equal(t, cb, pbQuote.ToCrossRate(basePairPrices))
-
- sort.Sort(cb)
-}
-
-func TestSqrt(t *testing.T) {
- num := math.LegacyNewDecWithPrec(144, 4)
- floatNum, err := strconv.ParseFloat(num.String(), 64)
- require.NoError(t, err)
-
- floatNum = basicmath.Sqrt(floatNum)
- num, err = math.LegacyNewDecFromStr(fmt.Sprintf("%f", floatNum))
- require.NoError(t, err)
-
- require.Equal(t, math.LegacyNewDecWithPrec(12, 2), num)
-}
-
-func TestPBPower(t *testing.T) {
- ctx := sdk.NewContext(nil, tmproto.Header{}, false, nil)
- _, valAccAddrs, sk := types.GenerateRandomTestCase()
- pb := types.ExchangeRateVotes{}
- totalPower := int64(0)
-
- for i := 0; i < len(sk.Validators()); i++ {
- power := sk.Validator(ctx, valAccAddrs[i]).GetConsensusPower(sdk.DefaultPowerReduction)
- vote := types.NewExchangeRateVote(
- math.LegacyZeroDec(),
- asset.Registry.Pair(denoms.ETH, denoms.NUSD),
- valAccAddrs[i],
- power,
- )
-
- pb = append(pb, vote)
-
- require.NotEqual(t, int64(0), vote.Power)
-
- totalPower += vote.Power
- }
-
- require.Equal(t, totalPower, pb.Power())
-
- // Mix in a fake validator, the total power should not have changed.
- pubKey := secp256k1.GenPrivKey().PubKey()
- faceValAddr := sdk.ValAddress(pubKey.Address())
- fakeVote := types.NewExchangeRateVote(
- math.LegacyOneDec(),
- asset.Registry.Pair(denoms.ETH, denoms.NUSD),
- faceValAddr,
- 0,
- )
-
- pb = append(pb, fakeVote)
- require.Equal(t, totalPower, pb.Power())
-}
-
-func TestPBWeightedMedian(t *testing.T) {
- tests := []struct {
- inputs []int64
- weights []int64
- isValidator []bool
- median sdk.Dec
- }{
- {
- // Supermajority one number
- []int64{1, 2, 10, 100000},
- []int64{1, 1, 100, 1},
- []bool{true, true, true, true},
- math.LegacyNewDec(10),
- },
- {
- // Adding fake validator doesn't change outcome
- []int64{1, 2, 10, 100000, 10000000000},
- []int64{1, 1, 100, 1, 10000},
- []bool{true, true, true, true, false},
- math.LegacyNewDec(10),
- },
- {
- // Tie votes
- []int64{1, 2, 3, 4},
- []int64{1, 100, 100, 1},
- []bool{true, true, true, true},
- math.LegacyNewDec(2),
- },
- {
- // No votes
- []int64{},
- []int64{},
- []bool{true, true, true, true},
- math.LegacyZeroDec(),
- },
- {
- // not sorted
- []int64{2, 1, 10, 100000},
- []int64{1, 1, 100, 1},
- []bool{true, true, true, true},
- math.LegacyNewDec(10),
- },
- }
-
- for _, tc := range tests {
- pb := types.ExchangeRateVotes{}
- for i, input := range tc.inputs {
- valAddr := sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address())
-
- power := tc.weights[i]
- if !tc.isValidator[i] {
- power = 0
- }
-
- vote := types.NewExchangeRateVote(
- math.LegacyNewDec(int64(input)),
- asset.Registry.Pair(denoms.ETH, denoms.NUSD),
- valAddr,
- power,
- )
-
- pb = append(pb, vote)
- }
-
- require.Equal(t, tc.median, pb.WeightedMedian())
- require.Equal(t, tc.median, pb.WeightedMedianWithAssertion())
- }
-}
-
-func TestPBStandardDeviation(t *testing.T) {
- tests := []struct {
- inputs []float64
- weights []int64
- isValidator []bool
- standardDeviation sdk.Dec
- }{
- {
- // Supermajority one number
- []float64{1.0, 2.0, 10.0, 100000.0},
- []int64{1, 1, 100, 1},
- []bool{true, true, true, true},
- math.LegacyMustNewDecFromStr("49995.000362536000000000"),
- },
- {
- // Adding fake validator doesn't change outcome
- []float64{1.0, 2.0, 10.0, 100000.0, 10000000000},
- []int64{1, 1, 100, 1, 10000},
- []bool{true, true, true, true, false},
- math.LegacyMustNewDecFromStr("4472135950.751005519000000000"),
- },
- {
- // Tie votes
- []float64{1.0, 2.0, 3.0, 4.0},
- []int64{1, 100, 100, 1},
- []bool{true, true, true, true},
- math.LegacyMustNewDecFromStr("1.224744871000000000"),
- },
- {
- // No votes
- []float64{},
- []int64{},
- []bool{true, true, true, true},
- math.LegacyNewDecWithPrec(0, 0),
- },
- {
- // Abstain votes are ignored
- []float64{1.0, 2.0, 10.0, 100000.0, -99999999999.0, 0},
- []int64{1, 1, 100, 1, 1, 1},
- []bool{true, true, true, true, true, true},
- math.LegacyMustNewDecFromStr("49995.000362536000000000"),
- },
- }
-
- base := basicmath.Pow10(types.OracleDecPrecision)
- for _, tc := range tests {
- pb := types.ExchangeRateVotes{}
- for i, input := range tc.inputs {
- valAddr := sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address())
-
- power := tc.weights[i]
- if !tc.isValidator[i] {
- power = 0
- }
-
- vote := types.NewExchangeRateVote(
- math.LegacyNewDecWithPrec(int64(input*base), int64(types.OracleDecPrecision)),
- asset.Registry.Pair(denoms.ETH, denoms.NUSD),
- valAddr,
- power,
- )
-
- pb = append(pb, vote)
- }
-
- require.Equal(t, tc.standardDeviation, pb.StandardDeviation(pb.WeightedMedianWithAssertion()))
- }
-}
-
-func TestPBStandardDeviationOverflow(t *testing.T) {
- valAddr := sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address())
- exchangeRate, err := math.LegacyNewDecFromStr("100000000000000000000000000000000000000000000000000000000.0")
- require.NoError(t, err)
-
- pb := types.ExchangeRateVotes{types.NewExchangeRateVote(
- math.LegacyZeroDec(),
- asset.Registry.Pair(denoms.ETH, denoms.NUSD),
- valAddr,
- 2,
- ), types.NewExchangeRateVote(
- exchangeRate,
- asset.Registry.Pair(denoms.ETH, denoms.NUSD),
- valAddr,
- 1,
- )}
-
- require.Equal(t, math.LegacyZeroDec(), pb.StandardDeviation(pb.WeightedMedianWithAssertion()))
-}
-
-func TestNewClaim(t *testing.T) {
- power := int64(10)
- weight := int64(11)
- winCount := int64(1)
- addr := sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address().Bytes())
- claim := types.ValidatorPerformance{
- Power: power,
- RewardWeight: weight,
- WinCount: winCount,
- ValAddress: addr,
- }
- require.Equal(t, types.ValidatorPerformance{
- Power: power,
- RewardWeight: weight,
- WinCount: winCount,
- ValAddress: addr,
- }, claim)
-}
-
-func TestValidatorPerformances(t *testing.T) {
- power := int64(42)
- valNames := []string{"val0", "val1", "val2", "val3"}
- perfList := []types.ValidatorPerformance{
- types.NewValidatorPerformance(power, sdk.ValAddress([]byte(valNames[0]))),
- types.NewValidatorPerformance(power, sdk.ValAddress([]byte(valNames[1]))),
- types.NewValidatorPerformance(power, sdk.ValAddress([]byte(valNames[2]))),
- types.NewValidatorPerformance(power, sdk.ValAddress([]byte(valNames[3]))),
- }
- perfs := make(types.ValidatorPerformances)
- for idx, perf := range perfList {
- perfs[valNames[idx]] = perf
- }
-
- require.NotPanics(t, func() {
- out := perfs.String()
- require.NotEmpty(t, out)
-
- out = perfs[valNames[0]].String()
- require.NotEmpty(t, out)
- })
-}
diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go
deleted file mode 100644
index efe53d14e..000000000
--- a/x/oracle/types/codec.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package types
-
-import (
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/msgservice"
-)
-
-// RegisterLegacyAminoCodec registers the necessary x/oracle interfaces and concrete types
-// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
-func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- cdc.RegisterConcrete(&MsgAggregateExchangeRatePrevote{}, "oracle/MsgAggregateExchangeRatePrevote", nil)
- cdc.RegisterConcrete(&MsgAggregateExchangeRateVote{}, "oracle/MsgAggregateExchangeRateVote", nil)
- cdc.RegisterConcrete(&MsgDelegateFeedConsent{}, "oracle/MsgDelegateFeedConsent", nil)
-}
-
-// RegisterInterfaces registers the x/oracle interfaces types with the interface registry
-func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- registry.RegisterImplementations((*sdk.Msg)(nil),
- &MsgDelegateFeedConsent{},
- &MsgAggregateExchangeRatePrevote{},
- &MsgAggregateExchangeRateVote{},
- )
-
- msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
-}
-
-var (
- amino = codec.NewLegacyAmino()
-
- // ModuleCdc references the global x/oracle module codec. Note, the codec should
- // ONLY be used in certain instances of tests and for JSON encoding as Amino is
- // still used for that purpose.
- //
- // The actual codec used for serialization should be provided to x/staking and
- // defined at the application level.
- ModuleCdc = codec.NewAminoCodec(amino)
-)
-
-func init() {
- RegisterLegacyAminoCodec(amino)
- cryptocodec.RegisterCrypto(amino)
- amino.Seal()
-}
diff --git a/x/oracle/types/core.go b/x/oracle/types/core.go
deleted file mode 100644
index 774c44850..000000000
--- a/x/oracle/types/core.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package types
-
-import sdk "github.com/cosmos/cosmos-sdk/types"
-
-// IsPeriodLastBlock returns true if we are at the last block of the period
-func IsPeriodLastBlock(ctx sdk.Context, blocksPerPeriod uint64) bool {
- return ((uint64)(ctx.BlockHeight())+1)%blocksPerPeriod == 0
-}
diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go
deleted file mode 100644
index 95332e116..000000000
--- a/x/oracle/types/errors.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package types
-
-import (
- "fmt"
- "sync/atomic"
-
- "github.com/cometbft/cometbft/crypto/tmhash"
-
- sdkerrors "cosmossdk.io/errors"
-)
-
-var moduleErrorCodeIdx uint32 = 1
-
-// registerError: Cleaner way of using 'sdkerrors.Register' without as much time
-// manually writing integers.
-func registerError(msg string) *sdkerrors.Error {
- // Atomic for thread safety on concurrent calls
- atomic.AddUint32(&moduleErrorCodeIdx, 1)
- return sdkerrors.Register(ModuleName, moduleErrorCodeIdx, msg)
-}
-
-// Oracle Errors
-var (
- ErrInvalidExchangeRate = registerError("invalid exchange rate")
- ErrNoPrevote = registerError("no prevote")
- ErrNoVote = registerError("no vote")
- ErrNoVotingPermission = registerError("unauthorized voter")
- ErrInvalidHash = registerError("invalid hash")
- ErrInvalidHashLength = registerError(
- fmt.Sprintf("invalid hash length; should equal %d", tmhash.TruncatedSize))
- ErrHashVerificationFailed = registerError("hash verification failed")
- ErrRevealPeriodMissMatch = registerError("reveal period of submitted vote do not match with registered prevote")
- ErrInvalidSaltLength = registerError("invalid salt length; should be 1~4")
- ErrNoAggregatePrevote = registerError("no aggregate prevote")
- ErrNoAggregateVote = registerError("no aggregate vote")
- ErrUnknownPair = registerError("unknown pair")
- ErrNoValidTWAP = registerError("TWA price not found")
-)
diff --git a/x/oracle/types/event.pb.go b/x/oracle/types/event.pb.go
deleted file mode 100644
index fb48c177f..000000000
--- a/x/oracle/types/event.pb.go
+++ /dev/null
@@ -1,1512 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/oracle/v1/event.proto
-
-package types
-
-import (
- fmt "fmt"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// Emitted when a price is posted
-type EventPriceUpdate struct {
- Pair string `protobuf:"bytes,1,opt,name=pair,proto3" json:"pair,omitempty"`
- Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"`
- TimestampMs int64 `protobuf:"varint,3,opt,name=timestamp_ms,json=timestampMs,proto3" json:"timestamp_ms,omitempty"`
-}
-
-func (m *EventPriceUpdate) Reset() { *m = EventPriceUpdate{} }
-func (m *EventPriceUpdate) String() string { return proto.CompactTextString(m) }
-func (*EventPriceUpdate) ProtoMessage() {}
-func (*EventPriceUpdate) Descriptor() ([]byte, []int) {
- return fileDescriptor_94ec441b793fc0ea, []int{0}
-}
-func (m *EventPriceUpdate) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventPriceUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventPriceUpdate.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventPriceUpdate) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventPriceUpdate.Merge(m, src)
-}
-func (m *EventPriceUpdate) XXX_Size() int {
- return m.Size()
-}
-func (m *EventPriceUpdate) XXX_DiscardUnknown() {
- xxx_messageInfo_EventPriceUpdate.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventPriceUpdate proto.InternalMessageInfo
-
-func (m *EventPriceUpdate) GetPair() string {
- if m != nil {
- return m.Pair
- }
- return ""
-}
-
-func (m *EventPriceUpdate) GetTimestampMs() int64 {
- if m != nil {
- return m.TimestampMs
- }
- return 0
-}
-
-// Emitted when a valoper delegates oracle voting rights to a feeder address.
-type EventDelegateFeederConsent struct {
- // Validator is the Bech32 address that is delegating voting rights.
- Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"`
- // Feeder is the delegate or representative that will be able to send
- // vote and prevote transaction messages.
- Feeder string `protobuf:"bytes,2,opt,name=feeder,proto3" json:"feeder,omitempty"`
-}
-
-func (m *EventDelegateFeederConsent) Reset() { *m = EventDelegateFeederConsent{} }
-func (m *EventDelegateFeederConsent) String() string { return proto.CompactTextString(m) }
-func (*EventDelegateFeederConsent) ProtoMessage() {}
-func (*EventDelegateFeederConsent) Descriptor() ([]byte, []int) {
- return fileDescriptor_94ec441b793fc0ea, []int{1}
-}
-func (m *EventDelegateFeederConsent) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventDelegateFeederConsent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventDelegateFeederConsent.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventDelegateFeederConsent) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventDelegateFeederConsent.Merge(m, src)
-}
-func (m *EventDelegateFeederConsent) XXX_Size() int {
- return m.Size()
-}
-func (m *EventDelegateFeederConsent) XXX_DiscardUnknown() {
- xxx_messageInfo_EventDelegateFeederConsent.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventDelegateFeederConsent proto.InternalMessageInfo
-
-func (m *EventDelegateFeederConsent) GetValidator() string {
- if m != nil {
- return m.Validator
- }
- return ""
-}
-
-func (m *EventDelegateFeederConsent) GetFeeder() string {
- if m != nil {
- return m.Feeder
- }
- return ""
-}
-
-// Emitted by MsgAggregateExchangeVote when an aggregate vote is added to state
-type EventAggregateVote struct {
- // Validator is the Bech32 address to which the vote will be credited.
- Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"`
- // Feeder is the delegate or representative that will send vote and prevote
- // transaction messages on behalf of the voting validator.
- Feeder string `protobuf:"bytes,2,opt,name=feeder,proto3" json:"feeder,omitempty"`
- Prices ExchangeRateTuples `protobuf:"bytes,3,rep,name=prices,proto3,castrepeated=ExchangeRateTuples" json:"prices"`
-}
-
-func (m *EventAggregateVote) Reset() { *m = EventAggregateVote{} }
-func (m *EventAggregateVote) String() string { return proto.CompactTextString(m) }
-func (*EventAggregateVote) ProtoMessage() {}
-func (*EventAggregateVote) Descriptor() ([]byte, []int) {
- return fileDescriptor_94ec441b793fc0ea, []int{2}
-}
-func (m *EventAggregateVote) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventAggregateVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventAggregateVote.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventAggregateVote) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventAggregateVote.Merge(m, src)
-}
-func (m *EventAggregateVote) XXX_Size() int {
- return m.Size()
-}
-func (m *EventAggregateVote) XXX_DiscardUnknown() {
- xxx_messageInfo_EventAggregateVote.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventAggregateVote proto.InternalMessageInfo
-
-func (m *EventAggregateVote) GetValidator() string {
- if m != nil {
- return m.Validator
- }
- return ""
-}
-
-func (m *EventAggregateVote) GetFeeder() string {
- if m != nil {
- return m.Feeder
- }
- return ""
-}
-
-func (m *EventAggregateVote) GetPrices() ExchangeRateTuples {
- if m != nil {
- return m.Prices
- }
- return nil
-}
-
-// Emitted by MsgAggregateExchangePrevote when an aggregate prevote is added
-// to state
-type EventAggregatePrevote struct {
- // Validator is the Bech32 address to which the vote will be credited.
- Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"`
- // Feeder is the delegate or representative that will send vote and prevote
- // transaction messages on behalf of the voting validator.
- Feeder string `protobuf:"bytes,2,opt,name=feeder,proto3" json:"feeder,omitempty"`
-}
-
-func (m *EventAggregatePrevote) Reset() { *m = EventAggregatePrevote{} }
-func (m *EventAggregatePrevote) String() string { return proto.CompactTextString(m) }
-func (*EventAggregatePrevote) ProtoMessage() {}
-func (*EventAggregatePrevote) Descriptor() ([]byte, []int) {
- return fileDescriptor_94ec441b793fc0ea, []int{3}
-}
-func (m *EventAggregatePrevote) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventAggregatePrevote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventAggregatePrevote.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventAggregatePrevote) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventAggregatePrevote.Merge(m, src)
-}
-func (m *EventAggregatePrevote) XXX_Size() int {
- return m.Size()
-}
-func (m *EventAggregatePrevote) XXX_DiscardUnknown() {
- xxx_messageInfo_EventAggregatePrevote.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventAggregatePrevote proto.InternalMessageInfo
-
-func (m *EventAggregatePrevote) GetValidator() string {
- if m != nil {
- return m.Validator
- }
- return ""
-}
-
-func (m *EventAggregatePrevote) GetFeeder() string {
- if m != nil {
- return m.Feeder
- }
- return ""
-}
-
-type EventValidatorPerformance struct {
- // Validator is the Bech32 address to which the vote will be credited.
- Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"`
- // Tendermint consensus voting power
- VotingPower int64 `protobuf:"varint,2,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"`
- // RewardWeight: Weight of rewards the validator should receive in units of
- // consensus power.
- RewardWeight int64 `protobuf:"varint,3,opt,name=reward_weight,json=rewardWeight,proto3" json:"reward_weight,omitempty"`
- // Number of valid votes for which the validator will be rewarded
- WinCount int64 `protobuf:"varint,4,opt,name=win_count,json=winCount,proto3" json:"win_count,omitempty"`
- // Number of abstained votes for which there will be no reward or punishment
- AbstainCount int64 `protobuf:"varint,5,opt,name=abstain_count,json=abstainCount,proto3" json:"abstain_count,omitempty"`
- // Number of invalid/punishable votes
- MissCount int64 `protobuf:"varint,6,opt,name=miss_count,json=missCount,proto3" json:"miss_count,omitempty"`
-}
-
-func (m *EventValidatorPerformance) Reset() { *m = EventValidatorPerformance{} }
-func (m *EventValidatorPerformance) String() string { return proto.CompactTextString(m) }
-func (*EventValidatorPerformance) ProtoMessage() {}
-func (*EventValidatorPerformance) Descriptor() ([]byte, []int) {
- return fileDescriptor_94ec441b793fc0ea, []int{4}
-}
-func (m *EventValidatorPerformance) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventValidatorPerformance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventValidatorPerformance.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventValidatorPerformance) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventValidatorPerformance.Merge(m, src)
-}
-func (m *EventValidatorPerformance) XXX_Size() int {
- return m.Size()
-}
-func (m *EventValidatorPerformance) XXX_DiscardUnknown() {
- xxx_messageInfo_EventValidatorPerformance.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventValidatorPerformance proto.InternalMessageInfo
-
-func (m *EventValidatorPerformance) GetValidator() string {
- if m != nil {
- return m.Validator
- }
- return ""
-}
-
-func (m *EventValidatorPerformance) GetVotingPower() int64 {
- if m != nil {
- return m.VotingPower
- }
- return 0
-}
-
-func (m *EventValidatorPerformance) GetRewardWeight() int64 {
- if m != nil {
- return m.RewardWeight
- }
- return 0
-}
-
-func (m *EventValidatorPerformance) GetWinCount() int64 {
- if m != nil {
- return m.WinCount
- }
- return 0
-}
-
-func (m *EventValidatorPerformance) GetAbstainCount() int64 {
- if m != nil {
- return m.AbstainCount
- }
- return 0
-}
-
-func (m *EventValidatorPerformance) GetMissCount() int64 {
- if m != nil {
- return m.MissCount
- }
- return 0
-}
-
-func init() {
- proto.RegisterType((*EventPriceUpdate)(nil), "nibiru.oracle.v1.EventPriceUpdate")
- proto.RegisterType((*EventDelegateFeederConsent)(nil), "nibiru.oracle.v1.EventDelegateFeederConsent")
- proto.RegisterType((*EventAggregateVote)(nil), "nibiru.oracle.v1.EventAggregateVote")
- proto.RegisterType((*EventAggregatePrevote)(nil), "nibiru.oracle.v1.EventAggregatePrevote")
- proto.RegisterType((*EventValidatorPerformance)(nil), "nibiru.oracle.v1.EventValidatorPerformance")
-}
-
-func init() { proto.RegisterFile("nibiru/oracle/v1/event.proto", fileDescriptor_94ec441b793fc0ea) }
-
-var fileDescriptor_94ec441b793fc0ea = []byte{
- // 510 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xdd, 0x6e, 0xd3, 0x30,
- 0x14, 0x6e, 0xe8, 0x56, 0x51, 0xb7, 0x48, 0x93, 0x05, 0xa8, 0x94, 0x2e, 0xdd, 0x3a, 0x09, 0xf5,
- 0x02, 0x12, 0x0d, 0x9e, 0x80, 0xb6, 0xdb, 0xdd, 0x50, 0x15, 0xc1, 0x26, 0x71, 0x53, 0xb9, 0xc9,
- 0x99, 0x6b, 0x91, 0xd8, 0x91, 0xed, 0x26, 0xe3, 0x29, 0xe0, 0x1d, 0xb8, 0xe3, 0x49, 0x76, 0xb9,
- 0x4b, 0xc4, 0xc5, 0x40, 0xed, 0x8b, 0x20, 0x3b, 0xee, 0xf8, 0xd9, 0x05, 0xd2, 0xae, 0x72, 0xfc,
- 0x7d, 0x9f, 0xbf, 0x7c, 0xc9, 0x39, 0x07, 0xf5, 0x38, 0x9b, 0x33, 0xb9, 0x0c, 0x85, 0x24, 0x71,
- 0x0a, 0x61, 0x71, 0x18, 0x42, 0x01, 0x5c, 0x07, 0xb9, 0x14, 0x5a, 0xe0, 0x9d, 0x8a, 0x0d, 0x2a,
- 0x36, 0x28, 0x0e, 0xbb, 0xbb, 0xb7, 0xf4, 0x8e, 0xb3, 0x17, 0xba, 0x0f, 0xa9, 0xa0, 0xc2, 0x96,
- 0xa1, 0xa9, 0x1c, 0xda, 0xa3, 0x42, 0xd0, 0x14, 0x42, 0x92, 0xb3, 0x90, 0x70, 0x2e, 0x34, 0xd1,
- 0x4c, 0x70, 0x55, 0xb1, 0x83, 0x4f, 0x1e, 0xda, 0x39, 0x32, 0x2f, 0x9d, 0x4a, 0x16, 0xc3, 0xbb,
- 0x3c, 0x21, 0x1a, 0x30, 0x46, 0x5b, 0x39, 0x61, 0xb2, 0xe3, 0xed, 0x79, 0xc3, 0x66, 0x64, 0x6b,
- 0x3c, 0x41, 0xdb, 0xb9, 0x91, 0x74, 0xee, 0x19, 0x70, 0x14, 0x5c, 0x5e, 0xf7, 0x6b, 0xdf, 0xaf,
- 0xfb, 0xcf, 0x28, 0xd3, 0x8b, 0xe5, 0x3c, 0x88, 0x45, 0x16, 0xc6, 0x42, 0x65, 0x42, 0xb9, 0xc7,
- 0x0b, 0x95, 0x7c, 0x08, 0xf5, 0xc7, 0x1c, 0x54, 0x30, 0x81, 0x38, 0xaa, 0x2e, 0xe3, 0x7d, 0xd4,
- 0xd6, 0x2c, 0x03, 0xa5, 0x49, 0x96, 0xcf, 0x32, 0xd5, 0xa9, 0xef, 0x79, 0xc3, 0x7a, 0xd4, 0xba,
- 0xc1, 0x4e, 0xd4, 0x20, 0x42, 0x5d, 0x1b, 0x68, 0x02, 0x29, 0x50, 0xa2, 0xe1, 0x18, 0x20, 0x01,
- 0x39, 0x16, 0x5c, 0x01, 0xd7, 0xb8, 0x87, 0x9a, 0x05, 0x49, 0x59, 0x42, 0xb4, 0xd8, 0xe4, 0xfb,
- 0x0d, 0xe0, 0xc7, 0xa8, 0x71, 0x6e, 0xe5, 0x55, 0xca, 0xc8, 0x9d, 0x06, 0x5f, 0x3c, 0x84, 0xad,
- 0xe9, 0x6b, 0x4a, 0xa5, 0x75, 0x3d, 0x15, 0x1a, 0xee, 0x66, 0x86, 0xcf, 0x50, 0xc3, 0x7e, 0x8c,
- 0x49, 0x5f, 0x1f, 0xb6, 0x5e, 0x1e, 0x04, 0xff, 0x36, 0x2a, 0x38, 0xba, 0x88, 0x17, 0x84, 0x53,
- 0x88, 0x88, 0x86, 0xb7, 0xcb, 0x3c, 0x85, 0x51, 0xd7, 0xfc, 0xaf, 0xaf, 0x3f, 0xfa, 0xf8, 0x16,
- 0xa5, 0x22, 0x67, 0x37, 0x38, 0x41, 0x8f, 0xfe, 0x0e, 0x39, 0x95, 0x50, 0xdc, 0x39, 0xe7, 0x60,
- 0xe5, 0xa1, 0x27, 0xd6, 0xef, 0x74, 0x23, 0x9d, 0x82, 0x3c, 0x17, 0x32, 0x23, 0x3c, 0xfe, 0x9f,
- 0xe7, 0x3e, 0x6a, 0x17, 0x42, 0x33, 0x4e, 0x67, 0xb9, 0x28, 0x9d, 0x73, 0x3d, 0x6a, 0x55, 0xd8,
- 0xd4, 0x40, 0xf8, 0x00, 0x3d, 0x90, 0x50, 0x12, 0x99, 0xcc, 0x4a, 0x60, 0x74, 0xa1, 0x5d, 0x2f,
- 0xdb, 0x15, 0x78, 0x66, 0x31, 0xfc, 0x14, 0x35, 0x4b, 0xc6, 0x67, 0xb1, 0x58, 0x72, 0xdd, 0xd9,
- 0xb2, 0x82, 0xfb, 0x25, 0xe3, 0x63, 0x73, 0x36, 0x0e, 0x64, 0xae, 0x34, 0xb9, 0x11, 0x6c, 0x57,
- 0x0e, 0x0e, 0xac, 0x44, 0xbb, 0x08, 0x65, 0x4c, 0x29, 0xa7, 0x68, 0x58, 0x45, 0xd3, 0x20, 0x96,
- 0x1e, 0x1d, 0x5f, 0xae, 0x7c, 0xef, 0x6a, 0xe5, 0x7b, 0x3f, 0x57, 0xbe, 0xf7, 0x79, 0xed, 0xd7,
- 0xae, 0xd6, 0x7e, 0xed, 0xdb, 0xda, 0xaf, 0xbd, 0x7f, 0xfe, 0xc7, 0x64, 0xbe, 0xb1, 0x0d, 0x1a,
- 0x2f, 0x08, 0xe3, 0xa1, 0xdb, 0xa1, 0x8b, 0xcd, 0x16, 0xd9, 0x19, 0x9d, 0x37, 0xec, 0x3a, 0xbc,
- 0xfa, 0x15, 0x00, 0x00, 0xff, 0xff, 0x5f, 0xd7, 0x9a, 0x89, 0x93, 0x03, 0x00, 0x00,
-}
-
-func (m *EventPriceUpdate) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventPriceUpdate) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventPriceUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.TimestampMs != 0 {
- i = encodeVarintEvent(dAtA, i, uint64(m.TimestampMs))
- i--
- dAtA[i] = 0x18
- }
- {
- size := m.Price.Size()
- i -= size
- if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintEvent(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Pair) > 0 {
- i -= len(m.Pair)
- copy(dAtA[i:], m.Pair)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Pair)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventDelegateFeederConsent) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventDelegateFeederConsent) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventDelegateFeederConsent) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Feeder) > 0 {
- i -= len(m.Feeder)
- copy(dAtA[i:], m.Feeder)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Feeder)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Validator) > 0 {
- i -= len(m.Validator)
- copy(dAtA[i:], m.Validator)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Validator)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventAggregateVote) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventAggregateVote) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventAggregateVote) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Prices) > 0 {
- for iNdEx := len(m.Prices) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Prices[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvent(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- }
- if len(m.Feeder) > 0 {
- i -= len(m.Feeder)
- copy(dAtA[i:], m.Feeder)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Feeder)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Validator) > 0 {
- i -= len(m.Validator)
- copy(dAtA[i:], m.Validator)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Validator)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventAggregatePrevote) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventAggregatePrevote) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventAggregatePrevote) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Feeder) > 0 {
- i -= len(m.Feeder)
- copy(dAtA[i:], m.Feeder)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Feeder)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Validator) > 0 {
- i -= len(m.Validator)
- copy(dAtA[i:], m.Validator)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Validator)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventValidatorPerformance) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventValidatorPerformance) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventValidatorPerformance) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.MissCount != 0 {
- i = encodeVarintEvent(dAtA, i, uint64(m.MissCount))
- i--
- dAtA[i] = 0x30
- }
- if m.AbstainCount != 0 {
- i = encodeVarintEvent(dAtA, i, uint64(m.AbstainCount))
- i--
- dAtA[i] = 0x28
- }
- if m.WinCount != 0 {
- i = encodeVarintEvent(dAtA, i, uint64(m.WinCount))
- i--
- dAtA[i] = 0x20
- }
- if m.RewardWeight != 0 {
- i = encodeVarintEvent(dAtA, i, uint64(m.RewardWeight))
- i--
- dAtA[i] = 0x18
- }
- if m.VotingPower != 0 {
- i = encodeVarintEvent(dAtA, i, uint64(m.VotingPower))
- i--
- dAtA[i] = 0x10
- }
- if len(m.Validator) > 0 {
- i -= len(m.Validator)
- copy(dAtA[i:], m.Validator)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Validator)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintEvent(dAtA []byte, offset int, v uint64) int {
- offset -= sovEvent(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *EventPriceUpdate) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Pair)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = m.Price.Size()
- n += 1 + l + sovEvent(uint64(l))
- if m.TimestampMs != 0 {
- n += 1 + sovEvent(uint64(m.TimestampMs))
- }
- return n
-}
-
-func (m *EventDelegateFeederConsent) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Validator)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Feeder)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func (m *EventAggregateVote) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Validator)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Feeder)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- if len(m.Prices) > 0 {
- for _, e := range m.Prices {
- l = e.Size()
- n += 1 + l + sovEvent(uint64(l))
- }
- }
- return n
-}
-
-func (m *EventAggregatePrevote) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Validator)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Feeder)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func (m *EventValidatorPerformance) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Validator)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- if m.VotingPower != 0 {
- n += 1 + sovEvent(uint64(m.VotingPower))
- }
- if m.RewardWeight != 0 {
- n += 1 + sovEvent(uint64(m.RewardWeight))
- }
- if m.WinCount != 0 {
- n += 1 + sovEvent(uint64(m.WinCount))
- }
- if m.AbstainCount != 0 {
- n += 1 + sovEvent(uint64(m.AbstainCount))
- }
- if m.MissCount != 0 {
- n += 1 + sovEvent(uint64(m.MissCount))
- }
- return n
-}
-
-func sovEvent(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozEvent(x uint64) (n int) {
- return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *EventPriceUpdate) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventPriceUpdate: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventPriceUpdate: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Pair", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Pair = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field TimestampMs", wireType)
- }
- m.TimestampMs = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.TimestampMs |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventDelegateFeederConsent) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventDelegateFeederConsent: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventDelegateFeederConsent: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Validator = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Feeder", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Feeder = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventAggregateVote) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventAggregateVote: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventAggregateVote: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Validator = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Feeder", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Feeder = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Prices = append(m.Prices, ExchangeRateTuple{})
- if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventAggregatePrevote) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventAggregatePrevote: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventAggregatePrevote: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Validator = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Feeder", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Feeder = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventValidatorPerformance) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventValidatorPerformance: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventValidatorPerformance: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Validator = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType)
- }
- m.VotingPower = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.VotingPower |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field RewardWeight", wireType)
- }
- m.RewardWeight = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.RewardWeight |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field WinCount", wireType)
- }
- m.WinCount = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.WinCount |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field AbstainCount", wireType)
- }
- m.AbstainCount = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.AbstainCount |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MissCount", wireType)
- }
- m.MissCount = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MissCount |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipEvent(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthEvent
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupEvent
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthEvent
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/oracle/types/expected_keeper.go b/x/oracle/types/expected_keeper.go
deleted file mode 100644
index c50f4b987..000000000
--- a/x/oracle/types/expected_keeper.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package types
-
-import (
- sdkmath "cosmossdk.io/math"
- sdk "github.com/cosmos/cosmos-sdk/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
-)
-
-// StakingKeeper is expected keeper for staking module
-type StakingKeeper interface {
- Validator(ctx sdk.Context, address sdk.ValAddress) stakingtypes.ValidatorI // get validator by operator address; nil when validator not found
- TotalBondedTokens(sdk.Context) sdkmath.Int // total bonded tokens within the validator set
- Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) sdkmath.Int // slash the validator and delegators of the validator, specifying offense height, offense power, and slash fraction
- Jail(sdk.Context, sdk.ConsAddress) // jail a validator
- ValidatorsPowerStoreIterator(ctx sdk.Context) sdk.Iterator // an iterator for the current validator power store
- MaxValidators(sdk.Context) uint32 // MaxValidators returns the maximum amount of bonded validators
- PowerReduction(ctx sdk.Context) (res sdkmath.Int)
-}
-
-type SlashingKeeper interface {
- Slash(ctx sdk.Context, consAddr sdk.ConsAddress, fraction sdk.Dec, power int64, height int64)
- Jail(sdk.Context, sdk.ConsAddress)
-}
-
-// DistributionKeeper is expected keeper for distribution module
-type DistributionKeeper interface {
- AllocateTokensToValidator(ctx sdk.Context, val stakingtypes.ValidatorI, tokens sdk.DecCoins)
-
- // only used for simulation
- GetValidatorOutstandingRewardsCoins(ctx sdk.Context, val sdk.ValAddress) sdk.DecCoins
-}
-
-// AccountKeeper is expected keeper for auth module
-type AccountKeeper interface {
- GetModuleAddress(name string) sdk.AccAddress
- GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI
- GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI // only used for simulation
-}
-
-// BankKeeper defines the expected interface needed to retrieve account balances.
-type BankKeeper interface {
- GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
- GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
- SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error
- // only used for simulation
- SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
-}
-
-type SudoKeeper interface {
- // CheckPermissions Checks if a contract is contained within the set of sudo
- // contracts defined in the x/sudo module. These smart contracts are able to
- // execute certain permissioned functions.
- CheckPermissions(contract sdk.AccAddress, ctx sdk.Context) error
-}
diff --git a/x/oracle/types/export.go b/x/oracle/types/export.go
deleted file mode 100644
index fb4b6e3b6..000000000
--- a/x/oracle/types/export.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package types
-
-import (
- grpc "google.golang.org/grpc"
-)
-
-// GrpcQueryServiceDesc represents the query server's RPC service specification.
-// This gives access to the service name and method names needed for stargate
-// queries.
-func GrpcQueryServiceDesc() grpc.ServiceDesc {
- return _Query_serviceDesc
-}
diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go
deleted file mode 100644
index 18aa327ed..000000000
--- a/x/oracle/types/genesis.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package types
-
-import (
- "encoding/json"
-
- "github.com/cosmos/cosmos-sdk/codec"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
-)
-
-// NewGenesisState creates a new GenesisState object
-func NewGenesisState(
- params Params, rates []ExchangeRateTuple,
- feederDelegations []FeederDelegation, missCounters []MissCounter,
- aggregateExchangeRatePrevotes []AggregateExchangeRatePrevote,
- aggregateExchangeRateVotes []AggregateExchangeRateVote,
- pairs []asset.Pair,
- rewards []Rewards,
-) *GenesisState {
- return &GenesisState{
- Params: params,
- FeederDelegations: feederDelegations,
- ExchangeRates: rates,
- MissCounters: missCounters,
- AggregateExchangeRatePrevotes: aggregateExchangeRatePrevotes,
- AggregateExchangeRateVotes: aggregateExchangeRateVotes,
- Pairs: pairs,
- Rewards: rewards,
- }
-}
-
-// DefaultGenesisState - default GenesisState
-func DefaultGenesisState() *GenesisState {
- return NewGenesisState(
- DefaultParams(),
- []ExchangeRateTuple{},
- []FeederDelegation{},
- []MissCounter{},
- []AggregateExchangeRatePrevote{},
- []AggregateExchangeRateVote{},
- []asset.Pair{},
- []Rewards{})
-}
-
-// ValidateGenesis validates the oracle genesis state
-func ValidateGenesis(data *GenesisState) error {
- return data.Params.Validate()
-}
-
-// GetGenesisStateFromAppState returns x/oracle GenesisState given raw application
-// genesis state.
-func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *GenesisState {
- var genesisState GenesisState
-
- if appState[ModuleName] != nil {
- cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState)
- }
-
- return &genesisState
-}
diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go
deleted file mode 100644
index 6f7706c1e..000000000
--- a/x/oracle/types/genesis.pb.go
+++ /dev/null
@@ -1,1205 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/oracle/v1/genesis.proto
-
-package types
-
-import (
- fmt "fmt"
- github_com_NibiruChain_nibiru_x_common_asset "github.com/NibiruChain/nibiru/x/common/asset"
- _ "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// GenesisState defines the oracle module's genesis state.
-type GenesisState struct {
- Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
- FeederDelegations []FeederDelegation `protobuf:"bytes,2,rep,name=feeder_delegations,json=feederDelegations,proto3" json:"feeder_delegations"`
- ExchangeRates ExchangeRateTuples `protobuf:"bytes,3,rep,name=exchange_rates,json=exchangeRates,proto3,castrepeated=ExchangeRateTuples" json:"exchange_rates"`
- MissCounters []MissCounter `protobuf:"bytes,4,rep,name=miss_counters,json=missCounters,proto3" json:"miss_counters"`
- AggregateExchangeRatePrevotes []AggregateExchangeRatePrevote `protobuf:"bytes,5,rep,name=aggregate_exchange_rate_prevotes,json=aggregateExchangeRatePrevotes,proto3" json:"aggregate_exchange_rate_prevotes"`
- AggregateExchangeRateVotes []AggregateExchangeRateVote `protobuf:"bytes,6,rep,name=aggregate_exchange_rate_votes,json=aggregateExchangeRateVotes,proto3" json:"aggregate_exchange_rate_votes"`
- Pairs []github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,7,rep,name=pairs,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pairs"`
- Rewards []Rewards `protobuf:"bytes,8,rep,name=rewards,proto3" json:"rewards"`
-}
-
-func (m *GenesisState) Reset() { *m = GenesisState{} }
-func (m *GenesisState) String() string { return proto.CompactTextString(m) }
-func (*GenesisState) ProtoMessage() {}
-func (*GenesisState) Descriptor() ([]byte, []int) {
- return fileDescriptor_d88ebb2fa2659942, []int{0}
-}
-func (m *GenesisState) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *GenesisState) XXX_Merge(src proto.Message) {
- xxx_messageInfo_GenesisState.Merge(m, src)
-}
-func (m *GenesisState) XXX_Size() int {
- return m.Size()
-}
-func (m *GenesisState) XXX_DiscardUnknown() {
- xxx_messageInfo_GenesisState.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_GenesisState proto.InternalMessageInfo
-
-func (m *GenesisState) GetParams() Params {
- if m != nil {
- return m.Params
- }
- return Params{}
-}
-
-func (m *GenesisState) GetFeederDelegations() []FeederDelegation {
- if m != nil {
- return m.FeederDelegations
- }
- return nil
-}
-
-func (m *GenesisState) GetExchangeRates() ExchangeRateTuples {
- if m != nil {
- return m.ExchangeRates
- }
- return nil
-}
-
-func (m *GenesisState) GetMissCounters() []MissCounter {
- if m != nil {
- return m.MissCounters
- }
- return nil
-}
-
-func (m *GenesisState) GetAggregateExchangeRatePrevotes() []AggregateExchangeRatePrevote {
- if m != nil {
- return m.AggregateExchangeRatePrevotes
- }
- return nil
-}
-
-func (m *GenesisState) GetAggregateExchangeRateVotes() []AggregateExchangeRateVote {
- if m != nil {
- return m.AggregateExchangeRateVotes
- }
- return nil
-}
-
-func (m *GenesisState) GetRewards() []Rewards {
- if m != nil {
- return m.Rewards
- }
- return nil
-}
-
-// FeederDelegation is the address for where oracle feeder authority are
-// delegated to. By default this struct is only used at genesis to feed in
-// default feeder addresses.
-type FeederDelegation struct {
- FeederAddress string `protobuf:"bytes,1,opt,name=feeder_address,json=feederAddress,proto3" json:"feeder_address,omitempty"`
- ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"`
-}
-
-func (m *FeederDelegation) Reset() { *m = FeederDelegation{} }
-func (m *FeederDelegation) String() string { return proto.CompactTextString(m) }
-func (*FeederDelegation) ProtoMessage() {}
-func (*FeederDelegation) Descriptor() ([]byte, []int) {
- return fileDescriptor_d88ebb2fa2659942, []int{1}
-}
-func (m *FeederDelegation) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *FeederDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_FeederDelegation.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *FeederDelegation) XXX_Merge(src proto.Message) {
- xxx_messageInfo_FeederDelegation.Merge(m, src)
-}
-func (m *FeederDelegation) XXX_Size() int {
- return m.Size()
-}
-func (m *FeederDelegation) XXX_DiscardUnknown() {
- xxx_messageInfo_FeederDelegation.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_FeederDelegation proto.InternalMessageInfo
-
-func (m *FeederDelegation) GetFeederAddress() string {
- if m != nil {
- return m.FeederAddress
- }
- return ""
-}
-
-func (m *FeederDelegation) GetValidatorAddress() string {
- if m != nil {
- return m.ValidatorAddress
- }
- return ""
-}
-
-// MissCounter defines an miss counter and validator address pair used in
-// oracle module's genesis state
-type MissCounter struct {
- ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"`
- MissCounter uint64 `protobuf:"varint,2,opt,name=miss_counter,json=missCounter,proto3" json:"miss_counter,omitempty"`
-}
-
-func (m *MissCounter) Reset() { *m = MissCounter{} }
-func (m *MissCounter) String() string { return proto.CompactTextString(m) }
-func (*MissCounter) ProtoMessage() {}
-func (*MissCounter) Descriptor() ([]byte, []int) {
- return fileDescriptor_d88ebb2fa2659942, []int{2}
-}
-func (m *MissCounter) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MissCounter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MissCounter.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MissCounter) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MissCounter.Merge(m, src)
-}
-func (m *MissCounter) XXX_Size() int {
- return m.Size()
-}
-func (m *MissCounter) XXX_DiscardUnknown() {
- xxx_messageInfo_MissCounter.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MissCounter proto.InternalMessageInfo
-
-func (m *MissCounter) GetValidatorAddress() string {
- if m != nil {
- return m.ValidatorAddress
- }
- return ""
-}
-
-func (m *MissCounter) GetMissCounter() uint64 {
- if m != nil {
- return m.MissCounter
- }
- return 0
-}
-
-func init() {
- proto.RegisterType((*GenesisState)(nil), "nibiru.oracle.v1.GenesisState")
- proto.RegisterType((*FeederDelegation)(nil), "nibiru.oracle.v1.FeederDelegation")
- proto.RegisterType((*MissCounter)(nil), "nibiru.oracle.v1.MissCounter")
-}
-
-func init() { proto.RegisterFile("nibiru/oracle/v1/genesis.proto", fileDescriptor_d88ebb2fa2659942) }
-
-var fileDescriptor_d88ebb2fa2659942 = []byte{
- // 546 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x5f, 0x6b, 0x13, 0x4d,
- 0x14, 0xc6, 0xb3, 0xfd, 0xfb, 0x76, 0xd2, 0x94, 0x74, 0x78, 0x2f, 0xd6, 0x40, 0x36, 0x31, 0x22,
- 0x04, 0x2a, 0xbb, 0xa4, 0x82, 0xd0, 0xcb, 0xa6, 0x5a, 0xbd, 0x51, 0xc3, 0x2a, 0x0a, 0x82, 0x84,
- 0xc9, 0xee, 0xc9, 0x66, 0x20, 0xbb, 0xb3, 0xcc, 0x99, 0xc4, 0x7a, 0xe1, 0x77, 0xf0, 0x73, 0xf8,
- 0x49, 0x7a, 0x59, 0xbc, 0x12, 0x2f, 0xaa, 0x24, 0x5f, 0x44, 0x76, 0x66, 0xdb, 0xc4, 0x6c, 0xab,
- 0xde, 0x85, 0xf3, 0xfc, 0xce, 0xf3, 0x9c, 0x09, 0x4f, 0x42, 0x9c, 0x84, 0x0f, 0xb8, 0x9c, 0x78,
- 0x42, 0xb2, 0x60, 0x0c, 0xde, 0xb4, 0xe3, 0x45, 0x90, 0x00, 0x72, 0x74, 0x53, 0x29, 0x94, 0xa0,
- 0x55, 0xa3, 0xbb, 0x46, 0x77, 0xa7, 0x9d, 0xda, 0xff, 0x91, 0x88, 0x84, 0x16, 0xbd, 0xec, 0x93,
- 0xe1, 0x6a, 0xf5, 0x82, 0x4f, 0xbe, 0x61, 0x64, 0x27, 0x10, 0x18, 0x0b, 0xf4, 0x06, 0x0c, 0x33,
- 0x71, 0x00, 0x8a, 0x75, 0xbc, 0x40, 0xf0, 0xc4, 0xe8, 0xad, 0xaf, 0x9b, 0x64, 0xf7, 0xa9, 0x09,
- 0x7e, 0xa5, 0x98, 0x02, 0xfa, 0x88, 0x6c, 0xa5, 0x4c, 0xb2, 0x18, 0x6d, 0xab, 0x69, 0xb5, 0xcb,
- 0x87, 0xb6, 0xbb, 0x7a, 0x88, 0xdb, 0xd3, 0x7a, 0x77, 0xe3, 0xfc, 0xb2, 0x51, 0xf2, 0x73, 0x9a,
- 0xbe, 0x25, 0x74, 0x08, 0x10, 0x82, 0xec, 0x87, 0x30, 0x86, 0x88, 0x29, 0x2e, 0x12, 0xb4, 0xd7,
- 0x9a, 0xeb, 0xed, 0xf2, 0x61, 0xab, 0xe8, 0x71, 0xaa, 0xd9, 0xc7, 0xd7, 0x68, 0xee, 0xb6, 0x3f,
- 0x5c, 0x99, 0x23, 0x1d, 0x92, 0x3d, 0x38, 0x0b, 0x46, 0x2c, 0x89, 0xa0, 0x2f, 0x99, 0x02, 0xb4,
- 0xd7, 0xb5, 0xe9, 0xbd, 0xa2, 0xe9, 0x93, 0x9c, 0xf3, 0x99, 0x82, 0xd7, 0x93, 0x74, 0x0c, 0xdd,
- 0x5a, 0xe6, 0xfa, 0xe5, 0x47, 0x83, 0x16, 0x24, 0xf4, 0x2b, 0xb0, 0x34, 0x43, 0xfa, 0x8c, 0x54,
- 0x62, 0x8e, 0xd8, 0x0f, 0xc4, 0x24, 0x51, 0x20, 0xd1, 0xde, 0xd0, 0x31, 0xf5, 0x62, 0xcc, 0x73,
- 0x8e, 0x78, 0x62, 0xa8, 0xfc, 0xec, 0xdd, 0x78, 0x31, 0x42, 0xfa, 0x89, 0x34, 0x59, 0x14, 0xc9,
- 0xec, 0x05, 0xd0, 0xff, 0xed, 0xf6, 0x7e, 0x2a, 0x61, 0x2a, 0xb2, 0x37, 0x6c, 0x6a, 0x73, 0xb7,
- 0x68, 0x7e, 0x7c, 0xb5, 0xb9, 0x7c, 0x71, 0xcf, 0xac, 0xe5, 0x69, 0x75, 0xf6, 0x07, 0x06, 0xa9,
- 0x22, 0xf5, 0xdb, 0xe2, 0x4d, 0xf6, 0x96, 0xce, 0x3e, 0xf8, 0xc7, 0xec, 0x37, 0x8b, 0xe0, 0x1a,
- 0xbb, 0x0d, 0x40, 0xfa, 0x92, 0x6c, 0xa6, 0x8c, 0x4b, 0xb4, 0xb7, 0x9b, 0xeb, 0xed, 0x9d, 0xee,
- 0x51, 0xb6, 0xf0, 0xfd, 0xb2, 0xd1, 0x89, 0xb8, 0x1a, 0x4d, 0x06, 0x6e, 0x20, 0x62, 0xef, 0x85,
- 0xce, 0x3b, 0x19, 0x31, 0x9e, 0x78, 0x79, 0x6b, 0xcf, 0xbc, 0x40, 0xc4, 0xb1, 0x48, 0x3c, 0x86,
- 0x08, 0xca, 0xed, 0x31, 0x2e, 0x7d, 0xe3, 0x43, 0x8f, 0xc8, 0xb6, 0x84, 0x0f, 0x4c, 0x86, 0x68,
- 0xff, 0xa7, 0x0f, 0xbe, 0x53, 0x3c, 0xd8, 0x37, 0x40, 0x7e, 0xde, 0x15, 0xdf, 0x1a, 0x92, 0xea,
- 0x6a, 0xbf, 0xe8, 0x7d, 0xb2, 0x97, 0xf7, 0x93, 0x85, 0xa1, 0x04, 0x34, 0xfd, 0xde, 0xf1, 0x2b,
- 0x66, 0x7a, 0x6c, 0x86, 0xf4, 0x80, 0xec, 0x4f, 0xd9, 0x98, 0x87, 0x4c, 0x89, 0x05, 0xb9, 0xa6,
- 0xc9, 0xea, 0xb5, 0x90, 0xc3, 0xad, 0xf7, 0xa4, 0xbc, 0xd4, 0x85, 0x9b, 0x77, 0xad, 0x9b, 0x77,
- 0xe9, 0x5d, 0xb2, 0xbb, 0x5c, 0x37, 0x9d, 0xb1, 0xe1, 0x97, 0x97, 0x8a, 0xd4, 0x3d, 0x3d, 0x9f,
- 0x39, 0xd6, 0xc5, 0xcc, 0xb1, 0x7e, 0xce, 0x1c, 0xeb, 0xf3, 0xdc, 0x29, 0x5d, 0xcc, 0x9d, 0xd2,
- 0xb7, 0xb9, 0x53, 0x7a, 0xf7, 0xe0, 0x6f, 0xdf, 0x6a, 0xfe, 0x6f, 0xa0, 0x3e, 0xa6, 0x80, 0x83,
- 0x2d, 0xfd, 0x53, 0x7f, 0xf8, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x56, 0x94, 0xe7, 0x7b, 0x73, 0x04,
- 0x00, 0x00,
-}
-
-func (m *GenesisState) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Rewards) > 0 {
- for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Rewards[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x42
- }
- }
- if len(m.Pairs) > 0 {
- for iNdEx := len(m.Pairs) - 1; iNdEx >= 0; iNdEx-- {
- {
- size := m.Pairs[iNdEx].Size()
- i -= size
- if _, err := m.Pairs[iNdEx].MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x3a
- }
- }
- if len(m.AggregateExchangeRateVotes) > 0 {
- for iNdEx := len(m.AggregateExchangeRateVotes) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.AggregateExchangeRateVotes[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x32
- }
- }
- if len(m.AggregateExchangeRatePrevotes) > 0 {
- for iNdEx := len(m.AggregateExchangeRatePrevotes) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.AggregateExchangeRatePrevotes[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x2a
- }
- }
- if len(m.MissCounters) > 0 {
- for iNdEx := len(m.MissCounters) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.MissCounters[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x22
- }
- }
- if len(m.ExchangeRates) > 0 {
- for iNdEx := len(m.ExchangeRates) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.ExchangeRates[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- }
- if len(m.FeederDelegations) > 0 {
- for iNdEx := len(m.FeederDelegations) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.FeederDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- }
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *FeederDelegation) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *FeederDelegation) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *FeederDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.ValidatorAddress) > 0 {
- i -= len(m.ValidatorAddress)
- copy(dAtA[i:], m.ValidatorAddress)
- i = encodeVarintGenesis(dAtA, i, uint64(len(m.ValidatorAddress)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.FeederAddress) > 0 {
- i -= len(m.FeederAddress)
- copy(dAtA[i:], m.FeederAddress)
- i = encodeVarintGenesis(dAtA, i, uint64(len(m.FeederAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MissCounter) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MissCounter) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MissCounter) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.MissCounter != 0 {
- i = encodeVarintGenesis(dAtA, i, uint64(m.MissCounter))
- i--
- dAtA[i] = 0x10
- }
- if len(m.ValidatorAddress) > 0 {
- i -= len(m.ValidatorAddress)
- copy(dAtA[i:], m.ValidatorAddress)
- i = encodeVarintGenesis(dAtA, i, uint64(len(m.ValidatorAddress)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
- offset -= sovGenesis(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *GenesisState) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Params.Size()
- n += 1 + l + sovGenesis(uint64(l))
- if len(m.FeederDelegations) > 0 {
- for _, e := range m.FeederDelegations {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- if len(m.ExchangeRates) > 0 {
- for _, e := range m.ExchangeRates {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- if len(m.MissCounters) > 0 {
- for _, e := range m.MissCounters {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- if len(m.AggregateExchangeRatePrevotes) > 0 {
- for _, e := range m.AggregateExchangeRatePrevotes {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- if len(m.AggregateExchangeRateVotes) > 0 {
- for _, e := range m.AggregateExchangeRateVotes {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- if len(m.Pairs) > 0 {
- for _, e := range m.Pairs {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- if len(m.Rewards) > 0 {
- for _, e := range m.Rewards {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
- return n
-}
-
-func (m *FeederDelegation) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.FeederAddress)
- if l > 0 {
- n += 1 + l + sovGenesis(uint64(l))
- }
- l = len(m.ValidatorAddress)
- if l > 0 {
- n += 1 + l + sovGenesis(uint64(l))
- }
- return n
-}
-
-func (m *MissCounter) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ValidatorAddress)
- if l > 0 {
- n += 1 + l + sovGenesis(uint64(l))
- }
- if m.MissCounter != 0 {
- n += 1 + sovGenesis(uint64(m.MissCounter))
- }
- return n
-}
-
-func sovGenesis(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozGenesis(x uint64) (n int) {
- return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *GenesisState) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field FeederDelegations", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.FeederDelegations = append(m.FeederDelegations, FeederDelegation{})
- if err := m.FeederDelegations[len(m.FeederDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRates", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ExchangeRates = append(m.ExchangeRates, ExchangeRateTuple{})
- if err := m.ExchangeRates[len(m.ExchangeRates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field MissCounters", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.MissCounters = append(m.MissCounters, MissCounter{})
- if err := m.MissCounters[len(m.MissCounters)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AggregateExchangeRatePrevotes", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.AggregateExchangeRatePrevotes = append(m.AggregateExchangeRatePrevotes, AggregateExchangeRatePrevote{})
- if err := m.AggregateExchangeRatePrevotes[len(m.AggregateExchangeRatePrevotes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AggregateExchangeRateVotes", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.AggregateExchangeRateVotes = append(m.AggregateExchangeRateVotes, AggregateExchangeRateVote{})
- if err := m.AggregateExchangeRateVotes[len(m.AggregateExchangeRateVotes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Pairs", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_NibiruChain_nibiru_x_common_asset.Pair
- m.Pairs = append(m.Pairs, v)
- if err := m.Pairs[len(m.Pairs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Rewards", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Rewards = append(m.Rewards, Rewards{})
- if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipGenesis(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenesis
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *FeederDelegation) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: FeederDelegation: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: FeederDelegation: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field FeederAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.FeederAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ValidatorAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipGenesis(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenesis
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MissCounter) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MissCounter: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MissCounter: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ValidatorAddress = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MissCounter", wireType)
- }
- m.MissCounter = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MissCounter |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipGenesis(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthGenesis
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipGenesis(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthGenesis
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupGenesis
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenesis
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/oracle/types/genesis_test.go b/x/oracle/types/genesis_test.go
deleted file mode 100644
index a20b2620c..000000000
--- a/x/oracle/types/genesis_test.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package types_test
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestGenesisValidation(t *testing.T) {
- genState := types.DefaultGenesisState()
- require.NoError(t, types.ValidateGenesis(genState))
-
- genState.Params.VotePeriod = 0
- require.Error(t, types.ValidateGenesis(genState))
-}
-
-func TestGetGenesisStateFromAppState(t *testing.T) {
- cdc := app.MakeEncodingConfig().Codec
- appState := make(map[string]json.RawMessage)
-
- defaultGenesisState := types.DefaultGenesisState()
- appState[types.ModuleName] = cdc.MustMarshalJSON(defaultGenesisState)
- require.Equal(t, *defaultGenesisState, *types.GetGenesisStateFromAppState(cdc, appState))
-}
diff --git a/x/oracle/types/hash.go b/x/oracle/types/hash.go
deleted file mode 100644
index b9d816ecc..000000000
--- a/x/oracle/types/hash.go
+++ /dev/null
@@ -1,121 +0,0 @@
-package types
-
-import (
- "bytes"
- "encoding/hex"
- "encoding/json"
- "fmt"
-
- "gopkg.in/yaml.v2"
-
- "github.com/cometbft/cometbft/crypto/tmhash"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-var _ yaml.Marshaler = AggregateVoteHash{}
-
-// AggregateVoteHash is hash value to hide vote exchange rates
-// which is formatted as hex string in SHA256("{salt}:({pair},{exchange_rate})|...|({pair},{exchange_rate}):{voter}")
-type AggregateVoteHash []byte
-
-// GetAggregateVoteHash computes hash value of ExchangeRateVote
-// to avoid redundant DecCoins stringify operation, use string argument
-// TODO(mercilex): use ExchangeRateTuples
-func GetAggregateVoteHash(salt string, exchangeRatesStr string, voter sdk.ValAddress) AggregateVoteHash {
- hash := tmhash.NewTruncated()
- sourceStr := fmt.Sprintf("%s:%s:%s", salt, exchangeRatesStr, voter.String())
- _, err := hash.Write([]byte(sourceStr))
- if err != nil {
- panic(err)
- }
- bz := hash.Sum(nil)
- return bz
-}
-
-// AggregateVoteHashFromHexString convert hex string to AggregateVoteHash
-func AggregateVoteHashFromHexString(s string) (AggregateVoteHash, error) {
- h, err := hex.DecodeString(s)
- if err != nil {
- return nil, err
- }
-
- return h, nil
-}
-
-// String implements fmt.Stringer interface
-func (h AggregateVoteHash) String() string {
- return hex.EncodeToString(h)
-}
-
-// Equal does bytes equal check
-func (h AggregateVoteHash) Equal(h2 AggregateVoteHash) bool {
- return bytes.Equal(h, h2)
-}
-
-// Empty check the name hash has zero length
-func (h AggregateVoteHash) Empty() bool {
- return len(h) == 0
-}
-
-// Bytes returns the raw address bytes.
-func (h AggregateVoteHash) Bytes() []byte {
- return h
-}
-
-// Size returns the raw address bytes.
-func (h AggregateVoteHash) Size() int {
- return len(h)
-}
-
-// Format implements the fmt.Formatter interface.
-func (h AggregateVoteHash) Format(s fmt.State, verb rune) {
- switch verb {
- case 's':
- _, _ = s.Write([]byte(h.String()))
- case 'p':
- _, _ = s.Write([]byte(fmt.Sprintf("%p", h)))
- default:
- _, _ = s.Write([]byte(fmt.Sprintf("%X", []byte(h))))
- }
-}
-
-// Marshal returns the raw address bytes. It is needed for protobuf
-// compatibility.
-func (h AggregateVoteHash) Marshal() ([]byte, error) {
- return h, nil
-}
-
-// Unmarshal sets the address to the given data. It is needed for protobuf
-// compatibility.
-func (h *AggregateVoteHash) Unmarshal(data []byte) error {
- *h = data
- return nil
-}
-
-// MarshalJSON marshals to JSON using Bech32.
-func (h AggregateVoteHash) MarshalJSON() ([]byte, error) {
- return json.Marshal(h.String())
-}
-
-// MarshalYAML marshals to YAML using Bech32.
-func (h AggregateVoteHash) MarshalYAML() (interface{}, error) {
- return h.String(), nil
-}
-
-// UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.
-func (h *AggregateVoteHash) UnmarshalJSON(data []byte) error {
- var s string
- err := json.Unmarshal(data, &s)
- if err != nil {
- return err
- }
-
- h2, err := AggregateVoteHashFromHexString(s)
- if err != nil {
- return err
- }
-
- *h = h2
- return nil
-}
diff --git a/x/oracle/types/hash_test.go b/x/oracle/types/hash_test.go
deleted file mode 100644
index 86b47fb50..000000000
--- a/x/oracle/types/hash_test.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package types_test
-
-import (
- "encoding/hex"
- "testing"
-
- "github.com/stretchr/testify/require"
- "gopkg.in/yaml.v2"
-
- "github.com/NibiruChain/nibiru/x/oracle/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-func TestAggregateVoteHash(t *testing.T) {
- addrs := []sdk.AccAddress{
- sdk.AccAddress([]byte("addr1_______________")),
- }
-
- aggregateVoteHash := types.GetAggregateVoteHash("salt", "(100,nibi:usd)|(200000,btc:usd)", sdk.ValAddress(addrs[0]))
- hexStr := hex.EncodeToString(aggregateVoteHash)
- aggregateVoteHashRes, err := types.AggregateVoteHashFromHexString(hexStr)
- require.NoError(t, err)
- require.Equal(t, aggregateVoteHash, aggregateVoteHashRes)
- require.True(t, aggregateVoteHash.Equal(aggregateVoteHash))
- require.True(t, types.AggregateVoteHash([]byte{}).Empty())
-
- got, _ := yaml.Marshal(&aggregateVoteHash)
- require.Equal(t, aggregateVoteHash.String()+"\n", string(got))
-
- res := types.AggregateVoteHash{}
- testMarshal(t, &aggregateVoteHash, &res, aggregateVoteHash.MarshalJSON, (&res).UnmarshalJSON)
- testMarshal(t, &aggregateVoteHash, &res, aggregateVoteHash.Marshal, (&res).Unmarshal)
-}
-
-func testMarshal(t *testing.T, original interface{}, res interface{}, marshal func() ([]byte, error), unmarshal func([]byte) error) {
- bz, err := marshal()
- require.Nil(t, err)
- err = unmarshal(bz)
- require.Nil(t, err)
- require.Equal(t, original, res)
-}
diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go
deleted file mode 100644
index f27b45a8b..000000000
--- a/x/oracle/types/keys.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package types
-
-const (
- // ModuleName is the name of the oracle module
- ModuleName = "oracle"
-
- // StoreKey is the string store representation
- StoreKey = ModuleName
-
- // RouterKey is the msg router key for the oracle module
- RouterKey = ModuleName
-
- // QuerierRoute is the query router key for the oracle module
- QuerierRoute = ModuleName
-)
diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go
deleted file mode 100644
index 317566226..000000000
--- a/x/oracle/types/msgs.go
+++ /dev/null
@@ -1,222 +0,0 @@
-package types
-
-import (
- "github.com/cometbft/cometbft/crypto/tmhash"
- "github.com/cosmos/cosmos-sdk/types/errors"
-
- sdkerrors "cosmossdk.io/errors"
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// ensure Msg interface compliance at compile time
-var (
- _ sdk.Msg = &MsgDelegateFeedConsent{}
- _ sdk.Msg = &MsgAggregateExchangeRatePrevote{}
- _ sdk.Msg = &MsgAggregateExchangeRateVote{}
- _ sdk.Msg = &MsgEditOracleParams{}
-)
-
-// oracle message types
-const (
- TypeMsgDelegateFeedConsent = "delegate_feeder"
- TypeMsgAggregateExchangeRatePrevote = "aggregate_exchange_rate_prevote"
- TypeMsgAggregateExchangeRateVote = "aggregate_exchange_rate_vote"
- TypeMsgEditOracleParams = "edit_oracle_params"
-)
-
-//-------------------------------------------------
-//-------------------------------------------------
-
-// NewMsgAggregateExchangeRatePrevote returns MsgAggregateExchangeRatePrevote instance
-func NewMsgAggregateExchangeRatePrevote(hash AggregateVoteHash, feeder sdk.AccAddress, validator sdk.ValAddress) *MsgAggregateExchangeRatePrevote {
- return &MsgAggregateExchangeRatePrevote{
- Hash: hash.String(),
- Feeder: feeder.String(),
- Validator: validator.String(),
- }
-}
-
-// Route implements sdk.Msg
-func (msg MsgAggregateExchangeRatePrevote) Route() string { return RouterKey }
-
-// Type implements sdk.Msg
-func (msg MsgAggregateExchangeRatePrevote) Type() string { return TypeMsgAggregateExchangeRatePrevote }
-
-// GetSignBytes implements sdk.Msg
-func (msg MsgAggregateExchangeRatePrevote) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
-}
-
-// GetSigners implements sdk.Msg
-func (msg MsgAggregateExchangeRatePrevote) GetSigners() []sdk.AccAddress {
- feeder, err := sdk.AccAddressFromBech32(msg.Feeder)
- if err != nil {
- panic(err)
- }
-
- return []sdk.AccAddress{feeder}
-}
-
-// ValidateBasic Implements sdk.Msg
-func (msg MsgAggregateExchangeRatePrevote) ValidateBasic() error {
- _, err := AggregateVoteHashFromHexString(msg.Hash)
- if err != nil {
- return sdkerrors.Wrapf(ErrInvalidHash, "Invalid vote hash (%s)", err)
- }
-
- // HEX encoding doubles the hash length
- if len(msg.Hash) != tmhash.TruncatedSize*2 {
- return ErrInvalidHashLength
- }
-
- _, err = sdk.AccAddressFromBech32(msg.Feeder)
- if err != nil {
- return sdkerrors.Wrapf(errors.ErrInvalidAddress, "Invalid feeder address (%s)", err)
- }
-
- _, err = sdk.ValAddressFromBech32(msg.Validator)
- if err != nil {
- return sdkerrors.Wrapf(errors.ErrInvalidAddress, "Invalid operator address (%s)", err)
- }
-
- return nil
-}
-
-// NewMsgAggregateExchangeRateVote returns MsgAggregateExchangeRateVote instance
-// TODO(mercilex): accept ExchangeRatesTuples
-func NewMsgAggregateExchangeRateVote(salt string, exchangeRates string, feeder sdk.AccAddress, validator sdk.ValAddress) *MsgAggregateExchangeRateVote {
- return &MsgAggregateExchangeRateVote{
- Salt: salt,
- ExchangeRates: exchangeRates,
- Feeder: feeder.String(),
- Validator: validator.String(),
- }
-}
-
-// Route implements sdk.Msg
-func (msg MsgAggregateExchangeRateVote) Route() string { return RouterKey }
-
-// Type implements sdk.Msg
-func (msg MsgAggregateExchangeRateVote) Type() string { return TypeMsgAggregateExchangeRateVote }
-
-// GetSignBytes implements sdk.Msg
-func (msg MsgAggregateExchangeRateVote) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
-}
-
-// GetSigners implements sdk.Msg
-func (msg MsgAggregateExchangeRateVote) GetSigners() []sdk.AccAddress {
- feeder, err := sdk.AccAddressFromBech32(msg.Feeder)
- if err != nil {
- panic(err)
- }
-
- return []sdk.AccAddress{feeder}
-}
-
-// ValidateBasic implements sdk.Msg
-func (msg MsgAggregateExchangeRateVote) ValidateBasic() error {
- _, err := sdk.AccAddressFromBech32(msg.Feeder)
- if err != nil {
- return sdkerrors.Wrapf(errors.ErrInvalidAddress, "Invalid feeder address (%s)", err)
- }
-
- _, err = sdk.ValAddressFromBech32(msg.Validator)
- if err != nil {
- return sdkerrors.Wrapf(errors.ErrInvalidAddress, "Invalid operator address (%s)", err)
- }
-
- if l := len(msg.ExchangeRates); l == 0 {
- return sdkerrors.Wrap(errors.ErrUnknownRequest, "must provide at least one oracle exchange rate")
- } else if l > 4096 {
- return sdkerrors.Wrap(errors.ErrInvalidRequest, "exchange rates string can not exceed 4096 characters")
- }
-
- exchangeRates, err := ParseExchangeRateTuples(msg.ExchangeRates)
- if err != nil {
- return sdkerrors.Wrap(errors.ErrInvalidCoins, "failed to parse exchange rates string cause: "+err.Error())
- }
-
- for _, exchangeRate := range exchangeRates {
- // Check overflow bit length
- if exchangeRate.ExchangeRate.BigInt().BitLen() > 255+sdk.DecimalPrecisionBits {
- return sdkerrors.Wrap(ErrInvalidExchangeRate, "overflow")
- }
- }
-
- if len(msg.Salt) > 4 || len(msg.Salt) < 1 {
- return sdkerrors.Wrap(ErrInvalidSaltLength, "salt length must be [1, 4]")
- }
-
- return nil
-}
-
-// ------------------------ MsgDelegateFeedConsent ------------------------
-
-// NewMsgDelegateFeedConsent creates a MsgDelegateFeedConsent instance
-func NewMsgDelegateFeedConsent(operatorAddress sdk.ValAddress, feederAddress sdk.AccAddress) *MsgDelegateFeedConsent {
- return &MsgDelegateFeedConsent{
- Operator: operatorAddress.String(),
- Delegate: feederAddress.String(),
- }
-}
-
-// Route implements sdk.Msg
-func (msg MsgDelegateFeedConsent) Route() string { return RouterKey }
-
-// Type implements sdk.Msg
-func (msg MsgDelegateFeedConsent) Type() string { return TypeMsgDelegateFeedConsent }
-
-// GetSignBytes implements sdk.Msg
-func (msg MsgDelegateFeedConsent) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
-}
-
-// GetSigners implements sdk.Msg
-func (msg MsgDelegateFeedConsent) GetSigners() []sdk.AccAddress {
- operator, err := sdk.ValAddressFromBech32(msg.Operator)
- if err != nil {
- panic(err)
- }
-
- return []sdk.AccAddress{sdk.AccAddress(operator)}
-}
-
-// ValidateBasic implements sdk.Msg
-func (msg MsgDelegateFeedConsent) ValidateBasic() error {
- _, err := sdk.ValAddressFromBech32(msg.Operator)
- if err != nil {
- return sdkerrors.Wrapf(errors.ErrInvalidAddress, "Invalid operator address (%s)", err)
- }
-
- _, err = sdk.AccAddressFromBech32(msg.Delegate)
- if err != nil {
- return sdkerrors.Wrapf(errors.ErrInvalidAddress, "Invalid delegate address (%s)", err)
- }
-
- return nil
-}
-
-// ------------------------ MsgEditOracleParams ------------------------
-
-func (m MsgEditOracleParams) Route() string { return RouterKey }
-func (m MsgEditOracleParams) Type() string { return TypeMsgEditOracleParams }
-
-func (m MsgEditOracleParams) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil {
- return err
- }
- return nil
-}
-
-func (m MsgEditOracleParams) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
-
-func (m MsgEditOracleParams) GetSigners() []sdk.AccAddress {
- signer, err := sdk.AccAddressFromBech32(m.Sender)
- if err != nil {
- panic(err)
- }
- return []sdk.AccAddress{signer}
-}
diff --git a/x/oracle/types/msgs_test.go b/x/oracle/types/msgs_test.go
deleted file mode 100644
index 9f1d9c8f8..000000000
--- a/x/oracle/types/msgs_test.go
+++ /dev/null
@@ -1,125 +0,0 @@
-package types_test
-
-import (
- "testing"
-
- "cosmossdk.io/math"
-
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/oracle/types"
-
- "github.com/stretchr/testify/require"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-func TestMsgFeederDelegation(t *testing.T) {
- addrs := []sdk.AccAddress{
- sdk.AccAddress([]byte("addr1_______________")),
- sdk.AccAddress([]byte("addr2_______________")),
- }
-
- tests := []struct {
- delegator sdk.ValAddress
- delegate sdk.AccAddress
- expectPass bool
- }{
- {sdk.ValAddress(addrs[0]), addrs[1], true},
- {sdk.ValAddress{}, addrs[1], false},
- {sdk.ValAddress(addrs[0]), sdk.AccAddress{}, false},
- {nil, nil, false},
- }
-
- for i, tc := range tests {
- msg := types.NewMsgDelegateFeedConsent(tc.delegator, tc.delegate)
- if tc.expectPass {
- require.Nil(t, msg.ValidateBasic(), "test: %v", i)
- } else {
- require.NotNil(t, msg.ValidateBasic(), "test: %v", i)
- }
- }
-}
-
-func TestMsgAggregateExchangeRatePrevote(t *testing.T) {
- addrs := []sdk.AccAddress{
- sdk.AccAddress([]byte("addr1_______________")),
- }
-
- exchangeRates := sdk.DecCoins{sdk.NewDecCoinFromDec(denoms.USDC, math.LegacyOneDec()), sdk.NewDecCoinFromDec(denoms.NUSD, math.LegacyNewDecWithPrec(32121, 1))}
- bz := types.GetAggregateVoteHash("1", exchangeRates.String(), sdk.ValAddress(addrs[0]))
-
- tests := []struct {
- hash types.AggregateVoteHash
- exchangeRates sdk.DecCoins
- voter sdk.AccAddress
- expectPass bool
- }{
- {bz, exchangeRates, addrs[0], true},
- {bz[1:], exchangeRates, addrs[0], false},
- {bz, exchangeRates, sdk.AccAddress{}, false},
- {types.AggregateVoteHash{}, exchangeRates, addrs[0], false},
- }
-
- for i, tc := range tests {
- msg := types.NewMsgAggregateExchangeRatePrevote(tc.hash, tc.voter, sdk.ValAddress(tc.voter))
- if tc.expectPass {
- require.NoError(t, msg.ValidateBasic(), "test: %v", i)
- } else {
- require.Error(t, msg.ValidateBasic(), "test: %v", i)
- }
- }
-}
-
-func TestMsgAggregateExchangeRateVote(t *testing.T) {
- addrs := []sdk.AccAddress{
- sdk.AccAddress("addr1_______________"),
- }
-
- exchangeRates := types.ExchangeRateTuples{
- {
- Pair: "FOO:USD",
- ExchangeRate: math.LegacyMustNewDecFromStr("1.0"),
- },
- {
- Pair: "BAR:USD",
- ExchangeRate: math.LegacyMustNewDecFromStr("1232.132"),
- },
- }
-
- abstainExchangeRates := types.ExchangeRateTuples{
- {
- Pair: "FOO:USD",
- ExchangeRate: math.LegacyZeroDec(),
- },
- {
- Pair: "BAR:USD",
- ExchangeRate: math.LegacyMustNewDecFromStr("1232.132"),
- },
- }
-
- tests := []struct {
- voter sdk.AccAddress
- validator sdk.ValAddress
- salt string
- exchangeRates types.ExchangeRateTuples
- expectPass bool
- }{
- {addrs[0], sdk.ValAddress(addrs[0]), "123", exchangeRates, true},
- {addrs[0], sdk.ValAddress(addrs[0]), "123", abstainExchangeRates, true},
- {sdk.AccAddress{}, sdk.ValAddress(addrs[0]), "123", exchangeRates, false},
- {addrs[0], sdk.ValAddress(addrs[0]), "123", types.ExchangeRateTuples{}, false},
- {addrs[0], sdk.ValAddress{}, "123", abstainExchangeRates, false},
- {addrs[0], sdk.ValAddress(addrs[0]), "", abstainExchangeRates, false},
- }
-
- for i, tc := range tests {
- exchangeRates, err := tc.exchangeRates.ToString()
- require.NoError(t, err)
- msg := types.NewMsgAggregateExchangeRateVote(tc.salt, exchangeRates, tc.voter, tc.validator)
- if tc.expectPass {
- require.Nil(t, msg.ValidateBasic(), "test: %v", i)
- } else {
- require.NotNil(t, msg.ValidateBasic(), "test: %v", i)
- }
- }
-}
diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go
deleted file mode 100644
index 65b124512..000000000
--- a/x/oracle/types/oracle.pb.go
+++ /dev/null
@@ -1,2021 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/oracle/v1/oracle.proto
-
-package types
-
-import (
- fmt "fmt"
- github_com_NibiruChain_nibiru_x_common_asset "github.com/NibiruChain/nibiru/x/common/asset"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types"
- _ "google.golang.org/protobuf/types/known/durationpb"
- io "io"
- math "math"
- math_bits "math/bits"
- time "time"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-var _ = time.Kitchen
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// Params defines the module parameters for the x/oracle module.
-type Params struct {
- // VotePeriod defines the number of blocks during which voting takes place.
- VotePeriod uint64 `protobuf:"varint,1,opt,name=vote_period,json=votePeriod,proto3" json:"vote_period,omitempty" yaml:"vote_period"`
- // VoteThreshold specifies the minimum proportion of votes that must be
- // received for a ballot to pass.
- VoteThreshold github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=vote_threshold,json=voteThreshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"vote_threshold" yaml:"vote_threshold"`
- // RewardBand defines a maxium divergence that a price vote can have from the
- // weighted median in the ballot. If a vote lies within the valid range
- // defined by:
- // μ := weightedMedian,
- // validRange := μ ± (μ * rewardBand / 2),
- // then rewards are added to the validator performance.
- // Note that if the reward band is smaller than 1 standard
- // deviation, the band is taken to be 1 standard deviation.a price
- RewardBand github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=reward_band,json=rewardBand,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_band" yaml:"reward_band"`
- // The set of whitelisted markets, or asset pairs, for the module.
- // Ex. '["unibi:uusd","ubtc:uusd"]'
- Whitelist []github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,4,rep,name=whitelist,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"whitelist,omitempty" yaml:"whitelist"`
- // SlashFraction returns the proportion of an oracle's stake that gets
- // slashed in the event of slashing. `SlashFraction` specifies the exact
- // penalty for failing a voting period.
- SlashFraction github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=slash_fraction,json=slashFraction,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction" yaml:"slash_fraction"`
- // SlashWindow returns the number of voting periods that specify a
- // "slash window". After each slash window, all oracles that have missed more
- // than the penalty threshold are slashed. Missing the penalty threshold is
- // synonymous with submitting fewer valid votes than `MinValidPerWindow`.
- SlashWindow uint64 `protobuf:"varint,6,opt,name=slash_window,json=slashWindow,proto3" json:"slash_window,omitempty" yaml:"slash_window"`
- MinValidPerWindow github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=min_valid_per_window,json=minValidPerWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_valid_per_window" yaml:"min_valid_per_window"`
- // Amount of time to look back for TWAP calculations.
- // Ex: "900.000000069s" corresponds to 900 seconds and 69 nanoseconds in JSON.
- TwapLookbackWindow time.Duration `protobuf:"bytes,8,opt,name=twap_lookback_window,json=twapLookbackWindow,proto3,stdduration" json:"twap_lookback_window,omitempty" yaml:"twap_lookback_window"`
- // The minimum number of voters (i.e. oracle validators) per pair for it to be
- // considered a passing ballot. Recommended at least 4.
- MinVoters uint64 `protobuf:"varint,9,opt,name=min_voters,json=minVoters,proto3" json:"min_voters,omitempty" yaml:"min_voters"`
- // The validator fee ratio that is given to validators every epoch.
- ValidatorFeeRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=validator_fee_ratio,json=validatorFeeRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"validator_fee_ratio" yaml:"validator_fee_ratio"`
- ExpirationBlocks uint64 `protobuf:"varint,11,opt,name=expiration_blocks,json=expirationBlocks,proto3" json:"expiration_blocks,omitempty" yaml:"expiration_blocks"`
-}
-
-func (m *Params) Reset() { *m = Params{} }
-func (m *Params) String() string { return proto.CompactTextString(m) }
-func (*Params) ProtoMessage() {}
-func (*Params) Descriptor() ([]byte, []int) {
- return fileDescriptor_43d45df86ea09ed4, []int{0}
-}
-func (m *Params) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_Params.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *Params) XXX_Merge(src proto.Message) {
- xxx_messageInfo_Params.Merge(m, src)
-}
-func (m *Params) XXX_Size() int {
- return m.Size()
-}
-func (m *Params) XXX_DiscardUnknown() {
- xxx_messageInfo_Params.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_Params proto.InternalMessageInfo
-
-func (m *Params) GetVotePeriod() uint64 {
- if m != nil {
- return m.VotePeriod
- }
- return 0
-}
-
-func (m *Params) GetSlashWindow() uint64 {
- if m != nil {
- return m.SlashWindow
- }
- return 0
-}
-
-func (m *Params) GetTwapLookbackWindow() time.Duration {
- if m != nil {
- return m.TwapLookbackWindow
- }
- return 0
-}
-
-func (m *Params) GetMinVoters() uint64 {
- if m != nil {
- return m.MinVoters
- }
- return 0
-}
-
-func (m *Params) GetExpirationBlocks() uint64 {
- if m != nil {
- return m.ExpirationBlocks
- }
- return 0
-}
-
-// Struct for aggregate prevoting on the ExchangeRateVote.
-// The purpose of aggregate prevote is to hide vote exchange rates with hash
-// which is formatted as hex string in
-// SHA256("{salt}:({pair},{exchange_rate})|...|({pair},{exchange_rate}):{voter}")
-type AggregateExchangeRatePrevote struct {
- Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty" yaml:"hash"`
- Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty" yaml:"voter"`
- SubmitBlock uint64 `protobuf:"varint,3,opt,name=submit_block,json=submitBlock,proto3" json:"submit_block,omitempty" yaml:"submit_block"`
-}
-
-func (m *AggregateExchangeRatePrevote) Reset() { *m = AggregateExchangeRatePrevote{} }
-func (m *AggregateExchangeRatePrevote) String() string { return proto.CompactTextString(m) }
-func (*AggregateExchangeRatePrevote) ProtoMessage() {}
-func (*AggregateExchangeRatePrevote) Descriptor() ([]byte, []int) {
- return fileDescriptor_43d45df86ea09ed4, []int{1}
-}
-func (m *AggregateExchangeRatePrevote) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *AggregateExchangeRatePrevote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_AggregateExchangeRatePrevote.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *AggregateExchangeRatePrevote) XXX_Merge(src proto.Message) {
- xxx_messageInfo_AggregateExchangeRatePrevote.Merge(m, src)
-}
-func (m *AggregateExchangeRatePrevote) XXX_Size() int {
- return m.Size()
-}
-func (m *AggregateExchangeRatePrevote) XXX_DiscardUnknown() {
- xxx_messageInfo_AggregateExchangeRatePrevote.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_AggregateExchangeRatePrevote proto.InternalMessageInfo
-
-// MsgAggregateExchangeRateVote - struct for voting on
-// the exchange rates different assets.
-type AggregateExchangeRateVote struct {
- ExchangeRateTuples ExchangeRateTuples `protobuf:"bytes,1,rep,name=exchange_rate_tuples,json=exchangeRateTuples,proto3,castrepeated=ExchangeRateTuples" json:"exchange_rate_tuples" yaml:"exchange_rate_tuples"`
- Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty" yaml:"voter"`
-}
-
-func (m *AggregateExchangeRateVote) Reset() { *m = AggregateExchangeRateVote{} }
-func (m *AggregateExchangeRateVote) String() string { return proto.CompactTextString(m) }
-func (*AggregateExchangeRateVote) ProtoMessage() {}
-func (*AggregateExchangeRateVote) Descriptor() ([]byte, []int) {
- return fileDescriptor_43d45df86ea09ed4, []int{2}
-}
-func (m *AggregateExchangeRateVote) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *AggregateExchangeRateVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_AggregateExchangeRateVote.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *AggregateExchangeRateVote) XXX_Merge(src proto.Message) {
- xxx_messageInfo_AggregateExchangeRateVote.Merge(m, src)
-}
-func (m *AggregateExchangeRateVote) XXX_Size() int {
- return m.Size()
-}
-func (m *AggregateExchangeRateVote) XXX_DiscardUnknown() {
- xxx_messageInfo_AggregateExchangeRateVote.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_AggregateExchangeRateVote proto.InternalMessageInfo
-
-// ExchangeRateTuple - struct to store interpreted exchange rates data to store
-type ExchangeRateTuple struct {
- Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair" yaml:"pair"`
- ExchangeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=exchange_rate,json=exchangeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"exchange_rate" yaml:"exchange_rate"`
-}
-
-func (m *ExchangeRateTuple) Reset() { *m = ExchangeRateTuple{} }
-func (m *ExchangeRateTuple) String() string { return proto.CompactTextString(m) }
-func (*ExchangeRateTuple) ProtoMessage() {}
-func (*ExchangeRateTuple) Descriptor() ([]byte, []int) {
- return fileDescriptor_43d45df86ea09ed4, []int{3}
-}
-func (m *ExchangeRateTuple) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *ExchangeRateTuple) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_ExchangeRateTuple.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *ExchangeRateTuple) XXX_Merge(src proto.Message) {
- xxx_messageInfo_ExchangeRateTuple.Merge(m, src)
-}
-func (m *ExchangeRateTuple) XXX_Size() int {
- return m.Size()
-}
-func (m *ExchangeRateTuple) XXX_DiscardUnknown() {
- xxx_messageInfo_ExchangeRateTuple.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ExchangeRateTuple proto.InternalMessageInfo
-
-type DatedPrice struct {
- ExchangeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=exchange_rate,json=exchangeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"exchange_rate" yaml:"exchange_rate"`
- CreatedBlock uint64 `protobuf:"varint,2,opt,name=created_block,json=createdBlock,proto3" json:"created_block,omitempty" yaml:"created_block"`
-}
-
-func (m *DatedPrice) Reset() { *m = DatedPrice{} }
-func (m *DatedPrice) String() string { return proto.CompactTextString(m) }
-func (*DatedPrice) ProtoMessage() {}
-func (*DatedPrice) Descriptor() ([]byte, []int) {
- return fileDescriptor_43d45df86ea09ed4, []int{4}
-}
-func (m *DatedPrice) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *DatedPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_DatedPrice.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *DatedPrice) XXX_Merge(src proto.Message) {
- xxx_messageInfo_DatedPrice.Merge(m, src)
-}
-func (m *DatedPrice) XXX_Size() int {
- return m.Size()
-}
-func (m *DatedPrice) XXX_DiscardUnknown() {
- xxx_messageInfo_DatedPrice.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_DatedPrice proto.InternalMessageInfo
-
-func (m *DatedPrice) GetCreatedBlock() uint64 {
- if m != nil {
- return m.CreatedBlock
- }
- return 0
-}
-
-// Rewards defines a credit object towards validators
-// which provide prices faithfully for different pairs.
-type Rewards struct {
- // id uniquely identifies the rewards instance of the pair
- Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
- // vote_periods defines the vote periods left in which rewards will be
- // distributed.
- VotePeriods uint64 `protobuf:"varint,2,opt,name=vote_periods,json=votePeriods,proto3" json:"vote_periods,omitempty"`
- // Coins defines the amount of coins to distribute in a single vote period.
- Coins []types.Coin `protobuf:"bytes,3,rep,name=coins,proto3" json:"coins"`
-}
-
-func (m *Rewards) Reset() { *m = Rewards{} }
-func (m *Rewards) String() string { return proto.CompactTextString(m) }
-func (*Rewards) ProtoMessage() {}
-func (*Rewards) Descriptor() ([]byte, []int) {
- return fileDescriptor_43d45df86ea09ed4, []int{5}
-}
-func (m *Rewards) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *Rewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_Rewards.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *Rewards) XXX_Merge(src proto.Message) {
- xxx_messageInfo_Rewards.Merge(m, src)
-}
-func (m *Rewards) XXX_Size() int {
- return m.Size()
-}
-func (m *Rewards) XXX_DiscardUnknown() {
- xxx_messageInfo_Rewards.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_Rewards proto.InternalMessageInfo
-
-func (m *Rewards) GetId() uint64 {
- if m != nil {
- return m.Id
- }
- return 0
-}
-
-func (m *Rewards) GetVotePeriods() uint64 {
- if m != nil {
- return m.VotePeriods
- }
- return 0
-}
-
-func (m *Rewards) GetCoins() []types.Coin {
- if m != nil {
- return m.Coins
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*Params)(nil), "nibiru.oracle.v1.Params")
- proto.RegisterType((*AggregateExchangeRatePrevote)(nil), "nibiru.oracle.v1.AggregateExchangeRatePrevote")
- proto.RegisterType((*AggregateExchangeRateVote)(nil), "nibiru.oracle.v1.AggregateExchangeRateVote")
- proto.RegisterType((*ExchangeRateTuple)(nil), "nibiru.oracle.v1.ExchangeRateTuple")
- proto.RegisterType((*DatedPrice)(nil), "nibiru.oracle.v1.DatedPrice")
- proto.RegisterType((*Rewards)(nil), "nibiru.oracle.v1.Rewards")
-}
-
-func init() { proto.RegisterFile("nibiru/oracle/v1/oracle.proto", fileDescriptor_43d45df86ea09ed4) }
-
-var fileDescriptor_43d45df86ea09ed4 = []byte{
- // 976 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x6f, 0x1b, 0xc5,
- 0x1b, 0xf6, 0x26, 0x4e, 0x1a, 0x8f, 0x93, 0xfe, 0x92, 0x69, 0xfa, 0x63, 0x13, 0x8a, 0x37, 0x4c,
- 0xa5, 0xca, 0x87, 0xb2, 0xab, 0x14, 0x10, 0x22, 0x12, 0x07, 0xb6, 0x21, 0x10, 0xa9, 0x20, 0x6b,
- 0x54, 0x81, 0x84, 0x90, 0xac, 0xd9, 0xdd, 0xc9, 0x7a, 0xe4, 0xdd, 0x1d, 0x6b, 0x66, 0x1d, 0x27,
- 0x12, 0xe2, 0xcc, 0xb1, 0x27, 0xc4, 0x31, 0x67, 0x6e, 0xdc, 0xf8, 0x08, 0x95, 0xb8, 0xf4, 0x88,
- 0x7a, 0xd8, 0x56, 0xc9, 0x25, 0xe2, 0xe8, 0x4f, 0x80, 0x66, 0x76, 0x1c, 0x6f, 0xb0, 0x25, 0x08,
- 0x88, 0x93, 0xf7, 0x7d, 0x9f, 0x99, 0xe7, 0x7d, 0xde, 0x3f, 0x33, 0x63, 0xf0, 0x56, 0xc6, 0x02,
- 0x26, 0x86, 0x1e, 0x17, 0x24, 0x4c, 0xa8, 0x77, 0xbc, 0x6b, 0xbe, 0xdc, 0x81, 0xe0, 0x39, 0x87,
- 0xeb, 0x25, 0xec, 0x1a, 0xe7, 0xf1, 0xee, 0xf6, 0x66, 0xcc, 0x63, 0xae, 0x41, 0x4f, 0x7d, 0x95,
- 0xeb, 0xb6, 0x5b, 0x31, 0xe7, 0x71, 0x42, 0x3d, 0x6d, 0x05, 0xc3, 0x23, 0x2f, 0x1a, 0x0a, 0x92,
- 0x33, 0x9e, 0x4d, 0xf0, 0x90, 0xcb, 0x94, 0x4b, 0x2f, 0x20, 0x52, 0x05, 0x09, 0x68, 0x4e, 0x76,
- 0xbd, 0x90, 0x33, 0x83, 0xa3, 0x5f, 0x57, 0xc0, 0x72, 0x87, 0x08, 0x92, 0x4a, 0xf8, 0x01, 0x68,
- 0x1e, 0xf3, 0x9c, 0x76, 0x07, 0x54, 0x30, 0x1e, 0xd9, 0xd6, 0x8e, 0xd5, 0xae, 0xfb, 0xff, 0x1f,
- 0x17, 0x0e, 0x3c, 0x25, 0x69, 0xb2, 0x87, 0x2a, 0x20, 0xc2, 0x40, 0x59, 0x1d, 0x6d, 0xc0, 0x0c,
- 0xdc, 0xd6, 0x58, 0xde, 0x13, 0x54, 0xf6, 0x78, 0x12, 0xd9, 0x0b, 0x3b, 0x56, 0xbb, 0xe1, 0x7f,
- 0xfa, 0xbc, 0x70, 0x6a, 0x2f, 0x0b, 0xe7, 0x41, 0xcc, 0xf2, 0xde, 0x30, 0x70, 0x43, 0x9e, 0x7a,
- 0x46, 0x4e, 0xf9, 0xf3, 0x8e, 0x8c, 0xfa, 0x5e, 0x7e, 0x3a, 0xa0, 0xd2, 0xdd, 0xa7, 0xe1, 0xb8,
- 0x70, 0xee, 0x56, 0x22, 0x5d, 0xb1, 0x21, 0xbc, 0xa6, 0x1c, 0x4f, 0x27, 0x36, 0xa4, 0xa0, 0x29,
- 0xe8, 0x88, 0x88, 0xa8, 0x1b, 0x90, 0x2c, 0xb2, 0x17, 0x75, 0xb0, 0xfd, 0x1b, 0x07, 0x33, 0x69,
- 0x55, 0xa8, 0x10, 0x06, 0xa5, 0xe5, 0x93, 0x2c, 0x82, 0x31, 0x68, 0x8c, 0x7a, 0x2c, 0xa7, 0x09,
- 0x93, 0xb9, 0x5d, 0xdf, 0x59, 0x6c, 0x37, 0xfc, 0xc3, 0x97, 0x85, 0xb3, 0x5b, 0x09, 0xf0, 0x85,
- 0x6e, 0xd2, 0xe3, 0x1e, 0x61, 0x99, 0x67, 0xfa, 0x79, 0xe2, 0x85, 0x3c, 0x4d, 0x79, 0xe6, 0x11,
- 0x29, 0x69, 0xee, 0x76, 0x08, 0x13, 0xe3, 0xc2, 0x59, 0x2f, 0x63, 0x5d, 0xf1, 0x21, 0x3c, 0xe5,
- 0x56, 0xf5, 0x93, 0x09, 0x91, 0xbd, 0xee, 0x91, 0x20, 0xa1, 0xea, 0x9d, 0xbd, 0xf4, 0xef, 0xea,
- 0x77, 0x9d, 0x0d, 0xe1, 0x35, 0xed, 0x38, 0x30, 0x36, 0xdc, 0x03, 0xab, 0xe5, 0x8a, 0x11, 0xcb,
- 0x22, 0x3e, 0xb2, 0x97, 0x75, 0xa7, 0xdf, 0x18, 0x17, 0xce, 0x9d, 0xea, 0xfe, 0x12, 0x45, 0xb8,
- 0xa9, 0xcd, 0xaf, 0xb4, 0x05, 0xbf, 0x03, 0x9b, 0x29, 0xcb, 0xba, 0xc7, 0x24, 0x61, 0x91, 0x1a,
- 0x86, 0x09, 0xc7, 0x2d, 0xad, 0xf8, 0xf3, 0x1b, 0x2b, 0x7e, 0xb3, 0x8c, 0x38, 0x8f, 0x13, 0xe1,
- 0x8d, 0x94, 0x65, 0x5f, 0x2a, 0x6f, 0x87, 0x0a, 0x13, 0xff, 0x07, 0x0b, 0x6c, 0xe6, 0x23, 0x32,
- 0xe8, 0x26, 0x9c, 0xf7, 0x03, 0x12, 0xf6, 0x27, 0x02, 0x56, 0x76, 0xac, 0x76, 0xf3, 0xd1, 0x96,
- 0x5b, 0x9e, 0x07, 0x77, 0x72, 0x1e, 0xdc, 0x7d, 0x73, 0x1e, 0xfc, 0x43, 0xa5, 0xed, 0xf7, 0xc2,
- 0x69, 0xcd, 0xdb, 0xfe, 0x90, 0xa7, 0x2c, 0xa7, 0xe9, 0x20, 0x3f, 0x9d, 0x6a, 0x9a, 0xb7, 0x0e,
- 0xfd, 0xf8, 0xca, 0xb1, 0x30, 0x54, 0xd0, 0x13, 0x83, 0x18, 0x61, 0xef, 0x01, 0xa0, 0x93, 0xe0,
- 0x39, 0x15, 0xd2, 0x6e, 0xe8, 0x92, 0xde, 0x1d, 0x17, 0xce, 0x46, 0x25, 0x41, 0x8d, 0x21, 0xdc,
- 0x50, 0x69, 0xe9, 0x6f, 0xf8, 0x2d, 0xb8, 0xa3, 0xd3, 0x26, 0x39, 0x17, 0xdd, 0x23, 0x4a, 0xbb,
- 0x5a, 0xac, 0x0d, 0x74, 0x35, 0x9f, 0xdc, 0xb8, 0x9a, 0xdb, 0xe6, 0xfc, 0xcc, 0x52, 0x22, 0xbc,
- 0x71, 0xe5, 0x3d, 0xa0, 0x14, 0x2b, 0x1f, 0x3c, 0x04, 0x1b, 0xf4, 0x64, 0xc0, 0xca, 0x02, 0x75,
- 0x83, 0x84, 0x87, 0x7d, 0x69, 0x37, 0xb5, 0xf4, 0x7b, 0xe3, 0xc2, 0xb1, 0x4b, 0xb6, 0x99, 0x25,
- 0x08, 0xaf, 0x4f, 0x7d, 0xbe, 0x76, 0xed, 0xd5, 0x2f, 0xcf, 0x1c, 0x0b, 0xfd, 0x6c, 0x81, 0x7b,
- 0x1f, 0xc7, 0xb1, 0xa0, 0x31, 0xc9, 0xe9, 0x27, 0x27, 0x61, 0x8f, 0x64, 0xb1, 0x8a, 0x45, 0x3b,
- 0x82, 0xaa, 0xec, 0xe1, 0x7d, 0x50, 0xef, 0x11, 0xd9, 0xd3, 0x97, 0x4b, 0xc3, 0xff, 0xdf, 0xb8,
- 0x70, 0x9a, 0x65, 0x10, 0xe5, 0x45, 0x58, 0x83, 0xf0, 0x01, 0x58, 0xd2, 0xa5, 0x32, 0xd7, 0xc8,
- 0xfa, 0xb8, 0x70, 0x56, 0xa7, 0x17, 0x83, 0x40, 0xb8, 0x84, 0xf5, 0x1c, 0x0f, 0x83, 0x94, 0xe5,
- 0xa5, 0x2e, 0x7d, 0x11, 0x5c, 0x9f, 0xe3, 0x0a, 0xaa, 0xe6, 0x58, 0x9b, 0x5a, 0xf0, 0xde, 0xca,
- 0xf7, 0x67, 0x4e, 0xed, 0xf2, 0xcc, 0xa9, 0xa1, 0xd7, 0x16, 0xd8, 0x9a, 0xab, 0x59, 0xb5, 0x08,
- 0x3e, 0xb3, 0xc0, 0x26, 0x35, 0x4e, 0x55, 0x49, 0xda, 0xcd, 0x87, 0x83, 0x84, 0x4a, 0xdb, 0xda,
- 0x59, 0x6c, 0x37, 0x1f, 0xdd, 0x77, 0xff, 0x7c, 0x4f, 0xbb, 0x55, 0x8a, 0xa7, 0x6a, 0xad, 0xff,
- 0xa1, 0xea, 0xe3, 0x74, 0xae, 0xe6, 0xd1, 0xa1, 0x9f, 0x5e, 0x39, 0x70, 0x66, 0xa7, 0xc4, 0x90,
- 0xce, 0xf8, 0xfe, 0x6e, 0x79, 0x2a, 0x29, 0x5e, 0x5a, 0x60, 0x63, 0x86, 0x1c, 0x7e, 0x03, 0xea,
- 0x03, 0xc2, 0x84, 0xe9, 0xc5, 0x67, 0x66, 0xd8, 0xfe, 0xd1, 0xf5, 0x66, 0x9a, 0xa8, 0xe8, 0x10,
- 0xd6, 0xac, 0xb0, 0x0f, 0xd6, 0xae, 0x25, 0x6a, 0xd4, 0x1e, 0xdc, 0x78, 0xa6, 0x37, 0xe7, 0x54,
- 0x0d, 0xe1, 0xd5, 0x6a, 0x61, 0x2a, 0xa9, 0xfe, 0x62, 0x01, 0xb0, 0x4f, 0x72, 0x1a, 0x75, 0x04,
- 0x0b, 0xe9, 0xac, 0x0a, 0xeb, 0xbf, 0x53, 0x01, 0x3f, 0x02, 0x6b, 0xa1, 0xa0, 0x2a, 0xb8, 0x19,
- 0xc8, 0x05, 0x3d, 0x90, 0xf6, 0x74, 0xfb, 0x35, 0x18, 0xe1, 0x55, 0x63, 0xeb, 0x91, 0x44, 0x12,
- 0xdc, 0xc2, 0xfa, 0xf5, 0x91, 0xf0, 0x36, 0x58, 0x60, 0xe6, 0x05, 0xc6, 0x0b, 0x2c, 0x82, 0x6f,
- 0x83, 0xd5, 0xca, 0xeb, 0x2b, 0x4b, 0x62, 0xdc, 0x9c, 0xbe, 0xc1, 0x12, 0xbe, 0x0f, 0x96, 0xd4,
- 0xb3, 0x2e, 0xed, 0x45, 0x3d, 0x98, 0x5b, 0x6e, 0x99, 0x88, 0xab, 0x1e, 0x7e, 0xd7, 0x3c, 0xfc,
- 0xee, 0x63, 0xce, 0x32, 0xbf, 0xae, 0x92, 0xc7, 0xe5, 0x6a, 0xff, 0xe0, 0xf9, 0x79, 0xcb, 0x7a,
- 0x71, 0xde, 0xb2, 0x5e, 0x9f, 0xb7, 0xac, 0x67, 0x17, 0xad, 0xda, 0x8b, 0x8b, 0x56, 0xed, 0xb7,
- 0x8b, 0x56, 0xed, 0xeb, 0x87, 0x7f, 0x35, 0x08, 0xe6, 0x9f, 0x8b, 0xae, 0x52, 0xb0, 0xac, 0x2f,
- 0xdc, 0x77, 0xff, 0x08, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x42, 0xc8, 0x75, 0xd7, 0x08, 0x00, 0x00,
-}
-
-func (this *Params) Equal(that interface{}) bool {
- if that == nil {
- return this == nil
- }
-
- that1, ok := that.(*Params)
- if !ok {
- that2, ok := that.(Params)
- if ok {
- that1 = &that2
- } else {
- return false
- }
- }
- if that1 == nil {
- return this == nil
- } else if this == nil {
- return false
- }
- if this.VotePeriod != that1.VotePeriod {
- return false
- }
- if !this.VoteThreshold.Equal(that1.VoteThreshold) {
- return false
- }
- if !this.RewardBand.Equal(that1.RewardBand) {
- return false
- }
- if len(this.Whitelist) != len(that1.Whitelist) {
- return false
- }
- for i := range this.Whitelist {
- if !this.Whitelist[i].Equal(that1.Whitelist[i]) {
- return false
- }
- }
- if !this.SlashFraction.Equal(that1.SlashFraction) {
- return false
- }
- if this.SlashWindow != that1.SlashWindow {
- return false
- }
- if !this.MinValidPerWindow.Equal(that1.MinValidPerWindow) {
- return false
- }
- if this.TwapLookbackWindow != that1.TwapLookbackWindow {
- return false
- }
- if this.MinVoters != that1.MinVoters {
- return false
- }
- if !this.ValidatorFeeRatio.Equal(that1.ValidatorFeeRatio) {
- return false
- }
- if this.ExpirationBlocks != that1.ExpirationBlocks {
- return false
- }
- return true
-}
-func (m *Params) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Params) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.ExpirationBlocks != 0 {
- i = encodeVarintOracle(dAtA, i, uint64(m.ExpirationBlocks))
- i--
- dAtA[i] = 0x58
- }
- {
- size := m.ValidatorFeeRatio.Size()
- i -= size
- if _, err := m.ValidatorFeeRatio.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x52
- if m.MinVoters != 0 {
- i = encodeVarintOracle(dAtA, i, uint64(m.MinVoters))
- i--
- dAtA[i] = 0x48
- }
- n1, err1 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.TwapLookbackWindow, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TwapLookbackWindow):])
- if err1 != nil {
- return 0, err1
- }
- i -= n1
- i = encodeVarintOracle(dAtA, i, uint64(n1))
- i--
- dAtA[i] = 0x42
- {
- size := m.MinValidPerWindow.Size()
- i -= size
- if _, err := m.MinValidPerWindow.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x3a
- if m.SlashWindow != 0 {
- i = encodeVarintOracle(dAtA, i, uint64(m.SlashWindow))
- i--
- dAtA[i] = 0x30
- }
- {
- size := m.SlashFraction.Size()
- i -= size
- if _, err := m.SlashFraction.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x2a
- if len(m.Whitelist) > 0 {
- for iNdEx := len(m.Whitelist) - 1; iNdEx >= 0; iNdEx-- {
- {
- size := m.Whitelist[iNdEx].Size()
- i -= size
- if _, err := m.Whitelist[iNdEx].MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x22
- }
- }
- {
- size := m.RewardBand.Size()
- i -= size
- if _, err := m.RewardBand.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- {
- size := m.VoteThreshold.Size()
- i -= size
- if _, err := m.VoteThreshold.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if m.VotePeriod != 0 {
- i = encodeVarintOracle(dAtA, i, uint64(m.VotePeriod))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func (m *AggregateExchangeRatePrevote) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AggregateExchangeRatePrevote) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *AggregateExchangeRatePrevote) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.SubmitBlock != 0 {
- i = encodeVarintOracle(dAtA, i, uint64(m.SubmitBlock))
- i--
- dAtA[i] = 0x18
- }
- if len(m.Voter) > 0 {
- i -= len(m.Voter)
- copy(dAtA[i:], m.Voter)
- i = encodeVarintOracle(dAtA, i, uint64(len(m.Voter)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Hash) > 0 {
- i -= len(m.Hash)
- copy(dAtA[i:], m.Hash)
- i = encodeVarintOracle(dAtA, i, uint64(len(m.Hash)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *AggregateExchangeRateVote) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AggregateExchangeRateVote) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *AggregateExchangeRateVote) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Voter) > 0 {
- i -= len(m.Voter)
- copy(dAtA[i:], m.Voter)
- i = encodeVarintOracle(dAtA, i, uint64(len(m.Voter)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.ExchangeRateTuples) > 0 {
- for iNdEx := len(m.ExchangeRateTuples) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.ExchangeRateTuples[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *ExchangeRateTuple) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ExchangeRateTuple) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *ExchangeRateTuple) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size := m.ExchangeRate.Size()
- i -= size
- if _, err := m.ExchangeRate.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- {
- size := m.Pair.Size()
- i -= size
- if _, err := m.Pair.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *DatedPrice) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *DatedPrice) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *DatedPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.CreatedBlock != 0 {
- i = encodeVarintOracle(dAtA, i, uint64(m.CreatedBlock))
- i--
- dAtA[i] = 0x10
- }
- {
- size := m.ExchangeRate.Size()
- i -= size
- if _, err := m.ExchangeRate.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *Rewards) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Rewards) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *Rewards) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Coins) > 0 {
- for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintOracle(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- }
- if m.VotePeriods != 0 {
- i = encodeVarintOracle(dAtA, i, uint64(m.VotePeriods))
- i--
- dAtA[i] = 0x10
- }
- if m.Id != 0 {
- i = encodeVarintOracle(dAtA, i, uint64(m.Id))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintOracle(dAtA []byte, offset int, v uint64) int {
- offset -= sovOracle(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *Params) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.VotePeriod != 0 {
- n += 1 + sovOracle(uint64(m.VotePeriod))
- }
- l = m.VoteThreshold.Size()
- n += 1 + l + sovOracle(uint64(l))
- l = m.RewardBand.Size()
- n += 1 + l + sovOracle(uint64(l))
- if len(m.Whitelist) > 0 {
- for _, e := range m.Whitelist {
- l = e.Size()
- n += 1 + l + sovOracle(uint64(l))
- }
- }
- l = m.SlashFraction.Size()
- n += 1 + l + sovOracle(uint64(l))
- if m.SlashWindow != 0 {
- n += 1 + sovOracle(uint64(m.SlashWindow))
- }
- l = m.MinValidPerWindow.Size()
- n += 1 + l + sovOracle(uint64(l))
- l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TwapLookbackWindow)
- n += 1 + l + sovOracle(uint64(l))
- if m.MinVoters != 0 {
- n += 1 + sovOracle(uint64(m.MinVoters))
- }
- l = m.ValidatorFeeRatio.Size()
- n += 1 + l + sovOracle(uint64(l))
- if m.ExpirationBlocks != 0 {
- n += 1 + sovOracle(uint64(m.ExpirationBlocks))
- }
- return n
-}
-
-func (m *AggregateExchangeRatePrevote) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Hash)
- if l > 0 {
- n += 1 + l + sovOracle(uint64(l))
- }
- l = len(m.Voter)
- if l > 0 {
- n += 1 + l + sovOracle(uint64(l))
- }
- if m.SubmitBlock != 0 {
- n += 1 + sovOracle(uint64(m.SubmitBlock))
- }
- return n
-}
-
-func (m *AggregateExchangeRateVote) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.ExchangeRateTuples) > 0 {
- for _, e := range m.ExchangeRateTuples {
- l = e.Size()
- n += 1 + l + sovOracle(uint64(l))
- }
- }
- l = len(m.Voter)
- if l > 0 {
- n += 1 + l + sovOracle(uint64(l))
- }
- return n
-}
-
-func (m *ExchangeRateTuple) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Pair.Size()
- n += 1 + l + sovOracle(uint64(l))
- l = m.ExchangeRate.Size()
- n += 1 + l + sovOracle(uint64(l))
- return n
-}
-
-func (m *DatedPrice) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.ExchangeRate.Size()
- n += 1 + l + sovOracle(uint64(l))
- if m.CreatedBlock != 0 {
- n += 1 + sovOracle(uint64(m.CreatedBlock))
- }
- return n
-}
-
-func (m *Rewards) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.Id != 0 {
- n += 1 + sovOracle(uint64(m.Id))
- }
- if m.VotePeriods != 0 {
- n += 1 + sovOracle(uint64(m.VotePeriods))
- }
- if len(m.Coins) > 0 {
- for _, e := range m.Coins {
- l = e.Size()
- n += 1 + l + sovOracle(uint64(l))
- }
- }
- return n
-}
-
-func sovOracle(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozOracle(x uint64) (n int) {
- return sovOracle(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *Params) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: Params: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field VotePeriod", wireType)
- }
- m.VotePeriod = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.VotePeriod |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field VoteThreshold", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.VoteThreshold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RewardBand", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.RewardBand.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Whitelist", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_NibiruChain_nibiru_x_common_asset.Pair
- m.Whitelist = append(m.Whitelist, v)
- if err := m.Whitelist[len(m.Whitelist)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field SlashFraction", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.SlashFraction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field SlashWindow", wireType)
- }
- m.SlashWindow = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.SlashWindow |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field MinValidPerWindow", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.MinValidPerWindow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field TwapLookbackWindow", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.TwapLookbackWindow, dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 9:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MinVoters", wireType)
- }
- m.MinVoters = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MinVoters |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 10:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ValidatorFeeRatio", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.ValidatorFeeRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 11:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ExpirationBlocks", wireType)
- }
- m.ExpirationBlocks = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ExpirationBlocks |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipOracle(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthOracle
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AggregateExchangeRatePrevote) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AggregateExchangeRatePrevote: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AggregateExchangeRatePrevote: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Hash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Voter = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field SubmitBlock", wireType)
- }
- m.SubmitBlock = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.SubmitBlock |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipOracle(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthOracle
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AggregateExchangeRateVote) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AggregateExchangeRateVote: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AggregateExchangeRateVote: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRateTuples", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ExchangeRateTuples = append(m.ExchangeRateTuples, ExchangeRateTuple{})
- if err := m.ExchangeRateTuples[len(m.ExchangeRateTuples)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Voter = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipOracle(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthOracle
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *ExchangeRateTuple) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ExchangeRateTuple: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ExchangeRateTuple: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Pair", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Pair.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRate", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.ExchangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipOracle(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthOracle
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *DatedPrice) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: DatedPrice: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: DatedPrice: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRate", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.ExchangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CreatedBlock", wireType)
- }
- m.CreatedBlock = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.CreatedBlock |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipOracle(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthOracle
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *Rewards) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: Rewards: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: Rewards: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType)
- }
- m.Id = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Id |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field VotePeriods", wireType)
- }
- m.VotePeriods = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.VotePeriods |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthOracle
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthOracle
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Coins = append(m.Coins, types.Coin{})
- if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipOracle(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthOracle
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipOracle(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowOracle
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthOracle
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupOracle
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthOracle
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthOracle = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowOracle = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupOracle = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go
deleted file mode 100644
index b31e8ac7a..000000000
--- a/x/oracle/types/params.go
+++ /dev/null
@@ -1,116 +0,0 @@
-package types
-
-import (
- "fmt"
- time "time"
-
- "cosmossdk.io/math"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/denoms"
-)
-
-// Parameter keys
-var (
- KeyVotePeriod = []byte("VotePeriod")
- KeyVoteThreshold = []byte("VoteThreshold")
- KeyMinVoters = []byte("MinVoters")
- KeyRewardBand = []byte("RewardBand")
- KeyWhitelist = []byte("Whitelist")
- KeySlashFraction = []byte("SlashFraction")
- KeySlashWindow = []byte("SlashWindow")
- KeyMinValidPerWindow = []byte("MinValidPerWindow")
- KeyTwapLookbackWindow = []byte("TwapLookbackWindow")
- KeyValidatorFeeRatio = []byte("ValidatorFeeRatio")
-)
-
-// Default parameter values
-// Assumes block times are 2s
-const (
- DefaultVotePeriod = 30 // vote every 1 minute
- DefaultSlashWindow = 3600 // 2 hours
- DefaultMinVoters = 4 // minimum of 4 voters for a pair to become valid
- DefaultExpirationBlocks = 900 // 30 minutes
-)
-
-// Default parameter values
-var (
- DefaultVoteThreshold = math.LegacyOneDec().Quo(math.LegacyNewDec(3)) // 33.33%
- DefaultRewardBand = math.LegacyNewDecWithPrec(2, 2) // 2% (-1, 1)
- DefaultWhitelist = []asset.Pair{
- // paired against the US fiat dollar
- asset.Registry.Pair(denoms.BTC, denoms.USD),
- asset.Registry.Pair(denoms.ETH, denoms.USD),
- asset.Registry.Pair(denoms.ATOM, denoms.USD),
- asset.Registry.Pair(denoms.BNB, denoms.USD),
- asset.Registry.Pair(denoms.USDC, denoms.USD),
- asset.Registry.Pair(denoms.USDT, denoms.USD),
- // asset.Registry.Pair(denoms.OSMO, denoms.USD),
- // asset.Registry.Pair(denoms.AVAX, denoms.USD),
- // asset.Registry.Pair(denoms.SOL, denoms.USD),
- // asset.Registry.Pair(denoms.ADA, denoms.USD),
- }
- DefaultSlashFraction = math.LegacyNewDecWithPrec(5, 3) // 0.5%
- DefaultMinValidPerWindow = math.LegacyNewDecWithPrec(69, 2) // 69%
- DefaultTwapLookbackWindow = time.Duration(15 * time.Minute) // 15 minutes
- DefaultValidatorFeeRatio = math.LegacyNewDecWithPrec(5, 2) // 0.05%
-)
-
-// DefaultParams creates default oracle module parameters
-func DefaultParams() Params {
- return Params{
- VotePeriod: DefaultVotePeriod,
- VoteThreshold: DefaultVoteThreshold,
- MinVoters: DefaultMinVoters,
- ExpirationBlocks: DefaultExpirationBlocks,
- RewardBand: DefaultRewardBand,
- Whitelist: DefaultWhitelist,
- SlashFraction: DefaultSlashFraction,
- SlashWindow: DefaultSlashWindow,
- MinValidPerWindow: DefaultMinValidPerWindow,
- TwapLookbackWindow: DefaultTwapLookbackWindow,
- ValidatorFeeRatio: DefaultValidatorFeeRatio,
- }
-}
-
-// Validate performs basic validation on oracle parameters.
-func (p Params) Validate() error {
- if p.VotePeriod == 0 {
- return fmt.Errorf("oracle parameter VotePeriod must be > 0, is %d", p.VotePeriod)
- }
-
- if p.VoteThreshold.LTE(math.LegacyNewDecWithPrec(33, 2)) {
- return fmt.Errorf("oracle parameter VoteThreshold must be greater than 33 percent")
- }
-
- if p.MinVoters <= 0 {
- return fmt.Errorf("oracle parameter MinVoters must be greater than 0")
- }
-
- if p.RewardBand.GT(math.LegacyOneDec()) || p.RewardBand.IsNegative() {
- return fmt.Errorf("oracle parameter RewardBand must be between [0, 1]")
- }
-
- if p.SlashFraction.GT(math.LegacyOneDec()) || p.SlashFraction.IsNegative() {
- return fmt.Errorf("oracle parameter SlashFraction must be between [0, 1]")
- }
-
- if p.SlashWindow < p.VotePeriod {
- return fmt.Errorf("oracle parameter SlashWindow must be greater than or equal with VotePeriod")
- }
-
- if p.MinValidPerWindow.GT(math.LegacyOneDec()) || p.MinValidPerWindow.IsNegative() {
- return fmt.Errorf("oracle parameter MinValidPerWindow must be between [0, 1]")
- }
-
- if p.ValidatorFeeRatio.GT(math.LegacyOneDec()) || p.ValidatorFeeRatio.IsNegative() {
- return fmt.Errorf("oracle parameter ValidatorFeeRatio must be between [0, 1]")
- }
-
- for _, pair := range p.Whitelist {
- if err := pair.Validate(); err != nil {
- return fmt.Errorf("oracle parameter Whitelist Pair invalid format: %w", err)
- }
- }
- return nil
-}
diff --git a/x/oracle/types/params_test.go b/x/oracle/types/params_test.go
deleted file mode 100644
index 6fff8f748..000000000
--- a/x/oracle/types/params_test.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package types_test
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestParamsEqual(t *testing.T) {
- p1 := types.DefaultParams()
- err := p1.Validate()
- require.NoError(t, err)
-
- // minus vote period
- p1.VotePeriod = 0
- err = p1.Validate()
- require.Error(t, err)
-
- p1.MinVoters = 0
- err = p1.Validate()
- require.Error(t, err)
-
- // small vote threshold
- p2 := types.DefaultParams()
- p2.VoteThreshold = math.LegacyZeroDec()
- err = p2.Validate()
- require.Error(t, err)
-
- // negative reward band
- p3 := types.DefaultParams()
- p3.RewardBand = math.LegacyNewDecWithPrec(-1, 2)
- err = p3.Validate()
- require.Error(t, err)
-
- // negative slash fraction
- p4 := types.DefaultParams()
- p4.SlashFraction = math.LegacyNewDec(-1)
- err = p4.Validate()
- require.Error(t, err)
-
- // negative min valid per window
- p5 := types.DefaultParams()
- p5.MinValidPerWindow = math.LegacyNewDec(-1)
- err = p5.Validate()
- require.Error(t, err)
-
- // small slash window
- p6 := types.DefaultParams()
- p6.SlashWindow = 0
- err = p6.Validate()
- require.Error(t, err)
-
- // empty name
- p10 := types.DefaultParams()
- p10.Whitelist[0] = ""
- err = p10.Validate()
- require.Error(t, err)
-
- // oracle fee ratio > 1
- p12 := types.DefaultParams()
- p12.ValidatorFeeRatio = math.LegacyNewDec(2)
- err = p12.Validate()
- require.Error(t, err)
-
- // oracle fee ratio < 0
- p13 := types.DefaultParams()
- p13.ValidatorFeeRatio = math.LegacyNewDec(-1)
- err = p13.Validate()
- require.Error(t, err)
-
- p11 := types.DefaultParams()
- require.NotNil(t, p11.String())
-}
diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go
deleted file mode 100644
index 3d82a1d37..000000000
--- a/x/oracle/types/query.pb.go
+++ /dev/null
@@ -1,4210 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/oracle/v1/query.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- github_com_NibiruChain_nibiru_x_common_asset "github.com/NibiruChain/nibiru/x/common/asset"
- _ "github.com/cosmos/cosmos-sdk/types"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// QueryExchangeRateRequest is the request type for the Query/ExchangeRate RPC
-// method.
-type QueryExchangeRateRequest struct {
- // pair defines the pair to query for.
- Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
-}
-
-func (m *QueryExchangeRateRequest) Reset() { *m = QueryExchangeRateRequest{} }
-func (m *QueryExchangeRateRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryExchangeRateRequest) ProtoMessage() {}
-func (*QueryExchangeRateRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{0}
-}
-func (m *QueryExchangeRateRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryExchangeRateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryExchangeRateRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryExchangeRateRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryExchangeRateRequest.Merge(m, src)
-}
-func (m *QueryExchangeRateRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryExchangeRateRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryExchangeRateRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryExchangeRateRequest proto.InternalMessageInfo
-
-// QueryExchangeRateResponse is response type for the
-// Query/ExchangeRate RPC method.
-type QueryExchangeRateResponse struct {
- // exchange_rate defines the exchange rate of assets voted by validators
- ExchangeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=exchange_rate,json=exchangeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"exchange_rate"`
-}
-
-func (m *QueryExchangeRateResponse) Reset() { *m = QueryExchangeRateResponse{} }
-func (m *QueryExchangeRateResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryExchangeRateResponse) ProtoMessage() {}
-func (*QueryExchangeRateResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{1}
-}
-func (m *QueryExchangeRateResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryExchangeRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryExchangeRateResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryExchangeRateResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryExchangeRateResponse.Merge(m, src)
-}
-func (m *QueryExchangeRateResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryExchangeRateResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryExchangeRateResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryExchangeRateResponse proto.InternalMessageInfo
-
-// QueryExchangeRatesRequest is the request type for the Query/ExchangeRates RPC
-// method.
-type QueryExchangeRatesRequest struct {
-}
-
-func (m *QueryExchangeRatesRequest) Reset() { *m = QueryExchangeRatesRequest{} }
-func (m *QueryExchangeRatesRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryExchangeRatesRequest) ProtoMessage() {}
-func (*QueryExchangeRatesRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{2}
-}
-func (m *QueryExchangeRatesRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryExchangeRatesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryExchangeRatesRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryExchangeRatesRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryExchangeRatesRequest.Merge(m, src)
-}
-func (m *QueryExchangeRatesRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryExchangeRatesRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryExchangeRatesRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryExchangeRatesRequest proto.InternalMessageInfo
-
-// QueryExchangeRatesResponse is response type for the
-// Query/ExchangeRates RPC method.
-type QueryExchangeRatesResponse struct {
- // exchange_rates defines a list of the exchange rate for all whitelisted
- // pairs.
- ExchangeRates ExchangeRateTuples `protobuf:"bytes,1,rep,name=exchange_rates,json=exchangeRates,proto3,castrepeated=ExchangeRateTuples" json:"exchange_rates"`
-}
-
-func (m *QueryExchangeRatesResponse) Reset() { *m = QueryExchangeRatesResponse{} }
-func (m *QueryExchangeRatesResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryExchangeRatesResponse) ProtoMessage() {}
-func (*QueryExchangeRatesResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{3}
-}
-func (m *QueryExchangeRatesResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryExchangeRatesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryExchangeRatesResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryExchangeRatesResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryExchangeRatesResponse.Merge(m, src)
-}
-func (m *QueryExchangeRatesResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryExchangeRatesResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryExchangeRatesResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryExchangeRatesResponse proto.InternalMessageInfo
-
-func (m *QueryExchangeRatesResponse) GetExchangeRates() ExchangeRateTuples {
- if m != nil {
- return m.ExchangeRates
- }
- return nil
-}
-
-// QueryActivesRequest is the request type for the Query/Actives RPC method.
-type QueryActivesRequest struct {
-}
-
-func (m *QueryActivesRequest) Reset() { *m = QueryActivesRequest{} }
-func (m *QueryActivesRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryActivesRequest) ProtoMessage() {}
-func (*QueryActivesRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{4}
-}
-func (m *QueryActivesRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryActivesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryActivesRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryActivesRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryActivesRequest.Merge(m, src)
-}
-func (m *QueryActivesRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryActivesRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryActivesRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryActivesRequest proto.InternalMessageInfo
-
-// QueryActivesResponse is response type for the
-// Query/Actives RPC method.
-type QueryActivesResponse struct {
- // actives defines a list of the pair which oracle prices agreed upon.
- Actives []github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,rep,name=actives,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"actives"`
-}
-
-func (m *QueryActivesResponse) Reset() { *m = QueryActivesResponse{} }
-func (m *QueryActivesResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryActivesResponse) ProtoMessage() {}
-func (*QueryActivesResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{5}
-}
-func (m *QueryActivesResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryActivesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryActivesResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryActivesResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryActivesResponse.Merge(m, src)
-}
-func (m *QueryActivesResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryActivesResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryActivesResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryActivesResponse proto.InternalMessageInfo
-
-// QueryVoteTargetsRequest is the request type for the Query/VoteTargets RPC
-// method.
-type QueryVoteTargetsRequest struct {
-}
-
-func (m *QueryVoteTargetsRequest) Reset() { *m = QueryVoteTargetsRequest{} }
-func (m *QueryVoteTargetsRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryVoteTargetsRequest) ProtoMessage() {}
-func (*QueryVoteTargetsRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{6}
-}
-func (m *QueryVoteTargetsRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryVoteTargetsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryVoteTargetsRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryVoteTargetsRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryVoteTargetsRequest.Merge(m, src)
-}
-func (m *QueryVoteTargetsRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryVoteTargetsRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryVoteTargetsRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryVoteTargetsRequest proto.InternalMessageInfo
-
-// QueryVoteTargetsResponse is response type for the
-// Query/VoteTargets RPC method.
-type QueryVoteTargetsResponse struct {
- // vote_targets defines a list of the pairs in which everyone
- // should vote in the current vote period.
- VoteTargets []github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,rep,name=vote_targets,json=voteTargets,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"vote_targets"`
-}
-
-func (m *QueryVoteTargetsResponse) Reset() { *m = QueryVoteTargetsResponse{} }
-func (m *QueryVoteTargetsResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryVoteTargetsResponse) ProtoMessage() {}
-func (*QueryVoteTargetsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{7}
-}
-func (m *QueryVoteTargetsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryVoteTargetsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryVoteTargetsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryVoteTargetsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryVoteTargetsResponse.Merge(m, src)
-}
-func (m *QueryVoteTargetsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryVoteTargetsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryVoteTargetsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryVoteTargetsResponse proto.InternalMessageInfo
-
-// QueryFeederDelegationRequest is the request type for the
-// Query/FeederDelegation RPC method.
-type QueryFeederDelegationRequest struct {
- // validator defines the validator address to query for.
- ValidatorAddr string `protobuf:"bytes,1,opt,name=validator_addr,json=validatorAddr,proto3" json:"validator_addr,omitempty"`
-}
-
-func (m *QueryFeederDelegationRequest) Reset() { *m = QueryFeederDelegationRequest{} }
-func (m *QueryFeederDelegationRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryFeederDelegationRequest) ProtoMessage() {}
-func (*QueryFeederDelegationRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{8}
-}
-func (m *QueryFeederDelegationRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryFeederDelegationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryFeederDelegationRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryFeederDelegationRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryFeederDelegationRequest.Merge(m, src)
-}
-func (m *QueryFeederDelegationRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryFeederDelegationRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryFeederDelegationRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryFeederDelegationRequest proto.InternalMessageInfo
-
-// QueryFeederDelegationResponse is response type for the
-// Query/FeederDelegation RPC method.
-type QueryFeederDelegationResponse struct {
- // feeder_addr defines the feeder delegation of a validator
- FeederAddr string `protobuf:"bytes,1,opt,name=feeder_addr,json=feederAddr,proto3" json:"feeder_addr,omitempty"`
-}
-
-func (m *QueryFeederDelegationResponse) Reset() { *m = QueryFeederDelegationResponse{} }
-func (m *QueryFeederDelegationResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryFeederDelegationResponse) ProtoMessage() {}
-func (*QueryFeederDelegationResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{9}
-}
-func (m *QueryFeederDelegationResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryFeederDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryFeederDelegationResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryFeederDelegationResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryFeederDelegationResponse.Merge(m, src)
-}
-func (m *QueryFeederDelegationResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryFeederDelegationResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryFeederDelegationResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryFeederDelegationResponse proto.InternalMessageInfo
-
-func (m *QueryFeederDelegationResponse) GetFeederAddr() string {
- if m != nil {
- return m.FeederAddr
- }
- return ""
-}
-
-// QueryMissCounterRequest is the request type for the Query/MissCounter RPC
-// method.
-type QueryMissCounterRequest struct {
- // validator defines the validator address to query for.
- ValidatorAddr string `protobuf:"bytes,1,opt,name=validator_addr,json=validatorAddr,proto3" json:"validator_addr,omitempty"`
-}
-
-func (m *QueryMissCounterRequest) Reset() { *m = QueryMissCounterRequest{} }
-func (m *QueryMissCounterRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryMissCounterRequest) ProtoMessage() {}
-func (*QueryMissCounterRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{10}
-}
-func (m *QueryMissCounterRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryMissCounterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryMissCounterRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryMissCounterRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryMissCounterRequest.Merge(m, src)
-}
-func (m *QueryMissCounterRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryMissCounterRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryMissCounterRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryMissCounterRequest proto.InternalMessageInfo
-
-// QueryMissCounterResponse is response type for the
-// Query/MissCounter RPC method.
-type QueryMissCounterResponse struct {
- // miss_counter defines the oracle miss counter of a validator
- MissCounter uint64 `protobuf:"varint,1,opt,name=miss_counter,json=missCounter,proto3" json:"miss_counter,omitempty"`
-}
-
-func (m *QueryMissCounterResponse) Reset() { *m = QueryMissCounterResponse{} }
-func (m *QueryMissCounterResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryMissCounterResponse) ProtoMessage() {}
-func (*QueryMissCounterResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{11}
-}
-func (m *QueryMissCounterResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryMissCounterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryMissCounterResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryMissCounterResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryMissCounterResponse.Merge(m, src)
-}
-func (m *QueryMissCounterResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryMissCounterResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryMissCounterResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryMissCounterResponse proto.InternalMessageInfo
-
-func (m *QueryMissCounterResponse) GetMissCounter() uint64 {
- if m != nil {
- return m.MissCounter
- }
- return 0
-}
-
-// QueryAggregatePrevoteRequest is the request type for the
-// Query/AggregatePrevote RPC method.
-type QueryAggregatePrevoteRequest struct {
- // validator defines the validator address to query for.
- ValidatorAddr string `protobuf:"bytes,1,opt,name=validator_addr,json=validatorAddr,proto3" json:"validator_addr,omitempty"`
-}
-
-func (m *QueryAggregatePrevoteRequest) Reset() { *m = QueryAggregatePrevoteRequest{} }
-func (m *QueryAggregatePrevoteRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryAggregatePrevoteRequest) ProtoMessage() {}
-func (*QueryAggregatePrevoteRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{12}
-}
-func (m *QueryAggregatePrevoteRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryAggregatePrevoteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryAggregatePrevoteRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryAggregatePrevoteRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryAggregatePrevoteRequest.Merge(m, src)
-}
-func (m *QueryAggregatePrevoteRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryAggregatePrevoteRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryAggregatePrevoteRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryAggregatePrevoteRequest proto.InternalMessageInfo
-
-// QueryAggregatePrevoteResponse is response type for the
-// Query/AggregatePrevote RPC method.
-type QueryAggregatePrevoteResponse struct {
- // aggregate_prevote defines oracle aggregate prevote submitted by a validator
- // in the current vote period
- AggregatePrevote AggregateExchangeRatePrevote `protobuf:"bytes,1,opt,name=aggregate_prevote,json=aggregatePrevote,proto3" json:"aggregate_prevote"`
-}
-
-func (m *QueryAggregatePrevoteResponse) Reset() { *m = QueryAggregatePrevoteResponse{} }
-func (m *QueryAggregatePrevoteResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryAggregatePrevoteResponse) ProtoMessage() {}
-func (*QueryAggregatePrevoteResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{13}
-}
-func (m *QueryAggregatePrevoteResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryAggregatePrevoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryAggregatePrevoteResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryAggregatePrevoteResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryAggregatePrevoteResponse.Merge(m, src)
-}
-func (m *QueryAggregatePrevoteResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryAggregatePrevoteResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryAggregatePrevoteResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryAggregatePrevoteResponse proto.InternalMessageInfo
-
-func (m *QueryAggregatePrevoteResponse) GetAggregatePrevote() AggregateExchangeRatePrevote {
- if m != nil {
- return m.AggregatePrevote
- }
- return AggregateExchangeRatePrevote{}
-}
-
-// QueryAggregatePrevotesRequest is the request type for the
-// Query/AggregatePrevotes RPC method.
-type QueryAggregatePrevotesRequest struct {
-}
-
-func (m *QueryAggregatePrevotesRequest) Reset() { *m = QueryAggregatePrevotesRequest{} }
-func (m *QueryAggregatePrevotesRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryAggregatePrevotesRequest) ProtoMessage() {}
-func (*QueryAggregatePrevotesRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{14}
-}
-func (m *QueryAggregatePrevotesRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryAggregatePrevotesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryAggregatePrevotesRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryAggregatePrevotesRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryAggregatePrevotesRequest.Merge(m, src)
-}
-func (m *QueryAggregatePrevotesRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryAggregatePrevotesRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryAggregatePrevotesRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryAggregatePrevotesRequest proto.InternalMessageInfo
-
-// QueryAggregatePrevotesResponse is response type for the
-// Query/AggregatePrevotes RPC method.
-type QueryAggregatePrevotesResponse struct {
- // aggregate_prevotes defines all oracle aggregate prevotes submitted in the
- // current vote period
- AggregatePrevotes []AggregateExchangeRatePrevote `protobuf:"bytes,1,rep,name=aggregate_prevotes,json=aggregatePrevotes,proto3" json:"aggregate_prevotes"`
-}
-
-func (m *QueryAggregatePrevotesResponse) Reset() { *m = QueryAggregatePrevotesResponse{} }
-func (m *QueryAggregatePrevotesResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryAggregatePrevotesResponse) ProtoMessage() {}
-func (*QueryAggregatePrevotesResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{15}
-}
-func (m *QueryAggregatePrevotesResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryAggregatePrevotesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryAggregatePrevotesResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryAggregatePrevotesResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryAggregatePrevotesResponse.Merge(m, src)
-}
-func (m *QueryAggregatePrevotesResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryAggregatePrevotesResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryAggregatePrevotesResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryAggregatePrevotesResponse proto.InternalMessageInfo
-
-func (m *QueryAggregatePrevotesResponse) GetAggregatePrevotes() []AggregateExchangeRatePrevote {
- if m != nil {
- return m.AggregatePrevotes
- }
- return nil
-}
-
-// QueryAggregateVoteRequest is the request type for the Query/AggregateVote RPC
-// method.
-type QueryAggregateVoteRequest struct {
- // validator defines the validator address to query for.
- ValidatorAddr string `protobuf:"bytes,1,opt,name=validator_addr,json=validatorAddr,proto3" json:"validator_addr,omitempty"`
-}
-
-func (m *QueryAggregateVoteRequest) Reset() { *m = QueryAggregateVoteRequest{} }
-func (m *QueryAggregateVoteRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryAggregateVoteRequest) ProtoMessage() {}
-func (*QueryAggregateVoteRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{16}
-}
-func (m *QueryAggregateVoteRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryAggregateVoteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryAggregateVoteRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryAggregateVoteRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryAggregateVoteRequest.Merge(m, src)
-}
-func (m *QueryAggregateVoteRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryAggregateVoteRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryAggregateVoteRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryAggregateVoteRequest proto.InternalMessageInfo
-
-// QueryAggregateVoteResponse is response type for the
-// Query/AggregateVote RPC method.
-type QueryAggregateVoteResponse struct {
- // aggregate_vote defines oracle aggregate vote submitted by a validator in
- // the current vote period
- AggregateVote AggregateExchangeRateVote `protobuf:"bytes,1,opt,name=aggregate_vote,json=aggregateVote,proto3" json:"aggregate_vote"`
-}
-
-func (m *QueryAggregateVoteResponse) Reset() { *m = QueryAggregateVoteResponse{} }
-func (m *QueryAggregateVoteResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryAggregateVoteResponse) ProtoMessage() {}
-func (*QueryAggregateVoteResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{17}
-}
-func (m *QueryAggregateVoteResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryAggregateVoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryAggregateVoteResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryAggregateVoteResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryAggregateVoteResponse.Merge(m, src)
-}
-func (m *QueryAggregateVoteResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryAggregateVoteResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryAggregateVoteResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryAggregateVoteResponse proto.InternalMessageInfo
-
-func (m *QueryAggregateVoteResponse) GetAggregateVote() AggregateExchangeRateVote {
- if m != nil {
- return m.AggregateVote
- }
- return AggregateExchangeRateVote{}
-}
-
-// QueryAggregateVotesRequest is the request type for the Query/AggregateVotes
-// RPC method.
-type QueryAggregateVotesRequest struct {
-}
-
-func (m *QueryAggregateVotesRequest) Reset() { *m = QueryAggregateVotesRequest{} }
-func (m *QueryAggregateVotesRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryAggregateVotesRequest) ProtoMessage() {}
-func (*QueryAggregateVotesRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{18}
-}
-func (m *QueryAggregateVotesRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryAggregateVotesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryAggregateVotesRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryAggregateVotesRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryAggregateVotesRequest.Merge(m, src)
-}
-func (m *QueryAggregateVotesRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryAggregateVotesRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryAggregateVotesRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryAggregateVotesRequest proto.InternalMessageInfo
-
-// QueryAggregateVotesResponse is response type for the
-// Query/AggregateVotes RPC method.
-type QueryAggregateVotesResponse struct {
- // aggregate_votes defines all oracle aggregate votes submitted in the current
- // vote period
- AggregateVotes []AggregateExchangeRateVote `protobuf:"bytes,1,rep,name=aggregate_votes,json=aggregateVotes,proto3" json:"aggregate_votes"`
-}
-
-func (m *QueryAggregateVotesResponse) Reset() { *m = QueryAggregateVotesResponse{} }
-func (m *QueryAggregateVotesResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryAggregateVotesResponse) ProtoMessage() {}
-func (*QueryAggregateVotesResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{19}
-}
-func (m *QueryAggregateVotesResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryAggregateVotesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryAggregateVotesResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryAggregateVotesResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryAggregateVotesResponse.Merge(m, src)
-}
-func (m *QueryAggregateVotesResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryAggregateVotesResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryAggregateVotesResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryAggregateVotesResponse proto.InternalMessageInfo
-
-func (m *QueryAggregateVotesResponse) GetAggregateVotes() []AggregateExchangeRateVote {
- if m != nil {
- return m.AggregateVotes
- }
- return nil
-}
-
-// QueryParamsRequest is the request type for the Query/Params RPC method.
-type QueryParamsRequest struct {
-}
-
-func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} }
-func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryParamsRequest) ProtoMessage() {}
-func (*QueryParamsRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{20}
-}
-func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryParamsRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryParamsRequest.Merge(m, src)
-}
-func (m *QueryParamsRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryParamsRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo
-
-// QueryParamsResponse is the response type for the Query/Params RPC method.
-type QueryParamsResponse struct {
- // params defines the parameters of the module.
- Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
-}
-
-func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} }
-func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryParamsResponse) ProtoMessage() {}
-func (*QueryParamsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_16aef2382d1249a8, []int{21}
-}
-func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryParamsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryParamsResponse.Merge(m, src)
-}
-func (m *QueryParamsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryParamsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo
-
-func (m *QueryParamsResponse) GetParams() Params {
- if m != nil {
- return m.Params
- }
- return Params{}
-}
-
-func init() {
- proto.RegisterType((*QueryExchangeRateRequest)(nil), "nibiru.oracle.v1.QueryExchangeRateRequest")
- proto.RegisterType((*QueryExchangeRateResponse)(nil), "nibiru.oracle.v1.QueryExchangeRateResponse")
- proto.RegisterType((*QueryExchangeRatesRequest)(nil), "nibiru.oracle.v1.QueryExchangeRatesRequest")
- proto.RegisterType((*QueryExchangeRatesResponse)(nil), "nibiru.oracle.v1.QueryExchangeRatesResponse")
- proto.RegisterType((*QueryActivesRequest)(nil), "nibiru.oracle.v1.QueryActivesRequest")
- proto.RegisterType((*QueryActivesResponse)(nil), "nibiru.oracle.v1.QueryActivesResponse")
- proto.RegisterType((*QueryVoteTargetsRequest)(nil), "nibiru.oracle.v1.QueryVoteTargetsRequest")
- proto.RegisterType((*QueryVoteTargetsResponse)(nil), "nibiru.oracle.v1.QueryVoteTargetsResponse")
- proto.RegisterType((*QueryFeederDelegationRequest)(nil), "nibiru.oracle.v1.QueryFeederDelegationRequest")
- proto.RegisterType((*QueryFeederDelegationResponse)(nil), "nibiru.oracle.v1.QueryFeederDelegationResponse")
- proto.RegisterType((*QueryMissCounterRequest)(nil), "nibiru.oracle.v1.QueryMissCounterRequest")
- proto.RegisterType((*QueryMissCounterResponse)(nil), "nibiru.oracle.v1.QueryMissCounterResponse")
- proto.RegisterType((*QueryAggregatePrevoteRequest)(nil), "nibiru.oracle.v1.QueryAggregatePrevoteRequest")
- proto.RegisterType((*QueryAggregatePrevoteResponse)(nil), "nibiru.oracle.v1.QueryAggregatePrevoteResponse")
- proto.RegisterType((*QueryAggregatePrevotesRequest)(nil), "nibiru.oracle.v1.QueryAggregatePrevotesRequest")
- proto.RegisterType((*QueryAggregatePrevotesResponse)(nil), "nibiru.oracle.v1.QueryAggregatePrevotesResponse")
- proto.RegisterType((*QueryAggregateVoteRequest)(nil), "nibiru.oracle.v1.QueryAggregateVoteRequest")
- proto.RegisterType((*QueryAggregateVoteResponse)(nil), "nibiru.oracle.v1.QueryAggregateVoteResponse")
- proto.RegisterType((*QueryAggregateVotesRequest)(nil), "nibiru.oracle.v1.QueryAggregateVotesRequest")
- proto.RegisterType((*QueryAggregateVotesResponse)(nil), "nibiru.oracle.v1.QueryAggregateVotesResponse")
- proto.RegisterType((*QueryParamsRequest)(nil), "nibiru.oracle.v1.QueryParamsRequest")
- proto.RegisterType((*QueryParamsResponse)(nil), "nibiru.oracle.v1.QueryParamsResponse")
-}
-
-func init() { proto.RegisterFile("nibiru/oracle/v1/query.proto", fileDescriptor_16aef2382d1249a8) }
-
-var fileDescriptor_16aef2382d1249a8 = []byte{
- // 1105 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x97, 0xcf, 0x6f, 0x1b, 0x45,
- 0x14, 0xc7, 0x3d, 0x50, 0x52, 0x18, 0xc7, 0xae, 0x33, 0x04, 0x91, 0x6e, 0x13, 0xbb, 0x2c, 0x4d,
- 0xd4, 0x36, 0xc9, 0x2e, 0x4e, 0x50, 0x51, 0xf8, 0x21, 0x70, 0x12, 0x22, 0x81, 0x1a, 0x08, 0xa6,
- 0x8a, 0x50, 0x85, 0x64, 0x8d, 0xd7, 0xd3, 0xcd, 0xaa, 0xf6, 0xce, 0x76, 0x67, 0x6d, 0x12, 0x01,
- 0x97, 0x0a, 0x10, 0x47, 0x24, 0x84, 0xb8, 0x41, 0x2f, 0x48, 0x88, 0x33, 0x70, 0x87, 0x53, 0x8f,
- 0x95, 0xb8, 0x20, 0x0e, 0x05, 0x25, 0x1c, 0xf8, 0x33, 0xd0, 0xce, 0x8c, 0xd7, 0xbb, 0x5e, 0x8f,
- 0xbc, 0x38, 0xe2, 0x94, 0x68, 0xde, 0xdb, 0xf7, 0xfd, 0xbc, 0x37, 0xb3, 0xf3, 0xf5, 0xc2, 0x79,
- 0xd7, 0x69, 0x3a, 0x7e, 0xd7, 0xa4, 0x3e, 0xb6, 0xda, 0xc4, 0xec, 0x55, 0xcd, 0x3b, 0x5d, 0xe2,
- 0x1f, 0x19, 0x9e, 0x4f, 0x03, 0x8a, 0x4a, 0x22, 0x6a, 0x88, 0xa8, 0xd1, 0xab, 0x6a, 0xb3, 0x36,
- 0xb5, 0x29, 0x0f, 0x9a, 0xe1, 0x7f, 0x22, 0x4f, 0x9b, 0xb7, 0x29, 0xb5, 0xdb, 0xc4, 0xc4, 0x9e,
- 0x63, 0x62, 0xd7, 0xa5, 0x01, 0x0e, 0x1c, 0xea, 0x32, 0x19, 0x5d, 0x48, 0x69, 0xc8, 0x7a, 0x22,
- 0x5c, 0xb6, 0x28, 0xeb, 0x50, 0x66, 0x36, 0x31, 0x0b, 0x83, 0x4d, 0x12, 0xe0, 0xaa, 0x69, 0x51,
- 0xc7, 0x15, 0x71, 0x9d, 0xc1, 0xb9, 0x77, 0x42, 0xa6, 0xd7, 0x0f, 0xad, 0x03, 0xec, 0xda, 0xa4,
- 0x8e, 0x03, 0x52, 0x27, 0x77, 0xba, 0x84, 0x05, 0x68, 0x17, 0x9e, 0xf1, 0xb0, 0xe3, 0xcf, 0x81,
- 0x8b, 0xe0, 0xf2, 0x13, 0x9b, 0x1b, 0xf7, 0x1f, 0x56, 0x72, 0x7f, 0x3c, 0xac, 0x54, 0x6d, 0x27,
- 0x38, 0xe8, 0x36, 0x0d, 0x8b, 0x76, 0xcc, 0xb7, 0xb8, 0xf6, 0xd6, 0x01, 0x76, 0x5c, 0x53, 0x72,
- 0x1c, 0x9a, 0x16, 0xed, 0x74, 0xa8, 0x6b, 0x62, 0xc6, 0x48, 0x60, 0xec, 0x61, 0xc7, 0xaf, 0xf3,
- 0x32, 0x2f, 0x3e, 0xfe, 0xf9, 0xbd, 0x4a, 0xee, 0x9f, 0x7b, 0x95, 0x9c, 0xee, 0xc1, 0xf3, 0x23,
- 0x44, 0x99, 0x47, 0x5d, 0x46, 0xd0, 0xbb, 0xb0, 0x40, 0xe4, 0x7a, 0xc3, 0xc7, 0x01, 0x91, 0xf2,
- 0x86, 0x94, 0x5f, 0x8a, 0xc9, 0xcb, 0xde, 0xc4, 0x9f, 0x55, 0xd6, 0xba, 0x6d, 0x06, 0x47, 0x1e,
- 0x61, 0xc6, 0x36, 0xb1, 0xea, 0xd3, 0x24, 0x56, 0x5c, 0xbf, 0x30, 0x42, 0x91, 0xc9, 0x3e, 0xf5,
- 0x4f, 0x00, 0xd4, 0x46, 0x45, 0x25, 0xd0, 0x2d, 0x58, 0x4c, 0x00, 0xb1, 0x39, 0x70, 0xf1, 0xd1,
- 0xcb, 0xf9, 0xb5, 0x67, 0x8d, 0xe1, 0x0d, 0x34, 0xe2, 0x05, 0x6e, 0x74, 0xbd, 0x36, 0xd9, 0xd4,
- 0x42, 0xec, 0x1f, 0xfe, 0xac, 0xa0, 0x54, 0x88, 0xd5, 0x0b, 0x71, 0x44, 0xa6, 0x3f, 0x05, 0x9f,
- 0xe4, 0x14, 0x35, 0x2b, 0x70, 0x7a, 0x03, 0xba, 0xdb, 0x70, 0x36, 0xb9, 0x1c, 0xcd, 0xe9, 0x2c,
- 0x16, 0x4b, 0x9c, 0xe7, 0x54, 0x1b, 0xd4, 0xaf, 0xa4, 0x9f, 0x87, 0x4f, 0x73, 0xb1, 0x7d, 0x1a,
- 0x90, 0x1b, 0xd8, 0xb7, 0x49, 0x10, 0x71, 0x1c, 0xca, 0x93, 0x92, 0x08, 0x49, 0x96, 0xf7, 0xe1,
- 0x74, 0x8f, 0x06, 0xa4, 0x11, 0x88, 0xf5, 0xd3, 0x03, 0xe5, 0x7b, 0x03, 0x15, 0xfd, 0x6d, 0x38,
- 0xcf, 0x95, 0x77, 0x08, 0x69, 0x11, 0x7f, 0x9b, 0xb4, 0x89, 0xcd, 0x5f, 0x81, 0xfe, 0x39, 0x5d,
- 0x84, 0xc5, 0x1e, 0x6e, 0x3b, 0x2d, 0x1c, 0x50, 0xbf, 0x81, 0x5b, 0x2d, 0x79, 0x62, 0xeb, 0x85,
- 0x68, 0xb5, 0xd6, 0x6a, 0xc5, 0xcf, 0xdf, 0x6b, 0x70, 0x41, 0x51, 0x50, 0xf6, 0x53, 0x81, 0xf9,
- 0x5b, 0x3c, 0x16, 0x2f, 0x07, 0xc5, 0x52, 0x58, 0x4b, 0x7f, 0x53, 0xce, 0x69, 0xd7, 0x61, 0x6c,
- 0x8b, 0x76, 0xdd, 0x80, 0xf8, 0x13, 0xd3, 0xbc, 0x22, 0x07, 0x9b, 0xa8, 0x25, 0x41, 0x9e, 0x81,
- 0xd3, 0x1d, 0x87, 0xb1, 0x86, 0x25, 0xd6, 0x79, 0xa9, 0x33, 0xf5, 0x7c, 0x67, 0x90, 0x1a, 0x4d,
- 0xa7, 0x66, 0xdb, 0x7e, 0xd8, 0x07, 0xd9, 0xf3, 0x49, 0x38, 0xbd, 0x89, 0x79, 0xee, 0x02, 0x39,
- 0x9e, 0x74, 0x45, 0x49, 0x85, 0xe1, 0x0c, 0xee, 0xc7, 0x1a, 0x9e, 0x08, 0xf2, 0xaa, 0xf9, 0x35,
- 0x23, 0xfd, 0x52, 0x44, 0x65, 0xe2, 0xaf, 0x80, 0x2c, 0xb9, 0x79, 0x26, 0x3c, 0x23, 0xf5, 0x12,
- 0x1e, 0x92, 0xd2, 0x2b, 0x0a, 0x86, 0xe8, 0x38, 0x7e, 0x0a, 0x60, 0x59, 0x95, 0x21, 0x31, 0x2d,
- 0x88, 0x52, 0x98, 0xfd, 0x97, 0x77, 0x32, 0xce, 0x99, 0x61, 0x4e, 0xa6, 0x5f, 0x97, 0x37, 0x4b,
- 0xf4, 0xf4, 0xfe, 0x69, 0x66, 0xdf, 0x93, 0x37, 0xd1, 0x50, 0x35, 0xd9, 0xd0, 0x7b, 0xb0, 0x38,
- 0x68, 0x28, 0x36, 0xf4, 0xe5, 0x8c, 0xcd, 0xec, 0x0f, 0x3a, 0x29, 0xe0, 0xb8, 0x82, 0x3e, 0x3f,
- 0x4a, 0x37, 0x9a, 0xf5, 0x11, 0xbc, 0x30, 0x32, 0x2a, 0xb1, 0x6e, 0xc2, 0x73, 0x49, 0xac, 0xfe,
- 0x90, 0x27, 0xe0, 0x2a, 0x26, 0xb8, 0x98, 0x3e, 0x0b, 0x11, 0x97, 0xde, 0xc3, 0x3e, 0xee, 0x44,
- 0x40, 0xbb, 0xf2, 0xaa, 0xec, 0xaf, 0x4a, 0x90, 0x6b, 0x70, 0xca, 0xe3, 0x2b, 0x72, 0x2e, 0x73,
- 0x69, 0x7d, 0xf1, 0x84, 0x14, 0x93, 0xd9, 0x6b, 0xbf, 0x9e, 0x83, 0x8f, 0xf1, 0x7a, 0xe8, 0x2b,
- 0x00, 0xa7, 0xe3, 0x64, 0xe8, 0x6a, 0xba, 0x84, 0xca, 0x2f, 0xb5, 0xe5, 0x4c, 0xb9, 0x82, 0x55,
- 0x5f, 0xb9, 0xfb, 0xdb, 0xdf, 0x5f, 0x3e, 0xb2, 0x84, 0x2e, 0x99, 0xc3, 0x06, 0x2e, 0x3c, 0x3a,
- 0x61, 0x39, 0xe8, 0x1b, 0x00, 0x4b, 0x09, 0x07, 0xf9, 0x00, 0x7b, 0xff, 0x1f, 0x5b, 0x95, 0xb3,
- 0x2d, 0xa3, 0x2b, 0x59, 0xd8, 0x1a, 0x41, 0xc8, 0xf2, 0x2d, 0x80, 0x85, 0x84, 0x7d, 0xa2, 0x2c,
- 0x8a, 0xfd, 0x0d, 0xd5, 0x56, 0xb2, 0x25, 0x4b, 0xbe, 0x75, 0xce, 0xb7, 0x8a, 0x96, 0x15, 0x7c,
- 0xe1, 0xcf, 0x0d, 0x96, 0xa4, 0x64, 0xe8, 0x33, 0x00, 0xcf, 0x4a, 0x0f, 0x45, 0x8b, 0x0a, 0xb9,
- 0xa4, 0xf5, 0x6a, 0x4b, 0xe3, 0xd2, 0x32, 0xee, 0xa5, 0xe0, 0x91, 0x1e, 0x8b, 0xbe, 0x06, 0x30,
- 0x1f, 0x33, 0x51, 0x74, 0x45, 0xa1, 0x92, 0xf6, 0x60, 0xed, 0x6a, 0x96, 0xd4, 0x8c, 0x9b, 0x28,
- 0xa0, 0xe2, 0xb6, 0x8d, 0x7e, 0x06, 0xb0, 0x34, 0xec, 0x89, 0xc8, 0x50, 0x68, 0x2a, 0xdc, 0x58,
- 0x33, 0x33, 0xe7, 0x4b, 0xd0, 0x1a, 0x07, 0x7d, 0x09, 0x6d, 0x28, 0x40, 0xa3, 0xbb, 0x92, 0x99,
- 0x1f, 0x26, 0x6f, 0xd3, 0x8f, 0x4d, 0x61, 0xc9, 0xe8, 0x3b, 0x00, 0xf3, 0x31, 0xfb, 0x54, 0x8e,
- 0x34, 0x6d, 0xd7, 0xca, 0x91, 0x8e, 0x70, 0x63, 0xfd, 0x55, 0x4e, 0xba, 0x81, 0x5e, 0x98, 0x80,
- 0x34, 0xb4, 0x6c, 0xf4, 0x0b, 0x80, 0xa5, 0x61, 0xbf, 0x52, 0x0e, 0x58, 0x61, 0xe8, 0xca, 0x01,
- 0xab, 0xec, 0x5a, 0xbf, 0xce, 0xb1, 0x77, 0xd0, 0xf6, 0x04, 0xd8, 0x29, 0x03, 0x45, 0x3f, 0x02,
- 0x38, 0x93, 0xf2, 0x5c, 0x94, 0x15, 0x2a, 0x3a, 0xca, 0xcf, 0x65, 0x7f, 0x40, 0xb6, 0xf1, 0x32,
- 0x6f, 0xe3, 0x1a, 0x7a, 0x7e, 0x7c, 0x1b, 0x69, 0xdb, 0x47, 0x3f, 0x01, 0x58, 0x48, 0xf8, 0x97,
- 0xf2, 0x82, 0x1a, 0xe5, 0xe4, 0xca, 0x0b, 0x6a, 0xa4, 0x51, 0xeb, 0x6f, 0x70, 0xd4, 0x2d, 0x54,
- 0x53, 0xa3, 0xb6, 0x9c, 0xb1, 0x13, 0xe7, 0xe3, 0xfe, 0x1e, 0xc0, 0x62, 0xd2, 0x77, 0x51, 0x26,
- 0x96, 0x68, 0xd0, 0xab, 0x19, 0xb3, 0x25, 0xfa, 0x06, 0x47, 0x5f, 0x47, 0xd5, 0xff, 0x32, 0x65,
- 0x31, 0xe2, 0x8f, 0xe0, 0x94, 0xb0, 0x57, 0x74, 0x49, 0xa1, 0x99, 0x70, 0x71, 0x6d, 0x71, 0x4c,
- 0x96, 0x24, 0x5a, 0xe4, 0x44, 0x15, 0xb4, 0xa0, 0xbc, 0xc8, 0xb8, 0xa5, 0xef, 0xdc, 0x3f, 0x2e,
- 0x83, 0x07, 0xc7, 0x65, 0xf0, 0xd7, 0x71, 0x19, 0x7c, 0x71, 0x52, 0xce, 0x3d, 0x38, 0x29, 0xe7,
- 0x7e, 0x3f, 0x29, 0xe7, 0x6e, 0xae, 0x8c, 0xfb, 0xfe, 0x90, 0x05, 0xf9, 0xc7, 0x63, 0x73, 0x8a,
- 0x7f, 0x18, 0xaf, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x10, 0x7a, 0x57, 0xeb, 0xbd, 0x0f, 0x00,
- 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// QueryClient is the client API for Query service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type QueryClient interface {
- // ExchangeRate returns exchange rate of a pair
- ExchangeRate(ctx context.Context, in *QueryExchangeRateRequest, opts ...grpc.CallOption) (*QueryExchangeRateResponse, error)
- // ExchangeRateTwap returns twap exchange rate of a pair
- ExchangeRateTwap(ctx context.Context, in *QueryExchangeRateRequest, opts ...grpc.CallOption) (*QueryExchangeRateResponse, error)
- // ExchangeRates returns exchange rates of all pairs
- ExchangeRates(ctx context.Context, in *QueryExchangeRatesRequest, opts ...grpc.CallOption) (*QueryExchangeRatesResponse, error)
- // Actives returns all active pairs
- Actives(ctx context.Context, in *QueryActivesRequest, opts ...grpc.CallOption) (*QueryActivesResponse, error)
- // VoteTargets returns all vote target for pairs
- VoteTargets(ctx context.Context, in *QueryVoteTargetsRequest, opts ...grpc.CallOption) (*QueryVoteTargetsResponse, error)
- // FeederDelegation returns feeder delegation of a validator
- FeederDelegation(ctx context.Context, in *QueryFeederDelegationRequest, opts ...grpc.CallOption) (*QueryFeederDelegationResponse, error)
- // MissCounter returns oracle miss counter of a validator
- MissCounter(ctx context.Context, in *QueryMissCounterRequest, opts ...grpc.CallOption) (*QueryMissCounterResponse, error)
- // AggregatePrevote returns an aggregate prevote of a validator
- AggregatePrevote(ctx context.Context, in *QueryAggregatePrevoteRequest, opts ...grpc.CallOption) (*QueryAggregatePrevoteResponse, error)
- // AggregatePrevotes returns aggregate prevotes of all validators
- AggregatePrevotes(ctx context.Context, in *QueryAggregatePrevotesRequest, opts ...grpc.CallOption) (*QueryAggregatePrevotesResponse, error)
- // AggregateVote returns an aggregate vote of a validator
- AggregateVote(ctx context.Context, in *QueryAggregateVoteRequest, opts ...grpc.CallOption) (*QueryAggregateVoteResponse, error)
- // AggregateVotes returns aggregate votes of all validators
- AggregateVotes(ctx context.Context, in *QueryAggregateVotesRequest, opts ...grpc.CallOption) (*QueryAggregateVotesResponse, error)
- // Params queries all parameters.
- Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
-}
-
-type queryClient struct {
- cc grpc1.ClientConn
-}
-
-func NewQueryClient(cc grpc1.ClientConn) QueryClient {
- return &queryClient{cc}
-}
-
-func (c *queryClient) ExchangeRate(ctx context.Context, in *QueryExchangeRateRequest, opts ...grpc.CallOption) (*QueryExchangeRateResponse, error) {
- out := new(QueryExchangeRateResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/ExchangeRate", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) ExchangeRateTwap(ctx context.Context, in *QueryExchangeRateRequest, opts ...grpc.CallOption) (*QueryExchangeRateResponse, error) {
- out := new(QueryExchangeRateResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/ExchangeRateTwap", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) ExchangeRates(ctx context.Context, in *QueryExchangeRatesRequest, opts ...grpc.CallOption) (*QueryExchangeRatesResponse, error) {
- out := new(QueryExchangeRatesResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/ExchangeRates", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) Actives(ctx context.Context, in *QueryActivesRequest, opts ...grpc.CallOption) (*QueryActivesResponse, error) {
- out := new(QueryActivesResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/Actives", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) VoteTargets(ctx context.Context, in *QueryVoteTargetsRequest, opts ...grpc.CallOption) (*QueryVoteTargetsResponse, error) {
- out := new(QueryVoteTargetsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/VoteTargets", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) FeederDelegation(ctx context.Context, in *QueryFeederDelegationRequest, opts ...grpc.CallOption) (*QueryFeederDelegationResponse, error) {
- out := new(QueryFeederDelegationResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/FeederDelegation", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) MissCounter(ctx context.Context, in *QueryMissCounterRequest, opts ...grpc.CallOption) (*QueryMissCounterResponse, error) {
- out := new(QueryMissCounterResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/MissCounter", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) AggregatePrevote(ctx context.Context, in *QueryAggregatePrevoteRequest, opts ...grpc.CallOption) (*QueryAggregatePrevoteResponse, error) {
- out := new(QueryAggregatePrevoteResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/AggregatePrevote", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) AggregatePrevotes(ctx context.Context, in *QueryAggregatePrevotesRequest, opts ...grpc.CallOption) (*QueryAggregatePrevotesResponse, error) {
- out := new(QueryAggregatePrevotesResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/AggregatePrevotes", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) AggregateVote(ctx context.Context, in *QueryAggregateVoteRequest, opts ...grpc.CallOption) (*QueryAggregateVoteResponse, error) {
- out := new(QueryAggregateVoteResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/AggregateVote", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) AggregateVotes(ctx context.Context, in *QueryAggregateVotesRequest, opts ...grpc.CallOption) (*QueryAggregateVotesResponse, error) {
- out := new(QueryAggregateVotesResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/AggregateVotes", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) {
- out := new(QueryParamsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Query/Params", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// QueryServer is the server API for Query service.
-type QueryServer interface {
- // ExchangeRate returns exchange rate of a pair
- ExchangeRate(context.Context, *QueryExchangeRateRequest) (*QueryExchangeRateResponse, error)
- // ExchangeRateTwap returns twap exchange rate of a pair
- ExchangeRateTwap(context.Context, *QueryExchangeRateRequest) (*QueryExchangeRateResponse, error)
- // ExchangeRates returns exchange rates of all pairs
- ExchangeRates(context.Context, *QueryExchangeRatesRequest) (*QueryExchangeRatesResponse, error)
- // Actives returns all active pairs
- Actives(context.Context, *QueryActivesRequest) (*QueryActivesResponse, error)
- // VoteTargets returns all vote target for pairs
- VoteTargets(context.Context, *QueryVoteTargetsRequest) (*QueryVoteTargetsResponse, error)
- // FeederDelegation returns feeder delegation of a validator
- FeederDelegation(context.Context, *QueryFeederDelegationRequest) (*QueryFeederDelegationResponse, error)
- // MissCounter returns oracle miss counter of a validator
- MissCounter(context.Context, *QueryMissCounterRequest) (*QueryMissCounterResponse, error)
- // AggregatePrevote returns an aggregate prevote of a validator
- AggregatePrevote(context.Context, *QueryAggregatePrevoteRequest) (*QueryAggregatePrevoteResponse, error)
- // AggregatePrevotes returns aggregate prevotes of all validators
- AggregatePrevotes(context.Context, *QueryAggregatePrevotesRequest) (*QueryAggregatePrevotesResponse, error)
- // AggregateVote returns an aggregate vote of a validator
- AggregateVote(context.Context, *QueryAggregateVoteRequest) (*QueryAggregateVoteResponse, error)
- // AggregateVotes returns aggregate votes of all validators
- AggregateVotes(context.Context, *QueryAggregateVotesRequest) (*QueryAggregateVotesResponse, error)
- // Params queries all parameters.
- Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
-}
-
-// UnimplementedQueryServer can be embedded to have forward compatible implementations.
-type UnimplementedQueryServer struct {
-}
-
-func (*UnimplementedQueryServer) ExchangeRate(ctx context.Context, req *QueryExchangeRateRequest) (*QueryExchangeRateResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ExchangeRate not implemented")
-}
-func (*UnimplementedQueryServer) ExchangeRateTwap(ctx context.Context, req *QueryExchangeRateRequest) (*QueryExchangeRateResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ExchangeRateTwap not implemented")
-}
-func (*UnimplementedQueryServer) ExchangeRates(ctx context.Context, req *QueryExchangeRatesRequest) (*QueryExchangeRatesResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ExchangeRates not implemented")
-}
-func (*UnimplementedQueryServer) Actives(ctx context.Context, req *QueryActivesRequest) (*QueryActivesResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Actives not implemented")
-}
-func (*UnimplementedQueryServer) VoteTargets(ctx context.Context, req *QueryVoteTargetsRequest) (*QueryVoteTargetsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method VoteTargets not implemented")
-}
-func (*UnimplementedQueryServer) FeederDelegation(ctx context.Context, req *QueryFeederDelegationRequest) (*QueryFeederDelegationResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method FeederDelegation not implemented")
-}
-func (*UnimplementedQueryServer) MissCounter(ctx context.Context, req *QueryMissCounterRequest) (*QueryMissCounterResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method MissCounter not implemented")
-}
-func (*UnimplementedQueryServer) AggregatePrevote(ctx context.Context, req *QueryAggregatePrevoteRequest) (*QueryAggregatePrevoteResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method AggregatePrevote not implemented")
-}
-func (*UnimplementedQueryServer) AggregatePrevotes(ctx context.Context, req *QueryAggregatePrevotesRequest) (*QueryAggregatePrevotesResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method AggregatePrevotes not implemented")
-}
-func (*UnimplementedQueryServer) AggregateVote(ctx context.Context, req *QueryAggregateVoteRequest) (*QueryAggregateVoteResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method AggregateVote not implemented")
-}
-func (*UnimplementedQueryServer) AggregateVotes(ctx context.Context, req *QueryAggregateVotesRequest) (*QueryAggregateVotesResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method AggregateVotes not implemented")
-}
-func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
-}
-
-func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
- s.RegisterService(&_Query_serviceDesc, srv)
-}
-
-func _Query_ExchangeRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryExchangeRateRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).ExchangeRate(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/ExchangeRate",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).ExchangeRate(ctx, req.(*QueryExchangeRateRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_ExchangeRateTwap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryExchangeRateRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).ExchangeRateTwap(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/ExchangeRateTwap",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).ExchangeRateTwap(ctx, req.(*QueryExchangeRateRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_ExchangeRates_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryExchangeRatesRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).ExchangeRates(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/ExchangeRates",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).ExchangeRates(ctx, req.(*QueryExchangeRatesRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_Actives_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryActivesRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Actives(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/Actives",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Actives(ctx, req.(*QueryActivesRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_VoteTargets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryVoteTargetsRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).VoteTargets(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/VoteTargets",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).VoteTargets(ctx, req.(*QueryVoteTargetsRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_FeederDelegation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryFeederDelegationRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).FeederDelegation(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/FeederDelegation",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).FeederDelegation(ctx, req.(*QueryFeederDelegationRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_MissCounter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryMissCounterRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).MissCounter(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/MissCounter",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).MissCounter(ctx, req.(*QueryMissCounterRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_AggregatePrevote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryAggregatePrevoteRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).AggregatePrevote(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/AggregatePrevote",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).AggregatePrevote(ctx, req.(*QueryAggregatePrevoteRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_AggregatePrevotes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryAggregatePrevotesRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).AggregatePrevotes(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/AggregatePrevotes",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).AggregatePrevotes(ctx, req.(*QueryAggregatePrevotesRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_AggregateVote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryAggregateVoteRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).AggregateVote(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/AggregateVote",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).AggregateVote(ctx, req.(*QueryAggregateVoteRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_AggregateVotes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryAggregateVotesRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).AggregateVotes(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/AggregateVotes",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).AggregateVotes(ctx, req.(*QueryAggregateVotesRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryParamsRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Params(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Query/Params",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Query_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.oracle.v1.Query",
- HandlerType: (*QueryServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "ExchangeRate",
- Handler: _Query_ExchangeRate_Handler,
- },
- {
- MethodName: "ExchangeRateTwap",
- Handler: _Query_ExchangeRateTwap_Handler,
- },
- {
- MethodName: "ExchangeRates",
- Handler: _Query_ExchangeRates_Handler,
- },
- {
- MethodName: "Actives",
- Handler: _Query_Actives_Handler,
- },
- {
- MethodName: "VoteTargets",
- Handler: _Query_VoteTargets_Handler,
- },
- {
- MethodName: "FeederDelegation",
- Handler: _Query_FeederDelegation_Handler,
- },
- {
- MethodName: "MissCounter",
- Handler: _Query_MissCounter_Handler,
- },
- {
- MethodName: "AggregatePrevote",
- Handler: _Query_AggregatePrevote_Handler,
- },
- {
- MethodName: "AggregatePrevotes",
- Handler: _Query_AggregatePrevotes_Handler,
- },
- {
- MethodName: "AggregateVote",
- Handler: _Query_AggregateVote_Handler,
- },
- {
- MethodName: "AggregateVotes",
- Handler: _Query_AggregateVotes_Handler,
- },
- {
- MethodName: "Params",
- Handler: _Query_Params_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/oracle/v1/query.proto",
-}
-
-func (m *QueryExchangeRateRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryExchangeRateRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryExchangeRateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size := m.Pair.Size()
- i -= size
- if _, err := m.Pair.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *QueryExchangeRateResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryExchangeRateResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryExchangeRateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size := m.ExchangeRate.Size()
- i -= size
- if _, err := m.ExchangeRate.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *QueryExchangeRatesRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryExchangeRatesRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryExchangeRatesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryExchangeRatesResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryExchangeRatesResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryExchangeRatesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.ExchangeRates) > 0 {
- for iNdEx := len(m.ExchangeRates) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.ExchangeRates[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryActivesRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryActivesRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryActivesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryActivesResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryActivesResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryActivesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Actives) > 0 {
- for iNdEx := len(m.Actives) - 1; iNdEx >= 0; iNdEx-- {
- {
- size := m.Actives[iNdEx].Size()
- i -= size
- if _, err := m.Actives[iNdEx].MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryVoteTargetsRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryVoteTargetsRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryVoteTargetsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryVoteTargetsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryVoteTargetsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryVoteTargetsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.VoteTargets) > 0 {
- for iNdEx := len(m.VoteTargets) - 1; iNdEx >= 0; iNdEx-- {
- {
- size := m.VoteTargets[iNdEx].Size()
- i -= size
- if _, err := m.VoteTargets[iNdEx].MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryFeederDelegationRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryFeederDelegationRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryFeederDelegationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.ValidatorAddr) > 0 {
- i -= len(m.ValidatorAddr)
- copy(dAtA[i:], m.ValidatorAddr)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddr)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryFeederDelegationResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryFeederDelegationResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryFeederDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.FeederAddr) > 0 {
- i -= len(m.FeederAddr)
- copy(dAtA[i:], m.FeederAddr)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.FeederAddr)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryMissCounterRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryMissCounterRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryMissCounterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.ValidatorAddr) > 0 {
- i -= len(m.ValidatorAddr)
- copy(dAtA[i:], m.ValidatorAddr)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddr)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryMissCounterResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryMissCounterResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryMissCounterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.MissCounter != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.MissCounter))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryAggregatePrevoteRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryAggregatePrevoteRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryAggregatePrevoteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.ValidatorAddr) > 0 {
- i -= len(m.ValidatorAddr)
- copy(dAtA[i:], m.ValidatorAddr)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddr)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryAggregatePrevoteResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryAggregatePrevoteResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryAggregatePrevoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.AggregatePrevote.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *QueryAggregatePrevotesRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryAggregatePrevotesRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryAggregatePrevotesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryAggregatePrevotesResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryAggregatePrevotesResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryAggregatePrevotesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.AggregatePrevotes) > 0 {
- for iNdEx := len(m.AggregatePrevotes) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.AggregatePrevotes[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryAggregateVoteRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryAggregateVoteRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryAggregateVoteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.ValidatorAddr) > 0 {
- i -= len(m.ValidatorAddr)
- copy(dAtA[i:], m.ValidatorAddr)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddr)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryAggregateVoteResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryAggregateVoteResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryAggregateVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.AggregateVote.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *QueryAggregateVotesRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryAggregateVotesRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryAggregateVotesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryAggregateVotesResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryAggregateVotesResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryAggregateVotesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.AggregateVotes) > 0 {
- for iNdEx := len(m.AggregateVotes) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.AggregateVotes[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
- offset -= sovQuery(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *QueryExchangeRateRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Pair.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *QueryExchangeRateResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.ExchangeRate.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *QueryExchangeRatesRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryExchangeRatesResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.ExchangeRates) > 0 {
- for _, e := range m.ExchangeRates {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- return n
-}
-
-func (m *QueryActivesRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryActivesResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Actives) > 0 {
- for _, e := range m.Actives {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- return n
-}
-
-func (m *QueryVoteTargetsRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryVoteTargetsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.VoteTargets) > 0 {
- for _, e := range m.VoteTargets {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- return n
-}
-
-func (m *QueryFeederDelegationRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ValidatorAddr)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryFeederDelegationResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.FeederAddr)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryMissCounterRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ValidatorAddr)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryMissCounterResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.MissCounter != 0 {
- n += 1 + sovQuery(uint64(m.MissCounter))
- }
- return n
-}
-
-func (m *QueryAggregatePrevoteRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ValidatorAddr)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryAggregatePrevoteResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.AggregatePrevote.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *QueryAggregatePrevotesRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryAggregatePrevotesResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.AggregatePrevotes) > 0 {
- for _, e := range m.AggregatePrevotes {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- return n
-}
-
-func (m *QueryAggregateVoteRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.ValidatorAddr)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryAggregateVoteResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.AggregateVote.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *QueryAggregateVotesRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryAggregateVotesResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.AggregateVotes) > 0 {
- for _, e := range m.AggregateVotes {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- return n
-}
-
-func (m *QueryParamsRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryParamsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Params.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func sovQuery(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozQuery(x uint64) (n int) {
- return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *QueryExchangeRateRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryExchangeRateRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryExchangeRateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Pair", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Pair.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryExchangeRateResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryExchangeRateResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryExchangeRateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRate", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.ExchangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryExchangeRatesRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryExchangeRatesRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryExchangeRatesRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryExchangeRatesResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryExchangeRatesResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryExchangeRatesResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRates", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ExchangeRates = append(m.ExchangeRates, ExchangeRateTuple{})
- if err := m.ExchangeRates[len(m.ExchangeRates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryActivesRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryActivesRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryActivesRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryActivesResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryActivesResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryActivesResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Actives", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_NibiruChain_nibiru_x_common_asset.Pair
- m.Actives = append(m.Actives, v)
- if err := m.Actives[len(m.Actives)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryVoteTargetsRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryVoteTargetsRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryVoteTargetsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryVoteTargetsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryVoteTargetsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryVoteTargetsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field VoteTargets", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_NibiruChain_nibiru_x_common_asset.Pair
- m.VoteTargets = append(m.VoteTargets, v)
- if err := m.VoteTargets[len(m.VoteTargets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryFeederDelegationRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryFeederDelegationRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryFeederDelegationRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddr", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ValidatorAddr = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryFeederDelegationResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryFeederDelegationResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryFeederDelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field FeederAddr", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.FeederAddr = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryMissCounterRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryMissCounterRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryMissCounterRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddr", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ValidatorAddr = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryMissCounterResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryMissCounterResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryMissCounterResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MissCounter", wireType)
- }
- m.MissCounter = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MissCounter |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryAggregatePrevoteRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryAggregatePrevoteRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryAggregatePrevoteRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddr", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ValidatorAddr = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryAggregatePrevoteResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryAggregatePrevoteResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryAggregatePrevoteResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AggregatePrevote", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.AggregatePrevote.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryAggregatePrevotesRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryAggregatePrevotesRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryAggregatePrevotesRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryAggregatePrevotesResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryAggregatePrevotesResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryAggregatePrevotesResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AggregatePrevotes", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.AggregatePrevotes = append(m.AggregatePrevotes, AggregateExchangeRatePrevote{})
- if err := m.AggregatePrevotes[len(m.AggregatePrevotes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryAggregateVoteRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryAggregateVoteRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryAggregateVoteRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddr", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ValidatorAddr = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryAggregateVoteResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryAggregateVoteResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryAggregateVoteResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AggregateVote", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.AggregateVote.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryAggregateVotesRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryAggregateVotesRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryAggregateVotesRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryAggregateVotesResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryAggregateVotesResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryAggregateVotesResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AggregateVotes", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.AggregateVotes = append(m.AggregateVotes, AggregateExchangeRateVote{})
- if err := m.AggregateVotes[len(m.AggregateVotes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipQuery(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthQuery
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupQuery
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthQuery
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go
deleted file mode 100644
index f8af1a4f8..000000000
--- a/x/oracle/types/query.pb.gw.go
+++ /dev/null
@@ -1,1048 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: nibiru/oracle/v1/query.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-var (
- filter_Query_ExchangeRate_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Query_ExchangeRate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryExchangeRateRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ExchangeRate_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.ExchangeRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_ExchangeRate_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryExchangeRateRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ExchangeRate_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.ExchangeRate(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Query_ExchangeRateTwap_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Query_ExchangeRateTwap_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryExchangeRateRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ExchangeRateTwap_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.ExchangeRateTwap(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_ExchangeRateTwap_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryExchangeRateRequest
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ExchangeRateTwap_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.ExchangeRateTwap(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_ExchangeRates_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryExchangeRatesRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.ExchangeRates(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_ExchangeRates_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryExchangeRatesRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.ExchangeRates(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_Actives_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryActivesRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.Actives(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Actives_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryActivesRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.Actives(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_VoteTargets_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryVoteTargetsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.VoteTargets(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_VoteTargets_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryVoteTargetsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.VoteTargets(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_FeederDelegation_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryFeederDelegationRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["validator_addr"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr")
- }
-
- protoReq.ValidatorAddr, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err)
- }
-
- msg, err := client.FeederDelegation(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_FeederDelegation_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryFeederDelegationRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["validator_addr"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr")
- }
-
- protoReq.ValidatorAddr, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err)
- }
-
- msg, err := server.FeederDelegation(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_MissCounter_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryMissCounterRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["validator_addr"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr")
- }
-
- protoReq.ValidatorAddr, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err)
- }
-
- msg, err := client.MissCounter(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_MissCounter_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryMissCounterRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["validator_addr"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr")
- }
-
- protoReq.ValidatorAddr, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err)
- }
-
- msg, err := server.MissCounter(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_AggregatePrevote_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryAggregatePrevoteRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["validator_addr"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr")
- }
-
- protoReq.ValidatorAddr, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err)
- }
-
- msg, err := client.AggregatePrevote(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_AggregatePrevote_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryAggregatePrevoteRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["validator_addr"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr")
- }
-
- protoReq.ValidatorAddr, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err)
- }
-
- msg, err := server.AggregatePrevote(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_AggregatePrevotes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryAggregatePrevotesRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.AggregatePrevotes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_AggregatePrevotes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryAggregatePrevotesRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.AggregatePrevotes(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_AggregateVote_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryAggregateVoteRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["validator_addr"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr")
- }
-
- protoReq.ValidatorAddr, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err)
- }
-
- msg, err := client.AggregateVote(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_AggregateVote_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryAggregateVoteRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["validator_addr"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_addr")
- }
-
- protoReq.ValidatorAddr, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_addr", err)
- }
-
- msg, err := server.AggregateVote(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_AggregateVotes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryAggregateVotesRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.AggregateVotes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_AggregateVotes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryAggregateVotesRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.AggregateVotes(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryParamsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryParamsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.Params(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
-// UnaryRPC :call QueryServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
-func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
-
- mux.Handle("GET", pattern_Query_ExchangeRate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_ExchangeRate_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_ExchangeRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_ExchangeRateTwap_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_ExchangeRateTwap_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_ExchangeRateTwap_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_ExchangeRates_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_ExchangeRates_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_ExchangeRates_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Actives_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Actives_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Actives_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_VoteTargets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_VoteTargets_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_VoteTargets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_FeederDelegation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_FeederDelegation_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_FeederDelegation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_MissCounter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_MissCounter_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_MissCounter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_AggregatePrevote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_AggregatePrevote_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_AggregatePrevote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_AggregatePrevotes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_AggregatePrevotes_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_AggregatePrevotes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_AggregateVote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_AggregateVote_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_AggregateVote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_AggregateVotes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_AggregateVotes_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_AggregateVotes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterQueryHandler(ctx, mux, conn)
-}
-
-// RegisterQueryHandler registers the http handlers for service Query to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
-}
-
-// RegisterQueryHandlerClient registers the http handlers for service Query
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "QueryClient" to call the correct interceptors.
-func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
-
- mux.Handle("GET", pattern_Query_ExchangeRate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_ExchangeRate_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_ExchangeRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_ExchangeRateTwap_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_ExchangeRateTwap_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_ExchangeRateTwap_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_ExchangeRates_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_ExchangeRates_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_ExchangeRates_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Actives_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Actives_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Actives_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_VoteTargets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_VoteTargets_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_VoteTargets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_FeederDelegation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_FeederDelegation_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_FeederDelegation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_MissCounter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_MissCounter_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_MissCounter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_AggregatePrevote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_AggregatePrevote_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_AggregatePrevote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_AggregatePrevotes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_AggregatePrevotes_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_AggregatePrevotes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_AggregateVote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_AggregateVote_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_AggregateVote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_AggregateVotes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_AggregateVotes_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_AggregateVotes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Query_ExchangeRate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "oracle", "v1beta1", "exchange_rate"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_ExchangeRateTwap_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "oracle", "v1beta1", "exchange_rate_twap"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_ExchangeRates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"nibiru", "oracle", "v1beta1", "pairs", "exchange_rates"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_Actives_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"nibiru", "oracle", "v1beta1", "pairs", "actives"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_VoteTargets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"nibiru", "oracle", "v1beta1", "pairs", "vote_targets"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_FeederDelegation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"nibiru", "oracle", "v1beta1", "validators", "validator_addr", "feeder"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_MissCounter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"nibiru", "oracle", "v1beta1", "validators", "validator_addr", "miss"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_AggregatePrevote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"nibiru", "oracle", "v1beta1", "validators", "validator_addr", "aggregate_prevote"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_AggregatePrevotes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"nibiru", "oracle", "v1beta1", "validators", "aggregate_prevotes"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_AggregateVote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"nibiru", "oracle", "v1beta1", "valdiators", "validator_addr", "aggregate_vote"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_AggregateVotes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"nibiru", "oracle", "v1beta1", "validators", "aggregate_votes"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "oracle", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Query_ExchangeRate_0 = runtime.ForwardResponseMessage
-
- forward_Query_ExchangeRateTwap_0 = runtime.ForwardResponseMessage
-
- forward_Query_ExchangeRates_0 = runtime.ForwardResponseMessage
-
- forward_Query_Actives_0 = runtime.ForwardResponseMessage
-
- forward_Query_VoteTargets_0 = runtime.ForwardResponseMessage
-
- forward_Query_FeederDelegation_0 = runtime.ForwardResponseMessage
-
- forward_Query_MissCounter_0 = runtime.ForwardResponseMessage
-
- forward_Query_AggregatePrevote_0 = runtime.ForwardResponseMessage
-
- forward_Query_AggregatePrevotes_0 = runtime.ForwardResponseMessage
-
- forward_Query_AggregateVote_0 = runtime.ForwardResponseMessage
-
- forward_Query_AggregateVotes_0 = runtime.ForwardResponseMessage
-
- forward_Query_Params_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/oracle/types/state.pb.go b/x/oracle/types/state.pb.go
deleted file mode 100644
index 1569bbca1..000000000
--- a/x/oracle/types/state.pb.go
+++ /dev/null
@@ -1,410 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/oracle/v1/state.proto
-
-package types
-
-import (
- fmt "fmt"
- github_com_NibiruChain_nibiru_x_common_asset "github.com/NibiruChain/nibiru/x/common/asset"
- _ "github.com/cosmos/cosmos-sdk/types"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// a snapshot of the prices at a given point in time
-type PriceSnapshot struct {
- Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair" yaml:"pair"`
- Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"`
- // milliseconds since unix epoch
- TimestampMs int64 `protobuf:"varint,3,opt,name=timestamp_ms,json=timestampMs,proto3" json:"timestamp_ms,omitempty"`
-}
-
-func (m *PriceSnapshot) Reset() { *m = PriceSnapshot{} }
-func (m *PriceSnapshot) String() string { return proto.CompactTextString(m) }
-func (*PriceSnapshot) ProtoMessage() {}
-func (*PriceSnapshot) Descriptor() ([]byte, []int) {
- return fileDescriptor_125e6c5a6e45c0d0, []int{0}
-}
-func (m *PriceSnapshot) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *PriceSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_PriceSnapshot.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *PriceSnapshot) XXX_Merge(src proto.Message) {
- xxx_messageInfo_PriceSnapshot.Merge(m, src)
-}
-func (m *PriceSnapshot) XXX_Size() int {
- return m.Size()
-}
-func (m *PriceSnapshot) XXX_DiscardUnknown() {
- xxx_messageInfo_PriceSnapshot.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_PriceSnapshot proto.InternalMessageInfo
-
-func (m *PriceSnapshot) GetTimestampMs() int64 {
- if m != nil {
- return m.TimestampMs
- }
- return 0
-}
-
-func init() {
- proto.RegisterType((*PriceSnapshot)(nil), "nibiru.oracle.v1.PriceSnapshot")
-}
-
-func init() { proto.RegisterFile("nibiru/oracle/v1/state.proto", fileDescriptor_125e6c5a6e45c0d0) }
-
-var fileDescriptor_125e6c5a6e45c0d0 = []byte{
- // 329 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0x41, 0x4b, 0xf3, 0x30,
- 0x18, 0x80, 0xdb, 0x6f, 0x9f, 0x82, 0x9d, 0x82, 0x14, 0x0f, 0x63, 0xcc, 0x6c, 0xee, 0x20, 0x3b,
- 0x68, 0x42, 0xf1, 0xe6, 0x71, 0x0e, 0xf1, 0xa2, 0x8c, 0x79, 0x13, 0x41, 0xde, 0xc6, 0xd0, 0x05,
- 0x97, 0xbc, 0xa1, 0xc9, 0x86, 0xfb, 0x17, 0xfe, 0xac, 0x1d, 0x77, 0x12, 0xf1, 0x30, 0x64, 0xfb,
- 0x07, 0xfe, 0x02, 0x69, 0x53, 0x44, 0xf0, 0xe0, 0xa9, 0x25, 0x4f, 0xf2, 0x3c, 0xc9, 0x1b, 0xb5,
- 0xb4, 0x4c, 0x65, 0x3e, 0x65, 0x98, 0x03, 0x9f, 0x08, 0x36, 0x4b, 0x98, 0x75, 0xe0, 0x04, 0x35,
- 0x39, 0x3a, 0x8c, 0xf7, 0x3d, 0xa5, 0x9e, 0xd2, 0x59, 0xd2, 0x3c, 0xc8, 0x30, 0xc3, 0x12, 0xb2,
- 0xe2, 0xcf, 0xef, 0x6b, 0xb6, 0x32, 0xc4, 0x6c, 0x22, 0x18, 0x18, 0xc9, 0x40, 0x6b, 0x74, 0xe0,
- 0x24, 0x6a, 0x5b, 0xd1, 0xc3, 0x5f, 0x8d, 0xca, 0xe7, 0x31, 0xe1, 0x68, 0x15, 0x5a, 0x96, 0x82,
- 0x2d, 0x60, 0x2a, 0x1c, 0x24, 0x8c, 0xa3, 0xd4, 0x9e, 0x77, 0x5f, 0xc3, 0x68, 0x6f, 0x98, 0x4b,
- 0x2e, 0x6e, 0x35, 0x18, 0x3b, 0x46, 0x17, 0xdf, 0x47, 0xff, 0x0d, 0xc8, 0xbc, 0x11, 0x76, 0xc2,
- 0xde, 0x4e, 0xff, 0x6a, 0xb1, 0x6a, 0x07, 0xef, 0xab, 0x76, 0x92, 0x49, 0x37, 0x9e, 0xa6, 0x94,
- 0xa3, 0x62, 0x37, 0x65, 0xf1, 0x62, 0x0c, 0x52, 0xb3, 0xaa, 0xfe, 0xcc, 0x38, 0x2a, 0x85, 0x9a,
- 0x81, 0xb5, 0xc2, 0xd1, 0x21, 0xc8, 0xfc, 0x73, 0xd5, 0xae, 0xcf, 0x41, 0x4d, 0xce, 0xbb, 0x85,
- 0xae, 0x3b, 0x2a, 0xad, 0xf1, 0x20, 0xda, 0x32, 0x45, 0xae, 0xf1, 0xaf, 0xd4, 0xd3, 0x4a, 0x7f,
- 0xfc, 0x43, 0x5f, 0xdd, 0xd8, 0x7f, 0x4e, 0xed, 0xe3, 0x13, 0x73, 0x73, 0x23, 0x2c, 0x1d, 0x08,
- 0x3e, 0xf2, 0x87, 0xe3, 0xa3, 0x68, 0xd7, 0x49, 0x25, 0xac, 0x03, 0x65, 0x1e, 0x94, 0x6d, 0xd4,
- 0x3a, 0x61, 0xaf, 0x36, 0xaa, 0x7f, 0xaf, 0x5d, 0xdb, 0xfe, 0xe5, 0x62, 0x4d, 0xc2, 0xe5, 0x9a,
- 0x84, 0x1f, 0x6b, 0x12, 0xbe, 0x6c, 0x48, 0xb0, 0xdc, 0x90, 0xe0, 0x6d, 0x43, 0x82, 0xbb, 0x93,
- 0xbf, 0x9e, 0x52, 0x8d, 0xb2, 0xac, 0xa6, 0xdb, 0xe5, 0x9c, 0xce, 0xbe, 0x02, 0x00, 0x00, 0xff,
- 0xff, 0x21, 0xeb, 0xd1, 0x23, 0xcc, 0x01, 0x00, 0x00,
-}
-
-func (m *PriceSnapshot) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *PriceSnapshot) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *PriceSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.TimestampMs != 0 {
- i = encodeVarintState(dAtA, i, uint64(m.TimestampMs))
- i--
- dAtA[i] = 0x18
- }
- {
- size := m.Price.Size()
- i -= size
- if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintState(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- {
- size := m.Pair.Size()
- i -= size
- if _, err := m.Pair.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintState(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func encodeVarintState(dAtA []byte, offset int, v uint64) int {
- offset -= sovState(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *PriceSnapshot) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Pair.Size()
- n += 1 + l + sovState(uint64(l))
- l = m.Price.Size()
- n += 1 + l + sovState(uint64(l))
- if m.TimestampMs != 0 {
- n += 1 + sovState(uint64(m.TimestampMs))
- }
- return n
-}
-
-func sovState(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozState(x uint64) (n int) {
- return sovState(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *PriceSnapshot) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: PriceSnapshot: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: PriceSnapshot: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Pair", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Pair.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field TimestampMs", wireType)
- }
- m.TimestampMs = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.TimestampMs |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipState(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthState
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipState(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthState
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupState
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthState
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthState = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowState = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupState = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/oracle/types/test_utils.go b/x/oracle/types/test_utils.go
deleted file mode 100644
index c5e06e88f..000000000
--- a/x/oracle/types/test_utils.go
+++ /dev/null
@@ -1,162 +0,0 @@
-// nolint
-package types
-
-import (
- "math"
- "math/rand"
- "time"
-
- sdkmath "cosmossdk.io/math"
-
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
-
- "github.com/cometbft/cometbft/crypto/secp256k1"
- tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
-)
-
-// OracleDecPrecision nolint
-const OracleDecPrecision = 8
-
-// GenerateRandomTestCase nolint
-func GenerateRandomTestCase() (rates []float64, valAddrs []sdk.ValAddress, stakingKeeper DummyStakingKeeper) {
- valAddrs = []sdk.ValAddress{}
- mockValidators := []MockValidator{}
-
- base := math.Pow10(OracleDecPrecision)
-
- rand.Seed(int64(time.Now().Nanosecond()))
- numInputs := 10 + (rand.Int() % 100)
- for i := 0; i < numInputs; i++ {
- rate := float64(int64(rand.Float64()*base)) / base
- rates = append(rates, rate)
-
- pubKey := secp256k1.GenPrivKey().PubKey()
- valAddr := sdk.ValAddress(pubKey.Address())
- valAddrs = append(valAddrs, valAddr)
-
- power := rand.Int63()%1000 + 1
- mockValidator := NewMockValidator(valAddr, power)
- mockValidators = append(mockValidators, mockValidator)
- }
-
- stakingKeeper = NewDummyStakingKeeper(mockValidators)
-
- return
-}
-
-var _ StakingKeeper = DummyStakingKeeper{}
-
-// DummyStakingKeeper dummy staking keeper to test votes
-type DummyStakingKeeper struct {
- validators []MockValidator
-}
-
-// NewDummyStakingKeeper returns new DummyStakingKeeper instance
-func NewDummyStakingKeeper(validators []MockValidator) DummyStakingKeeper {
- return DummyStakingKeeper{
- validators: validators,
- }
-}
-
-// Validators nolint
-func (sk DummyStakingKeeper) Validators() []MockValidator {
- return sk.validators
-}
-
-// Validator nolint
-func (sk DummyStakingKeeper) Validator(ctx sdk.Context, address sdk.ValAddress) stakingtypes.ValidatorI {
- for _, validator := range sk.validators {
- if validator.GetOperator().Equals(address) {
- return validator
- }
- }
-
- return nil
-}
-
-// TotalBondedTokens nolint
-func (DummyStakingKeeper) TotalBondedTokens(_ sdk.Context) sdk.Int {
- return sdkmath.ZeroInt()
-}
-
-// Slash nolint
-func (DummyStakingKeeper) Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) sdkmath.Int {
- return sdkmath.ZeroInt()
-}
-
-// ValidatorsPowerStoreIterator nolint
-func (DummyStakingKeeper) ValidatorsPowerStoreIterator(ctx sdk.Context) sdk.Iterator {
- return sdk.KVStoreReversePrefixIterator(nil, nil)
-}
-
-// Jail nolint
-func (DummyStakingKeeper) Jail(sdk.Context, sdk.ConsAddress) {
-}
-
-// GetLastValidatorPower nolint
-func (sk DummyStakingKeeper) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) (power int64) {
- return sk.Validator(ctx, operator).GetConsensusPower(sdk.DefaultPowerReduction)
-}
-
-// MaxValidators returns the maximum amount of bonded validators
-func (DummyStakingKeeper) MaxValidators(sdk.Context) uint32 {
- return 100
-}
-
-// PowerReduction - is the amount of staking tokens required for 1 unit of consensus-engine power
-func (DummyStakingKeeper) PowerReduction(ctx sdk.Context) (res sdk.Int) {
- res = sdk.DefaultPowerReduction
- return
-}
-
-// MockValidator nolint
-type MockValidator struct {
- power int64
- valOperAddr sdk.ValAddress
-}
-
-var _ stakingtypes.ValidatorI = MockValidator{}
-
-func (MockValidator) IsJailed() bool { return false }
-func (MockValidator) GetMoniker() string { return "" }
-func (MockValidator) GetStatus() stakingtypes.BondStatus { return stakingtypes.Bonded }
-func (MockValidator) IsBonded() bool { return true }
-func (MockValidator) IsUnbonded() bool { return false }
-func (MockValidator) IsUnbonding() bool { return false }
-func (v MockValidator) GetOperator() sdk.ValAddress { return v.valOperAddr }
-func (MockValidator) ConsPubKey() (cryptotypes.PubKey, error) { return nil, nil }
-func (MockValidator) TmConsPublicKey() (tmprotocrypto.PublicKey, error) {
- return tmprotocrypto.PublicKey{}, nil
-}
-func (MockValidator) GetConsAddr() (sdk.ConsAddress, error) { return nil, nil }
-func (v MockValidator) GetTokens() sdk.Int {
- return sdk.TokensFromConsensusPower(v.power, sdk.DefaultPowerReduction)
-}
-
-func (v MockValidator) GetBondedTokens() sdk.Int {
- return sdk.TokensFromConsensusPower(v.power, sdk.DefaultPowerReduction)
-}
-func (v MockValidator) GetConsensusPower(powerReduction sdk.Int) int64 { return v.power }
-func (v *MockValidator) SetConsensusPower(power int64) { v.power = power }
-func (v MockValidator) GetCommission() sdk.Dec { return sdkmath.LegacyZeroDec() }
-func (v MockValidator) GetMinSelfDelegation() sdk.Int { return sdkmath.OneInt() }
-func (v MockValidator) GetDelegatorShares() sdk.Dec { return sdkmath.LegacyNewDec(v.power) }
-func (v MockValidator) TokensFromShares(sdk.Dec) sdk.Dec { return sdkmath.LegacyZeroDec() }
-func (v MockValidator) TokensFromSharesTruncated(sdk.Dec) sdk.Dec { return sdkmath.LegacyZeroDec() }
-func (v MockValidator) TokensFromSharesRoundUp(sdk.Dec) sdk.Dec { return sdkmath.LegacyZeroDec() }
-func (v MockValidator) SharesFromTokens(amt sdk.Int) (sdk.Dec, error) {
- return sdkmath.LegacyZeroDec(), nil
-}
-
-func (v MockValidator) SharesFromTokensTruncated(amt sdk.Int) (sdk.Dec, error) {
- return sdkmath.LegacyZeroDec(), nil
-}
-
-func NewMockValidator(valAddr sdk.ValAddress, power int64) MockValidator {
- return MockValidator{
- power: power,
- valOperAddr: valAddr,
- }
-}
diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go
deleted file mode 100644
index 559b17c45..000000000
--- a/x/oracle/types/tx.pb.go
+++ /dev/null
@@ -1,2424 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/oracle/v1/tx.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// MsgAggregateExchangeRatePrevote represents a message to submit
-// aggregate exchange rate prevote.
-type MsgAggregateExchangeRatePrevote struct {
- Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty" yaml:"hash"`
- // Feeder is the Bech32 address of the price feeder. A validator may
- // specify multiple price feeders by delegating them consent. The validator
- // address is also a valid feeder by default.
- Feeder string `protobuf:"bytes,2,opt,name=feeder,proto3" json:"feeder,omitempty" yaml:"feeder"`
- // Validator is the Bech32 address to which the prevote will be credited.
- Validator string `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator,omitempty" yaml:"validator"`
-}
-
-func (m *MsgAggregateExchangeRatePrevote) Reset() { *m = MsgAggregateExchangeRatePrevote{} }
-func (m *MsgAggregateExchangeRatePrevote) String() string { return proto.CompactTextString(m) }
-func (*MsgAggregateExchangeRatePrevote) ProtoMessage() {}
-func (*MsgAggregateExchangeRatePrevote) Descriptor() ([]byte, []int) {
- return fileDescriptor_11e362c65eb610f4, []int{0}
-}
-func (m *MsgAggregateExchangeRatePrevote) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgAggregateExchangeRatePrevote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgAggregateExchangeRatePrevote.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgAggregateExchangeRatePrevote) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgAggregateExchangeRatePrevote.Merge(m, src)
-}
-func (m *MsgAggregateExchangeRatePrevote) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgAggregateExchangeRatePrevote) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgAggregateExchangeRatePrevote.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgAggregateExchangeRatePrevote proto.InternalMessageInfo
-
-// MsgAggregateExchangeRatePrevoteResponse defines the
-// Msg/AggregateExchangeRatePrevote response type.
-type MsgAggregateExchangeRatePrevoteResponse struct {
-}
-
-func (m *MsgAggregateExchangeRatePrevoteResponse) Reset() {
- *m = MsgAggregateExchangeRatePrevoteResponse{}
-}
-func (m *MsgAggregateExchangeRatePrevoteResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgAggregateExchangeRatePrevoteResponse) ProtoMessage() {}
-func (*MsgAggregateExchangeRatePrevoteResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_11e362c65eb610f4, []int{1}
-}
-func (m *MsgAggregateExchangeRatePrevoteResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgAggregateExchangeRatePrevoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgAggregateExchangeRatePrevoteResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgAggregateExchangeRatePrevoteResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgAggregateExchangeRatePrevoteResponse.Merge(m, src)
-}
-func (m *MsgAggregateExchangeRatePrevoteResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgAggregateExchangeRatePrevoteResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgAggregateExchangeRatePrevoteResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgAggregateExchangeRatePrevoteResponse proto.InternalMessageInfo
-
-// MsgAggregateExchangeRateVote represents a message to submit
-// aggregate exchange rate vote.
-type MsgAggregateExchangeRateVote struct {
- Salt string `protobuf:"bytes,1,opt,name=salt,proto3" json:"salt,omitempty" yaml:"salt"`
- ExchangeRates string `protobuf:"bytes,2,opt,name=exchange_rates,json=exchangeRates,proto3" json:"exchange_rates,omitempty" yaml:"exchange_rates"`
- // Feeder is the Bech32 address of the price feeder. A validator may
- // specify multiple price feeders by delegating them consent. The validator
- // address is also a valid feeder by default.
- Feeder string `protobuf:"bytes,3,opt,name=feeder,proto3" json:"feeder,omitempty" yaml:"feeder"`
- // Validator is the Bech32 address to which the vote will be credited.
- Validator string `protobuf:"bytes,4,opt,name=validator,proto3" json:"validator,omitempty" yaml:"validator"`
-}
-
-func (m *MsgAggregateExchangeRateVote) Reset() { *m = MsgAggregateExchangeRateVote{} }
-func (m *MsgAggregateExchangeRateVote) String() string { return proto.CompactTextString(m) }
-func (*MsgAggregateExchangeRateVote) ProtoMessage() {}
-func (*MsgAggregateExchangeRateVote) Descriptor() ([]byte, []int) {
- return fileDescriptor_11e362c65eb610f4, []int{2}
-}
-func (m *MsgAggregateExchangeRateVote) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgAggregateExchangeRateVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgAggregateExchangeRateVote.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgAggregateExchangeRateVote) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgAggregateExchangeRateVote.Merge(m, src)
-}
-func (m *MsgAggregateExchangeRateVote) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgAggregateExchangeRateVote) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgAggregateExchangeRateVote.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgAggregateExchangeRateVote proto.InternalMessageInfo
-
-// MsgAggregateExchangeRateVoteResponse defines the
-// Msg/AggregateExchangeRateVote response type.
-type MsgAggregateExchangeRateVoteResponse struct {
-}
-
-func (m *MsgAggregateExchangeRateVoteResponse) Reset() { *m = MsgAggregateExchangeRateVoteResponse{} }
-func (m *MsgAggregateExchangeRateVoteResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgAggregateExchangeRateVoteResponse) ProtoMessage() {}
-func (*MsgAggregateExchangeRateVoteResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_11e362c65eb610f4, []int{3}
-}
-func (m *MsgAggregateExchangeRateVoteResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgAggregateExchangeRateVoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgAggregateExchangeRateVoteResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgAggregateExchangeRateVoteResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgAggregateExchangeRateVoteResponse.Merge(m, src)
-}
-func (m *MsgAggregateExchangeRateVoteResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgAggregateExchangeRateVoteResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgAggregateExchangeRateVoteResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgAggregateExchangeRateVoteResponse proto.InternalMessageInfo
-
-// MsgDelegateFeedConsent represents a message to delegate oracle voting rights
-// to another address.
-type MsgDelegateFeedConsent struct {
- Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty" yaml:"operator"`
- Delegate string `protobuf:"bytes,2,opt,name=delegate,proto3" json:"delegate,omitempty" yaml:"delegate"`
-}
-
-func (m *MsgDelegateFeedConsent) Reset() { *m = MsgDelegateFeedConsent{} }
-func (m *MsgDelegateFeedConsent) String() string { return proto.CompactTextString(m) }
-func (*MsgDelegateFeedConsent) ProtoMessage() {}
-func (*MsgDelegateFeedConsent) Descriptor() ([]byte, []int) {
- return fileDescriptor_11e362c65eb610f4, []int{4}
-}
-func (m *MsgDelegateFeedConsent) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgDelegateFeedConsent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgDelegateFeedConsent.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgDelegateFeedConsent) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgDelegateFeedConsent.Merge(m, src)
-}
-func (m *MsgDelegateFeedConsent) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgDelegateFeedConsent) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgDelegateFeedConsent.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgDelegateFeedConsent proto.InternalMessageInfo
-
-// MsgDelegateFeedConsentResponse defines the Msg/DelegateFeedConsent response
-// type.
-type MsgDelegateFeedConsentResponse struct {
-}
-
-func (m *MsgDelegateFeedConsentResponse) Reset() { *m = MsgDelegateFeedConsentResponse{} }
-func (m *MsgDelegateFeedConsentResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgDelegateFeedConsentResponse) ProtoMessage() {}
-func (*MsgDelegateFeedConsentResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_11e362c65eb610f4, []int{5}
-}
-func (m *MsgDelegateFeedConsentResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgDelegateFeedConsentResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgDelegateFeedConsentResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgDelegateFeedConsentResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgDelegateFeedConsentResponse.Merge(m, src)
-}
-func (m *MsgDelegateFeedConsentResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgDelegateFeedConsentResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgDelegateFeedConsentResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgDelegateFeedConsentResponse proto.InternalMessageInfo
-
-// MsgEditOracleParams: gRPC tx message for updating the x/oracle module params
-// [SUDO] Only callable by sudoers.
-type MsgEditOracleParams struct {
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"`
- VotePeriod *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=vote_period,json=votePeriod,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"vote_period,omitempty"`
- // vote_threshold: [cosmossdk.io/math.LegacyDec] TODO:
- VoteThreshold *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=vote_threshold,json=voteThreshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"vote_threshold,omitempty"`
- // reward_band: [cosmossdk.io/math.LegacyDec] TODO:
- RewardBand *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=reward_band,json=rewardBand,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_band,omitempty"`
- Whitelist []string `protobuf:"bytes,5,rep,name=whitelist,proto3" json:"whitelist,omitempty"`
- // slash_fraction: [cosmossdk.io/math.LegacyDec] TODO:
- SlashFraction *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=slash_fraction,json=slashFraction,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction,omitempty"`
- SlashWindow *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=slash_window,json=slashWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"slash_window,omitempty"`
- // min_valid_per_window: [cosmossdk.io/math.LegacyDec] TODO:
- MinValidPerWindow *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=min_valid_per_window,json=minValidPerWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_valid_per_window,omitempty"`
- TwapLookbackWindow *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=twap_lookback_window,json=twapLookbackWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"twap_lookback_window,omitempty"`
- MinVoters *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=min_voters,json=minVoters,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_voters,omitempty"`
- // VoteThreshold: [cosmossdk.io/math.LegacyDec] TODO:
- ValidatorFeeRatio *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=validator_fee_ratio,json=validatorFeeRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"validator_fee_ratio,omitempty"`
-}
-
-func (m *MsgEditOracleParams) Reset() { *m = MsgEditOracleParams{} }
-func (m *MsgEditOracleParams) String() string { return proto.CompactTextString(m) }
-func (*MsgEditOracleParams) ProtoMessage() {}
-func (*MsgEditOracleParams) Descriptor() ([]byte, []int) {
- return fileDescriptor_11e362c65eb610f4, []int{6}
-}
-func (m *MsgEditOracleParams) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgEditOracleParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgEditOracleParams.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgEditOracleParams) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgEditOracleParams.Merge(m, src)
-}
-func (m *MsgEditOracleParams) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgEditOracleParams) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgEditOracleParams.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgEditOracleParams proto.InternalMessageInfo
-
-func (m *MsgEditOracleParams) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-func (m *MsgEditOracleParams) GetWhitelist() []string {
- if m != nil {
- return m.Whitelist
- }
- return nil
-}
-
-// MsgEditOracleParamsResponse defines the Msg/EditOracleParams response
-// type.
-type MsgEditOracleParamsResponse struct {
- NewParams *Params `protobuf:"bytes,1,opt,name=new_params,json=newParams,proto3" json:"new_params,omitempty"`
-}
-
-func (m *MsgEditOracleParamsResponse) Reset() { *m = MsgEditOracleParamsResponse{} }
-func (m *MsgEditOracleParamsResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgEditOracleParamsResponse) ProtoMessage() {}
-func (*MsgEditOracleParamsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_11e362c65eb610f4, []int{7}
-}
-func (m *MsgEditOracleParamsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgEditOracleParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgEditOracleParamsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgEditOracleParamsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgEditOracleParamsResponse.Merge(m, src)
-}
-func (m *MsgEditOracleParamsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgEditOracleParamsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgEditOracleParamsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgEditOracleParamsResponse proto.InternalMessageInfo
-
-func (m *MsgEditOracleParamsResponse) GetNewParams() *Params {
- if m != nil {
- return m.NewParams
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*MsgAggregateExchangeRatePrevote)(nil), "nibiru.oracle.v1.MsgAggregateExchangeRatePrevote")
- proto.RegisterType((*MsgAggregateExchangeRatePrevoteResponse)(nil), "nibiru.oracle.v1.MsgAggregateExchangeRatePrevoteResponse")
- proto.RegisterType((*MsgAggregateExchangeRateVote)(nil), "nibiru.oracle.v1.MsgAggregateExchangeRateVote")
- proto.RegisterType((*MsgAggregateExchangeRateVoteResponse)(nil), "nibiru.oracle.v1.MsgAggregateExchangeRateVoteResponse")
- proto.RegisterType((*MsgDelegateFeedConsent)(nil), "nibiru.oracle.v1.MsgDelegateFeedConsent")
- proto.RegisterType((*MsgDelegateFeedConsentResponse)(nil), "nibiru.oracle.v1.MsgDelegateFeedConsentResponse")
- proto.RegisterType((*MsgEditOracleParams)(nil), "nibiru.oracle.v1.MsgEditOracleParams")
- proto.RegisterType((*MsgEditOracleParamsResponse)(nil), "nibiru.oracle.v1.MsgEditOracleParamsResponse")
-}
-
-func init() { proto.RegisterFile("nibiru/oracle/v1/tx.proto", fileDescriptor_11e362c65eb610f4) }
-
-var fileDescriptor_11e362c65eb610f4 = []byte{
- // 915 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x96, 0x41, 0x6f, 0xdc, 0x44,
- 0x14, 0xc7, 0xd7, 0x4d, 0xba, 0x64, 0x67, 0x49, 0x9b, 0x7a, 0xd3, 0xc8, 0xd9, 0x06, 0x3b, 0xb8,
- 0x10, 0x12, 0x89, 0xb5, 0x49, 0x90, 0x40, 0xf4, 0x04, 0x69, 0x1b, 0x09, 0x89, 0xa5, 0xc1, 0x82,
- 0x20, 0x71, 0xc0, 0xcc, 0xae, 0x5f, 0x6c, 0x2b, 0x5e, 0x8f, 0x35, 0x33, 0xcd, 0xa6, 0x57, 0xc4,
- 0x01, 0x6e, 0x48, 0x3d, 0x71, 0xcb, 0x07, 0x40, 0xe2, 0x6b, 0xf4, 0x58, 0x89, 0x0b, 0xe2, 0xb0,
- 0x42, 0x09, 0x42, 0x9c, 0x38, 0xec, 0x27, 0x40, 0x33, 0x1e, 0xbb, 0xdb, 0xcd, 0xb6, 0xcd, 0xee,
- 0x29, 0xce, 0xbc, 0xff, 0xfc, 0xde, 0xff, 0x3d, 0x7b, 0xde, 0x2c, 0x5a, 0x4d, 0xe3, 0x4e, 0x4c,
- 0x1f, 0xba, 0x84, 0xe2, 0x6e, 0x02, 0xee, 0xf1, 0xb6, 0xcb, 0x4f, 0x9c, 0x8c, 0x12, 0x4e, 0xf4,
- 0xa5, 0x3c, 0xe4, 0xe4, 0x21, 0xe7, 0x78, 0xbb, 0xb9, 0x1c, 0x92, 0x90, 0xc8, 0xa0, 0x2b, 0x9e,
- 0x72, 0x5d, 0x73, 0x2d, 0x24, 0x24, 0x4c, 0xc0, 0xc5, 0x59, 0xec, 0xe2, 0x34, 0x25, 0x1c, 0xf3,
- 0x98, 0xa4, 0x4c, 0x45, 0xdf, 0xb8, 0x90, 0x40, 0xf1, 0x64, 0xd8, 0xfe, 0x4d, 0x43, 0x56, 0x9b,
- 0x85, 0x9f, 0x84, 0x21, 0x85, 0x10, 0x73, 0xb8, 0x7f, 0xd2, 0x8d, 0x70, 0x1a, 0x82, 0x87, 0x39,
- 0xec, 0x53, 0x38, 0x26, 0x1c, 0xf4, 0xdb, 0x68, 0x3e, 0xc2, 0x2c, 0x32, 0xb4, 0x75, 0x6d, 0xb3,
- 0xb6, 0x7b, 0x7d, 0x38, 0xb0, 0xea, 0x8f, 0x70, 0x2f, 0xb9, 0x63, 0x8b, 0x55, 0xdb, 0x93, 0x41,
- 0x7d, 0x0b, 0x55, 0x0f, 0x01, 0x02, 0xa0, 0xc6, 0x15, 0x29, 0xbb, 0x31, 0x1c, 0x58, 0x8b, 0xb9,
- 0x2c, 0x5f, 0xb7, 0x3d, 0x25, 0xd0, 0x77, 0x50, 0xed, 0x18, 0x27, 0x71, 0x80, 0x39, 0xa1, 0xc6,
- 0x9c, 0x54, 0x2f, 0x0f, 0x07, 0xd6, 0x52, 0xae, 0x2e, 0x43, 0xb6, 0xf7, 0x4c, 0x76, 0x67, 0xe1,
- 0xc7, 0x53, 0xab, 0xf2, 0xef, 0xa9, 0x55, 0xb1, 0xb7, 0xd0, 0x3b, 0xaf, 0x30, 0xec, 0x01, 0xcb,
- 0x48, 0xca, 0xc0, 0xfe, 0x4f, 0x43, 0x6b, 0x2f, 0xd2, 0x1e, 0xa8, 0xca, 0x18, 0x4e, 0xf8, 0xc5,
- 0xca, 0xc4, 0xaa, 0xed, 0xc9, 0xa0, 0xfe, 0x31, 0xba, 0x06, 0x6a, 0xa3, 0x4f, 0x31, 0x07, 0xa6,
- 0x2a, 0x5c, 0x1d, 0x0e, 0xac, 0x9b, 0xb9, 0xfc, 0xf9, 0xb8, 0xed, 0x2d, 0xc2, 0x48, 0x26, 0x36,
- 0xd2, 0x9b, 0xb9, 0xa9, 0x7a, 0x33, 0x3f, 0x6d, 0x6f, 0x36, 0xd0, 0x5b, 0x2f, 0xab, 0xb7, 0x6c,
- 0xcc, 0x0f, 0x1a, 0x5a, 0x69, 0xb3, 0xf0, 0x1e, 0x24, 0x52, 0xb7, 0x07, 0x10, 0xdc, 0x15, 0x81,
- 0x94, 0xeb, 0x2e, 0x5a, 0x20, 0x19, 0x50, 0x99, 0x3f, 0x6f, 0x4b, 0x63, 0x38, 0xb0, 0xae, 0xe7,
- 0xf9, 0x8b, 0x88, 0xed, 0x95, 0x22, 0xb1, 0x21, 0x50, 0x1c, 0xd5, 0x98, 0x91, 0x0d, 0x45, 0xc4,
- 0xf6, 0x4a, 0xd1, 0x88, 0xdd, 0x75, 0x64, 0x4e, 0x76, 0x51, 0x1a, 0xfd, 0xa7, 0x8a, 0x1a, 0x6d,
- 0x16, 0xde, 0x0f, 0x62, 0xfe, 0x40, 0x7e, 0xb6, 0xfb, 0x98, 0xe2, 0x1e, 0xd3, 0x57, 0x50, 0x95,
- 0x41, 0x2a, 0x3a, 0x2a, 0x3d, 0x7a, 0xea, 0x3f, 0xfd, 0x01, 0xaa, 0x8b, 0x2f, 0xc0, 0xcf, 0x80,
- 0xc6, 0x24, 0x50, 0x7e, 0x9c, 0x27, 0x03, 0x4b, 0xfb, 0x73, 0x60, 0x6d, 0x84, 0x31, 0x8f, 0x1e,
- 0x76, 0x9c, 0x2e, 0xe9, 0xb9, 0x5d, 0xc2, 0x7a, 0x84, 0xa9, 0x3f, 0x2d, 0x16, 0x1c, 0xb9, 0xfc,
- 0x51, 0x06, 0xcc, 0xf9, 0x34, 0xe5, 0x1e, 0x12, 0x88, 0x7d, 0x49, 0xd0, 0xbf, 0x42, 0xd7, 0x24,
- 0x90, 0x47, 0x14, 0x58, 0x44, 0x92, 0x40, 0xbd, 0xc2, 0x69, 0x98, 0xf7, 0xa0, 0xeb, 0x2d, 0x0a,
- 0xca, 0x97, 0x05, 0x44, 0xf8, 0xa4, 0xd0, 0xc7, 0x34, 0xf0, 0x3b, 0x38, 0x0d, 0xd4, 0x8b, 0x9e,
- 0x96, 0x89, 0x72, 0xc4, 0x2e, 0x4e, 0x03, 0xdd, 0x46, 0xb5, 0x7e, 0x14, 0x73, 0x48, 0x62, 0xc6,
- 0x8d, 0xab, 0xeb, 0x73, 0x9b, 0xb5, 0xdd, 0x79, 0x81, 0xf3, 0x9e, 0x2d, 0x8b, 0x5a, 0x58, 0x82,
- 0x59, 0xe4, 0x1f, 0x52, 0xdc, 0x15, 0x33, 0xc2, 0xa8, 0xce, 0x56, 0x8b, 0xa4, 0xec, 0x29, 0x88,
- 0xfe, 0x05, 0x7a, 0x3d, 0xc7, 0xf6, 0xe3, 0x34, 0x20, 0x7d, 0xe3, 0xb5, 0x99, 0x9a, 0x5e, 0x97,
- 0x8c, 0xaf, 0x25, 0x42, 0xf7, 0xd1, 0x72, 0x2f, 0x4e, 0x7d, 0xf9, 0x89, 0x8b, 0x77, 0x59, 0xa0,
- 0x17, 0x66, 0xf2, 0x7b, 0xa3, 0x17, 0xa7, 0x07, 0x02, 0xb5, 0x0f, 0x54, 0x25, 0xf8, 0x0e, 0x2d,
- 0xf3, 0x3e, 0xce, 0xfc, 0x84, 0x90, 0xa3, 0x0e, 0xee, 0x1e, 0x15, 0x09, 0x6a, 0x33, 0x79, 0xd7,
- 0x05, 0xeb, 0x33, 0x85, 0x52, 0x19, 0xda, 0x08, 0xc9, 0x12, 0x08, 0x07, 0xca, 0x0c, 0x34, 0x13,
- 0xb7, 0x26, 0x8c, 0x4b, 0x80, 0xfe, 0x2d, 0x6a, 0x94, 0x07, 0xde, 0x3f, 0x04, 0x39, 0x69, 0x62,
- 0x62, 0xd4, 0x67, 0x6b, 0x48, 0x89, 0xda, 0x03, 0x31, 0x1c, 0x62, 0x62, 0x1f, 0xa0, 0x5b, 0x13,
- 0xce, 0x59, 0x71, 0x0e, 0xf5, 0x0f, 0x11, 0x4a, 0xa1, 0xef, 0x67, 0x72, 0x55, 0x9e, 0xb9, 0xfa,
- 0x8e, 0xe1, 0x8c, 0x5f, 0x50, 0x8e, 0xda, 0x55, 0x4b, 0xa1, 0x9f, 0x3f, 0xee, 0xfc, 0x74, 0x15,
- 0xcd, 0xb5, 0x59, 0xa8, 0xff, 0xaa, 0xa1, 0xb5, 0x97, 0x5e, 0x32, 0xdb, 0x17, 0x69, 0xaf, 0x18,
- 0xf3, 0xcd, 0x8f, 0xa6, 0xde, 0x52, 0xce, 0x15, 0xf3, 0xfb, 0xdf, 0xff, 0x7e, 0x7c, 0xc5, 0xb0,
- 0x57, 0xdc, 0xe7, 0xaf, 0xc7, 0x4c, 0xb9, 0x39, 0xd5, 0xd0, 0xea, 0x8b, 0xaf, 0x0d, 0xe7, 0xf2,
- 0x89, 0x85, 0xbe, 0xf9, 0xc1, 0x74, 0xfa, 0xd2, 0xe5, 0x2d, 0xe9, 0xf2, 0xa6, 0xdd, 0x18, 0x73,
- 0x29, 0x2d, 0xfe, 0xa2, 0xa1, 0xc6, 0xa4, 0x01, 0xbe, 0x39, 0x31, 0xd9, 0x04, 0x65, 0xf3, 0xbd,
- 0xcb, 0x2a, 0x4b, 0x43, 0x1b, 0xd2, 0xd0, 0xba, 0x6d, 0x8e, 0x19, 0xca, 0x2f, 0xaf, 0x56, 0x31,
- 0xe2, 0xf5, 0xc7, 0x1a, 0x5a, 0xba, 0x30, 0xb3, 0xdf, 0x9e, 0x98, 0x6e, 0x5c, 0xd6, 0x6c, 0x5d,
- 0x4a, 0x56, 0x5a, 0xda, 0x92, 0x96, 0x6e, 0xdb, 0x6f, 0x8e, 0x59, 0x82, 0x20, 0xe6, 0xad, 0xfc,
- 0xb9, 0x95, 0x7f, 0xb6, 0xbb, 0x7b, 0x4f, 0xce, 0x4c, 0xed, 0xe9, 0x99, 0xa9, 0xfd, 0x75, 0x66,
- 0x6a, 0x3f, 0x9f, 0x9b, 0x95, 0xa7, 0xe7, 0x66, 0xe5, 0x8f, 0x73, 0xb3, 0xf2, 0xcd, 0xbb, 0x23,
- 0x07, 0xe7, 0x73, 0x89, 0xb9, 0x1b, 0xe1, 0x38, 0x2d, 0x90, 0x27, 0x05, 0x54, 0x1e, 0xa1, 0x4e,
- 0x55, 0xfe, 0x74, 0x7a, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x67, 0xca, 0xa5, 0x9a, 0xbc,
- 0x09, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// MsgClient is the client API for Msg service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type MsgClient interface {
- // AggregateExchangeRatePrevote defines a method for submitting
- // aggregate exchange rate prevote
- AggregateExchangeRatePrevote(ctx context.Context, in *MsgAggregateExchangeRatePrevote, opts ...grpc.CallOption) (*MsgAggregateExchangeRatePrevoteResponse, error)
- // AggregateExchangeRateVote defines a method for submitting
- // aggregate exchange rate vote
- AggregateExchangeRateVote(ctx context.Context, in *MsgAggregateExchangeRateVote, opts ...grpc.CallOption) (*MsgAggregateExchangeRateVoteResponse, error)
- // DelegateFeedConsent defines a method for delegating oracle voting rights
- // to another address known as a price feeder.
- // See https://github.com/NibiruChain/pricefeeder.
- DelegateFeedConsent(ctx context.Context, in *MsgDelegateFeedConsent, opts ...grpc.CallOption) (*MsgDelegateFeedConsentResponse, error)
- EditOracleParams(ctx context.Context, in *MsgEditOracleParams, opts ...grpc.CallOption) (*MsgEditOracleParamsResponse, error)
-}
-
-type msgClient struct {
- cc grpc1.ClientConn
-}
-
-func NewMsgClient(cc grpc1.ClientConn) MsgClient {
- return &msgClient{cc}
-}
-
-func (c *msgClient) AggregateExchangeRatePrevote(ctx context.Context, in *MsgAggregateExchangeRatePrevote, opts ...grpc.CallOption) (*MsgAggregateExchangeRatePrevoteResponse, error) {
- out := new(MsgAggregateExchangeRatePrevoteResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Msg/AggregateExchangeRatePrevote", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) AggregateExchangeRateVote(ctx context.Context, in *MsgAggregateExchangeRateVote, opts ...grpc.CallOption) (*MsgAggregateExchangeRateVoteResponse, error) {
- out := new(MsgAggregateExchangeRateVoteResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Msg/AggregateExchangeRateVote", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) DelegateFeedConsent(ctx context.Context, in *MsgDelegateFeedConsent, opts ...grpc.CallOption) (*MsgDelegateFeedConsentResponse, error) {
- out := new(MsgDelegateFeedConsentResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Msg/DelegateFeedConsent", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) EditOracleParams(ctx context.Context, in *MsgEditOracleParams, opts ...grpc.CallOption) (*MsgEditOracleParamsResponse, error) {
- out := new(MsgEditOracleParamsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Msg/EditOracleParams", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// MsgServer is the server API for Msg service.
-type MsgServer interface {
- // AggregateExchangeRatePrevote defines a method for submitting
- // aggregate exchange rate prevote
- AggregateExchangeRatePrevote(context.Context, *MsgAggregateExchangeRatePrevote) (*MsgAggregateExchangeRatePrevoteResponse, error)
- // AggregateExchangeRateVote defines a method for submitting
- // aggregate exchange rate vote
- AggregateExchangeRateVote(context.Context, *MsgAggregateExchangeRateVote) (*MsgAggregateExchangeRateVoteResponse, error)
- // DelegateFeedConsent defines a method for delegating oracle voting rights
- // to another address known as a price feeder.
- // See https://github.com/NibiruChain/pricefeeder.
- DelegateFeedConsent(context.Context, *MsgDelegateFeedConsent) (*MsgDelegateFeedConsentResponse, error)
- EditOracleParams(context.Context, *MsgEditOracleParams) (*MsgEditOracleParamsResponse, error)
-}
-
-// UnimplementedMsgServer can be embedded to have forward compatible implementations.
-type UnimplementedMsgServer struct {
-}
-
-func (*UnimplementedMsgServer) AggregateExchangeRatePrevote(ctx context.Context, req *MsgAggregateExchangeRatePrevote) (*MsgAggregateExchangeRatePrevoteResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method AggregateExchangeRatePrevote not implemented")
-}
-func (*UnimplementedMsgServer) AggregateExchangeRateVote(ctx context.Context, req *MsgAggregateExchangeRateVote) (*MsgAggregateExchangeRateVoteResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method AggregateExchangeRateVote not implemented")
-}
-func (*UnimplementedMsgServer) DelegateFeedConsent(ctx context.Context, req *MsgDelegateFeedConsent) (*MsgDelegateFeedConsentResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method DelegateFeedConsent not implemented")
-}
-func (*UnimplementedMsgServer) EditOracleParams(ctx context.Context, req *MsgEditOracleParams) (*MsgEditOracleParamsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EditOracleParams not implemented")
-}
-
-func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
- s.RegisterService(&_Msg_serviceDesc, srv)
-}
-
-func _Msg_AggregateExchangeRatePrevote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgAggregateExchangeRatePrevote)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).AggregateExchangeRatePrevote(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Msg/AggregateExchangeRatePrevote",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).AggregateExchangeRatePrevote(ctx, req.(*MsgAggregateExchangeRatePrevote))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_AggregateExchangeRateVote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgAggregateExchangeRateVote)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).AggregateExchangeRateVote(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Msg/AggregateExchangeRateVote",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).AggregateExchangeRateVote(ctx, req.(*MsgAggregateExchangeRateVote))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_DelegateFeedConsent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgDelegateFeedConsent)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).DelegateFeedConsent(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Msg/DelegateFeedConsent",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).DelegateFeedConsent(ctx, req.(*MsgDelegateFeedConsent))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_EditOracleParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgEditOracleParams)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).EditOracleParams(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.oracle.v1.Msg/EditOracleParams",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).EditOracleParams(ctx, req.(*MsgEditOracleParams))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Msg_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.oracle.v1.Msg",
- HandlerType: (*MsgServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "AggregateExchangeRatePrevote",
- Handler: _Msg_AggregateExchangeRatePrevote_Handler,
- },
- {
- MethodName: "AggregateExchangeRateVote",
- Handler: _Msg_AggregateExchangeRateVote_Handler,
- },
- {
- MethodName: "DelegateFeedConsent",
- Handler: _Msg_DelegateFeedConsent_Handler,
- },
- {
- MethodName: "EditOracleParams",
- Handler: _Msg_EditOracleParams_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/oracle/v1/tx.proto",
-}
-
-func (m *MsgAggregateExchangeRatePrevote) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgAggregateExchangeRatePrevote) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgAggregateExchangeRatePrevote) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Validator) > 0 {
- i -= len(m.Validator)
- copy(dAtA[i:], m.Validator)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Validator)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.Feeder) > 0 {
- i -= len(m.Feeder)
- copy(dAtA[i:], m.Feeder)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Feeder)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Hash) > 0 {
- i -= len(m.Hash)
- copy(dAtA[i:], m.Hash)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Hash)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgAggregateExchangeRatePrevoteResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgAggregateExchangeRatePrevoteResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgAggregateExchangeRatePrevoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgAggregateExchangeRateVote) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgAggregateExchangeRateVote) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgAggregateExchangeRateVote) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Validator) > 0 {
- i -= len(m.Validator)
- copy(dAtA[i:], m.Validator)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Validator)))
- i--
- dAtA[i] = 0x22
- }
- if len(m.Feeder) > 0 {
- i -= len(m.Feeder)
- copy(dAtA[i:], m.Feeder)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Feeder)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.ExchangeRates) > 0 {
- i -= len(m.ExchangeRates)
- copy(dAtA[i:], m.ExchangeRates)
- i = encodeVarintTx(dAtA, i, uint64(len(m.ExchangeRates)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Salt) > 0 {
- i -= len(m.Salt)
- copy(dAtA[i:], m.Salt)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Salt)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgAggregateExchangeRateVoteResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgAggregateExchangeRateVoteResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgAggregateExchangeRateVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgDelegateFeedConsent) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgDelegateFeedConsent) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgDelegateFeedConsent) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Delegate) > 0 {
- i -= len(m.Delegate)
- copy(dAtA[i:], m.Delegate)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Delegate)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Operator) > 0 {
- i -= len(m.Operator)
- copy(dAtA[i:], m.Operator)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Operator)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgDelegateFeedConsentResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgDelegateFeedConsentResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgDelegateFeedConsentResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgEditOracleParams) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgEditOracleParams) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgEditOracleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.ValidatorFeeRatio != nil {
- {
- size := m.ValidatorFeeRatio.Size()
- i -= size
- if _, err := m.ValidatorFeeRatio.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x5a
- }
- if m.MinVoters != nil {
- {
- size := m.MinVoters.Size()
- i -= size
- if _, err := m.MinVoters.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x52
- }
- if m.TwapLookbackWindow != nil {
- {
- size := m.TwapLookbackWindow.Size()
- i -= size
- if _, err := m.TwapLookbackWindow.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x4a
- }
- if m.MinValidPerWindow != nil {
- {
- size := m.MinValidPerWindow.Size()
- i -= size
- if _, err := m.MinValidPerWindow.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x42
- }
- if m.SlashWindow != nil {
- {
- size := m.SlashWindow.Size()
- i -= size
- if _, err := m.SlashWindow.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x3a
- }
- if m.SlashFraction != nil {
- {
- size := m.SlashFraction.Size()
- i -= size
- if _, err := m.SlashFraction.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x32
- }
- if len(m.Whitelist) > 0 {
- for iNdEx := len(m.Whitelist) - 1; iNdEx >= 0; iNdEx-- {
- i -= len(m.Whitelist[iNdEx])
- copy(dAtA[i:], m.Whitelist[iNdEx])
- i = encodeVarintTx(dAtA, i, uint64(len(m.Whitelist[iNdEx])))
- i--
- dAtA[i] = 0x2a
- }
- }
- if m.RewardBand != nil {
- {
- size := m.RewardBand.Size()
- i -= size
- if _, err := m.RewardBand.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x22
- }
- if m.VoteThreshold != nil {
- {
- size := m.VoteThreshold.Size()
- i -= size
- if _, err := m.VoteThreshold.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- if m.VotePeriod != nil {
- {
- size := m.VotePeriod.Size()
- i -= size
- if _, err := m.VotePeriod.MarshalTo(dAtA[i:]); err != nil {
- return 0, err
- }
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgEditOracleParamsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgEditOracleParamsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgEditOracleParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.NewParams != nil {
- {
- size, err := m.NewParams.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
- offset -= sovTx(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *MsgAggregateExchangeRatePrevote) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Hash)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.Feeder)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.Validator)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgAggregateExchangeRatePrevoteResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgAggregateExchangeRateVote) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Salt)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.ExchangeRates)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.Feeder)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.Validator)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgAggregateExchangeRateVoteResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgDelegateFeedConsent) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Operator)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.Delegate)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgDelegateFeedConsentResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgEditOracleParams) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if m.VotePeriod != nil {
- l = m.VotePeriod.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.VoteThreshold != nil {
- l = m.VoteThreshold.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.RewardBand != nil {
- l = m.RewardBand.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if len(m.Whitelist) > 0 {
- for _, s := range m.Whitelist {
- l = len(s)
- n += 1 + l + sovTx(uint64(l))
- }
- }
- if m.SlashFraction != nil {
- l = m.SlashFraction.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.SlashWindow != nil {
- l = m.SlashWindow.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.MinValidPerWindow != nil {
- l = m.MinValidPerWindow.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.TwapLookbackWindow != nil {
- l = m.TwapLookbackWindow.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.MinVoters != nil {
- l = m.MinVoters.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- if m.ValidatorFeeRatio != nil {
- l = m.ValidatorFeeRatio.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgEditOracleParamsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.NewParams != nil {
- l = m.NewParams.Size()
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func sovTx(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozTx(x uint64) (n int) {
- return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *MsgAggregateExchangeRatePrevote) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgAggregateExchangeRatePrevote: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgAggregateExchangeRatePrevote: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Hash = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Feeder", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Feeder = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Validator = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgAggregateExchangeRatePrevoteResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgAggregateExchangeRatePrevoteResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgAggregateExchangeRatePrevoteResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgAggregateExchangeRateVote) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgAggregateExchangeRateVote: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgAggregateExchangeRateVote: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Salt", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Salt = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRates", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ExchangeRates = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Feeder", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Feeder = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Validator = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgAggregateExchangeRateVoteResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgAggregateExchangeRateVoteResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgAggregateExchangeRateVoteResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgDelegateFeedConsent) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgDelegateFeedConsent: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgDelegateFeedConsent: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Operator", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Operator = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Delegate", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Delegate = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgDelegateFeedConsentResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgDelegateFeedConsentResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgDelegateFeedConsentResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgEditOracleParams: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgEditOracleParams: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field VotePeriod", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Int
- m.VotePeriod = &v
- if err := m.VotePeriod.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field VoteThreshold", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Dec
- m.VoteThreshold = &v
- if err := m.VoteThreshold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RewardBand", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Dec
- m.RewardBand = &v
- if err := m.RewardBand.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Whitelist", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Whitelist = append(m.Whitelist, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field SlashFraction", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Dec
- m.SlashFraction = &v
- if err := m.SlashFraction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field SlashWindow", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Int
- m.SlashWindow = &v
- if err := m.SlashWindow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field MinValidPerWindow", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Dec
- m.MinValidPerWindow = &v
- if err := m.MinValidPerWindow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 9:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field TwapLookbackWindow", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Int
- m.TwapLookbackWindow = &v
- if err := m.TwapLookbackWindow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 10:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field MinVoters", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Int
- m.MinVoters = &v
- if err := m.MinVoters.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 11:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ValidatorFeeRatio", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- var v github_com_cosmos_cosmos_sdk_types.Dec
- m.ValidatorFeeRatio = &v
- if err := m.ValidatorFeeRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgEditOracleParamsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgEditOracleParamsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgEditOracleParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field NewParams", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.NewParams == nil {
- m.NewParams = &Params{}
- }
- if err := m.NewParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipTx(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthTx
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupTx
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthTx
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowTx = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/oracle/types/tx.pb.gw.go b/x/oracle/types/tx.pb.gw.go
deleted file mode 100644
index 5c9ddb424..000000000
--- a/x/oracle/types/tx.pb.gw.go
+++ /dev/null
@@ -1,420 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: nibiru/oracle/v1/tx.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-var (
- filter_Msg_AggregateExchangeRatePrevote_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_AggregateExchangeRatePrevote_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgAggregateExchangeRatePrevote
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_AggregateExchangeRatePrevote_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.AggregateExchangeRatePrevote(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_AggregateExchangeRatePrevote_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgAggregateExchangeRatePrevote
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_AggregateExchangeRatePrevote_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.AggregateExchangeRatePrevote(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Msg_AggregateExchangeRateVote_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_AggregateExchangeRateVote_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgAggregateExchangeRateVote
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_AggregateExchangeRateVote_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.AggregateExchangeRateVote(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_AggregateExchangeRateVote_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgAggregateExchangeRateVote
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_AggregateExchangeRateVote_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.AggregateExchangeRateVote(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Msg_DelegateFeedConsent_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_DelegateFeedConsent_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgDelegateFeedConsent
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_DelegateFeedConsent_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.DelegateFeedConsent(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_DelegateFeedConsent_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgDelegateFeedConsent
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_DelegateFeedConsent_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.DelegateFeedConsent(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Msg_EditOracleParams_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_EditOracleParams_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgEditOracleParams
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_EditOracleParams_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.EditOracleParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_EditOracleParams_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgEditOracleParams
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_EditOracleParams_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.EditOracleParams(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux".
-// UnaryRPC :call MsgServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead.
-func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error {
-
- mux.Handle("POST", pattern_Msg_AggregateExchangeRatePrevote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_AggregateExchangeRatePrevote_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_AggregateExchangeRatePrevote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_AggregateExchangeRateVote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_AggregateExchangeRateVote_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_AggregateExchangeRateVote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_DelegateFeedConsent_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_DelegateFeedConsent_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_DelegateFeedConsent_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_EditOracleParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_EditOracleParams_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_EditOracleParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterMsgHandler(ctx, mux, conn)
-}
-
-// RegisterMsgHandler registers the http handlers for service Msg to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn))
-}
-
-// RegisterMsgHandlerClient registers the http handlers for service Msg
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "MsgClient" to call the correct interceptors.
-func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error {
-
- mux.Handle("POST", pattern_Msg_AggregateExchangeRatePrevote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_AggregateExchangeRatePrevote_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_AggregateExchangeRatePrevote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_AggregateExchangeRateVote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_AggregateExchangeRateVote_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_AggregateExchangeRateVote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_DelegateFeedConsent_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_DelegateFeedConsent_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_DelegateFeedConsent_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_EditOracleParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_EditOracleParams_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_EditOracleParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Msg_AggregateExchangeRatePrevote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "oracle", "prevote"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Msg_AggregateExchangeRateVote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "oracle", "vote"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Msg_DelegateFeedConsent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "oracle", "feeder-delegate"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Msg_EditOracleParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "oracle", "edit-oracle-params"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Msg_AggregateExchangeRatePrevote_0 = runtime.ForwardResponseMessage
-
- forward_Msg_AggregateExchangeRateVote_0 = runtime.ForwardResponseMessage
-
- forward_Msg_DelegateFeedConsent_0 = runtime.ForwardResponseMessage
-
- forward_Msg_EditOracleParams_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/oracle/types/vote.go b/x/oracle/types/vote.go
deleted file mode 100644
index 5a74eecc8..000000000
--- a/x/oracle/types/vote.go
+++ /dev/null
@@ -1,157 +0,0 @@
-package types
-
-import (
- "fmt"
- "strings"
-
- "cosmossdk.io/math"
-
- "github.com/NibiruChain/nibiru/x/common/asset"
- "github.com/NibiruChain/nibiru/x/common/set"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-const (
- ExchangeRateTuplesSeparator = "|"
- ExchangeRateTupleStringPrefix = '('
- ExchangeRateTupleStringSuffix = ')'
- ExchangeRateTuplePairRateSeparator = ","
-)
-
-// NewAggregateExchangeRatePrevote returns AggregateExchangeRatePrevote object
-func NewAggregateExchangeRatePrevote(hash AggregateVoteHash, voter sdk.ValAddress, submitBlock uint64) AggregateExchangeRatePrevote {
- return AggregateExchangeRatePrevote{
- Hash: hash.String(),
- Voter: voter.String(),
- SubmitBlock: submitBlock,
- }
-}
-
-// NewAggregateExchangeRateVote creates a AggregateExchangeRateVote instance
-func NewAggregateExchangeRateVote(exchangeRateTuples ExchangeRateTuples, voter sdk.ValAddress) AggregateExchangeRateVote {
- return AggregateExchangeRateVote{
- ExchangeRateTuples: exchangeRateTuples,
- Voter: voter.String(),
- }
-}
-
-// NewExchangeRateTuple creates a ExchangeRateTuple instance
-func NewExchangeRateTuple(pair asset.Pair, exchangeRate sdk.Dec) ExchangeRateTuple {
- return ExchangeRateTuple{
- pair,
- exchangeRate,
- }
-}
-
-// ToString converts the ExchangeRateTuple to the vote string.
-func (m ExchangeRateTuple) ToString() (string, error) {
- err := m.Pair.Validate()
- if err != nil {
- return "", err
- }
-
- return fmt.Sprintf(
- "%c%s%s%s%c",
- ExchangeRateTupleStringPrefix,
- m.Pair,
- ExchangeRateTuplePairRateSeparator,
- m.ExchangeRate.String(),
- ExchangeRateTupleStringSuffix,
- ), nil
-}
-
-// NewExchangeRateTupleFromString populates ExchangeRateTuple from a string, fails if the string is of invalid format.
-func NewExchangeRateTupleFromString(s string) (ExchangeRateTuple, error) {
- // strip parentheses
- if len(s) <= 2 {
- return ExchangeRateTuple{}, fmt.Errorf("invalid string length: %v", len(s))
- }
-
- if s[0] != ExchangeRateTupleStringPrefix || s[len(s)-1] != ExchangeRateTupleStringSuffix {
- return ExchangeRateTuple{}, fmt.Errorf("invalid ExchangeRateTuple delimiters, start is expected with '(', end with ')', got: %s", s)
- }
-
- stripParentheses := s[1 : len(s)-1]
- split := strings.Split(stripParentheses, ExchangeRateTuplePairRateSeparator)
- if len(split) != 2 {
- return ExchangeRateTuple{}, fmt.Errorf("invalid ExchangeRateTuple format")
- }
-
- pair, err := asset.TryNewPair(split[0])
- if err != nil {
- return ExchangeRateTuple{}, fmt.Errorf("invalid pair definition %s: %w", split[0], err)
- }
-
- dec, err := math.LegacyNewDecFromStr(split[1])
- if err != nil {
- return ExchangeRateTuple{}, fmt.Errorf("invalid decimal %s: %w", split[1], err)
- }
-
- return ExchangeRateTuple{
- Pair: pair,
- ExchangeRate: dec,
- }, nil
-}
-
-// ExchangeRateTuples - array of ExchangeRateTuple
-type ExchangeRateTuples []ExchangeRateTuple
-
-func (tuples ExchangeRateTuples) ToMap() (exchangeRateMap map[asset.Pair]sdk.Dec) {
- exchangeRateMap = make(map[asset.Pair]sdk.Dec)
- for _, tuple := range tuples {
- exchangeRateMap[tuple.Pair] = tuple.ExchangeRate
- }
- return exchangeRateMap
-}
-
-func NewExchangeRateTuplesFromString(s string) (ExchangeRateTuples, error) {
- stringTuples := strings.Split(s, ExchangeRateTuplesSeparator)
-
- tuples := make(ExchangeRateTuples, len(stringTuples))
-
- duplicates := make(set.Set[asset.Pair], len(stringTuples))
-
- for i, stringTuple := range stringTuples {
- exchangeRate, err := NewExchangeRateTupleFromString(stringTuple)
- if err != nil {
- return []ExchangeRateTuple{}, fmt.Errorf("invalid ExchangeRateTuple at index %d: %w", i, err)
- }
-
- // check duplicates
- if _, ok := duplicates[exchangeRate.Pair]; ok {
- return []ExchangeRateTuple{}, fmt.Errorf("found duplicate at index %d: %s", i, exchangeRate.Pair)
- } else {
- duplicates[exchangeRate.Pair] = struct{}{}
- }
-
- // insert exchange rate into the tuple
- tuples[i] = exchangeRate
- }
-
- return tuples, nil
-}
-
-func (tuples ExchangeRateTuples) ToString() (string, error) {
- tuplesStringSlice := make([]string, len(tuples))
- for i, r := range tuples {
- rStr, err := r.ToString()
- if err != nil {
- return "", fmt.Errorf("invalid ExchangeRateTuple at index %d: %w", i, err)
- }
-
- tuplesStringSlice[i] = rStr
- }
-
- return strings.Join(tuplesStringSlice, "|"), nil
-}
-
-// ParseExchangeRateTuples ExchangeRateTuple parser
-func ParseExchangeRateTuples(tuplesStr string) (ExchangeRateTuples, error) {
- tuples, err := NewExchangeRateTuplesFromString(tuplesStr)
- if err != nil {
- return nil, err
- }
-
- return tuples, nil
-}
diff --git a/x/oracle/types/vote_test.go b/x/oracle/types/vote_test.go
deleted file mode 100644
index d95f26fa6..000000000
--- a/x/oracle/types/vote_test.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package types_test
-
-import (
- "testing"
-
- "cosmossdk.io/math"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/oracle/types"
-)
-
-func TestExchangeRateTuples_ToString(t *testing.T) {
- t.Run("inverse", func(t *testing.T) {
- tuples := types.ExchangeRateTuples{
- {
- Pair: "BTC:USD",
- ExchangeRate: math.LegacyMustNewDecFromStr("40000.00"),
- },
-
- {
- Pair: "ETH:USD",
- ExchangeRate: math.LegacyMustNewDecFromStr("4000.00"),
- },
- }
-
- tuplesStr, err := tuples.ToString()
- require.NoError(t, err)
-
- parsedTuples, err := types.NewExchangeRateTuplesFromString(tuplesStr)
- require.NoError(t, err)
-
- require.Equal(t, tuples, parsedTuples)
- })
-
- t.Run("check duplicates", func(t *testing.T) {
- tuples := types.ExchangeRateTuples{
- {
- Pair: "BTC:USD",
- ExchangeRate: math.LegacyMustNewDecFromStr("40000.00"),
- },
-
- {
- Pair: "BTC:USD",
- ExchangeRate: math.LegacyMustNewDecFromStr("4000.00"),
- },
- }
-
- tuplesStr, err := tuples.ToString()
- require.NoError(t, err)
-
- _, err = types.NewExchangeRateTuplesFromString(tuplesStr)
- require.ErrorContains(t, err, "found duplicate")
- })
-}
-
-func TestExchangeRateTuple(t *testing.T) {
- t.Run("inverse", func(t *testing.T) {
- exchangeRate := types.ExchangeRateTuple{
- Pair: "BTC:USD",
- ExchangeRate: math.LegacyMustNewDecFromStr("40000.00"),
- }
- exchangeRateStr, err := exchangeRate.ToString()
- require.NoError(t, err)
-
- parsedExchangeRate, err := types.NewExchangeRateTupleFromString(exchangeRateStr)
- require.NoError(t, err)
-
- require.Equal(t, exchangeRate, parsedExchangeRate)
- })
-
- t.Run("invalid size", func(t *testing.T) {
- _, err := types.NewExchangeRateTupleFromString("00")
- require.ErrorContains(t, err, "invalid string length")
- })
-
- t.Run("invalid delimiters", func(t *testing.T) {
- _, err := types.NewExchangeRateTupleFromString("|1000.0,nibi:usd|")
- require.ErrorContains(t, err, "invalid ExchangeRateTuple delimiters")
- })
-
- t.Run("invalid format", func(t *testing.T) {
- _, err := types.NewExchangeRateTupleFromString("(1000.0,nibi:usd,1000.0)")
- require.ErrorContains(t, err, "invalid ExchangeRateTuple format")
- })
-}
diff --git a/x/sudo/cli/cli.go b/x/sudo/cli/cli.go
deleted file mode 100644
index 3e53138c7..000000000
--- a/x/sudo/cli/cli.go
+++ /dev/null
@@ -1,190 +0,0 @@
-package cli
-
-import (
- "fmt"
- "os"
- "strings"
-
- "github.com/NibiruChain/nibiru/x/sudo/types"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/client/tx"
- "github.com/cosmos/cosmos-sdk/version"
-
- "github.com/spf13/cobra"
-)
-
-// GetTxCmd returns a cli command for this module's transactions
-func GetTxCmd() *cobra.Command {
- txCmd := &cobra.Command{
- Use: types.ModuleName,
- Short: fmt.Sprintf("x/%s transaction subcommands", types.ModuleName),
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- // Add subcommands
- txCmd.AddCommand(
- CmdEditSudoers(),
- CmdChangeRoot(),
- )
-
- return txCmd
-}
-
-// GetQueryCmd returns a cli command for this module's queries
-func GetQueryCmd() *cobra.Command {
- moduleQueryCmd := &cobra.Command{
- Use: types.ModuleName,
- Short: fmt.Sprintf(
- "Query commands for the x/%s module", types.ModuleName),
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- // Add subcommands
- cmds := []*cobra.Command{
- CmdQuerySudoers(),
- }
- for _, cmd := range cmds {
- moduleQueryCmd.AddCommand(cmd)
- }
-
- return moduleQueryCmd
-}
-
-// CmdEditSudoers is a terminal command corresponding to the EditSudoers
-// function of the sdk.Msg handler for x/sudo.
-func CmdEditSudoers() *cobra.Command {
- cmd := &cobra.Command{
- Use: "edit [edit-json]",
- Args: cobra.ExactArgs(1),
- Short: "Edit the x/sudo state (sudoers) by adding or removing contracts",
- Example: strings.TrimSpace(fmt.Sprintf(`
- Example:
- $ %s tx sudo edit --from=
- `, version.AppName)),
- Long: strings.TrimSpace(
- `Adds or removes contracts from the x/sudo state, giving the
- contracts permissioned access to certain bindings in x/wasm.
-
- The edit.json for 'EditSudoers' is of the form:
- {
- "action": "add_contracts",
- "contracts": "..."
- }
-
- - Valid action types: "add_contracts", "remove_contracts"
- `),
- RunE: func(cmd *cobra.Command, args []string) (err error) {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- msg := new(types.MsgEditSudoers)
-
- // marshals contents into the proto.Message to which 'msg' points.
- contents, err := os.ReadFile(args[0])
- if err != nil {
- return err
- }
- if err = clientCtx.Codec.UnmarshalJSON(contents, msg); err != nil {
- return err
- }
-
- // Parse the message sender
- from := clientCtx.GetFromAddress()
- msg.Sender = from.String()
-
- if err = msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
-
- return cmd
-}
-
-// CmdChangeRoot is a terminal command corresponding to the ChangeRoot
-func CmdChangeRoot() *cobra.Command {
- cmd := &cobra.Command{
- Use: "change-root [new-root-address]",
- Args: cobra.ExactArgs(1),
- Short: "Change the root address of the x/sudo state",
- Example: strings.TrimSpace(fmt.Sprintf(`
- Example:
- $ %s tx sudo change-root --from=
- `, version.AppName)),
- Long: strings.TrimSpace(
- `Change the root address of the x/sudo state, giving the
- new address, should be executed by the current root address.
- `),
- RunE: func(cmd *cobra.Command, args []string) (err error) {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- msg := new(types.MsgChangeRoot)
-
- // marshals contents into the proto.Message to which 'msg' points.
- root := args[0]
- if err != nil {
- return err
- }
-
- // Parse the message sender
- from := clientCtx.GetFromAddress()
- msg.Sender = from.String()
- msg.NewRoot = root
-
- if err = msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
-
- return cmd
-}
-
-func CmdQuerySudoers() *cobra.Command {
- cmd := &cobra.Command{
- Use: "state",
- Short: "displays the internal state (sudoers) of the x/sudo module",
- Args: cobra.NoArgs,
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
-
- queryClient := types.NewQueryClient(clientCtx)
-
- req := new(types.QuerySudoersRequest)
- resp, err := queryClient.QuerySudoers(
- cmd.Context(), req,
- )
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(resp)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
diff --git a/x/sudo/cli/cli_test.go b/x/sudo/cli/cli_test.go
deleted file mode 100644
index dc27bd6e2..000000000
--- a/x/sudo/cli/cli_test.go
+++ /dev/null
@@ -1,276 +0,0 @@
-package cli_test
-
-import (
- "fmt"
- "os"
- "strings"
- "testing"
-
- "github.com/NibiruChain/nibiru/x/sudo/types"
-
- "github.com/cosmos/gogoproto/jsonpb"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- "github.com/stretchr/testify/suite"
-
- "github.com/cosmos/cosmos-sdk/crypto"
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
- sdktestutil "github.com/cosmos/cosmos-sdk/testutil"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/common/set"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- testutilcli "github.com/NibiruChain/nibiru/x/common/testutil/cli"
- "github.com/NibiruChain/nibiru/x/common/testutil/genesis"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/sudo/cli"
-)
-
-// ———————————————————————————————————————————————————————————————————
-// MsgEditSudoersPlus
-// ———————————————————————————————————————————————————————————————————
-
-// MsgEditSudoersPlus is a wrapper struct to extend the default MsgEditSudoers
-// type with convenience functions
-type MsgEditSudoersPlus struct {
- types.MsgEditSudoers
-}
-
-// ToJson converts the message into a json string and saves it in a temporary
-// file, returning the json bytes and file name if done successfully.
-func (msg MsgEditSudoersPlus) ToJson(t *testing.T) (fileJsonBz []byte, fileName string) {
- require.NoError(t, msg.ValidateBasic())
-
- // msgJsonStr showcases a valid example for the cmd args json file.
- msgJsonStr := fmt.Sprintf(`
- {
- "action": "%v",
- "contracts": ["%s"],
- "sender": "%v"
- }
- `, msg.Action, strings.Join(msg.Contracts, `", "`), msg.Sender)
-
- t.Log("check the unmarshal json → proto")
- tempMsg := new(types.MsgEditSudoers)
- err := jsonpb.UnmarshalString(msgJsonStr, tempMsg)
- assert.NoErrorf(t, err, "DEBUG tempMsg: %v\njsonStr: %v", tempMsg, msgJsonStr)
-
- t.Log("save example json to a file")
- jsonFile := sdktestutil.WriteToNewTempFile(
- t, msgJsonStr,
- )
-
- fileName = jsonFile.Name()
- fileJsonBz, err = os.ReadFile(fileName)
- assert.NoError(t, err)
- return fileJsonBz, fileName
-}
-
-func (MsgEditSudoersPlus) Exec(
- network *testutilcli.Network,
- fileName string,
- from sdk.AccAddress,
-) (*sdk.TxResponse, error) {
- args := []string{
- fileName,
- }
- return network.ExecTxCmd(cli.CmdEditSudoers(), from, args)
-}
-
-type IntegrationSuite struct {
- suite.Suite
- cfg testutilcli.Config
- network *testutilcli.Network
- root Account
-}
-
-type Account struct {
- privKey cryptotypes.PrivKey
- addr sdk.AccAddress
- passphrase string
-}
-
-func TestSuite_IntegrationSuite_RunAll(t *testing.T) {
- suite.Run(t, new(IntegrationSuite))
-}
-
-// ———————————————————————————————————————————————————————————————————
-// IntegrationSuite - Setup
-// ———————————————————————————————————————————————————————————————————
-
-func (s *IntegrationSuite) SetupSuite() {
- testutil.BeforeIntegrationSuite(s.T())
- testapp.EnsureNibiruPrefix()
-
- genState := genesis.NewTestGenesisState(app.MakeEncodingConfig())
- genState, rootPrivKey, rootAddr := genesis.AddSudoGenesis(genState)
- s.root = Account{
- privKey: rootPrivKey,
- addr: rootAddr,
- passphrase: "secure-password",
- }
- homeDir := s.T().TempDir()
- s.cfg = testutilcli.BuildNetworkConfig(genState)
- network, err := testutilcli.New(s.T(), homeDir, s.cfg)
- s.Require().NoError(err)
-
- s.network = network
- s.FundRoot(s.root)
- s.AddRootToKeyring(s.root)
-}
-
-func (s *IntegrationSuite) FundRoot(root Account) {
- val := s.network.Validators[0]
- funds := sdk.NewCoins(
- sdk.NewInt64Coin(denoms.NIBI, 420*common.TO_MICRO),
- )
- feeDenom := denoms.NIBI
- s.NoError(testutilcli.FillWalletFromValidator(
- root.addr, funds, val, feeDenom,
- ))
-}
-
-func (s *IntegrationSuite) AddRootToKeyring(root Account) {
- s.T().Log("add the x/sudo root account to the clientCtx.Keyring")
- // Encrypt the x/sudo root account's private key to get its "armor"
- passphrase := root.passphrase
- privKey := root.privKey
- armor := crypto.EncryptArmorPrivKey(privKey, passphrase, privKey.Type())
- // Import this account to the keyring
- val := s.network.Validators[0]
- s.NoError(
- val.ClientCtx.Keyring.ImportPrivKey("root", armor, passphrase),
- )
-}
-
-// ———————————————————————————————————————————————————————————————————
-// IntegrationSuite - Tests
-// ———————————————————————————————————————————————————————————————————
-
-func (s *IntegrationSuite) TestCmdEditSudoers() {
- val := s.network.Validators[0]
-
- _, contractAddrs := testutil.PrivKeyAddressPairs(3)
- var contracts []string
- for _, addr := range contractAddrs {
- contracts = append(contracts, addr.String())
- }
-
- var sender sdk.AccAddress = s.root.addr
-
- pbMsg := types.MsgEditSudoers{
- Action: "add_contracts",
- Contracts: []string{contracts[0], contracts[1], contracts[2]},
- Sender: sender.String(),
- }
-
- msg := MsgEditSudoersPlus{pbMsg}
- jsonBz, fileName := msg.ToJson(s.T())
-
- s.T().Log("sending from the wrong address should fail.")
- wrongSender := testutil.AccAddress()
- msg.Sender = wrongSender.String()
- out, err := msg.Exec(s.network, fileName, wrongSender)
- s.Assert().Errorf(err, "out: %s\n", out)
- s.Contains(err.Error(), "key not found", "msg: %s\nout: %s", jsonBz, out)
-
- s.T().Log("happy - add_contracts exec tx")
- msg.Sender = sender.String()
- out, err = msg.Exec(s.network, fileName, sender)
- s.NoErrorf(err, "msg: %s\nout: %s", jsonBz, out)
-
- state, err := testutilcli.QuerySudoers(val.ClientCtx)
- s.NoError(err)
-
- gotRoot := state.Sudoers.Root
- s.Equal(s.root.addr.String(), gotRoot)
-
- gotContracts := set.New(state.Sudoers.Contracts...)
- s.Equal(len(contracts), gotContracts.Len())
- for _, contract := range contracts {
- s.True(gotContracts.Has(contract))
- }
-
- pbMsg = types.MsgEditSudoers{
- Action: "remove_contracts",
- Contracts: []string{contracts[1]},
- Sender: sender.String(),
- }
-
- msg = MsgEditSudoersPlus{pbMsg}
- jsonBz, fileName = msg.ToJson(s.T())
-
- s.T().Log("happy - remove_contracts exec tx")
- out, err = msg.Exec(s.network, fileName, sender)
- s.NoErrorf(err, "msg: %s\nout: %s", jsonBz, out)
-
- state, err = testutilcli.QuerySudoers(val.ClientCtx)
- s.NoError(err)
-
- gotRoot = state.Sudoers.Root
- s.Equal(s.root.addr.String(), gotRoot)
-
- wantContracts := []string{contracts[0], contracts[2]}
- gotContracts = set.New(state.Sudoers.Contracts...)
- s.Equal(len(wantContracts), gotContracts.Len())
- for _, contract := range wantContracts {
- s.True(gotContracts.Has(contract))
- }
-}
-
-func (s *IntegrationSuite) Test_ZCmdChangeRoot() {
- val := s.network.Validators[0]
-
- sudoers, err := testutilcli.QuerySudoers(val.ClientCtx)
- s.NoError(err)
- initialRoot := sudoers.Sudoers.Root
-
- newRoot := testutil.AccAddress()
- _, err = s.network.ExecTxCmd(
- cli.CmdChangeRoot(), s.root.addr, []string{newRoot.String()})
- require.NoError(s.T(), err)
-
- sudoers, err = testutilcli.QuerySudoers(val.ClientCtx)
- s.NoError(err)
- require.NotEqual(s.T(), sudoers.Sudoers.Root, initialRoot)
- require.Equal(s.T(), sudoers.Sudoers.Root, newRoot.String())
-}
-
-// TestMarshal_EditSudoers verifies that the expected proto.Message for
-// the EditSudoders fn marshals and unmarshals properly from JSON.
-// This unmarshaling is used in the main body of the CmdEditSudoers command.
-func (s *IntegrationSuite) TestMarshal_EditSudoers() {
- t := s.T()
-
- t.Log("create valid example json for the message")
- _, addrs := testutil.PrivKeyAddressPairs(4)
- var contracts []string
- sender := addrs[0]
- for _, addr := range addrs[1:] {
- contracts = append(contracts, addr.String())
- }
- msg := types.MsgEditSudoers{
- Action: "add_contracts",
- Contracts: contracts,
- Sender: sender.String(),
- }
- require.NoError(t, msg.ValidateBasic())
-
- msgPlus := MsgEditSudoersPlus{msg}
- fileJsonBz, _ := msgPlus.ToJson(t)
-
- t.Log("check unmarshal file → proto")
- cdc := app.MakeEncodingConfig().Codec
- newMsg := new(types.MsgEditSudoers)
- err := cdc.UnmarshalJSON(fileJsonBz, newMsg)
- assert.NoErrorf(t, err, "fileJsonBz: #%v", fileJsonBz)
- require.NoError(t, newMsg.ValidateBasic(), newMsg.String())
-}
-
-func (s *IntegrationSuite) TearDownSuite() {
- s.T().Log("tearing down integration test suite")
- s.network.Cleanup()
-}
diff --git a/x/sudo/cli/gen_root.go b/x/sudo/cli/gen_root.go
deleted file mode 100644
index 4369ab3b8..000000000
--- a/x/sudo/cli/gen_root.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package cli
-
-import (
- "encoding/json"
- "fmt"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/server"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/x/genutil"
- genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/sudo/types"
-)
-
-func AddSudoRootAccountCmd(defaultNodeHome string) *cobra.Command {
- cmd := &cobra.Command{
- Use: "add-sudo-root-account",
- Short: "Add sudo module root account to genesis.json.",
- Long: `Add sudo module root account to genesis.json.`,
- Args: cobra.ExactArgs(1),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx := client.GetClientContextFromCmd(cmd)
- serverCtx := server.GetServerContextFromCmd(cmd)
- config := serverCtx.Config
-
- config.SetRoot(clientCtx.HomeDir)
-
- genFile := config.GenesisFile()
- appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
- if err != nil {
- return err
- }
-
- rootAccount := args[0]
- addr, err := sdk.AccAddressFromBech32(rootAccount)
- if err != nil {
- return fmt.Errorf("failed to parse address: %w", err)
- }
-
- sudoGenState := types.GetGenesisStateFromAppState(clientCtx.Codec, appState)
- sudoGenState.Sudoers.Root = addr.String()
-
- sudoGenStateBz, err := clientCtx.Codec.MarshalJSON(sudoGenState)
- if err != nil {
- return fmt.Errorf("failed to marshal market genesis state: %w", err)
- }
-
- appState[types.ModuleName] = sudoGenStateBz
-
- appStateJSON, err := json.Marshal(appState)
- if err != nil {
- return fmt.Errorf("failed to marshal application genesis state: %w", err)
- }
-
- genDoc.AppState = appStateJSON
- err = genutil.ExportGenesisFile(genDoc, genFile)
- if err != nil {
- return err
- }
-
- err = clientCtx.PrintString(fmt.Sprintf("sudo module root account added to genesis.json: %s\n", rootAccount))
- if err != nil {
- return err
- }
-
- return nil
- },
- }
-
- cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
-
- return cmd
-}
diff --git a/x/sudo/cli/gen_root_test.go b/x/sudo/cli/gen_root_test.go
deleted file mode 100644
index 68458a548..000000000
--- a/x/sudo/cli/gen_root_test.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package cli_test
-
-import (
- "testing"
-
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/sudo/cli"
-)
-
-func TestAddSudoRootAccountCmd(t *testing.T) {
- tests := []struct {
- name string
- account string
-
- expectErr bool
- }{
- {
- name: "valid",
- account: "nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl",
- expectErr: false,
- },
- }
-
- for _, tc := range tests {
- tc := tc
- t.Run(tc.name, func(t *testing.T) {
- testapp.EnsureNibiruPrefix()
- ctx := testutil.SetupClientCtx(t)
- cmd := cli.AddSudoRootAccountCmd(t.TempDir())
- cmd.SetArgs([]string{
- tc.account,
- })
-
- if tc.expectErr {
- require.Error(t, cmd.ExecuteContext(ctx))
- } else {
- require.NoError(t, cmd.ExecuteContext(ctx))
- }
- })
- }
-}
diff --git a/x/sudo/doc.go b/x/sudo/doc.go
deleted file mode 100644
index d75e435bd..000000000
--- a/x/sudo/doc.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package sudo
-
-/*
-Package sudo provides a simple way to manage, verify, and run smart contracts
-with elevated permissions, mimicking the functionality of a Unix-based sudoers
-file.
-
-In the context of Unix-based operating systems, such as Linux and macOS,
-"sudoers" refers to a configuration file that defines which users have the
-privilege to execute commands with elevated (superuser) permissions using the
-"sudo" command.
-
-The superuser, also known as the root user, has full
-administrative access to the system, allowing them to perform tasks that regular
-users cannot do, such as installing system-wide software, and modifying system
-files.
-
-Note that this package does not provide actual system integration or execute
-commands with elevated privileges. It only offers a way to manage and verify
-permissions in a sudoers-like manner within your application.
-*/
diff --git a/x/sudo/genesis.go b/x/sudo/genesis.go
deleted file mode 100644
index 9feb94e8d..000000000
--- a/x/sudo/genesis.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package sudo
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/sudo/keeper"
- "github.com/NibiruChain/nibiru/x/sudo/types"
-)
-
-// InitGenesis initializes the module's state from a provided genesis state JSON.
-func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
- if err := genState.Validate(); err != nil {
- panic(err)
- }
- k.Sudoers.Set(ctx, genState.Sudoers)
-}
-
-// ExportGenesis returns the module's exported genesis state.
-// This fn assumes InitGenesis has already been called.
-func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
- pbSudoers, err := k.Sudoers.Get(ctx)
- if err != nil {
- panic(err)
- }
-
- return &types.GenesisState{
- Sudoers: pbSudoers,
- }
-}
-
-// DefaultGenesis: A blank genesis state. The DefaultGenesis is invalid because
-// it does not specify a "Sudoers.Root".
-func DefaultGenesis() *types.GenesisState {
- return &types.GenesisState{
- Sudoers: types.Sudoers{
- Root: "",
- Contracts: []string{},
- },
- }
-}
diff --git a/x/sudo/keeper/keeper.go b/x/sudo/keeper/keeper.go
deleted file mode 100644
index e7474b0ee..000000000
--- a/x/sudo/keeper/keeper.go
+++ /dev/null
@@ -1,149 +0,0 @@
-package keeper
-
-import (
- "context"
- "fmt"
-
- "github.com/NibiruChain/collections"
- "github.com/cosmos/cosmos-sdk/codec"
- "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/common/set"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
-)
-
-type Keeper struct {
- Sudoers collections.Item[sudotypes.Sudoers]
-}
-
-func NewKeeper(
- cdc codec.BinaryCodec,
- storeKey types.StoreKey,
-) Keeper {
- return Keeper{
- Sudoers: collections.NewItem(storeKey, 1, SudoersValueEncoder(cdc)),
- }
-}
-
-// Returns the root address of the sudo module.
-func (k Keeper) GetRootAddr(ctx sdk.Context) (sdk.AccAddress, error) {
- sudoers, err := k.Sudoers.Get(ctx)
- if err != nil {
- return nil, err
- }
-
- addr, err := sdk.AccAddressFromBech32(sudoers.Root)
- if err != nil {
- return nil, err
- }
-
- return addr, nil
-}
-
-func (k Keeper) senderHasPermission(sender string, root string) error {
- if sender != root {
- return fmt.Errorf(`message must be sent by root user. root: "%s", sender: "%s"`,
- root, sender,
- )
- }
- return nil
-}
-
-// AddContracts executes a MsgEditSudoers message with action type
-// "add_contracts". This adds contract addresses to the sudoer set.
-func (k Keeper) AddContracts(
- goCtx context.Context, msg *sudotypes.MsgEditSudoers,
-) (msgResp *sudotypes.MsgEditSudoersResponse, err error) {
- if msg.RootAction() != sudotypes.AddContracts {
- err = fmt.Errorf("invalid action type %s for msg add contracts", msg.Action)
- return
- }
-
- // Read state
- ctx := sdk.UnwrapSDKContext(goCtx)
- pbSudoersBefore, err := k.Sudoers.Get(ctx)
- if err != nil {
- return
- }
- sudoersBefore := SudoersFromPb(pbSudoersBefore)
- err = k.senderHasPermission(msg.Sender, sudoersBefore.Root)
- if err != nil {
- return
- }
-
- // Update state
- contracts, err := sudoersBefore.AddContracts(msg.Contracts)
- if err != nil {
- return
- }
- pbSudoers := Sudoers{Root: sudoersBefore.Root, Contracts: contracts}.ToPb()
- k.Sudoers.Set(ctx, pbSudoers)
- msgResp = new(sudotypes.MsgEditSudoersResponse)
- return msgResp, ctx.EventManager().EmitTypedEvent(&sudotypes.EventUpdateSudoers{
- Sudoers: pbSudoers,
- Action: msg.Action,
- })
-}
-
-// ————————————————————————————————————————————————————————————————————————————
-// RemoveContracts
-// ————————————————————————————————————————————————————————————————————————————
-
-func (k Keeper) RemoveContracts(
- goCtx context.Context, msg *sudotypes.MsgEditSudoers,
-) (msgResp *sudotypes.MsgEditSudoersResponse, err error) {
- if msg.RootAction() != sudotypes.RemoveContracts {
- err = fmt.Errorf("invalid action type %s for msg add contracts", msg.Action)
- return
- }
-
- // Skip "msg.ValidateBasic" since this is a remove' operation. That means we
- // can only remove from state but can't write anything invalid that would
- // corrupt it.
-
- // Read state
- ctx := sdk.UnwrapSDKContext(goCtx)
- pbSudoers, err := k.Sudoers.Get(ctx)
- if err != nil {
- return
- }
- sudoers := SudoersFromPb(pbSudoers)
- err = k.senderHasPermission(msg.Sender, sudoers.Root)
- if err != nil {
- return
- }
-
- // Update state
- sudoers.RemoveContracts(msg.Contracts)
- pbSudoers = sudoers.ToPb()
- k.Sudoers.Set(ctx, pbSudoers)
-
- msgResp = new(sudotypes.MsgEditSudoersResponse)
- return msgResp, ctx.EventManager().EmitTypedEvent(&sudotypes.EventUpdateSudoers{
- Sudoers: pbSudoers,
- Action: msg.Action,
- })
-}
-
-// CheckPermissions Checks if a contract is contained within the set of sudo
-// contracts defined in the x/sudo module. These smart contracts are able to
-// execute certain permissioned functions.
-func (k Keeper) CheckPermissions(
- contract sdk.AccAddress, ctx sdk.Context,
-) error {
- state, err := k.Sudoers.Get(ctx)
- if err != nil {
- return err
- }
- contracts := state.Contracts
-
- hasPermission := set.New(contracts...).Has(contract.String()) || contract.String() == state.Root
- if !hasPermission {
- return fmt.Errorf(
- "%w: insufficient permissions on smart contract: %s. The sudo contracts are: %s",
- sudotypes.ErrUnauthorized, contract, contracts,
- )
- }
- return nil
-}
diff --git a/x/sudo/keeper/keeper_test.go b/x/sudo/keeper/keeper_test.go
deleted file mode 100644
index e0346ece9..000000000
--- a/x/sudo/keeper/keeper_test.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package keeper_test
-
-import (
- "testing"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
-)
-
-func TestCheckPermissions(t *testing.T) {
- var mockContractAddrStrs []string
- var mockContractAddrs []sdk.AccAddress
- for _, addrStr := range []string{"addraaa", "addrccc"} {
- mockAddr := sdk.AccAddress(addrStr)
- mockContractAddrs = append(mockContractAddrs, mockAddr)
- mockContractAddrStrs = append(mockContractAddrStrs, mockAddr.String())
- }
-
- nibiru, ctx := testapp.NewNibiruTestAppAndContext()
- nibiru.SudoKeeper.Sudoers.Set(ctx, sudotypes.Sudoers{
- Root: "mockroot",
- Contracts: mockContractAddrStrs,
- })
-
- err := nibiru.SudoKeeper.CheckPermissions(sdk.AccAddress([]byte("addrbbb")), ctx)
- require.Error(t, err)
- for _, mockAddr := range mockContractAddrs {
- err := nibiru.SudoKeeper.CheckPermissions(mockAddr, ctx)
- require.NoError(t, err)
- }
-}
diff --git a/x/sudo/keeper/msg_server.go b/x/sudo/keeper/msg_server.go
deleted file mode 100644
index bfba6d5c1..000000000
--- a/x/sudo/keeper/msg_server.go
+++ /dev/null
@@ -1,128 +0,0 @@
-package keeper
-
-import (
- "context"
- "fmt"
-
- "github.com/cosmos/cosmos-sdk/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/common/set"
- sudotypes "github.com/NibiruChain/nibiru/x/sudo/types"
-)
-
-type MsgServer struct {
- keeper Keeper
-}
-
-func NewMsgServer(keeper Keeper) *MsgServer {
- return &MsgServer{keeper: keeper}
-}
-
-// Ensure the interface is properly implemented at compile time
-var _ sudotypes.MsgServer = MsgServer{}
-
-// EditSudoers adds or removes sudo contracts from state.
-func (m MsgServer) EditSudoers(
- goCtx context.Context, msg *sudotypes.MsgEditSudoers,
-) (*sudotypes.MsgEditSudoersResponse, error) {
- switch msg.RootAction() {
- case sudotypes.AddContracts:
- return m.keeper.AddContracts(goCtx, msg)
- case sudotypes.RemoveContracts:
- return m.keeper.RemoveContracts(goCtx, msg)
- default:
- return nil, fmt.Errorf("invalid action type specified on msg: %s", msg)
- }
-}
-
-func (m MsgServer) ChangeRoot(ctx context.Context, msg *sudotypes.MsgChangeRoot) (*sudotypes.MsgChangeRootResponse, error) {
- sdkContext := sdk.UnwrapSDKContext(ctx)
-
- pbSudoers, err := m.keeper.Sudoers.Get(sdkContext)
- if err != nil {
- return nil, fmt.Errorf("failed to get sudoers: %w", err)
- }
-
- err = m.validateRootPermissions(pbSudoers, msg)
- if err != nil {
- return nil, err
- }
-
- pbSudoers.Root = msg.NewRoot
- m.keeper.Sudoers.Set(sdkContext, pbSudoers)
-
- return &sudotypes.MsgChangeRootResponse{}, nil
-}
-
-func (m MsgServer) validateRootPermissions(pbSudoers sudotypes.Sudoers, msg *sudotypes.MsgChangeRoot) error {
- root, err := sdk.AccAddressFromBech32(pbSudoers.Root)
- if err != nil {
- return fmt.Errorf("failed to parse root address: %w", err)
- }
-
- sender, err := sdk.AccAddressFromBech32(msg.Sender)
- if err != nil {
- return fmt.Errorf("failed to parse sender address: %w", err)
- }
-
- if !root.Equals(sender) {
- return sudotypes.ErrUnauthorized
- }
-
- return nil
-}
-
-// ————————————————————————————————————————————————————————————————————————————
-// Encoder for the Sudoers type
-// ————————————————————————————————————————————————————————————————————————————
-
-func SudoersValueEncoder(cdc codec.BinaryCodec) collections.ValueEncoder[sudotypes.Sudoers] {
- return collections.ProtoValueEncoder[sudotypes.Sudoers](cdc)
-}
-
-type Sudoers struct {
- Root string `json:"root"`
- Contracts set.Set[string] `json:"contracts"`
-}
-
-func (sudo Sudoers) String() string {
- r := sudo.ToPb()
- return r.String()
-}
-
-func (sudo Sudoers) ToPb() sudotypes.Sudoers {
- return sudotypes.Sudoers{
- Root: sudo.Root,
- Contracts: sudo.Contracts.ToSlice(),
- }
-}
-
-func SudoersFromPb(pbSudoers sudotypes.Sudoers) Sudoers {
- return Sudoers{
- Root: pbSudoers.Root,
- Contracts: set.New[string](pbSudoers.Contracts...),
- }
-}
-
-// AddContracts adds contract addresses to the sudoer set.
-func (sudo *Sudoers) AddContracts(
- contracts []string,
-) (out set.Set[string], err error) {
- for _, contractStr := range contracts {
- contract, err := sdk.AccAddressFromBech32(contractStr)
- if err != nil {
- return out, err
- }
- sudo.Contracts.Add(contract.String())
- }
- return sudo.Contracts, err
-}
-
-func (sudo *Sudoers) RemoveContracts(contracts []string) {
- for _, contract := range contracts {
- sudo.Contracts.Remove(contract)
- }
-}
diff --git a/x/sudo/keeper/msg_server_test.go b/x/sudo/keeper/msg_server_test.go
deleted file mode 100644
index 5c2d24d31..000000000
--- a/x/sudo/keeper/msg_server_test.go
+++ /dev/null
@@ -1,478 +0,0 @@
-package keeper_test
-
-import (
- "testing"
- "time"
-
- "github.com/NibiruChain/nibiru/x/sudo/keeper"
-
- "github.com/NibiruChain/nibiru/x/sudo/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/set"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/sudo"
-)
-
-func init() {
- testapp.EnsureNibiruPrefix()
-}
-
-func setup() (*app.NibiruApp, sdk.Context) {
- return testapp.NewNibiruTestAppAndContextAtTime(time.Now().UTC())
-}
-
-func TestGenesis(t *testing.T) {
- for _, testCase := range []struct {
- name string
- genState *types.GenesisState
- panic bool
- empty bool
- }{
- {
- name: "default genesis (empty)",
- genState: sudo.DefaultGenesis(),
- panic: true,
- },
- {
- name: "happy genesis with contracts",
- genState: &types.GenesisState{
- Sudoers: types.Sudoers{
- Root: testutil.AccAddress().String(),
- Contracts: []string{
- testutil.AccAddress().String(),
- testutil.AccAddress().String(),
- testutil.AccAddress().String(),
- },
- },
- },
- empty: false,
- },
- {
- name: "nil genesis (panic)",
- genState: nil,
- panic: true,
- },
- {
- name: "invalid genesis (panic)",
- genState: &types.GenesisState{
- Sudoers: types.Sudoers{
- Root: "root",
- Contracts: []string{"contract"},
- },
- },
- panic: true,
- },
- } {
- t.Run(testCase.name, func(t *testing.T) {
- // Setup
- nibiru, ctx := setup()
-
- // InitGenesis
- if testCase.panic {
- require.Panics(t, func() {
- sudo.InitGenesis(ctx, nibiru.SudoKeeper, *testCase.genState)
- })
- return
- }
- require.NotPanics(t, func() {
- sudo.InitGenesis(ctx, nibiru.SudoKeeper, *testCase.genState)
- })
-
- // ExportGenesis
- got := sudo.ExportGenesis(ctx, nibiru.SudoKeeper)
- require.NotNil(t, got)
-
- // Validate
- if testCase.empty {
- // We only run this when we expect empty or null values.
- // Otherwise, it resets the fields of the struct.
- testutil.Fill(got)
- }
- require.EqualValues(t, *testCase.genState, *got)
-
- // Validate with AppModule
- cdc := types.ModuleCdc
- require.Panics(t, func() {
- // failing case
- appModule := sudo.AppModule{}
- _ = appModule.ExportGenesis(ctx, cdc)
- })
- appModule := sudo.NewAppModule(cdc, nibiru.SudoKeeper)
- jsonBz := appModule.ExportGenesis(ctx, cdc)
- err := appModule.ValidateGenesis(cdc, nil, jsonBz)
- require.NoErrorf(t, err, "exportedGenesis: %s", jsonBz)
- })
- }
-}
-
-func TestSudo_AddContracts(t *testing.T) {
- exampleAddrs := []string{
- "nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl",
- "nibi1ah8gqrtjllhc5ld4rxgl4uglvwl93ag0sh6e6v",
- "nibi1x5zknk8va44th5vjpg0fagf0lxx0rvurpmp8gs",
- }
-
- for _, tc := range []struct {
- name string
- start []string
- delta []string
- end []string
- shouldError bool
- }{
- {
- name: "happy - add 1",
- start: []string{exampleAddrs[0]},
- delta: []string{exampleAddrs[1]},
- end: []string{exampleAddrs[0], exampleAddrs[1]},
- },
- {
- name: "happy - add multiple",
- start: []string{exampleAddrs[0]},
- delta: []string{exampleAddrs[1], exampleAddrs[2]},
- end: []string{exampleAddrs[0], exampleAddrs[1], exampleAddrs[2]},
- },
- {
- name: "sad - invalid addr",
- start: []string{exampleAddrs[0]},
- delta: []string{"not-an-address"},
- shouldError: true,
- },
- {
- name: "empty start",
- start: []string{},
- delta: []string{exampleAddrs[1], exampleAddrs[2]},
- end: []string{exampleAddrs[1], exampleAddrs[2]},
- },
- } {
- t.Run(tc.name, func(t *testing.T) {
- _, _ = setup()
- root := testutil.AccAddress().String()
- sudoers := keeper.Sudoers{
- Root: root,
- Contracts: set.New(tc.start...),
- }
-
- newContractsState, err := sudoers.AddContracts(tc.delta)
- if tc.shouldError {
- require.Error(t, err)
- return
- }
- require.NoErrorf(t, err, "newState: %s", newContractsState.ToSlice())
- })
- }
-}
-
-func TestMsgServer_ChangeRoot(t *testing.T) {
- app, ctx := setup()
-
- _, err := app.SudoKeeper.Sudoers.Get(ctx)
- require.NoError(t, err)
-
- actualRoot := testutil.AccAddress().String()
- newRoot := testutil.AccAddress().String()
- fakeRoot := testutil.AccAddress().String()
-
- app.SudoKeeper.Sudoers.Set(ctx, types.Sudoers{
- Root: actualRoot,
- })
-
- // try to change root with non-root account
- msgServer := keeper.NewMsgServer(app.SudoKeeper)
- _, err = msgServer.ChangeRoot(
- sdk.WrapSDKContext(ctx),
- &types.MsgChangeRoot{Sender: fakeRoot, NewRoot: newRoot},
- )
- require.EqualError(t, err, "unauthorized: missing sudo permissions")
-
- // try to change root with root account
- _, err = msgServer.ChangeRoot(
- sdk.WrapSDKContext(ctx),
- &types.MsgChangeRoot{Sender: actualRoot, NewRoot: newRoot},
- )
- require.NoError(t, err)
-
- // check that root has changed
- sudoers, err := app.SudoKeeper.Sudoers.Get(ctx)
- require.NoError(t, err)
-
- require.Equal(t, newRoot, sudoers.Root)
-}
-
-func TestSudo_FromPbSudoers(t *testing.T) {
- for _, tc := range []struct {
- name string
- in types.Sudoers
- out keeper.Sudoers
- }{
- {
- name: "empty",
- in: types.Sudoers{},
- out: keeper.Sudoers{
- Root: "",
- Contracts: set.Set[string]{},
- },
- },
- {
- name: "happy",
- in: types.Sudoers{Root: "root", Contracts: []string{"contractA", "contractB"}},
- out: keeper.Sudoers{
- Root: "root",
- Contracts: set.New[string]("contractA", "contractB"),
- },
- },
- } {
- t.Run(tc.name, func(t *testing.T) {
- out := keeper.SudoersFromPb(tc.in)
- assert.EqualValuesf(t, tc.out.Contracts, out.Contracts, "out: %s", out.String())
- assert.EqualValuesf(t, tc.out.Root, out.Root, "out: %s", out.String())
-
- pbSudoers := out.ToPb()
- for _, contract := range tc.in.Contracts {
- assert.True(t, set.New(pbSudoers.Contracts...).Has(contract))
- }
- })
- }
-}
-
-func TestKeeper_AddContracts(t *testing.T) {
- root := "nibi1ggpg3vluy09qmfkgwsgkumhmmv2z44rdafn6qa"
- exampleAddrs := []string{
- "nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl",
- "nibi1ah8gqrtjllhc5ld4rxgl4uglvwl93ag0sh6e6v",
- "nibi1x5zknk8va44th5vjpg0fagf0lxx0rvurpmp8gs",
- }
-
- testCases := []struct {
- name string
- contractsBefore []string
- msg *types.MsgEditSudoers
- contractsAfter []string
- shouldFail bool
- }{
- {
- name: "happy",
- contractsBefore: []string{
- exampleAddrs[0],
- },
- msg: &types.MsgEditSudoers{
- Action: string(types.AddContracts),
- Contracts: []string{
- exampleAddrs[1],
- exampleAddrs[2],
- },
- Sender: root,
- },
- contractsAfter: []string{
- exampleAddrs[0],
- exampleAddrs[1],
- exampleAddrs[2],
- },
- },
-
- {
- name: "rotten address",
- contractsBefore: []string{
- exampleAddrs[0],
- },
- msg: &types.MsgEditSudoers{
- Action: string(types.AddContracts),
- Contracts: []string{
- exampleAddrs[1],
- "rotten address",
- exampleAddrs[2],
- },
- Sender: root,
- },
- shouldFail: true,
- },
-
- {
- name: "wrong action type",
- contractsBefore: []string{
- exampleAddrs[0],
- },
- msg: &types.MsgEditSudoers{
- Action: "not an action type",
- Sender: root,
- },
- shouldFail: true,
- },
-
- {
- name: "sent by non-sudo user",
- contractsBefore: []string{
- exampleAddrs[0],
- },
- msg: &types.MsgEditSudoers{
- Action: string(types.AddContracts),
- Sender: exampleAddrs[1],
- Contracts: []string{
- exampleAddrs[1],
- exampleAddrs[2],
- },
- },
- contractsAfter: []string{
- exampleAddrs[0],
- exampleAddrs[1],
- exampleAddrs[2],
- },
- shouldFail: true,
- },
- }
-
- for _, tc := range testCases {
- t.Run(tc.name, func(t *testing.T) {
- nibiru, ctx := setup()
- k := nibiru.SudoKeeper
-
- t.Log("Set starting contracts state")
- stateBefore := types.Sudoers{
- Root: root,
- Contracts: tc.contractsBefore,
- }
- k.Sudoers.Set(ctx, stateBefore)
- gotStateBefore, err := k.Sudoers.Get(ctx)
- require.NoError(t, err)
- require.EqualValues(t, stateBefore, gotStateBefore)
-
- t.Log("Execute message")
- // Check via message handler directly
- msgServer := keeper.NewMsgServer(k)
- res, err := msgServer.EditSudoers(sdk.WrapSDKContext(ctx), tc.msg)
- // Check via Keeper
- res2, err2 := k.AddContracts(sdk.WrapSDKContext(ctx), tc.msg)
- if tc.shouldFail {
- require.Errorf(t, err, "resp: %s", res)
- require.Errorf(t, err2, "resp: %s", res2)
- return
- }
- require.NoError(t, err)
-
- t.Log("Check correctness of state updates")
- contractsAfter := set.New(tc.contractsAfter...)
- stateAfter, err := k.Sudoers.Get(ctx)
- require.NoError(t, err)
- got := set.New(stateAfter.Contracts...)
- // Checking cardinality (length) and iterating to check if one set
- // contains the other is equivalent to set equality in math.
- assert.EqualValues(t, contractsAfter.Len(), got.Len())
- for member := range got {
- assert.True(t, contractsAfter.Has(member))
- }
- })
- }
-}
-
-func TestKeeper_RemoveContracts(t *testing.T) {
- root := "nibi1ggpg3vluy09qmfkgwsgkumhmmv2z44rdafn6qa"
- // root := "nibi1ggpg3vluy09qmfkgwsgkumhmmv2z44rd2vhrfw"
- exampleAddrs := []string{
- "nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl",
- "nibi1ah8gqrtjllhc5ld4rxgl4uglvwl93ag0sh6e6v",
- "nibi1x5zknk8va44th5vjpg0fagf0lxx0rvurpmp8gs",
- }
-
- for _, tc := range []struct {
- name string
- contractsBefore []string
- msg *types.MsgEditSudoers
- contractsAfter []string
- shouldFail bool
- }{
- {
- name: "happy",
- contractsBefore: []string{
- exampleAddrs[0],
- exampleAddrs[1],
- exampleAddrs[2],
- },
- msg: &types.MsgEditSudoers{
- Action: string(types.RemoveContracts),
- Contracts: []string{
- exampleAddrs[1],
- exampleAddrs[2],
- },
- Sender: root,
- },
- contractsAfter: []string{
- exampleAddrs[0],
- },
- },
-
- {
- name: "wrong action type",
- contractsBefore: []string{
- exampleAddrs[0],
- },
- msg: &types.MsgEditSudoers{
- Action: "not an action type",
- Sender: root,
- },
- shouldFail: true,
- },
-
- {
- name: "happy - no op",
- contractsBefore: []string{
- exampleAddrs[0],
- exampleAddrs[2],
- },
- msg: &types.MsgEditSudoers{
- Action: string(types.RemoveContracts),
- Contracts: []string{
- exampleAddrs[1],
- },
- Sender: root,
- },
- contractsAfter: []string{
- exampleAddrs[0],
- exampleAddrs[2],
- },
- },
- } {
- t.Run(tc.name, func(t *testing.T) {
- nibiru, ctx := setup()
- k := nibiru.SudoKeeper
-
- t.Log("Set starting contracts state")
- stateBefore := types.Sudoers{
- Root: root,
- Contracts: tc.contractsBefore,
- }
- k.Sudoers.Set(ctx, stateBefore)
- gotStateBefore, err := k.Sudoers.Get(ctx)
- require.NoError(t, err)
- require.EqualValues(t, stateBefore, gotStateBefore)
-
- t.Log("Execute message")
- // Check via message handler directly
- msgServer := keeper.NewMsgServer(k)
- res, err := msgServer.EditSudoers(ctx, tc.msg)
- // Check via Keeper
- res2, err2 := k.RemoveContracts(sdk.WrapSDKContext(ctx), tc.msg)
- if tc.shouldFail {
- require.Errorf(t, err, "resp: %s", res)
- require.Errorf(t, err2, "resp: %s", res2)
- return
- }
-
- t.Log("Check correctness of state updates")
- contractsAfter := set.New(tc.contractsAfter...)
- stateAfter, err := k.Sudoers.Get(ctx)
- require.NoError(t, err)
- got := set.New(stateAfter.Contracts...)
- // Checking cardinality (length) and iterating to check if one set
- // contains the other is equivalent to set equality in math.
- assert.EqualValues(t, contractsAfter.Len(), got.Len())
- for member := range got {
- assert.True(t, contractsAfter.Has(member))
- }
- })
- }
-}
diff --git a/x/sudo/keeper/querier.go b/x/sudo/keeper/querier.go
deleted file mode 100644
index a4d224783..000000000
--- a/x/sudo/keeper/querier.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package keeper
-
-import (
- "context"
-
- "github.com/NibiruChain/nibiru/x/sudo/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-)
-
-// Ensure the interface is properly implemented at compile time
-var _ types.QueryServer = Querier{}
-
-type Querier struct {
- keeper Keeper
-}
-
-func NewQuerier(k Keeper) types.QueryServer {
- return Querier{keeper: k}
-}
-
-func (q Querier) QuerySudoers(
- goCtx context.Context,
- req *types.QuerySudoersRequest,
-) (resp *types.QuerySudoersResponse, err error) {
- if req == nil {
- return nil, status.Error(codes.InvalidArgument, "invalid request")
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
- sudoers, err := q.keeper.Sudoers.Get(ctx)
-
- return &types.QuerySudoersResponse{
- Sudoers: sudoers,
- }, err
-}
diff --git a/x/sudo/keeper/querier_test.go b/x/sudo/keeper/querier_test.go
deleted file mode 100644
index 4bfff282b..000000000
--- a/x/sudo/keeper/querier_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package keeper_test
-
-import (
- "testing"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/sudo/keeper"
- "github.com/NibiruChain/nibiru/x/sudo/types"
-)
-
-func TestQuerySudoers(t *testing.T) {
- for _, tc := range []struct {
- name string
- state types.Sudoers
- }{
- {
- name: "happy 1",
- state: types.Sudoers{
- Root: "alice",
- Contracts: []string{"contractA", "contractB"},
- },
- },
-
- {
- name: "happy 2 (empty)",
- state: types.Sudoers{
- Root: "",
- Contracts: []string(nil),
- },
- },
-
- {
- name: "happy 3",
- state: types.Sudoers{
- Root: "",
- Contracts: []string{"boop", "blap"},
- },
- },
- } {
- t.Run(tc.name, func(t *testing.T) {
- nibiru, ctx := setup()
-
- nibiru.SudoKeeper.Sudoers.Set(ctx, tc.state)
-
- req := new(types.QuerySudoersRequest)
- querier := keeper.NewQuerier(nibiru.SudoKeeper)
- resp, err := querier.QuerySudoers(
- sdk.WrapSDKContext(ctx), req,
- )
- require.NoError(t, err)
-
- outSudoers := resp.Sudoers
- require.EqualValues(t, tc.state, outSudoers)
- })
- }
-
- t.Run("nil request should error", func(t *testing.T) {
- nibiru, ctx := setup()
- var req *types.QuerySudoersRequest = nil
- querier := keeper.NewQuerier(nibiru.SudoKeeper)
- _, err := querier.QuerySudoers(
- sdk.WrapSDKContext(ctx), req,
- )
- require.Error(t, err)
- })
-}
diff --git a/x/sudo/module.go b/x/sudo/module.go
deleted file mode 100644
index 18a42eb46..000000000
--- a/x/sudo/module.go
+++ /dev/null
@@ -1,173 +0,0 @@
-package sudo
-
-import (
- "context"
- "encoding/json"
- "fmt"
-
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
- simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/sudo/cli"
- sudokeeper "github.com/NibiruChain/nibiru/x/sudo/keeper"
- simulation "github.com/NibiruChain/nibiru/x/sudo/simulation"
- "github.com/NibiruChain/nibiru/x/sudo/types"
-)
-
-// Ensure the interface is properly implemented at compile time
-var (
- _ module.AppModule = AppModule{}
- _ module.AppModuleBasic = AppModuleBasic{}
- _ module.AppModuleSimulation = AppModule{}
-)
-
-// ----------------------------------------------------------------------------
-// AppModuleBasic
-// ----------------------------------------------------------------------------
-
-type AppModuleBasic struct {
- binaryCodec codec.BinaryCodec
-}
-
-func NewAppModuleBasic(binaryCodec codec.BinaryCodec) AppModuleBasic {
- return AppModuleBasic{binaryCodec: binaryCodec}
-}
-
-func (AppModuleBasic) Name() string {
- return types.ModuleName
-}
-
-func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) {
- types.RegisterInterfaces(interfaceRegistry)
-}
-
-func (AppModuleBasic) RegisterLegacyAminoCodec(aminoCodec *codec.LegacyAmino) {
- types.RegisterLegacyAminoCodec(aminoCodec)
-}
-
-// DefaultGenesis returns default genesis state as raw bytes for the module.
-func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
- return cdc.MustMarshalJSON(DefaultGenesis())
-}
-
-// ValidateGenesis performs genesis state validation for the capability module.
-func (AppModuleBasic) ValidateGenesis(
- cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage,
-) error {
- var genState types.GenesisState
- if err := cdc.UnmarshalJSON(bz, &genState); err != nil {
- return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
- }
- return genState.Validate()
-}
-
-// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
-func (AppModuleBasic) RegisterGRPCGatewayRoutes(
- clientCtx client.Context, mux *runtime.ServeMux,
-) {
- if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
- panic(err)
- }
-}
-
-// GetTxCmd returns the capability module's root tx command.
-func (a AppModuleBasic) GetTxCmd() *cobra.Command {
- return cli.GetTxCmd()
-}
-
-// GetQueryCmd returns the capability module's root query command.
-func (AppModuleBasic) GetQueryCmd() *cobra.Command {
- return cli.GetQueryCmd()
-}
-
-// ----------------------------------------------------------------------------
-// AppModule
-// ----------------------------------------------------------------------------
-
-// AppModule implements the AppModule interface for the module.
-type AppModule struct {
- AppModuleBasic
-
- keeper sudokeeper.Keeper
-}
-
-func NewAppModule(
- cdc codec.Codec,
- keeper sudokeeper.Keeper,
-) AppModule {
- return AppModule{
- AppModuleBasic: NewAppModuleBasic(cdc),
- keeper: keeper,
- }
-}
-
-// Name returns the capability module's name.
-func (am AppModule) Name() string {
- return am.AppModuleBasic.Name()
-}
-
-// RegisterServices registers a GRPC query service to respond to the
-// module-specific GRPC queries.
-func (am AppModule) RegisterServices(cfg module.Configurator) {
- types.RegisterQueryServer(cfg.QueryServer(), sudokeeper.NewQuerier(am.keeper))
- types.RegisterMsgServer(cfg.MsgServer(), sudokeeper.NewMsgServer(am.keeper))
-}
-
-// RegisterInvariants registers the capability module's invariants.
-func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
-
-// InitGenesis performs the capability module's genesis initialization It returns
-// no validator updates.
-func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage,
-) []abci.ValidatorUpdate {
- var genState types.GenesisState
- // Initialize global index to index in genesis state
- cdc.MustUnmarshalJSON(gs, &genState)
-
- InitGenesis(ctx, am.keeper, genState)
-
- return []abci.ValidatorUpdate{}
-}
-
-// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes.
-func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
- genState := ExportGenesis(ctx, am.keeper)
- return cdc.MustMarshalJSON(genState)
-}
-
-// ConsensusVersion implements ConsensusVersion.
-func (AppModule) ConsensusVersion() uint64 { return 3 }
-
-// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
-func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
-
-// EndBlock executes all ABCI EndBlock logic respective to the capability module. It
-// returns no validator updates.
-func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
- return []abci.ValidatorUpdate{}
-}
-
-//----------------------------------------------------------------------------
-// AppModuleSimulation functions
-//----------------------------------------------------------------------------
-
-// GenerateGenesisState implements module.AppModuleSimulation.
-func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
- simulation.RandomizedGenState(simState)
-}
-
-// RegisterStoreDecoder implements module.AppModuleSimulation.
-func (AppModule) RegisterStoreDecoder(sdk.StoreDecoderRegistry) {
-}
-
-// WeightedOperations implements module.AppModuleSimulation.
-func (AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
- return nil
-}
diff --git a/x/sudo/simulation/genesis.go b/x/sudo/simulation/genesis.go
deleted file mode 100644
index 6558770e4..000000000
--- a/x/sudo/simulation/genesis.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package simulation
-
-// DONTCOVER
-
-import (
- "encoding/json"
- "fmt"
-
- "github.com/cosmos/cosmos-sdk/types/module"
-
- "github.com/NibiruChain/nibiru/x/sudo/types"
-)
-
-func RandomizedGenState(simState *module.SimulationState) {
- rootAddress := simState.Accounts[simState.Rand.Intn(len(simState.Accounts))].Address
-
- genState := types.GenesisState{
- Sudoers: types.Sudoers{
- Root: rootAddress.String(),
- Contracts: []string{},
- },
- }
-
- bz, err := json.MarshalIndent(&genState, "", " ")
- if err != nil {
- panic(err)
- }
- fmt.Printf("Selected randomly generated x/sudo parameters:\n%s\n", bz)
- simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&genState)
-}
diff --git a/x/sudo/types/actions.go b/x/sudo/types/actions.go
deleted file mode 100644
index 9d838bb8f..000000000
--- a/x/sudo/types/actions.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package types
-
-import "github.com/NibiruChain/nibiru/x/common/set"
-
-type RootAction string
-
-const (
- AddContracts RootAction = "add_contracts"
- RemoveContracts RootAction = "remove_contracts"
-)
-
-// RootActions set[string]: The set of all root actions.
-var RootActions = set.New[RootAction](
- AddContracts,
- RemoveContracts,
-)
diff --git a/x/sudo/types/codec.go b/x/sudo/types/codec.go
deleted file mode 100644
index f0a3a7d2a..000000000
--- a/x/sudo/types/codec.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package types
-
-import (
- "github.com/cosmos/cosmos-sdk/codec"
- cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/msgservice"
-)
-
-func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- cdc.RegisterConcrete(&MsgEditSudoers{}, "sudo/edit_sudoers", nil)
-}
-
-func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
- registry.RegisterImplementations(
- /* interface */ (*sdk.Msg)(nil),
- /* implementations */
- &MsgEditSudoers{},
- )
-
- msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
-}
-
-var ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
diff --git a/x/sudo/types/errors.go b/x/sudo/types/errors.go
deleted file mode 100644
index 16fd1dc12..000000000
--- a/x/sudo/types/errors.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package types
-
-import (
- "fmt"
-
- sdkerrors "cosmossdk.io/errors"
-)
-
-var (
- ErrUnauthorized = sdkerrors.Register(ModuleName, 2, "unauthorized: missing sudo permissions")
- errGenesis = sdkerrors.Register(ModuleName, 3, "sudo genesis error")
- errSudoers = sdkerrors.Register(ModuleName, 4, "sudoers error")
-)
-
-func ErrGenesis(errMsg string) error {
- return fmt.Errorf("%s: %s", errGenesis, errMsg)
-}
-
-func ErrSudoers(errMsg string) error {
- return fmt.Errorf("%s: %s", errSudoers, errMsg)
-}
diff --git a/x/sudo/types/event.pb.go b/x/sudo/types/event.pb.go
deleted file mode 100644
index f49fa8417..000000000
--- a/x/sudo/types/event.pb.go
+++ /dev/null
@@ -1,377 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/sudo/v1/event.proto
-
-package types
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// EventUpdateSudoers: ABCI event emitted upon execution of "MsgEditSudoers".
-type EventUpdateSudoers struct {
- Sudoers Sudoers `protobuf:"bytes,1,opt,name=sudoers,proto3" json:"sudoers"`
- // Action is the type of update that occured to the "sudoers"
- Action string `protobuf:"bytes,2,opt,name=action,proto3" json:"action,omitempty"`
-}
-
-func (m *EventUpdateSudoers) Reset() { *m = EventUpdateSudoers{} }
-func (m *EventUpdateSudoers) String() string { return proto.CompactTextString(m) }
-func (*EventUpdateSudoers) ProtoMessage() {}
-func (*EventUpdateSudoers) Descriptor() ([]byte, []int) {
- return fileDescriptor_7e6085948b018986, []int{0}
-}
-func (m *EventUpdateSudoers) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventUpdateSudoers) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventUpdateSudoers.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventUpdateSudoers) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventUpdateSudoers.Merge(m, src)
-}
-func (m *EventUpdateSudoers) XXX_Size() int {
- return m.Size()
-}
-func (m *EventUpdateSudoers) XXX_DiscardUnknown() {
- xxx_messageInfo_EventUpdateSudoers.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventUpdateSudoers proto.InternalMessageInfo
-
-func (m *EventUpdateSudoers) GetSudoers() Sudoers {
- if m != nil {
- return m.Sudoers
- }
- return Sudoers{}
-}
-
-func (m *EventUpdateSudoers) GetAction() string {
- if m != nil {
- return m.Action
- }
- return ""
-}
-
-func init() {
- proto.RegisterType((*EventUpdateSudoers)(nil), "nibiru.sudo.v1.EventUpdateSudoers")
-}
-
-func init() { proto.RegisterFile("nibiru/sudo/v1/event.proto", fileDescriptor_7e6085948b018986) }
-
-var fileDescriptor_7e6085948b018986 = []byte{
- // 242 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xca, 0xcb, 0x4c, 0xca,
- 0x2c, 0x2a, 0xd5, 0x2f, 0x2e, 0x4d, 0xc9, 0xd7, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b,
- 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xc8, 0xe9, 0x81, 0xe4, 0xf4, 0xca, 0x0c,
- 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x4c, 0x7a,
- 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x7e, 0x62, 0x41, 0xa6, 0x7e, 0x62, 0x5e, 0x5e, 0x7e, 0x49, 0x62,
- 0x49, 0x66, 0x7e, 0x5e, 0x31, 0x54, 0x16, 0xdd, 0xfc, 0xe2, 0x92, 0xc4, 0x92, 0x54, 0x88, 0x9c,
- 0x52, 0x2a, 0x97, 0x90, 0x2b, 0xc8, 0xba, 0xd0, 0x82, 0x94, 0xc4, 0x92, 0xd4, 0xe0, 0xd2, 0x94,
- 0xfc, 0xd4, 0xa2, 0x62, 0x21, 0x73, 0x2e, 0xf6, 0x62, 0x08, 0x53, 0x82, 0x51, 0x81, 0x51, 0x83,
- 0xdb, 0x48, 0x5c, 0x0f, 0xd5, 0x1d, 0x7a, 0x50, 0x95, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04,
- 0xc1, 0x54, 0x0b, 0x89, 0x71, 0xb1, 0x25, 0x26, 0x83, 0xec, 0x96, 0x60, 0x52, 0x60, 0xd4, 0xe0,
- 0x0c, 0x82, 0xf2, 0x9c, 0x5c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23,
- 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a,
- 0x2b, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xdf, 0x0f, 0x6c, 0x87, 0x73,
- 0x46, 0x62, 0x66, 0x9e, 0x3e, 0xd4, 0xcd, 0x15, 0x10, 0x57, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27,
- 0xb1, 0x81, 0xdd, 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xcb, 0xb3, 0x68, 0xee, 0x31, 0x01,
- 0x00, 0x00,
-}
-
-func (m *EventUpdateSudoers) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventUpdateSudoers) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventUpdateSudoers) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Action) > 0 {
- i -= len(m.Action)
- copy(dAtA[i:], m.Action)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Action)))
- i--
- dAtA[i] = 0x12
- }
- {
- size, err := m.Sudoers.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvent(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func encodeVarintEvent(dAtA []byte, offset int, v uint64) int {
- offset -= sovEvent(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *EventUpdateSudoers) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Sudoers.Size()
- n += 1 + l + sovEvent(uint64(l))
- l = len(m.Action)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func sovEvent(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozEvent(x uint64) (n int) {
- return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *EventUpdateSudoers) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventUpdateSudoers: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventUpdateSudoers: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sudoers", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Sudoers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Action = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipEvent(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthEvent
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupEvent
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthEvent
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/sudo/types/export.go b/x/sudo/types/export.go
deleted file mode 100644
index fb4b6e3b6..000000000
--- a/x/sudo/types/export.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package types
-
-import (
- grpc "google.golang.org/grpc"
-)
-
-// GrpcQueryServiceDesc represents the query server's RPC service specification.
-// This gives access to the service name and method names needed for stargate
-// queries.
-func GrpcQueryServiceDesc() grpc.ServiceDesc {
- return _Query_serviceDesc
-}
diff --git a/x/sudo/types/genesis.go b/x/sudo/types/genesis.go
deleted file mode 100644
index 02c0736c9..000000000
--- a/x/sudo/types/genesis.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package types
-
-import (
- "encoding/json"
-
- "github.com/cosmos/cosmos-sdk/codec"
-)
-
-func (gen *GenesisState) Validate() error {
- if gen.Sudoers.Contracts == nil {
- return ErrGenesis("nil contract state must be []string")
- } else if err := gen.Sudoers.Validate(); err != nil {
- return ErrGenesis(err.Error())
- }
- return nil
-}
-
-func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *GenesisState {
- var genesisState GenesisState
-
- if appState[ModuleName] != nil {
- cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState)
- }
-
- return &genesisState
-}
diff --git a/x/sudo/types/keys.go b/x/sudo/types/keys.go
deleted file mode 100644
index 0b929c41c..000000000
--- a/x/sudo/types/keys.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package types
-
-const (
- ModuleName = "sudo"
- StoreKey = ModuleName
-)
diff --git a/x/sudo/types/msgs.go b/x/sudo/types/msgs.go
deleted file mode 100644
index 7c8c7d9c4..000000000
--- a/x/sudo/types/msgs.go
+++ /dev/null
@@ -1,93 +0,0 @@
-package types
-
-import (
- "fmt"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
-)
-
-var (
- _ legacytx.LegacyMsg = &MsgEditSudoers{}
- _ legacytx.LegacyMsg = &MsgChangeRoot{}
-)
-
-// MsgEditSudoers
-
-func (m MsgEditSudoers) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil {
- return err
- }
-
- for _, contract := range m.Contracts {
- if _, err := sdk.AccAddressFromBech32(contract); err != nil {
- return err
- }
- }
-
- if !RootActions.Has(m.RootAction()) {
- return fmt.Errorf(
- "invalid action type %s, expected one of %s",
- m.Action, RootActions.ToSlice(),
- )
- }
-
- return nil
-}
-
-// GetSigners implements the sdk.Msg interface.
-func (m MsgEditSudoers) GetSigners() []sdk.AccAddress {
- signer, err := sdk.AccAddressFromBech32(m.Sender)
- if err != nil {
- panic(err)
- }
- return []sdk.AccAddress{signer}
-}
-
-// Route implements the sdk.Msg interface.
-func (msg MsgEditSudoers) Route() string { return ModuleName }
-
-// Type implements the sdk.Msg interface.
-func (msg MsgEditSudoers) Type() string { return "edit_sudoers" }
-
-// GetSignBytes implements the sdk.Msg interface.
-func (m MsgEditSudoers) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
-
-func (m MsgEditSudoers) RootAction() RootAction {
- return RootAction(m.Action)
-}
-
-// MsgChangeRoot
-
-func (m MsgChangeRoot) GetSigners() []sdk.AccAddress {
- signer, err := sdk.AccAddressFromBech32(m.Sender)
- if err != nil {
- panic(err)
- }
- return []sdk.AccAddress{signer}
-}
-
-func (m MsgChangeRoot) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil {
- return err
- }
-
- if _, err := sdk.AccAddressFromBech32(m.NewRoot); err != nil {
- return err
- }
-
- return nil
-}
-
-// Route Implements Msg.
-func (msg MsgChangeRoot) Route() string { return ModuleName }
-
-// Type Implements Msg.
-func (msg MsgChangeRoot) Type() string { return "change_root" }
-
-// GetSignBytes Implements Msg.
-func (m MsgChangeRoot) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
diff --git a/x/sudo/types/query.pb.go b/x/sudo/types/query.pb.go
deleted file mode 100644
index af9c1399e..000000000
--- a/x/sudo/types/query.pb.go
+++ /dev/null
@@ -1,531 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/sudo/v1/query.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-type QuerySudoersRequest struct {
-}
-
-func (m *QuerySudoersRequest) Reset() { *m = QuerySudoersRequest{} }
-func (m *QuerySudoersRequest) String() string { return proto.CompactTextString(m) }
-func (*QuerySudoersRequest) ProtoMessage() {}
-func (*QuerySudoersRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_3c5c8e03d8d77d77, []int{0}
-}
-func (m *QuerySudoersRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QuerySudoersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QuerySudoersRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QuerySudoersRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QuerySudoersRequest.Merge(m, src)
-}
-func (m *QuerySudoersRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QuerySudoersRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QuerySudoersRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QuerySudoersRequest proto.InternalMessageInfo
-
-// QuerySudoersResponse indicates the successful execution of MsgEditSudeors.
-type QuerySudoersResponse struct {
- Sudoers Sudoers `protobuf:"bytes,1,opt,name=sudoers,proto3" json:"sudoers"`
-}
-
-func (m *QuerySudoersResponse) Reset() { *m = QuerySudoersResponse{} }
-func (m *QuerySudoersResponse) String() string { return proto.CompactTextString(m) }
-func (*QuerySudoersResponse) ProtoMessage() {}
-func (*QuerySudoersResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_3c5c8e03d8d77d77, []int{1}
-}
-func (m *QuerySudoersResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QuerySudoersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QuerySudoersResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QuerySudoersResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QuerySudoersResponse.Merge(m, src)
-}
-func (m *QuerySudoersResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QuerySudoersResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QuerySudoersResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QuerySudoersResponse proto.InternalMessageInfo
-
-func (m *QuerySudoersResponse) GetSudoers() Sudoers {
- if m != nil {
- return m.Sudoers
- }
- return Sudoers{}
-}
-
-func init() {
- proto.RegisterType((*QuerySudoersRequest)(nil), "nibiru.sudo.v1.QuerySudoersRequest")
- proto.RegisterType((*QuerySudoersResponse)(nil), "nibiru.sudo.v1.QuerySudoersResponse")
-}
-
-func init() { proto.RegisterFile("nibiru/sudo/v1/query.proto", fileDescriptor_3c5c8e03d8d77d77) }
-
-var fileDescriptor_3c5c8e03d8d77d77 = []byte{
- // 280 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xca, 0xcb, 0x4c, 0xca,
- 0x2c, 0x2a, 0xd5, 0x2f, 0x2e, 0x4d, 0xc9, 0xd7, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa,
- 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xc8, 0xe9, 0x81, 0xe4, 0xf4, 0xca, 0x0c,
- 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x4c, 0x7a,
- 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x7e, 0x62, 0x41, 0xa6, 0x7e, 0x62, 0x5e, 0x5e, 0x7e, 0x49, 0x62,
- 0x49, 0x66, 0x7e, 0x5e, 0x31, 0x54, 0x16, 0xdd, 0xfc, 0xe2, 0x92, 0xc4, 0x92, 0x54, 0x88, 0x9c,
- 0x92, 0x28, 0x97, 0x70, 0x20, 0xc8, 0xba, 0xe0, 0xd2, 0x94, 0xfc, 0xd4, 0xa2, 0xe2, 0xa0, 0xd4,
- 0xc2, 0xd2, 0xd4, 0xe2, 0x12, 0x25, 0x7f, 0x2e, 0x11, 0x54, 0xe1, 0xe2, 0x82, 0xfc, 0xbc, 0xe2,
- 0x54, 0x21, 0x73, 0x2e, 0xf6, 0x62, 0x88, 0x90, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0xb8,
- 0x1e, 0xaa, 0x03, 0xf5, 0xa0, 0x3a, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0xa9, 0x36,
- 0x6a, 0x60, 0xe4, 0x62, 0x05, 0x9b, 0x28, 0x54, 0xce, 0xc5, 0x83, 0x6c, 0xb4, 0x90, 0x32, 0xba,
- 0x09, 0x58, 0xdc, 0x23, 0xa5, 0x82, 0x5f, 0x11, 0xc4, 0x75, 0x4a, 0x32, 0x4d, 0x97, 0x9f, 0x4c,
- 0x66, 0x12, 0x13, 0x12, 0xd1, 0x47, 0xf6, 0x31, 0xd4, 0x09, 0x4e, 0x2e, 0x27, 0x1e, 0xc9, 0x31,
- 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb,
- 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x95, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c,
- 0x9f, 0xab, 0xef, 0x07, 0xd6, 0xe9, 0x9c, 0x91, 0x98, 0x99, 0x07, 0x33, 0xa5, 0x02, 0x62, 0x4e,
- 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0xdc, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff,
- 0x97, 0xc1, 0x8d, 0xe0, 0xb5, 0x01, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// QueryClient is the client API for Query service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type QueryClient interface {
- QuerySudoers(ctx context.Context, in *QuerySudoersRequest, opts ...grpc.CallOption) (*QuerySudoersResponse, error)
-}
-
-type queryClient struct {
- cc grpc1.ClientConn
-}
-
-func NewQueryClient(cc grpc1.ClientConn) QueryClient {
- return &queryClient{cc}
-}
-
-func (c *queryClient) QuerySudoers(ctx context.Context, in *QuerySudoersRequest, opts ...grpc.CallOption) (*QuerySudoersResponse, error) {
- out := new(QuerySudoersResponse)
- err := c.cc.Invoke(ctx, "/nibiru.sudo.v1.Query/QuerySudoers", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// QueryServer is the server API for Query service.
-type QueryServer interface {
- QuerySudoers(context.Context, *QuerySudoersRequest) (*QuerySudoersResponse, error)
-}
-
-// UnimplementedQueryServer can be embedded to have forward compatible implementations.
-type UnimplementedQueryServer struct {
-}
-
-func (*UnimplementedQueryServer) QuerySudoers(ctx context.Context, req *QuerySudoersRequest) (*QuerySudoersResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method QuerySudoers not implemented")
-}
-
-func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
- s.RegisterService(&_Query_serviceDesc, srv)
-}
-
-func _Query_QuerySudoers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QuerySudoersRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).QuerySudoers(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.sudo.v1.Query/QuerySudoers",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).QuerySudoers(ctx, req.(*QuerySudoersRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Query_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.sudo.v1.Query",
- HandlerType: (*QueryServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "QuerySudoers",
- Handler: _Query_QuerySudoers_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/sudo/v1/query.proto",
-}
-
-func (m *QuerySudoersRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QuerySudoersRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QuerySudoersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QuerySudoersResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QuerySudoersResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QuerySudoersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Sudoers.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
- offset -= sovQuery(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *QuerySudoersRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QuerySudoersResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Sudoers.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func sovQuery(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozQuery(x uint64) (n int) {
- return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *QuerySudoersRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QuerySudoersRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QuerySudoersRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QuerySudoersResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QuerySudoersResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QuerySudoersResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sudoers", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Sudoers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipQuery(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthQuery
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupQuery
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthQuery
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/sudo/types/query.pb.gw.go b/x/sudo/types/query.pb.gw.go
deleted file mode 100644
index 42c9a6a60..000000000
--- a/x/sudo/types/query.pb.gw.go
+++ /dev/null
@@ -1,153 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: nibiru/sudo/v1/query.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-func request_Query_QuerySudoers_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QuerySudoersRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.QuerySudoers(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_QuerySudoers_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QuerySudoersRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.QuerySudoers(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
-// UnaryRPC :call QueryServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
-func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
-
- mux.Handle("GET", pattern_Query_QuerySudoers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_QuerySudoers_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_QuerySudoers_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterQueryHandler(ctx, mux, conn)
-}
-
-// RegisterQueryHandler registers the http handlers for service Query to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
-}
-
-// RegisterQueryHandlerClient registers the http handlers for service Query
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "QueryClient" to call the correct interceptors.
-func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
-
- mux.Handle("GET", pattern_Query_QuerySudoers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_QuerySudoers_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_QuerySudoers_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Query_QuerySudoers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "sudo", "sudoers"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Query_QuerySudoers_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/sudo/types/state.go b/x/sudo/types/state.go
deleted file mode 100644
index 80517bc78..000000000
--- a/x/sudo/types/state.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package types
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-func (sudo Sudoers) Validate() error {
- if _, err := sdk.AccAddressFromBech32(sudo.Root); err != nil {
- return ErrSudoers("root addr: " + err.Error())
- }
- for _, contract := range sudo.Contracts {
- if _, err := sdk.AccAddressFromBech32(contract); err != nil {
- return ErrSudoers("contract addr: " + err.Error())
- }
- }
- return nil
-}
-
-type SudoersJson struct {
- Root string `json:"root"`
- Contracts []string `json:"contracts"`
-}
diff --git a/x/sudo/types/state.pb.go b/x/sudo/types/state.pb.go
deleted file mode 100644
index 9ca78c3ea..000000000
--- a/x/sudo/types/state.pb.go
+++ /dev/null
@@ -1,553 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/sudo/v1/state.proto
-
-package types
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-type Sudoers struct {
- // Root: The "root" user.
- Root string `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"`
- // Contracts: The set of contracts with elevated permissions.
- Contracts []string `protobuf:"bytes,2,rep,name=contracts,proto3" json:"contracts,omitempty"`
-}
-
-func (m *Sudoers) Reset() { *m = Sudoers{} }
-func (m *Sudoers) String() string { return proto.CompactTextString(m) }
-func (*Sudoers) ProtoMessage() {}
-func (*Sudoers) Descriptor() ([]byte, []int) {
- return fileDescriptor_4b462ff6aaf658cf, []int{0}
-}
-func (m *Sudoers) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *Sudoers) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_Sudoers.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *Sudoers) XXX_Merge(src proto.Message) {
- xxx_messageInfo_Sudoers.Merge(m, src)
-}
-func (m *Sudoers) XXX_Size() int {
- return m.Size()
-}
-func (m *Sudoers) XXX_DiscardUnknown() {
- xxx_messageInfo_Sudoers.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_Sudoers proto.InternalMessageInfo
-
-func (m *Sudoers) GetRoot() string {
- if m != nil {
- return m.Root
- }
- return ""
-}
-
-func (m *Sudoers) GetContracts() []string {
- if m != nil {
- return m.Contracts
- }
- return nil
-}
-
-// GenesisState: State for migrations and genesis for the x/sudo module.
-type GenesisState struct {
- Sudoers Sudoers `protobuf:"bytes,1,opt,name=sudoers,proto3" json:"sudoers"`
-}
-
-func (m *GenesisState) Reset() { *m = GenesisState{} }
-func (m *GenesisState) String() string { return proto.CompactTextString(m) }
-func (*GenesisState) ProtoMessage() {}
-func (*GenesisState) Descriptor() ([]byte, []int) {
- return fileDescriptor_4b462ff6aaf658cf, []int{1}
-}
-func (m *GenesisState) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *GenesisState) XXX_Merge(src proto.Message) {
- xxx_messageInfo_GenesisState.Merge(m, src)
-}
-func (m *GenesisState) XXX_Size() int {
- return m.Size()
-}
-func (m *GenesisState) XXX_DiscardUnknown() {
- xxx_messageInfo_GenesisState.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_GenesisState proto.InternalMessageInfo
-
-func (m *GenesisState) GetSudoers() Sudoers {
- if m != nil {
- return m.Sudoers
- }
- return Sudoers{}
-}
-
-func init() {
- proto.RegisterType((*Sudoers)(nil), "nibiru.sudo.v1.Sudoers")
- proto.RegisterType((*GenesisState)(nil), "nibiru.sudo.v1.GenesisState")
-}
-
-func init() { proto.RegisterFile("nibiru/sudo/v1/state.proto", fileDescriptor_4b462ff6aaf658cf) }
-
-var fileDescriptor_4b462ff6aaf658cf = []byte{
- // 258 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0x31, 0x4b, 0x03, 0x31,
- 0x1c, 0xc5, 0xef, 0xb4, 0x58, 0x2e, 0x8a, 0x43, 0x10, 0x2c, 0x47, 0x89, 0xa5, 0x53, 0x71, 0x48,
- 0xa8, 0x0e, 0x0e, 0x6e, 0x55, 0xe8, 0xe6, 0x70, 0xdd, 0xdc, 0x72, 0xd7, 0x90, 0x06, 0x34, 0xff,
- 0x23, 0xf9, 0x5f, 0xd1, 0x6f, 0xe1, 0xc7, 0xea, 0xd8, 0xd1, 0x49, 0xe4, 0xee, 0x8b, 0xc8, 0x25,
- 0x15, 0x71, 0x7b, 0xe4, 0xf7, 0x78, 0x79, 0xff, 0x47, 0x72, 0x6b, 0x4a, 0xe3, 0x1a, 0xe1, 0x9b,
- 0x35, 0x88, 0xed, 0x5c, 0x78, 0x94, 0xa8, 0x78, 0xed, 0x00, 0x81, 0x9e, 0x47, 0xc6, 0x7b, 0xc6,
- 0xb7, 0xf3, 0xfc, 0x42, 0x83, 0x86, 0x80, 0x44, 0xaf, 0xa2, 0x2b, 0x1f, 0x6b, 0x00, 0xfd, 0xa2,
- 0x84, 0xac, 0x8d, 0x90, 0xd6, 0x02, 0x4a, 0x34, 0x60, 0x7d, 0xa4, 0xd3, 0x7b, 0x32, 0x5c, 0x35,
- 0x6b, 0x50, 0xce, 0x53, 0x4a, 0x06, 0x0e, 0x00, 0x47, 0xe9, 0x24, 0x9d, 0x65, 0x45, 0xd0, 0x74,
- 0x4c, 0xb2, 0x0a, 0x2c, 0x3a, 0x59, 0xa1, 0x1f, 0x1d, 0x4d, 0x8e, 0x67, 0x59, 0xf1, 0xf7, 0x30,
- 0x5d, 0x92, 0xb3, 0xa5, 0xb2, 0xca, 0x1b, 0xbf, 0xea, 0x6b, 0xd1, 0x3b, 0x32, 0xf4, 0x31, 0x2c,
- 0x84, 0x9c, 0xde, 0x5c, 0xf2, 0xff, 0x15, 0xf9, 0xe1, 0xaf, 0xc5, 0x60, 0xf7, 0x75, 0x95, 0x14,
- 0xbf, 0xee, 0xc5, 0xe3, 0xae, 0x65, 0xe9, 0xbe, 0x65, 0xe9, 0x77, 0xcb, 0xd2, 0x8f, 0x8e, 0x25,
- 0xfb, 0x8e, 0x25, 0x9f, 0x1d, 0x4b, 0x9e, 0xaf, 0xb5, 0xc1, 0x4d, 0x53, 0xf2, 0x0a, 0x5e, 0xc5,
- 0x53, 0xc8, 0x7a, 0xd8, 0x48, 0x63, 0xc5, 0x61, 0x96, 0xb7, 0x38, 0x0c, 0xbe, 0xd7, 0xca, 0x97,
- 0x27, 0xe1, 0xa4, 0xdb, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb4, 0x57, 0x7e, 0xb3, 0x34, 0x01,
- 0x00, 0x00,
-}
-
-func (m *Sudoers) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Sudoers) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *Sudoers) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Contracts) > 0 {
- for iNdEx := len(m.Contracts) - 1; iNdEx >= 0; iNdEx-- {
- i -= len(m.Contracts[iNdEx])
- copy(dAtA[i:], m.Contracts[iNdEx])
- i = encodeVarintState(dAtA, i, uint64(len(m.Contracts[iNdEx])))
- i--
- dAtA[i] = 0x12
- }
- }
- if len(m.Root) > 0 {
- i -= len(m.Root)
- copy(dAtA[i:], m.Root)
- i = encodeVarintState(dAtA, i, uint64(len(m.Root)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *GenesisState) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Sudoers.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintState(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func encodeVarintState(dAtA []byte, offset int, v uint64) int {
- offset -= sovState(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *Sudoers) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Root)
- if l > 0 {
- n += 1 + l + sovState(uint64(l))
- }
- if len(m.Contracts) > 0 {
- for _, s := range m.Contracts {
- l = len(s)
- n += 1 + l + sovState(uint64(l))
- }
- }
- return n
-}
-
-func (m *GenesisState) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Sudoers.Size()
- n += 1 + l + sovState(uint64(l))
- return n
-}
-
-func sovState(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozState(x uint64) (n int) {
- return sovState(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *Sudoers) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: Sudoers: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: Sudoers: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Root = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Contracts", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Contracts = append(m.Contracts, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipState(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthState
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *GenesisState) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sudoers", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Sudoers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipState(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthState
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipState(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthState
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupState
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthState
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthState = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowState = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupState = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/sudo/types/tx.pb.go b/x/sudo/types/tx.pb.go
deleted file mode 100644
index 6d59db760..000000000
--- a/x/sudo/types/tx.pb.go
+++ /dev/null
@@ -1,1028 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/sudo/v1/tx.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// MsgEditSudoers: Msg to update the "Sudoers" state.
-type MsgEditSudoers struct {
- // Action: identifier for the type of edit that will take place. Using this
- // action field prevents us from needing to create several similar message
- // types.
- Action string `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"`
- // Contracts: An input payload.
- Contracts []string `protobuf:"bytes,2,rep,name=contracts,proto3" json:"contracts,omitempty"`
- // Sender: Address for the signer of the transaction.
- Sender string `protobuf:"bytes,3,opt,name=sender,proto3" json:"sender,omitempty"`
-}
-
-func (m *MsgEditSudoers) Reset() { *m = MsgEditSudoers{} }
-func (m *MsgEditSudoers) String() string { return proto.CompactTextString(m) }
-func (*MsgEditSudoers) ProtoMessage() {}
-func (*MsgEditSudoers) Descriptor() ([]byte, []int) {
- return fileDescriptor_a610e3c1609cdcbc, []int{0}
-}
-func (m *MsgEditSudoers) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgEditSudoers) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgEditSudoers.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgEditSudoers) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgEditSudoers.Merge(m, src)
-}
-func (m *MsgEditSudoers) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgEditSudoers) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgEditSudoers.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgEditSudoers proto.InternalMessageInfo
-
-func (m *MsgEditSudoers) GetAction() string {
- if m != nil {
- return m.Action
- }
- return ""
-}
-
-func (m *MsgEditSudoers) GetContracts() []string {
- if m != nil {
- return m.Contracts
- }
- return nil
-}
-
-func (m *MsgEditSudoers) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-// MsgEditSudoersResponse indicates the successful execution of MsgEditSudeors.
-type MsgEditSudoersResponse struct {
-}
-
-func (m *MsgEditSudoersResponse) Reset() { *m = MsgEditSudoersResponse{} }
-func (m *MsgEditSudoersResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgEditSudoersResponse) ProtoMessage() {}
-func (*MsgEditSudoersResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_a610e3c1609cdcbc, []int{1}
-}
-func (m *MsgEditSudoersResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgEditSudoersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgEditSudoersResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgEditSudoersResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgEditSudoersResponse.Merge(m, src)
-}
-func (m *MsgEditSudoersResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgEditSudoersResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgEditSudoersResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgEditSudoersResponse proto.InternalMessageInfo
-
-// MsgChangeRoot: Msg to update the "Sudoers" state.
-type MsgChangeRoot struct {
- // Sender: Address for the signer of the transaction.
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"`
- // NewRoot: New root address.
- NewRoot string `protobuf:"bytes,2,opt,name=new_root,json=newRoot,proto3" json:"new_root,omitempty"`
-}
-
-func (m *MsgChangeRoot) Reset() { *m = MsgChangeRoot{} }
-func (m *MsgChangeRoot) String() string { return proto.CompactTextString(m) }
-func (*MsgChangeRoot) ProtoMessage() {}
-func (*MsgChangeRoot) Descriptor() ([]byte, []int) {
- return fileDescriptor_a610e3c1609cdcbc, []int{2}
-}
-func (m *MsgChangeRoot) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgChangeRoot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgChangeRoot.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgChangeRoot) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgChangeRoot.Merge(m, src)
-}
-func (m *MsgChangeRoot) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgChangeRoot) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgChangeRoot.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgChangeRoot proto.InternalMessageInfo
-
-func (m *MsgChangeRoot) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-func (m *MsgChangeRoot) GetNewRoot() string {
- if m != nil {
- return m.NewRoot
- }
- return ""
-}
-
-// MsgChangeRootResponse indicates the successful execution of MsgChangeRoot.
-type MsgChangeRootResponse struct {
-}
-
-func (m *MsgChangeRootResponse) Reset() { *m = MsgChangeRootResponse{} }
-func (m *MsgChangeRootResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgChangeRootResponse) ProtoMessage() {}
-func (*MsgChangeRootResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_a610e3c1609cdcbc, []int{3}
-}
-func (m *MsgChangeRootResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgChangeRootResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgChangeRootResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgChangeRootResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgChangeRootResponse.Merge(m, src)
-}
-func (m *MsgChangeRootResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgChangeRootResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgChangeRootResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgChangeRootResponse proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*MsgEditSudoers)(nil), "nibiru.sudo.v1.MsgEditSudoers")
- proto.RegisterType((*MsgEditSudoersResponse)(nil), "nibiru.sudo.v1.MsgEditSudoersResponse")
- proto.RegisterType((*MsgChangeRoot)(nil), "nibiru.sudo.v1.MsgChangeRoot")
- proto.RegisterType((*MsgChangeRootResponse)(nil), "nibiru.sudo.v1.MsgChangeRootResponse")
-}
-
-func init() { proto.RegisterFile("nibiru/sudo/v1/tx.proto", fileDescriptor_a610e3c1609cdcbc) }
-
-var fileDescriptor_a610e3c1609cdcbc = []byte{
- // 368 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xcd, 0x4e, 0xea, 0x40,
- 0x18, 0x86, 0x29, 0x24, 0x9c, 0xc3, 0x9c, 0x1c, 0x16, 0x8d, 0x42, 0xa9, 0xd8, 0x60, 0x13, 0x0d,
- 0x71, 0xd1, 0x09, 0x7a, 0x07, 0xa0, 0x4b, 0x5c, 0xd4, 0x9d, 0x0b, 0xc9, 0xd0, 0x4e, 0x86, 0x49,
- 0x74, 0xbe, 0xa6, 0x33, 0x05, 0xdc, 0x7a, 0x05, 0x26, 0xde, 0x94, 0x4b, 0x12, 0x37, 0x2e, 0x0d,
- 0x78, 0x0b, 0xee, 0x4d, 0xa7, 0xfc, 0xb4, 0x89, 0x61, 0xd7, 0xe9, 0xf3, 0xbd, 0xcf, 0x3b, 0x33,
- 0x2d, 0x6a, 0x0a, 0x3e, 0xe6, 0x71, 0x82, 0x65, 0x12, 0x02, 0x9e, 0xf6, 0xb0, 0x9a, 0x7b, 0x51,
- 0x0c, 0x0a, 0xcc, 0x7a, 0x06, 0xbc, 0x14, 0x78, 0xd3, 0x9e, 0x7d, 0xc0, 0x80, 0x81, 0x46, 0x38,
- 0x7d, 0xca, 0xa6, 0xec, 0x36, 0x03, 0x60, 0x0f, 0x14, 0x93, 0x88, 0x63, 0x22, 0x04, 0x28, 0xa2,
- 0x38, 0x08, 0x99, 0x51, 0xf7, 0x1e, 0xd5, 0x87, 0x92, 0x5d, 0x87, 0x5c, 0xdd, 0x26, 0x21, 0xd0,
- 0x58, 0x9a, 0x0d, 0x54, 0x25, 0x41, 0x3a, 0x62, 0x19, 0x1d, 0xa3, 0x5b, 0xf3, 0xd7, 0x2b, 0xb3,
- 0x8d, 0x6a, 0x01, 0x08, 0x15, 0x93, 0x40, 0x49, 0xab, 0xdc, 0xa9, 0x74, 0x6b, 0xfe, 0xee, 0x45,
- 0x9a, 0x92, 0x54, 0x84, 0x34, 0xb6, 0x2a, 0x59, 0x2a, 0x5b, 0xb9, 0x16, 0x6a, 0x14, 0xfd, 0x3e,
- 0x95, 0x11, 0x08, 0x49, 0xdd, 0x3e, 0xfa, 0x3f, 0x94, 0x6c, 0x30, 0x21, 0x82, 0x51, 0x1f, 0x40,
- 0xe5, 0x14, 0x46, 0x5e, 0x61, 0xb6, 0xd0, 0x5f, 0x41, 0x67, 0xa3, 0x18, 0x40, 0x59, 0x65, 0x4d,
- 0xfe, 0x08, 0x3a, 0x4b, 0x23, 0x6e, 0x13, 0x1d, 0x16, 0x1c, 0x1b, 0xf9, 0xc5, 0xb7, 0x81, 0x2a,
- 0x43, 0xc9, 0xcc, 0x39, 0xfa, 0x97, 0x3f, 0x9b, 0xe3, 0x15, 0xaf, 0xcc, 0x2b, 0xee, 0xcd, 0x3e,
- 0xdb, 0xcf, 0xb7, 0x7b, 0x3f, 0x79, 0x7e, 0xff, 0x7a, 0x2d, 0x1f, 0xb9, 0x2d, 0x9c, 0xff, 0x36,
- 0x34, 0xe4, 0x6a, 0x24, 0xd7, 0x55, 0x0a, 0xa1, 0xdc, 0xd9, 0x8e, 0x7f, 0x11, 0xef, 0xb0, 0x7d,
- 0xba, 0x17, 0x6f, 0x6b, 0x3b, 0xba, 0xd6, 0x76, 0xad, 0x42, 0x6d, 0xa0, 0x07, 0xf5, 0xfd, 0xf4,
- 0xaf, 0xde, 0x96, 0x8e, 0xb1, 0x58, 0x3a, 0xc6, 0xe7, 0xd2, 0x31, 0x5e, 0x56, 0x4e, 0x69, 0xb1,
- 0x72, 0x4a, 0x1f, 0x2b, 0xa7, 0x74, 0x77, 0xce, 0xb8, 0x9a, 0x24, 0x63, 0x2f, 0x80, 0x47, 0x7c,
- 0xa3, 0xd3, 0x83, 0x09, 0xe1, 0x62, 0x63, 0x9a, 0x67, 0x2e, 0xf5, 0x14, 0x51, 0x39, 0xae, 0xea,
- 0x7f, 0xe3, 0xf2, 0x27, 0x00, 0x00, 0xff, 0xff, 0x0d, 0x5c, 0x76, 0xe7, 0x7a, 0x02, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// MsgClient is the client API for Msg service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type MsgClient interface {
- // EditSudoers updates the "Sudoers" state
- EditSudoers(ctx context.Context, in *MsgEditSudoers, opts ...grpc.CallOption) (*MsgEditSudoersResponse, error)
- ChangeRoot(ctx context.Context, in *MsgChangeRoot, opts ...grpc.CallOption) (*MsgChangeRootResponse, error)
-}
-
-type msgClient struct {
- cc grpc1.ClientConn
-}
-
-func NewMsgClient(cc grpc1.ClientConn) MsgClient {
- return &msgClient{cc}
-}
-
-func (c *msgClient) EditSudoers(ctx context.Context, in *MsgEditSudoers, opts ...grpc.CallOption) (*MsgEditSudoersResponse, error) {
- out := new(MsgEditSudoersResponse)
- err := c.cc.Invoke(ctx, "/nibiru.sudo.v1.Msg/EditSudoers", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) ChangeRoot(ctx context.Context, in *MsgChangeRoot, opts ...grpc.CallOption) (*MsgChangeRootResponse, error) {
- out := new(MsgChangeRootResponse)
- err := c.cc.Invoke(ctx, "/nibiru.sudo.v1.Msg/ChangeRoot", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// MsgServer is the server API for Msg service.
-type MsgServer interface {
- // EditSudoers updates the "Sudoers" state
- EditSudoers(context.Context, *MsgEditSudoers) (*MsgEditSudoersResponse, error)
- ChangeRoot(context.Context, *MsgChangeRoot) (*MsgChangeRootResponse, error)
-}
-
-// UnimplementedMsgServer can be embedded to have forward compatible implementations.
-type UnimplementedMsgServer struct {
-}
-
-func (*UnimplementedMsgServer) EditSudoers(ctx context.Context, req *MsgEditSudoers) (*MsgEditSudoersResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EditSudoers not implemented")
-}
-func (*UnimplementedMsgServer) ChangeRoot(ctx context.Context, req *MsgChangeRoot) (*MsgChangeRootResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ChangeRoot not implemented")
-}
-
-func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
- s.RegisterService(&_Msg_serviceDesc, srv)
-}
-
-func _Msg_EditSudoers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgEditSudoers)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).EditSudoers(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.sudo.v1.Msg/EditSudoers",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).EditSudoers(ctx, req.(*MsgEditSudoers))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_ChangeRoot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgChangeRoot)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).ChangeRoot(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.sudo.v1.Msg/ChangeRoot",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).ChangeRoot(ctx, req.(*MsgChangeRoot))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Msg_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.sudo.v1.Msg",
- HandlerType: (*MsgServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "EditSudoers",
- Handler: _Msg_EditSudoers_Handler,
- },
- {
- MethodName: "ChangeRoot",
- Handler: _Msg_ChangeRoot_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/sudo/v1/tx.proto",
-}
-
-func (m *MsgEditSudoers) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgEditSudoers) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgEditSudoers) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.Contracts) > 0 {
- for iNdEx := len(m.Contracts) - 1; iNdEx >= 0; iNdEx-- {
- i -= len(m.Contracts[iNdEx])
- copy(dAtA[i:], m.Contracts[iNdEx])
- i = encodeVarintTx(dAtA, i, uint64(len(m.Contracts[iNdEx])))
- i--
- dAtA[i] = 0x12
- }
- }
- if len(m.Action) > 0 {
- i -= len(m.Action)
- copy(dAtA[i:], m.Action)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Action)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgEditSudoersResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgEditSudoersResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgEditSudoersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgChangeRoot) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgChangeRoot) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgChangeRoot) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.NewRoot) > 0 {
- i -= len(m.NewRoot)
- copy(dAtA[i:], m.NewRoot)
- i = encodeVarintTx(dAtA, i, uint64(len(m.NewRoot)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgChangeRootResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgChangeRootResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgChangeRootResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
- offset -= sovTx(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *MsgEditSudoers) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Action)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- if len(m.Contracts) > 0 {
- for _, s := range m.Contracts {
- l = len(s)
- n += 1 + l + sovTx(uint64(l))
- }
- }
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgEditSudoersResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgChangeRoot) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.NewRoot)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgChangeRootResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func sovTx(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozTx(x uint64) (n int) {
- return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *MsgEditSudoers) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgEditSudoers: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgEditSudoers: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Action = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Contracts", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Contracts = append(m.Contracts, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgEditSudoersResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgEditSudoersResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgEditSudoersResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgChangeRoot) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgChangeRoot: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgChangeRoot: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field NewRoot", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.NewRoot = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgChangeRootResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgChangeRootResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgChangeRootResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipTx(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthTx
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupTx
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthTx
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowTx = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/sudo/types/tx.pb.gw.go b/x/sudo/types/tx.pb.gw.go
deleted file mode 100644
index e2b7b401d..000000000
--- a/x/sudo/types/tx.pb.gw.go
+++ /dev/null
@@ -1,254 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: nibiru/sudo/v1/tx.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-var (
- filter_Msg_EditSudoers_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_EditSudoers_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgEditSudoers
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_EditSudoers_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.EditSudoers(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_EditSudoers_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgEditSudoers
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_EditSudoers_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.EditSudoers(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Msg_ChangeRoot_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Msg_ChangeRoot_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgChangeRoot
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_ChangeRoot_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.ChangeRoot(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Msg_ChangeRoot_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq MsgChangeRoot
- var metadata runtime.ServerMetadata
-
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_ChangeRoot_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.ChangeRoot(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux".
-// UnaryRPC :call MsgServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead.
-func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error {
-
- mux.Handle("POST", pattern_Msg_EditSudoers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_EditSudoers_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_EditSudoers_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_ChangeRoot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Msg_ChangeRoot_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_ChangeRoot_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterMsgHandler(ctx, mux, conn)
-}
-
-// RegisterMsgHandler registers the http handlers for service Msg to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn))
-}
-
-// RegisterMsgHandlerClient registers the http handlers for service Msg
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "MsgClient" to call the correct interceptors.
-func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error {
-
- mux.Handle("POST", pattern_Msg_EditSudoers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_EditSudoers_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_EditSudoers_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Msg_ChangeRoot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Msg_ChangeRoot_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Msg_ChangeRoot_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Msg_EditSudoers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "sudo", "edit_sudoers"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Msg_ChangeRoot_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "sudo", "change_root"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Msg_EditSudoers_0 = runtime.ForwardResponseMessage
-
- forward_Msg_ChangeRoot_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/tokenfactory/cli/cli_test.go b/x/tokenfactory/cli/cli_test.go
deleted file mode 100644
index c7d432cb4..000000000
--- a/x/tokenfactory/cli/cli_test.go
+++ /dev/null
@@ -1,195 +0,0 @@
-package cli_test
-
-import (
- "fmt"
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- testutilcli "github.com/NibiruChain/nibiru/x/common/testutil/cli"
- "github.com/NibiruChain/nibiru/x/common/testutil/genesis"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/tokenfactory/cli"
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-var _ suite.SetupAllSuite = (*IntegrationTestSuite)(nil)
-
-type IntegrationTestSuite struct {
- suite.Suite
-
- cfg testutilcli.Config
- network *testutilcli.Network
- val *testutilcli.Validator
-}
-
-func TestIntegrationTestSuite(t *testing.T) {
- suite.Run(t, new(IntegrationTestSuite))
-}
-
-// TestTokenFactory: Runs the test suite with a deterministic order.
-func (s *IntegrationTestSuite) TestTokenFactory() {
- s.Run("CreateDenomTest", s.CreateDenomTest)
- s.Run("MintBurnTest", s.MintBurnTest)
- s.Run("ChangeAdminTest", s.ChangeAdminTest)
-}
-
-func (s *IntegrationTestSuite) SetupSuite() {
- testutil.BeforeIntegrationSuite(s.T())
- testapp.EnsureNibiruPrefix()
- encodingConfig := app.MakeEncodingConfig()
- genState := genesis.NewTestGenesisState(encodingConfig)
- cfg := testutilcli.BuildNetworkConfig(genState)
- cfg.NumValidators = 1
- network, err := testutilcli.New(s.T(), s.T().TempDir(), cfg)
- s.NoError(err)
-
- s.cfg = cfg
- s.network = network
- s.val = network.Validators[0]
- s.NoError(s.network.WaitForNextBlock())
-}
-
-func (s *IntegrationTestSuite) CreateDenomTest() {
- creator := s.val.Address
- createDenom := func(subdenom string, wantErr bool) {
- _, err := s.network.ExecTxCmd(
- cli.NewTxCmd(),
- creator, []string{"create-denom", subdenom})
- if wantErr {
- s.Require().Error(err)
- return
- }
- s.Require().NoError(err)
- s.NoError(s.network.WaitForNextBlock())
- }
-
- createDenom("nusd", false)
- createDenom("nusd", true) // Can't create the same denom twice.
- createDenom("stnibi", false)
- createDenom("stnusd", false)
-
- denomResp := new(types.QueryDenomsResponse)
- s.NoError(
- s.network.ExecQuery(
- cli.CmdQueryDenoms(), []string{creator.String()}, denomResp,
- ),
- )
- denoms := denomResp.Denoms
- wantDenoms := []string{
- types.TFDenom{Creator: creator.String(), Subdenom: "nusd"}.Denom().String(),
- types.TFDenom{Creator: creator.String(), Subdenom: "stnibi"}.Denom().String(),
- types.TFDenom{Creator: creator.String(), Subdenom: "stnusd"}.Denom().String(),
- }
- s.ElementsMatch(denoms, wantDenoms)
-}
-
-func (s *IntegrationTestSuite) MintBurnTest() {
- creator := s.val.Address
- mint := func(coin string, mintTo string, wantErr bool) {
- mintToArg := fmt.Sprintf("--mint-to=%s", mintTo)
- _, err := s.network.ExecTxCmd(
- cli.NewTxCmd(), creator, []string{"mint", coin, mintToArg})
- if wantErr {
- s.Require().Error(err)
- return
- }
- s.Require().NoError(err)
- s.NoError(s.network.WaitForNextBlock())
- }
-
- burn := func(coin string, burnFrom string, wantErr bool) {
- burnFromArg := fmt.Sprintf("--burn-from=%s", burnFrom)
- _, err := s.network.ExecTxCmd(
- cli.NewTxCmd(), creator, []string{"burn", coin, burnFromArg})
- if wantErr {
- s.Require().Error(err)
- return
- }
- s.Require().NoError(err)
- s.NoError(s.network.WaitForNextBlock())
- }
-
- t := s.T()
- t.Log("mint successfully")
- denom := types.TFDenom{
- Creator: creator.String(),
- Subdenom: "nusd",
- }
- coin := sdk.NewInt64Coin(denom.Denom().String(), 420)
- wantErr := false
- mint(coin.String(), creator.String(), wantErr) // happy
-
- t.Log("want error: unregistered denom")
- coin.Denom = "notadenom"
- wantErr = true
- mint(coin.String(), creator.String(), wantErr)
- burn(coin.String(), creator.String(), wantErr)
-
- t.Log("want error: invalid coin")
- mint("notacoin_231,,", creator.String(), wantErr)
- burn("notacoin_231,,", creator.String(), wantErr)
-
- t.Log(`want error: unable to parse "mint-to" or "burn-from"`)
- coin.Denom = denom.Denom().String()
- mint(coin.String(), "invalidAddr", wantErr)
- burn(coin.String(), "invalidAddr", wantErr)
-
- t.Log("burn successfully")
- coin.Denom = denom.Denom().String()
- wantErr = false
- burn(coin.String(), creator.String(), wantErr) // happy
-}
-
-func (s *IntegrationTestSuite) ChangeAdminTest() {
- creator := s.val.Address
- admin := creator
- newAdmin := testutil.AccAddress()
- denom := types.TFDenom{
- Creator: creator.String(),
- Subdenom: "stnibi",
- }
-
- s.T().Log("Verify current admin is creator")
- infoResp := new(types.QueryDenomInfoResponse)
- s.NoError(
- s.network.ExecQuery(
- cli.NewQueryCmd(), []string{"denom-info", denom.Denom().String()}, infoResp,
- ),
- )
- s.Equal(infoResp.Admin, admin.String())
-
- s.T().Log("Change to a new admin")
- _, err := s.network.ExecTxCmd(
- cli.NewTxCmd(),
- admin, []string{"change-admin", denom.Denom().String(), newAdmin.String()})
- s.Require().NoError(err)
-
- s.T().Log("Verify new admin is in state")
- infoResp = new(types.QueryDenomInfoResponse)
- s.NoError(
- s.network.ExecQuery(
- cli.NewQueryCmd(), []string{"denom-info", denom.Denom().String()}, infoResp,
- ),
- )
- s.Equal(infoResp.Admin, newAdmin.String())
-}
-
-func (s *IntegrationTestSuite) TestQueryModuleParams() {
- paramResp := new(types.QueryParamsResponse)
- s.NoError(
- s.network.ExecQuery(
- cli.NewQueryCmd(), []string{"params"}, paramResp,
- ),
- )
- s.Equal(paramResp.Params, types.DefaultModuleParams())
-}
-
-func (s *IntegrationTestSuite) TearDownSuite() {
- s.T().Log("tearing down integration test suite")
- s.network.Cleanup()
-}
diff --git a/x/tokenfactory/cli/query.go b/x/tokenfactory/cli/query.go
deleted file mode 100644
index d67e46154..000000000
--- a/x/tokenfactory/cli/query.go
+++ /dev/null
@@ -1,122 +0,0 @@
-package cli
-
-import (
- "fmt"
-
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
-)
-
-// NewQueryCmd returns the cli query commands for this module
-func NewQueryCmd() *cobra.Command {
- cmd := &cobra.Command{
- Use: types.ModuleName,
- Aliases: []string{"tf"},
- Short: fmt.Sprintf("Queries for the %s module", types.ModuleName),
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- cmd.AddCommand(
- CmdQueryDenoms(),
- CmdQueryModuleParams(),
- CmdQueryDenomInfo(),
- )
-
- return cmd
-}
-
-// CmdQueryDenoms: Queries all TF denoms for a given creator.
-func CmdQueryDenoms() *cobra.Command {
- cmd := &cobra.Command{
- Use: "denoms [creator] [flags]",
- Short: "Returns token denoms created by a given creator address",
- Args: cobra.ExactArgs(1),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- res, err := queryClient.Denoms(
- cmd.Context(), &types.QueryDenomsRequest{
- Creator: args[0],
- })
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
-
-// CmdQueryModuleParams: Queries module params for x/tokenfactory.
-func CmdQueryModuleParams() *cobra.Command {
- cmd := &cobra.Command{
- Use: "params [flags]",
- Short: "Get the params for the x/tokenfactory module",
- Args: cobra.ExactArgs(0),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- res, err := queryClient.Params(
- cmd.Context(), &types.QueryParamsRequest{})
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
-
-// CmdQueryDenomInfo: Queries the admin and x/bank metadata for a TF denom
-func CmdQueryDenomInfo() *cobra.Command {
- cmd := &cobra.Command{
- Use: "denom-info [denom] [flags]",
- Short: "Get the admin and x/bank metadata for a denom",
- Args: cobra.ExactArgs(1),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientQueryContext(cmd)
- if err != nil {
- return err
- }
- queryClient := types.NewQueryClient(clientCtx)
-
- res, err := queryClient.DenomInfo(
- cmd.Context(),
- &types.QueryDenomInfoRequest{
- Denom: args[0],
- },
- )
- if err != nil {
- return err
- }
-
- return clientCtx.PrintProto(res)
- },
- }
-
- flags.AddQueryFlagsToCmd(cmd)
-
- return cmd
-}
diff --git a/x/tokenfactory/cli/tx.go b/x/tokenfactory/cli/tx.go
deleted file mode 100644
index 7c472b2cc..000000000
--- a/x/tokenfactory/cli/tx.go
+++ /dev/null
@@ -1,253 +0,0 @@
-package cli
-
-import (
- "fmt"
- "strings"
-
- "github.com/MakeNowJust/heredoc/v2"
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/client/tx"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-// NewTxCmd returns the transaction commands for this module
-func NewTxCmd() *cobra.Command {
- cmd := &cobra.Command{
- Use: types.ModuleName,
- Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
- Aliases: []string{"tf"},
- DisableFlagParsing: true,
- SuggestionsMinimumDistance: 2,
- RunE: client.ValidateCmd,
- }
-
- cmd.AddCommand(
- CmdCreateDenom(),
- CmdChangeAdmin(),
- CmdMint(),
- CmdBurn(),
- CmdBurnNative(),
- // CmdModifyDenomMetadata(), // CosmWasm only
- )
-
- return cmd
-}
-
-// CmdCreateDenom broadcast MsgCreateDenom
-func CmdCreateDenom() *cobra.Command {
- cmd := &cobra.Command{
- Use: "create-denom [subdenom] [flags]",
- Short: `Create a denom of the form "tf/{creator}/{subdenom}"`,
- Args: cobra.ExactArgs(1),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- txFactory, err := tx.NewFactoryCLI(clientCtx, cmd.Flags())
- if err != nil {
- return err
- }
-
- txFactory = txFactory.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(
- clientCtx.AccountRetriever)
-
- msg := &types.MsgCreateDenom{
- Sender: clientCtx.GetFromAddress().String(),
- Subdenom: args[0],
- }
-
- return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txFactory, msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
- return cmd
-}
-
-// CmdChangeAdmin: Broadcasts MsgChangeAdmin
-func CmdChangeAdmin() *cobra.Command {
- cmd := &cobra.Command{
- Use: "change-admin [denom] [new-admin] [flags]",
- Short: "Change the admin address for a token factory denom",
- Long: heredoc.Doc(`
- Change the admin address for a token factory denom.
- Must have admin authority to do so.
- `),
- Args: cobra.ExactArgs(2),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- txFactory, err := tx.NewFactoryCLI(clientCtx, cmd.Flags())
- if err != nil {
- return err
- }
- txFactory = txFactory.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever)
-
- msg := &types.MsgChangeAdmin{
- Sender: clientCtx.GetFromAddress().String(),
- Denom: args[0],
- NewAdmin: args[1],
- }
-
- return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txFactory, msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
- return cmd
-}
-
-// CmdMint: Broadcast MsgMint
-func CmdMint() *cobra.Command {
- cmd := &cobra.Command{
- Use: "mint [coin] [--mint-to] [flags]",
- Short: "Mint a denom to an address.",
- Long: heredoc.Doc(`
- Mint a denom to an address.
- Tx signer must be the denom admin.
- If no --mint-to address is provided, it defaults to the sender.`,
- ),
- Args: cobra.ExactArgs(1),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- txFactory, err := tx.NewFactoryCLI(clientCtx, cmd.Flags())
- if err != nil {
- return err
- }
-
- coin, err := sdk.ParseCoinNormalized(args[0])
- if err != nil {
- return err
- }
-
- mintTo, err := cmd.Flags().GetString("mint-to")
- if err != nil {
- return fmt.Errorf(
- "Please provide a valid address using the --mint-to flag: %s", err)
- }
- mintToAddr, err := sdk.AccAddressFromBech32(mintTo)
- if err != nil {
- return err
- }
-
- msg := &types.MsgMint{
- Sender: clientCtx.GetFromAddress().String(),
- Coin: coin,
- MintTo: mintToAddr.String(),
- }
-
- txFactory = txFactory.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever)
-
- return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txFactory, msg)
- },
- }
-
- cmd.Flags().String("mint-to", "", "Address to mint to")
- flags.AddTxFlagsToCmd(cmd)
- return cmd
-}
-
-// CmdBurn: Broadcast MsgBurn
-func CmdBurn() *cobra.Command {
- cmd := &cobra.Command{
- Use: "burn [coin] [--burn-from] [flags]",
- Short: "Burn tokens from an address.",
- Long: heredoc.Doc(`
- Burn tokens from an address.
- Tx signer must be the denom admin.
- If no --burn-from address is provided, it defaults to the sender.`,
- ),
- Args: cobra.ExactArgs(1),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- txFactory, err := tx.NewFactoryCLI(clientCtx, cmd.Flags())
- if err != nil {
- return err
- }
- txFactory = txFactory.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever)
-
- coin, err := sdk.ParseCoinNormalized(args[0])
- if err != nil {
- return err
- }
-
- burnFrom, err := cmd.Flags().GetString("burn-from")
- if err != nil {
- return fmt.Errorf(
- "Please provide a valid address using the --burn-from flag: %s", err)
- }
-
- burnFromAddr, err := sdk.AccAddressFromBech32(burnFrom)
- if err != nil {
- return err
- }
- msg := &types.MsgBurn{
- Sender: clientCtx.GetFromAddress().String(),
- Coin: coin,
- BurnFrom: burnFromAddr.String(),
- }
-
- return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txFactory, msg)
- },
- }
-
- cmd.Flags().String("burn-from", "", "Address to burn from")
- flags.AddTxFlagsToCmd(cmd)
- return cmd
-}
-
-func CmdBurnNative() *cobra.Command {
- cmd := &cobra.Command{
- Use: "burn-native [amount]",
- Args: cobra.ExactArgs(1),
- Short: "Burn native tokens.",
- Long: strings.TrimSpace(`
-Burn native tokens.
-
-$ nibid tx tokenfactory burn-native 100unibi
-`),
- RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- burnCoin, err := sdk.ParseCoinNormalized(args[0])
- if err != nil {
- return err
- }
-
- msg := &types.MsgBurnNative{
- Sender: clientCtx.GetFromAddress().String(),
- Coin: burnCoin,
- }
-
- if err := msg.ValidateBasic(); err != nil {
- return err
- }
-
- return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
- },
- }
-
- flags.AddTxFlagsToCmd(cmd)
-
- return cmd
-}
diff --git a/x/tokenfactory/fixture/fixture.go b/x/tokenfactory/fixture/fixture.go
deleted file mode 100644
index 5a16f682c..000000000
--- a/x/tokenfactory/fixture/fixture.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package fixture
-
-const (
- // WASM_NIBI_STARGATE is a compiled version of: https://github.com/NibiruChain/cw-nibiru/blob/main/contracts/nibi-stargate/src/contract.rs
- WASM_NIBI_STARGATE = "nibi_stargate.wasm"
-)
diff --git a/x/tokenfactory/fixture/nibi_stargate.wasm b/x/tokenfactory/fixture/nibi_stargate.wasm
deleted file mode 100644
index c9de84758..000000000
Binary files a/x/tokenfactory/fixture/nibi_stargate.wasm and /dev/null differ
diff --git a/x/tokenfactory/keeper/genesis.go b/x/tokenfactory/keeper/genesis.go
deleted file mode 100644
index 01f08fb16..000000000
--- a/x/tokenfactory/keeper/genesis.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package keeper
-
-import (
- "github.com/NibiruChain/collections"
- sdk "github.com/cosmos/cosmos-sdk/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
-
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-// InitGenesis initializes the tokenfactory module's state from a provided genesis
-// state.
-func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
- k.CreateModuleAccount(ctx)
-
- if err := genState.Validate(); err != nil {
- panic(err)
- }
-
- k.Store.ModuleParams.Set(ctx, genState.Params)
-
- for _, genDenom := range genState.GetFactoryDenoms() {
- // We don't need to validate the struct again here because it's
- // performed inside of the genState.Validate() execution above.
- k.Store.unsafeGenesisInsertDenom(ctx, genDenom)
- }
-}
-
-// ExportGenesis returns the tokenfactory module's exported genesis.
-func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
- genDenoms := []types.GenesisDenom{}
- // iterator := k.GetAllDenomsIterator(ctx)
- iter := k.Store.Denoms.Iterate(ctx, collections.Range[string]{})
- defer iter.Close()
- for ; iter.Valid(); iter.Next() {
- denom := iter.Value()
-
- authorityMetadata, err := k.Store.GetDenomAuthorityMetadata(
- ctx, denom.Denom().String())
- if err != nil {
- panic(err)
- }
-
- genDenoms = append(genDenoms, types.GenesisDenom{
- Denom: denom.Denom().String(),
- AuthorityMetadata: authorityMetadata,
- })
- }
-
- moduleParams, err := k.Store.ModuleParams.Get(ctx)
- if err != nil {
- panic(err)
- }
- return &types.GenesisState{
- FactoryDenoms: genDenoms,
- Params: moduleParams,
- }
-}
-
-// CreateModuleAccount creates a module account with minting and burning
-// capabilities This account isn't intended to store any coins, it purely mints
-// and burns them on behalf of the admin of respective denoms, and sends to the
-// relevant address.
-func (k Keeper) CreateModuleAccount(ctx sdk.Context) {
- moduleAcc := authtypes.NewEmptyModuleAccount(types.ModuleName, authtypes.Minter, authtypes.Burner)
- k.accountKeeper.SetModuleAccount(ctx, moduleAcc)
-}
diff --git a/x/tokenfactory/keeper/genesis_test.go b/x/tokenfactory/keeper/genesis_test.go
deleted file mode 100644
index 8c2748b57..000000000
--- a/x/tokenfactory/keeper/genesis_test.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package keeper_test
-
-import (
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-func (s *TestSuite) TestGenesis() {
- // Produces a valid token factory denom
- randomTFDenom := func() string {
- denom := types.TFDenom{
- Creator: testutil.AccAddress().String(),
- Subdenom: testutil.RandLetters(3),
- }
- s.Require().NoError(denom.Validate())
- return denom.Denom().String()
- }
-
- testCases := []struct {
- name string
- genesis types.GenesisState
- expPanic bool
- }{
- {
- name: "default genesis",
- genesis: s.genesis,
- expPanic: false,
- },
- {
- name: "genesis populated with valid data",
- genesis: types.GenesisState{
- Params: types.DefaultModuleParams(),
- FactoryDenoms: []types.GenesisDenom{
- {
- Denom: randomTFDenom(),
- AuthorityMetadata: types.DenomAuthorityMetadata{
- Admin: testutil.AccAddress().String(),
- },
- },
- {
- Denom: randomTFDenom(),
- AuthorityMetadata: types.DenomAuthorityMetadata{
- Admin: testutil.AccAddress().String(),
- },
- },
- },
- },
- expPanic: false,
- },
- // {}, // Invalid test case
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest() // reset
-
- if tc.expPanic {
- s.Require().Panics(func() {
- })
- } else {
- s.Require().NotPanics(func() {
- s.app.TokenFactoryKeeper.InitGenesis(s.ctx, tc.genesis)
- })
-
- params, err := s.app.TokenFactoryKeeper.Store.
- ModuleParams.Get(s.ctx)
- s.NoError(err)
- s.Require().EqualValues(tc.genesis.Params, params)
-
- gen := s.app.TokenFactoryKeeper.ExportGenesis(s.ctx)
- s.NoError(gen.Validate())
- }
- })
- }
-}
diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go
deleted file mode 100644
index 98070f8a2..000000000
--- a/x/tokenfactory/keeper/grpc_query.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package keeper
-
-import (
- "context"
-
- types "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-var _ types.QueryServer = Querier{}
-
-// Querier defines a wrapper around the keeper with functions for gRPC queries.
-type Querier struct {
- Keeper
-}
-
-func (k Keeper) Querier() Querier {
- return Querier{
- Keeper: k,
- }
-}
-
-// Params: Returns the module parameters.
-func (q Querier) Params(
- goCtx context.Context,
- _ *types.QueryParamsRequest,
-) (*types.QueryParamsResponse, error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
- params, _ := q.Keeper.Store.ModuleParams.Get(ctx)
- return &types.QueryParamsResponse{Params: params}, nil
-}
-
-// QueryDenoms: Returns all registered denoms for a given creator.
-func (k Keeper) QueryDenoms(ctx sdk.Context, creator string) []string {
- iter := k.Store.Denoms.Indexes.Creator.ExactMatch(ctx, creator)
- return iter.PrimaryKeys()
-}
-
-// Denoms: Returns all registered denoms for a given creator.
-func (q Querier) Denoms(
- goCtx context.Context,
- req *types.QueryDenomsRequest,
-) (resp *types.QueryDenomsResponse, err error) {
- if req == nil {
- return resp, errNilMsg
- }
- if req.Creator == "" {
- return resp, types.ErrInvalidCreator.Wrap("empty creator address")
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
- return &types.QueryDenomsResponse{
- Denoms: q.Keeper.QueryDenoms(ctx, req.Creator),
- }, err
-}
-
-// QueryDenomInfo: Returns bank and tokenfactory metadata for a registered denom.
-func (k Keeper) QueryDenomInfo(
- ctx sdk.Context, denom string,
-) (resp *types.QueryDenomInfoResponse, err error) {
- tfMetadata, err := k.Store.denomAdmins.Get(ctx, denom)
- if err != nil {
- return resp, err
- }
-
- bankMetadata, _ := k.bankKeeper.GetDenomMetaData(ctx, denom)
- return &types.QueryDenomInfoResponse{
- Admin: tfMetadata.Admin,
- Metadata: bankMetadata,
- }, err
-}
-
-// DenomInfo: Returns bank and tokenfactory metadata for a registered denom.
-func (q Querier) DenomInfo(
- goCtx context.Context,
- req *types.QueryDenomInfoRequest,
-) (resp *types.QueryDenomInfoResponse, err error) {
- if req == nil {
- return resp, errNilMsg
- }
- if err := types.DenomStr(req.Denom).Validate(); err != nil {
- return resp, err
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
- return q.Keeper.QueryDenomInfo(ctx, req.Denom)
-}
diff --git a/x/tokenfactory/keeper/grpc_query_test.go b/x/tokenfactory/keeper/grpc_query_test.go
deleted file mode 100644
index 6897a5ec3..000000000
--- a/x/tokenfactory/keeper/grpc_query_test.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package keeper_test
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-func (s *TestSuite) TestQueryModuleParams() {
- res, err := s.querier.Params(s.GoCtx(), &types.QueryParamsRequest{})
- s.NoError(err)
- s.Equal(res.Params, types.DefaultModuleParams())
-}
-
-func (s *TestSuite) createDenom(
- creator sdk.AccAddress,
- subdenom string,
-) {
- msg := &types.MsgCreateDenom{
- Sender: creator.String(),
- Subdenom: subdenom,
- }
- s.NoError(s.HandleMsg(msg))
-}
-
-func (s *TestSuite) TestQueryDenoms() {
- creator := testutil.AccAddress()
- denom := types.TFDenom{
- Creator: creator.String(),
- Subdenom: "abc",
- }
- s.createDenom(creator, denom.Subdenom)
- s.createDenom(creator, "foobar")
-
- queryDenoms := func(creator string) (
- resp *types.QueryDenomsResponse, err error,
- ) {
- return s.querier.Denoms(s.GoCtx(),
- &types.QueryDenomsRequest{
- Creator: creator,
- })
- }
-
- denomsResp, err := queryDenoms(denom.Creator)
- s.NoError(err)
- s.ElementsMatch(denomsResp.Denoms, []string{
- denom.Denom().String(),
- types.TFDenom{
- Creator: denom.Creator,
- Subdenom: "foobar",
- }.Denom().String(),
- })
-
- denomsResp, err = queryDenoms("creator")
- s.NoError(err)
- s.Len(denomsResp.Denoms, 0)
-
- _, err = queryDenoms("")
- s.ErrorContains(err, "empty creator address")
-
- _, err = s.querier.Denoms(s.GoCtx(), nil)
- s.ErrorContains(err, "nil msg")
-}
-
-func (s *TestSuite) TestQueryDenomInfo() {
- s.SetupTest()
- creator := testutil.AccAddress()
- denom := types.TFDenom{
- Creator: creator.String(),
- Subdenom: "abc",
- }
- s.createDenom(creator, denom.Subdenom)
-
- s.Run("case: nil msg", func() {
- _, err := s.querier.DenomInfo(s.GoCtx(),
- nil)
- s.ErrorContains(err, "nil msg")
- })
-
- s.Run("case: fail denom validation", func() {
- _, err := s.querier.DenomInfo(s.GoCtx(),
- &types.QueryDenomInfoRequest{
- Denom: "notadenom",
- })
- s.ErrorContains(err, "denom format error")
- _, err = s.app.TokenFactoryKeeper.QueryDenomInfo(s.ctx, "notadenom")
- s.Error(err)
- })
-
- s.Run("case: happy", func() {
- resp, err := s.querier.DenomInfo(s.GoCtx(),
- &types.QueryDenomInfoRequest{
- Denom: denom.Denom().String(),
- })
- s.NoError(err)
- s.Equal(creator.String(), resp.Admin)
- s.Equal(denom.DefaultBankMetadata(), resp.Metadata)
- })
-}
diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go
deleted file mode 100644
index bc2908d16..000000000
--- a/x/tokenfactory/keeper/keeper.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package keeper
-
-import (
- "fmt"
-
- "github.com/cometbft/cometbft/libs/log"
-
- "github.com/cosmos/cosmos-sdk/codec"
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/collections"
-
- tftypes "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-// Keeper of this module maintains collections of feeshares for contracts
-// registered to receive Nibiru Chain gas fees.
-type Keeper struct {
- storeKey storetypes.StoreKey
- cdc codec.BinaryCodec
-
- Store StoreAPI
-
- // interfaces with other modules
- bankKeeper tftypes.BankKeeper
- accountKeeper tftypes.AccountKeeper
- communityPoolKeeper tftypes.CommunityPoolKeeper
-
- // the address capable of executing a MsgUpdateParams message. Typically,
- // this should be the x/gov module account.
- authority string
-}
-
-// NewKeeper: creates a Keeper instance for the module.
-func NewKeeper(
- storeKey storetypes.StoreKey,
- cdc codec.BinaryCodec,
- bk tftypes.BankKeeper,
- ak tftypes.AccountKeeper,
- communityPoolKeeper tftypes.CommunityPoolKeeper,
- authority string,
-) Keeper {
- return Keeper{
- storeKey: storeKey,
- Store: StoreAPI{
- Denoms: NewTFDenomStore(storeKey, cdc),
- ModuleParams: collections.NewItem(
- storeKey, tftypes.KeyPrefixModuleParams,
- collections.ProtoValueEncoder[tftypes.ModuleParams](cdc),
- ),
- creator: collections.NewKeySet[string](
- storeKey, tftypes.KeyPrefixCreator,
- collections.StringKeyEncoder,
- ),
- denomAdmins: collections.NewMap[storePKType, tftypes.DenomAuthorityMetadata](
- storeKey, tftypes.KeyPrefixDenomAdmin,
- collections.StringKeyEncoder,
- collections.ProtoValueEncoder[tftypes.DenomAuthorityMetadata](cdc),
- ),
- bankKeeper: bk,
- },
- cdc: cdc,
- bankKeeper: bk,
- accountKeeper: ak,
- communityPoolKeeper: communityPoolKeeper,
- authority: authority,
- }
-}
-
-// GetAuthority returns the x/feeshare module's authority.
-func (k Keeper) GetAuthority() string {
- return k.authority
-}
-
-// Logger returns a module-specific logger.
-func (k Keeper) Logger(ctx sdk.Context) log.Logger {
- return ctx.Logger().With("module", fmt.Sprintf("x/%s", tftypes.ModuleName))
-}
diff --git a/x/tokenfactory/keeper/keeper_test.go b/x/tokenfactory/keeper/keeper_test.go
deleted file mode 100644
index fc7a44431..000000000
--- a/x/tokenfactory/keeper/keeper_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package keeper_test
-
-import (
- "context"
- "fmt"
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- tfkeeper "github.com/NibiruChain/nibiru/x/tokenfactory/keeper"
- tftypes "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-var _ suite.SetupTestSuite = (*TestSuite)(nil)
-
-type TestSuite struct {
- suite.Suite
-
- ctx sdk.Context
- app *app.NibiruApp
- encConfig app.EncodingConfig
-
- keeper tfkeeper.Keeper
- querier tfkeeper.Querier
-
- genesis tftypes.GenesisState
-}
-
-func TestKeeperTestSuite(t *testing.T) {
- suite.Run(t, new(TestSuite))
-}
-
-// SetupTest: Runs before each test in the suite. It initializes a fresh app
-// and ctx.
-func (s *TestSuite) SetupTest() {
- testapp.EnsureNibiruPrefix()
- s.encConfig = app.MakeEncodingConfig()
- nibiruApp, ctx := testapp.NewNibiruTestAppAndContext()
- s.app = nibiruApp
- s.ctx = ctx
- s.keeper = s.app.TokenFactoryKeeper
- s.genesis = *tftypes.DefaultGenesis()
- s.querier = s.keeper.Querier()
-}
-
-func (s *TestSuite) HandleMsg(txMsg sdk.Msg) (err error) {
- goCtx := sdk.WrapSDKContext(s.ctx)
- switch txMsg := txMsg.(type) {
- case *tftypes.MsgCreateDenom:
- _, err = s.app.TokenFactoryKeeper.CreateDenom(goCtx, txMsg)
- case *tftypes.MsgMint:
- _, err = s.app.TokenFactoryKeeper.Mint(goCtx, txMsg)
- case *tftypes.MsgBurn:
- _, err = s.app.TokenFactoryKeeper.Burn(goCtx, txMsg)
- case *tftypes.MsgChangeAdmin:
- _, err = s.app.TokenFactoryKeeper.ChangeAdmin(goCtx, txMsg)
- case *tftypes.MsgSetDenomMetadata:
- _, err = s.app.TokenFactoryKeeper.SetDenomMetadata(goCtx, txMsg)
- case *tftypes.MsgBurnNative:
- _, err = s.app.TokenFactoryKeeper.BurnNative(goCtx, txMsg)
- default:
- err = fmt.Errorf("unknown message type: %t", txMsg)
- }
- return err
-}
-
-func (s *TestSuite) GoCtx() context.Context { return sdk.WrapSDKContext(s.ctx) }
diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go
deleted file mode 100644
index 279d6c4ba..000000000
--- a/x/tokenfactory/keeper/msg_server.go
+++ /dev/null
@@ -1,302 +0,0 @@
-package keeper
-
-import (
- "context"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
-
- "github.com/NibiruChain/nibiru/x/common"
-
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-var _ types.MsgServer = (*Keeper)(nil)
-
-var errNilMsg error = common.ErrNilGrpcMsg()
-
-func (k Keeper) CreateDenom(
- goCtx context.Context, txMsg *types.MsgCreateDenom,
-) (resp *types.MsgCreateDenomResponse, err error) {
- if txMsg == nil {
- return resp, errNilMsg
- }
- if err := txMsg.ValidateBasic(); err != nil {
- return resp, err
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
- denom := types.TFDenom{
- Creator: txMsg.Sender,
- Subdenom: txMsg.Subdenom,
- }
- err = k.Store.InsertDenom(ctx, denom)
- if err != nil {
- return resp, err
- }
-
- return &types.MsgCreateDenomResponse{
- NewTokenDenom: denom.Denom().String(),
- }, err
-}
-
-func (k Keeper) ChangeAdmin(
- goCtx context.Context, txMsg *types.MsgChangeAdmin,
-) (resp *types.MsgChangeAdminResponse, err error) {
- if txMsg == nil {
- return resp, errNilMsg
- }
- if err := txMsg.ValidateBasic(); err != nil {
- return resp, err
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
- authData, err := k.Store.GetDenomAuthorityMetadata(ctx, txMsg.Denom)
- if err != nil {
- return resp, err
- }
- if txMsg.Sender != authData.Admin {
- return resp, types.ErrInvalidSender.Wrapf(
- "only the current admin can set a new admin: current admin (%s), sender (%s)",
- authData.Admin, txMsg.Sender,
- )
- }
-
- authData.Admin = txMsg.NewAdmin
- k.Store.denomAdmins.Insert(ctx, txMsg.Denom, authData)
-
- return &types.MsgChangeAdminResponse{}, ctx.EventManager().EmitTypedEvent(
- &types.EventChangeAdmin{
- Denom: txMsg.Denom,
- OldAdmin: txMsg.Sender,
- NewAdmin: txMsg.NewAdmin,
- })
-}
-
-// UpdateModuleParams: Message handler for the abci.Msg: MsgUpdateModuleParams
-func (k Keeper) UpdateModuleParams(
- goCtx context.Context, txMsg *types.MsgUpdateModuleParams,
-) (resp *types.MsgUpdateModuleParamsResponse, err error) {
- if txMsg == nil {
- return resp, errNilMsg
- }
- if err := txMsg.ValidateBasic(); err != nil {
- return resp, err
- }
-
- if k.authority != txMsg.Authority {
- return nil, govtypes.ErrInvalidSigner.Wrapf("invalid authority; expected %s, got %s", k.authority, txMsg.Authority)
- }
-
- if err := txMsg.Params.Validate(); err != nil {
- return resp, err
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
- k.Store.ModuleParams.Set(ctx, txMsg.Params)
- return &types.MsgUpdateModuleParamsResponse{}, err
-}
-
-// Mint: Message handler for the abci.Msg: MsgMint
-func (k Keeper) Mint(
- goCtx context.Context, txMsg *types.MsgMint,
-) (resp *types.MsgMintResponse, err error) {
- if txMsg == nil {
- return resp, errNilMsg
- }
- if err := txMsg.ValidateBasic(); err != nil {
- return resp, err
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- admin, err := k.Store.GetAdmin(ctx, txMsg.Coin.Denom)
- if err != nil {
- return nil, err
- }
-
- if txMsg.Sender != admin {
- return resp, types.ErrUnauthorized.Wrapf(
- "sender (%s), admin (%s)", txMsg.Sender, admin,
- )
- }
-
- if txMsg.MintTo == "" {
- txMsg.MintTo = txMsg.Sender
- }
-
- if err := k.mint(
- ctx, txMsg.Coin, txMsg.MintTo, txMsg.Sender,
- ); err != nil {
- return resp, err
- }
-
- return &types.MsgMintResponse{
- MintTo: txMsg.MintTo,
- }, ctx.EventManager().EmitTypedEvent(
- &types.EventMint{
- Coin: txMsg.Coin,
- ToAddr: txMsg.MintTo,
- Caller: txMsg.Sender,
- },
- )
-}
-
-func (k Keeper) mint(
- ctx sdk.Context, coin sdk.Coin, mintTo string, caller string,
-) error {
- if err := types.DenomStr(coin.Denom).Validate(); err != nil {
- return err
- }
-
- coins := sdk.NewCoins(coin)
- err := k.bankKeeper.MintCoins(ctx, types.ModuleName, coins)
- if err != nil {
- return err
- }
-
- mintToAddr, err := sdk.AccAddressFromBech32(mintTo)
- if err != nil {
- return err
- }
-
- if k.bankKeeper.BlockedAddr(mintToAddr) {
- return types.ErrBlockedAddress.Wrapf(
- "failed to mint to %s", mintToAddr)
- }
-
- return k.bankKeeper.SendCoinsFromModuleToAccount(
- ctx, types.ModuleName, mintToAddr, coins,
- )
-}
-
-// Burn: Message handler for the abci.Msg: MsgBurn
-func (k Keeper) Burn(
- goCtx context.Context, txMsg *types.MsgBurn,
-) (resp *types.MsgBurnResponse, err error) {
- if txMsg == nil {
- return resp, errNilMsg
- }
- if err := txMsg.ValidateBasic(); err != nil {
- return resp, err
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- admin, err := k.Store.GetAdmin(ctx, txMsg.Coin.Denom)
- if err != nil {
- return nil, err
- }
-
- if txMsg.Sender != admin {
- return resp, types.ErrUnauthorized.Wrapf(
- "sender (%s), admin (%s)", txMsg.Sender, admin,
- )
- }
-
- if txMsg.BurnFrom == "" {
- txMsg.BurnFrom = txMsg.Sender
- }
-
- if err := k.burn(
- ctx, txMsg.Coin, txMsg.BurnFrom, txMsg.Sender,
- ); err != nil {
- return resp, err
- }
-
- return &types.MsgBurnResponse{}, ctx.EventManager().EmitTypedEvent(
- &types.EventBurn{
- Coin: txMsg.Coin,
- FromAddr: txMsg.BurnFrom,
- Caller: txMsg.Sender,
- },
- )
-}
-
-func (k Keeper) burn(
- ctx sdk.Context, coin sdk.Coin, burnFrom string, caller string,
-) error {
- if err := types.DenomStr(coin.Denom).Validate(); err != nil {
- return err
- }
-
- burnFromAddr, err := sdk.AccAddressFromBech32(burnFrom)
- if err != nil {
- return err
- }
-
- if k.bankKeeper.BlockedAddr(burnFromAddr) {
- return types.ErrBlockedAddress.Wrapf(
- "failed to burn from %s", burnFromAddr)
- }
-
- coins := sdk.NewCoins(coin)
- if err = k.bankKeeper.SendCoinsFromAccountToModule(
- ctx, burnFromAddr, types.ModuleName, coins,
- ); err != nil {
- return err
- }
-
- return k.bankKeeper.BurnCoins(ctx, types.ModuleName, coins)
-}
-
-// SetDenomMetadata: Message handler for the abci.Msg: MsgSetDenomMetadata
-func (k Keeper) SetDenomMetadata(
- goCtx context.Context, txMsg *types.MsgSetDenomMetadata,
-) (resp *types.MsgSetDenomMetadataResponse, err error) {
- if txMsg == nil {
- return resp, errNilMsg
- }
- if err := txMsg.ValidateBasic(); err != nil {
- return resp, err
- }
-
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- denom := txMsg.Metadata.Base
- admin, err := k.Store.GetAdmin(ctx, denom)
- if err != nil {
- return nil, err
- }
-
- if txMsg.Sender != admin {
- return resp, types.ErrUnauthorized.Wrapf(
- "sender (%s), admin (%s)", txMsg.Sender, admin,
- )
- }
-
- k.bankKeeper.SetDenomMetaData(ctx, txMsg.Metadata)
-
- return &types.MsgSetDenomMetadataResponse{}, ctx.EventManager().
- EmitTypedEvent(&types.EventSetDenomMetadata{
- Denom: denom,
- Metadata: txMsg.Metadata,
- Caller: txMsg.Sender,
- })
-}
-
-func (k Keeper) BurnNative(
- goCtx context.Context, msg *types.MsgBurnNative,
-) (resp *types.MsgBurnNativeResponse, err error) {
- ctx := sdk.UnwrapSDKContext(goCtx)
-
- sender, err := sdk.AccAddressFromBech32(msg.Sender)
- if err != nil {
- return nil, err
- }
-
- coins := sdk.NewCoins(msg.Coin)
-
- if err := k.bankKeeper.SendCoinsFromAccountToModule(
- ctx, sender, types.ModuleName, coins,
- ); err != nil {
- return nil, err
- }
-
- err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, coins)
- if err != nil {
- return nil, err
- }
-
- return &types.MsgBurnNativeResponse{}, err
-}
diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go
deleted file mode 100644
index 0167bd507..000000000
--- a/x/tokenfactory/keeper/msg_server_test.go
+++ /dev/null
@@ -1,726 +0,0 @@
-package keeper_test
-
-import (
- "github.com/NibiruChain/collections"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "cosmossdk.io/math"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-func (s *TestSuite) TestCreateDenom() {
- _, addrs := testutil.PrivKeyAddressPairs(4)
-
- testCases := []struct {
- name string
- txMsg *types.MsgCreateDenom
- wantErr string
- preHook func(ctx sdk.Context, bapp *app.NibiruApp)
- postHook func(ctx sdk.Context, bapp *app.NibiruApp)
- }{
- {
- name: "happy path",
- txMsg: &types.MsgCreateDenom{Sender: addrs[0].String(), Subdenom: "nusd"},
- wantErr: "",
- preHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- allDenoms := bapp.TokenFactoryKeeper.Store.Denoms.
- Iterate(ctx, collections.Range[string]{}).Values()
- s.Len(allDenoms, 0)
- },
- postHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- allDenoms := bapp.TokenFactoryKeeper.Store.Denoms.
- Iterate(ctx, collections.Range[string]{}).Values()
- s.Len(allDenoms, 1)
- s.Equal(allDenoms[0].Subdenom, "nusd")
- },
- },
- {
- name: "creating the same denom a second time should fail",
- txMsg: &types.MsgCreateDenom{Sender: addrs[0].String(), Subdenom: "nusd"},
- wantErr: "attempting to create denom that is already registered",
- preHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- allDenoms := bapp.TokenFactoryKeeper.Store.Denoms.
- Iterate(ctx, collections.Range[string]{}).Values()
- s.Len(allDenoms, 0)
- _, err := bapp.TokenFactoryKeeper.CreateDenom(
- sdk.WrapSDKContext(s.ctx), &types.MsgCreateDenom{
- Sender: addrs[0].String(),
- Subdenom: "nusd",
- },
- )
- s.NoError(err)
- },
- postHook: func(ctx sdk.Context, bapp *app.NibiruApp) {},
- },
-
- {
- name: "sad: nil msg",
- txMsg: nil,
- wantErr: "nil msg",
- },
-
- {
- name: "sad: sender",
- txMsg: &types.MsgCreateDenom{Sender: "sender", Subdenom: "nusd"},
- wantErr: "invalid creator",
- },
-
- {
- name: "sad: denom",
- txMsg: &types.MsgCreateDenom{Sender: addrs[0].String(), Subdenom: ""},
- wantErr: "denom format error",
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest()
- if tc.preHook != nil {
- tc.preHook(s.ctx, s.app)
- }
-
- resp, err := s.app.TokenFactoryKeeper.CreateDenom(
- sdk.WrapSDKContext(s.ctx), tc.txMsg,
- )
-
- if tc.wantErr != "" {
- s.Error(err)
- s.ErrorContains(err, tc.wantErr)
- return
- }
-
- s.NoError(err)
- want := types.TFDenom{
- Creator: tc.txMsg.Sender,
- Subdenom: tc.txMsg.Subdenom,
- }.Denom()
- s.Equal(want.String(), resp.NewTokenDenom)
-
- if tc.postHook != nil {
- tc.postHook(s.ctx, s.app)
- }
- })
- }
-}
-
-func (s *TestSuite) TestChangeAdmin() {
- sbf := testutil.AccAddress().String()
-
- testCases := []struct {
- Name string
- txMsg *types.MsgChangeAdmin
- wantErr string
- preHook func(ctx sdk.Context, bapp *app.NibiruApp)
- postHook func(ctx sdk.Context, bapp *app.NibiruApp)
- }{
- {
- Name: "sad: nil msg",
- txMsg: nil,
- wantErr: "nil msg",
- },
-
- {
- Name: "sad: fail validate basic",
- txMsg: &types.MsgChangeAdmin{
- Sender: "sender", Denom: "tf/creator/nusd", NewAdmin: "new admin",
- },
- wantErr: "invalid sender",
- },
-
- {
- Name: "sad: non-admin tries to change admin",
- txMsg: &types.MsgChangeAdmin{
- Sender: testutil.AccAddress().String(),
- Denom: types.TFDenom{Creator: sbf, Subdenom: "ftt"}.Denom().String(),
- NewAdmin: testutil.AccAddress().String(),
- },
- wantErr: "only the current admin can set a new admin",
- preHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- _, err := bapp.TokenFactoryKeeper.CreateDenom(
- sdk.WrapSDKContext(ctx), &types.MsgCreateDenom{
- Sender: sbf,
- Subdenom: "ftt",
- },
- )
- s.NoError(err)
- },
- },
-
- {
- Name: "happy: SBF changes FTT admin",
- txMsg: &types.MsgChangeAdmin{
- Sender: sbf,
- Denom: types.TFDenom{Creator: sbf, Subdenom: "ftt"}.Denom().String(),
- NewAdmin: testutil.AccAddress().String(),
- },
- wantErr: "",
- preHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- _, err := bapp.TokenFactoryKeeper.CreateDenom(
- sdk.WrapSDKContext(ctx), &types.MsgCreateDenom{
- Sender: sbf,
- Subdenom: "ftt",
- },
- )
- s.NoError(err)
- },
- },
-
- {
- Name: "sad: change admin for denom that doesn't exist ",
- txMsg: &types.MsgChangeAdmin{
- Sender: sbf,
- Denom: types.TFDenom{Creator: sbf, Subdenom: "ftt"}.Denom().String(),
- NewAdmin: testutil.AccAddress().String(),
- },
- wantErr: collections.ErrNotFound.Error(),
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.Name, func() {
- s.SetupTest()
- if tc.preHook != nil {
- tc.preHook(s.ctx, s.app)
- }
-
- _, err := s.app.TokenFactoryKeeper.ChangeAdmin(
- sdk.WrapSDKContext(s.ctx), tc.txMsg,
- )
-
- if tc.wantErr != "" {
- s.Error(err)
- s.ErrorContains(err, tc.wantErr)
- return
- }
-
- s.T().Log("expect new admin to be set in state.")
- s.NoError(err)
- authData, err := s.app.TokenFactoryKeeper.Store.GetDenomAuthorityMetadata(
- s.ctx, tc.txMsg.Denom)
- s.NoError(err)
- s.Equal(authData.Admin, tc.txMsg.NewAdmin)
-
- if tc.postHook != nil {
- tc.postHook(s.ctx, s.app)
- }
- })
- }
-}
-
-func (s *TestSuite) TestUpdateModuleParams() {
- testCases := []struct {
- name string
- txMsg *types.MsgUpdateModuleParams
- wantErr string
- }{
- {
- name: "sad: nil msg",
- txMsg: nil,
- wantErr: "nil msg",
- },
-
- {
- name: "sad: fail validate basic",
- txMsg: &types.MsgUpdateModuleParams{
- Authority: "authority",
- Params: types.DefaultModuleParams(),
- },
- wantErr: "invalid authority",
- },
-
- {
- name: "sad: must be gov proposal form x/gov module account",
- txMsg: &types.MsgUpdateModuleParams{
- Authority: testutil.AccAddress().String(),
- Params: types.DefaultModuleParams(),
- },
- wantErr: "expected gov account as only signer for proposal message",
- },
-
- {
- name: "happy: new params",
- txMsg: &types.MsgUpdateModuleParams{
- Authority: testutil.GovModuleAddr().String(),
- Params: types.ModuleParams{
- DenomCreationGasConsume: 69_420,
- },
- },
- wantErr: "",
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- s.SetupTest()
- _, err := s.app.TokenFactoryKeeper.UpdateModuleParams(
- sdk.WrapSDKContext(s.ctx), tc.txMsg,
- )
-
- if tc.wantErr != "" {
- s.Error(err)
- s.ErrorContains(err, tc.wantErr)
- return
- }
- s.NoError(err)
-
- params, err := s.app.TokenFactoryKeeper.Store.ModuleParams.Get(s.ctx)
- s.Require().NoError(err)
- s.Equal(params, tc.txMsg.Params)
- })
- }
-}
-
-type TestCaseTx struct {
- // Name: identifier for the test case.
- Name string
-
- // SetupMsgs: a list of messages to broadcast in order that should execute
- // without error. These can be used to create complex scenarios.
- SetupMsgs []sdk.Msg
-
- // PreHook: an optional hook that runs before TestMsgs
- PreHook func(ctx sdk.Context, bapp *app.NibiruApp)
-
- TestMsgs []TestMsgElem
-
- // PostHook: an optional hook that runs after TestMsgs
- PostHook func(ctx sdk.Context, bapp *app.NibiruApp)
-}
-
-func (tc TestCaseTx) RunTest(s *TestSuite) {
- for _, txMsg := range tc.SetupMsgs {
- err := s.HandleMsg(txMsg)
- s.Require().NoError(err)
- }
-
- if tc.PreHook != nil {
- tc.PreHook(s.ctx, s.app)
- }
-
- for _, msgTc := range tc.TestMsgs {
- err := s.HandleMsg(msgTc.TestMsg)
- if msgTc.WantErr != "" {
- s.ErrorContains(err, msgTc.WantErr)
- continue
- }
- s.NoError(err)
- }
-
- if tc.PostHook != nil {
- tc.PostHook(s.ctx, s.app)
- }
-}
-
-type TestMsgElem struct {
- TestMsg sdk.Msg
- WantErr string
-}
-
-func (s *TestSuite) TestMintBurn() {
- _, addrs := testutil.PrivKeyAddressPairs(4)
- tfModuleAddr := authtypes.NewModuleAddress(types.ModuleName)
- tfdenom := types.TFDenom{
- Creator: addrs[0].String(),
- Subdenom: "nusd",
- }
- nusd69420 := sdk.Coin{
- Denom: tfdenom.Denom().String(),
- Amount: math.NewInt(69_420),
- }
-
- testCases := []TestCaseTx{
- {
- Name: "happy: mint and burn",
- SetupMsgs: []sdk.Msg{
- &types.MsgCreateDenom{
- Sender: addrs[0].String(),
- Subdenom: "nusd",
- },
-
- &types.MsgMint{
- Sender: addrs[0].String(),
- Coin: sdk.Coin{
- Denom: types.TFDenom{
- Creator: addrs[0].String(),
- Subdenom: "nusd",
- }.Denom().String(),
- Amount: math.NewInt(69_420),
- },
- MintTo: "",
- },
- },
- TestMsgs: []TestMsgElem{
- {
- TestMsg: &types.MsgBurn{
- Sender: addrs[0].String(),
- Coin: sdk.Coin{
- Denom: types.TFDenom{
- Creator: addrs[0].String(),
- Subdenom: "nusd",
- }.Denom().String(),
- Amount: math.NewInt(1),
- },
- BurnFrom: "",
- },
- WantErr: "",
- },
- },
- PreHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- allDenoms := bapp.TokenFactoryKeeper.Store.Denoms.
- Iterate(ctx, collections.Range[string]{}).Values()
- s.Len(allDenoms, 1)
- },
- PostHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- allDenoms := bapp.TokenFactoryKeeper.Store.Denoms.
- Iterate(ctx, collections.Range[string]{}).Values()
-
- s.T().Log("Total supply should decrease by burned amount.")
- denom := allDenoms[0]
- s.Equal(
- math.NewInt(69_419), s.app.BankKeeper.GetSupply(s.ctx, denom.Denom().String()).Amount,
- )
-
- s.T().Log("Module account should be empty.")
- coin := s.app.BankKeeper.GetBalance(
- s.ctx, tfModuleAddr, denom.Denom().String())
- s.Equal(
- math.NewInt(0),
- coin.Amount,
- )
- },
- },
-
- {
- Name: "sad: denom does not exist",
- SetupMsgs: []sdk.Msg{},
- TestMsgs: []TestMsgElem{
- {
- TestMsg: &types.MsgMint{
- Sender: addrs[0].String(),
- Coin: nusd69420,
- MintTo: "",
- },
- WantErr: collections.ErrNotFound.Error(),
- },
- {
- TestMsg: &types.MsgBurn{
- Sender: addrs[0].String(),
- Coin: nusd69420,
- BurnFrom: "",
- },
- WantErr: collections.ErrNotFound.Error(),
- },
- },
- },
-
- {
- Name: "sad: sender is not admin",
- SetupMsgs: []sdk.Msg{
- &types.MsgCreateDenom{
- Sender: addrs[0].String(),
- Subdenom: "nusd",
- },
-
- &types.MsgMint{
- Sender: addrs[0].String(),
- Coin: nusd69420,
- MintTo: "",
- },
-
- &types.MsgChangeAdmin{
- Sender: addrs[0].String(),
- Denom: tfdenom.Denom().String(),
- NewAdmin: addrs[1].String(),
- },
- },
- TestMsgs: []TestMsgElem{
- {
- TestMsg: &types.MsgMint{
- Sender: addrs[0].String(),
- Coin: nusd69420,
- MintTo: "",
- },
- WantErr: types.ErrUnauthorized.Error(),
- },
- {
- TestMsg: &types.MsgBurn{
- Sender: addrs[0].String(),
- Coin: nusd69420,
- BurnFrom: "",
- },
- WantErr: types.ErrUnauthorized.Error(),
- },
- },
- },
-
- {
- Name: "sad: blocked addrs",
- SetupMsgs: []sdk.Msg{
- &types.MsgCreateDenom{
- Sender: addrs[0].String(),
- Subdenom: "nusd",
- },
-
- &types.MsgMint{
- Sender: addrs[0].String(),
- Coin: nusd69420,
- MintTo: "",
- },
- },
- TestMsgs: []TestMsgElem{
- {
- TestMsg: &types.MsgMint{
- Sender: addrs[0].String(),
- Coin: nusd69420,
- MintTo: authtypes.NewModuleAddress(oracletypes.ModuleName).String(),
- },
- WantErr: types.ErrBlockedAddress.Error(),
- },
- {
- TestMsg: &types.MsgBurn{
- Sender: addrs[0].String(),
- Coin: nusd69420,
- BurnFrom: authtypes.NewModuleAddress(oracletypes.ModuleName).String(),
- },
- WantErr: types.ErrBlockedAddress.Error(),
- },
- },
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.Name, func() {
- s.SetupTest()
- tc.RunTest(s)
- })
- }
-}
-
-func (s *TestSuite) TestSetDenomMetadata() {
- _, addrs := testutil.PrivKeyAddressPairs(4)
- tfdenom := types.TFDenom{
- Creator: addrs[0].String(),
- Subdenom: "nusd",
- }
-
- testCases := []TestCaseTx{
- {
- Name: "happy: set metadata",
- SetupMsgs: []sdk.Msg{
- &types.MsgCreateDenom{
- Sender: addrs[0].String(),
- Subdenom: "nusd",
- },
- },
- TestMsgs: []TestMsgElem{
- {
- TestMsg: &types.MsgSetDenomMetadata{
- Sender: addrs[0].String(),
- Metadata: tfdenom.DefaultBankMetadata(),
- },
- WantErr: "",
- },
- {
- TestMsg: &types.MsgSetDenomMetadata{
- Sender: addrs[0].String(),
- Metadata: banktypes.Metadata{
- Description: "US Dollar",
- DenomUnits: []*banktypes.DenomUnit{
- {
- Denom: tfdenom.Denom().String(),
- Exponent: 0,
- Aliases: []string{"unusd"},
- },
- {Denom: "USD", Exponent: 6},
- },
- Base: tfdenom.Denom().String(),
- Display: "USD",
- Name: "USD",
- Symbol: "USD",
- URI: "https://www.federalreserve.gov/aboutthefed/currency.htm",
- },
- },
- WantErr: "",
- },
- },
- }, // end case
-
- {
- Name: "sad: sender not admin",
- SetupMsgs: []sdk.Msg{
- &types.MsgCreateDenom{
- Sender: addrs[0].String(),
- Subdenom: "nusd",
- },
- },
- TestMsgs: []TestMsgElem{
- {
- TestMsg: &types.MsgSetDenomMetadata{
- Sender: addrs[1].String(),
- Metadata: tfdenom.DefaultBankMetadata(),
- },
- WantErr: types.ErrUnauthorized.Error(),
- },
- },
- }, // end case
-
- {
- Name: "sad: invalid sender",
- SetupMsgs: []sdk.Msg{
- &types.MsgCreateDenom{
- Sender: addrs[0].String(),
- Subdenom: "nusd",
- },
- },
- TestMsgs: []TestMsgElem{
- {
- TestMsg: &types.MsgSetDenomMetadata{
- Sender: "sender",
- Metadata: tfdenom.DefaultBankMetadata(),
- },
- WantErr: "invalid sender",
- },
- },
- }, // end case
-
- {
- Name: "sad: nil msg",
- TestMsgs: []TestMsgElem{
- {
- TestMsg: (*types.MsgSetDenomMetadata)(nil),
- WantErr: "nil msg",
- },
- },
- },
-
- {
- Name: "sad: metadata.base is not registered",
- SetupMsgs: []sdk.Msg{
- &types.MsgCreateDenom{
- Sender: addrs[0].String(),
- Subdenom: "nusd",
- },
- },
- TestMsgs: []TestMsgElem{
- {
- TestMsg: &types.MsgSetDenomMetadata{
- Sender: addrs[0].String(),
- Metadata: banktypes.Metadata{
- DenomUnits: []*banktypes.DenomUnit{{
- Denom: "ust",
- Exponent: 0,
- }},
- Base: "ust",
- // The following is necessary for x/bank denom validation
- Display: "ust",
- Name: "ust",
- Symbol: "ust",
- },
- },
- WantErr: collections.ErrNotFound.Error(),
- },
- },
- }, // end case
-
- }
-
- for _, tc := range testCases {
- s.Run(tc.Name, func() {
- s.SetupTest()
- tc.RunTest(s)
- })
- }
-}
-
-func (s *TestSuite) TestBurnNative() {
- _, addrs := testutil.PrivKeyAddressPairs(4)
- tfModuleAddr := authtypes.NewModuleAddress(types.ModuleName)
-
- testCases := []TestCaseTx{
- {
- Name: "happy: burn",
- SetupMsgs: []sdk.Msg{},
- PreHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- coins := sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(123)))
- s.NoError(bapp.BankKeeper.MintCoins(ctx, types.ModuleName, coins))
- s.NoError(bapp.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addrs[0], coins))
- },
- TestMsgs: []TestMsgElem{
- {
- TestMsg: &types.MsgBurnNative{
- Sender: addrs[0].String(),
- Coin: sdk.NewCoin("unibi", math.NewInt(123)),
- },
- WantErr: "",
- },
- },
- PostHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- s.Equal(
- math.NewInt(0), s.app.BankKeeper.GetSupply(s.ctx, "unibi").Amount,
- )
-
- s.Equal(
- math.NewInt(0),
- s.app.BankKeeper.GetBalance(s.ctx, tfModuleAddr, "unibi").Amount,
- )
-
- s.Equal(
- math.NewInt(0),
- s.app.BankKeeper.GetBalance(s.ctx, addrs[0], "unibi").Amount,
- )
- },
- },
-
- {
- Name: "sad: not enough funds",
- SetupMsgs: []sdk.Msg{},
- PreHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- coins := sdk.NewCoins(sdk.NewCoin("unibi", math.NewInt(123)))
- s.NoError(bapp.BankKeeper.MintCoins(ctx, types.ModuleName, coins))
- s.NoError(bapp.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addrs[0], coins))
- },
- TestMsgs: []TestMsgElem{
- {
- TestMsg: &types.MsgBurnNative{
- Sender: addrs[0].String(),
- Coin: sdk.NewCoin("unibi", math.NewInt(124)),
- },
- WantErr: "spendable balance 123unibi is smaller than 124unibi: insufficient funds",
- },
- },
- PostHook: func(ctx sdk.Context, bapp *app.NibiruApp) {
- s.Equal(
- math.NewInt(123), s.app.BankKeeper.GetSupply(s.ctx, "unibi").Amount,
- )
-
- s.Equal(
- math.NewInt(123),
- s.app.BankKeeper.GetBalance(s.ctx, addrs[0], "unibi").Amount,
- )
- },
- },
-
- {
- Name: "sad: nil msg",
- TestMsgs: []TestMsgElem{
- {
- TestMsg: (*types.MsgSetDenomMetadata)(nil),
- WantErr: "nil msg",
- },
- },
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.Name, func() {
- s.SetupTest()
- tc.RunTest(s)
- })
- }
-}
diff --git a/x/tokenfactory/keeper/store.go b/x/tokenfactory/keeper/store.go
deleted file mode 100644
index a548ba392..000000000
--- a/x/tokenfactory/keeper/store.go
+++ /dev/null
@@ -1,163 +0,0 @@
-package keeper
-
-import (
- "github.com/NibiruChain/collections"
- sdkcodec "github.com/cosmos/cosmos-sdk/codec"
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- tftypes "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-// StoreAPI isolates the collections for the x/tokenfactory module.
-// Ultimately, the denoms are registered in the x/bank module if valid. Because
-// of this, a denom cannot be deleted once it exists.
-//
-// The StoreAPI hides private methods to make the developer experience less
-// error-prone when working on the module.
-type StoreAPI struct {
- // Denoms: IndexedMap
- // - primary key (PK): Token factory denom (TFDenom) as a string
- // - value (V): TFDenom payload with validation
- // - indexers (I): Indexed by creator for easy querying
- Denoms collections.IndexedMap[storePKType, storeVType, IndexesTokenFactory]
- ModuleParams collections.Item[tftypes.ModuleParams]
- creator collections.KeySet[storePKType]
- denomAdmins collections.Map[storePKType, tftypes.DenomAuthorityMetadata]
- bankKeeper tftypes.BankKeeper
-}
-
-func (api StoreAPI) InsertDenom(
- ctx sdk.Context, denom tftypes.TFDenom,
-) error {
- if err := denom.Validate(); err != nil {
- return err
- }
- // The x/bank keeper is the source of truth.
- key := denom.Denom()
- found := api.HasDenom(ctx, denom)
- if found {
- return tftypes.ErrDenomAlreadyRegistered.Wrap(key.String())
- }
-
- admin := denom.Creator
- api.unsafeInsertDenom(ctx, denom, admin)
-
- api.bankKeeper.SetDenomMetaData(ctx, denom.DefaultBankMetadata())
- api.denomAdmins.Insert(ctx, key.String(), tftypes.DenomAuthorityMetadata{
- Admin: admin,
- })
- return nil
-}
-
-// unsafeInsertDenom: Adds a token factory denom to state with the given admin.
-// NOTE: unsafe → assumes pre-validated inputs
-func (api StoreAPI) unsafeInsertDenom(
- ctx sdk.Context, denom tftypes.TFDenom, admin string,
-) {
- denomStr := denom.Denom()
- api.Denoms.Insert(ctx, denomStr.String(), denom)
- api.creator.Insert(ctx, denom.Creator)
- api.bankKeeper.SetDenomMetaData(ctx, denom.DefaultBankMetadata())
- api.denomAdmins.Insert(ctx, denomStr.String(), tftypes.DenomAuthorityMetadata{
- Admin: admin,
- })
- _ = ctx.EventManager().EmitTypedEvent(&tftypes.EventCreateDenom{
- Denom: denomStr.String(),
- Creator: denom.Creator,
- })
-}
-
-// unsafeGenesisInsertDenom: Populates the x/tokenfactory state without
-// making any assumptions about the x/bank state. This function should only be
-// used in InitGenesis or upgrades that populate state from an exported genesis.
-// NOTE: unsafe → assumes pre-validated inputs
-func (api StoreAPI) unsafeGenesisInsertDenom(
- ctx sdk.Context, genDenom tftypes.GenesisDenom,
-) {
- denom := tftypes.DenomStr(genDenom.Denom).MustToStruct()
- admin := genDenom.AuthorityMetadata.Admin
- api.unsafeInsertDenom(ctx, denom, admin)
-}
-
-// HasDenom: True if the denom has already been registered.
-func (api StoreAPI) HasDenom(
- ctx sdk.Context, denom tftypes.TFDenom,
-) bool {
- _, found := api.bankKeeper.GetDenomMetaData(ctx, denom.Denom().String())
- return found
-}
-
-func (api StoreAPI) HasCreator(ctx sdk.Context, creator string) bool {
- return api.creator.Has(ctx, creator)
-}
-
-// GetDenomAuthorityMetadata returns the admin (authority metadata) for a
-// specific denom. This differs from the x/bank metadata.
-func (api StoreAPI) GetDenomAuthorityMetadata(
- ctx sdk.Context, denom string,
-) (tftypes.DenomAuthorityMetadata, error) {
- metadata, err := api.denomAdmins.Get(ctx, denom)
- if err != nil {
- return metadata, tftypes.ErrGetAdmin.Wrap(err.Error())
- }
- return metadata, nil
-}
-
-func (api StoreAPI) GetAdmin(
- ctx sdk.Context, denom string,
-) (string, error) {
- metadata, err := api.denomAdmins.Get(ctx, denom)
- if err != nil {
- return "", err
- }
- return metadata.Admin, nil
-}
-
-// ---------------------------------------------
-// StoreAPI - Under the hood
-// ---------------------------------------------
-
-type (
- storePKType = string
- storeVType = tftypes.TFDenom
-)
-
-// NewTFDenomStore: Creates an indexed map over token facotry denoms indexed
-// by creator address.
-func NewTFDenomStore(
- storeKey storetypes.StoreKey, cdc sdkcodec.BinaryCodec,
-) collections.IndexedMap[storePKType, storeVType, IndexesTokenFactory] {
- primaryKeyEncoder := collections.StringKeyEncoder
- valueEncoder := collections.ProtoValueEncoder[tftypes.TFDenom](cdc)
-
- var namespace collections.Namespace = tftypes.KeyPrefixDenom
- var namespaceCreatorIdx collections.Namespace = tftypes.KeyPrefixCreatorIndexer
-
- return collections.NewIndexedMap[storePKType, storeVType](
- storeKey, namespace, primaryKeyEncoder, valueEncoder,
- IndexesTokenFactory{
- Creator: collections.NewMultiIndex[string, storePKType, storeVType](
- storeKey, namespaceCreatorIdx,
- collections.StringKeyEncoder, // index key (IK)
- collections.StringKeyEncoder, // primary key (PK)
- func(v tftypes.TFDenom) string { return v.Creator },
- ),
- },
- )
-}
-
-// IndexesTokenFactory: Abstraction for indexing over the TF denom store.
-type IndexesTokenFactory struct {
- // Creator MultiIndex:
- // - indexing key (IK): bech32 address of the creator of TF denom.
- // - primary key (PK): full TF denom of the form 'factory/{creator}/{subdenom}'
- // - value (V): struct version of TF denom with validate function
- Creator collections.MultiIndex[string, string, storeVType]
-}
-
-func (idxs IndexesTokenFactory) IndexerList() []collections.Indexer[string, storeVType] {
- return []collections.Indexer[string, storeVType]{
- idxs.Creator,
- }
-}
diff --git a/x/tokenfactory/keeper/store_test.go b/x/tokenfactory/keeper/store_test.go
deleted file mode 100644
index c4892cdcc..000000000
--- a/x/tokenfactory/keeper/store_test.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package keeper_test
-
-import (
- "github.com/NibiruChain/collections"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
-
- tftypes "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-func (s *TestSuite) TestStoreWrite() {
- numCreators := 2
- subdenoms := []string{"aaaa", "bbbb"}
- tfdenoms := []tftypes.TFDenom{}
- for idx := 0; idx < numCreators; idx++ {
- _, creator := testutil.PrivKey()
- for _, subdenom := range subdenoms {
- tfdenom := tftypes.TFDenom{
- Creator: creator.String(),
- Subdenom: subdenom,
- }
- tfdenoms = append(tfdenoms, tfdenom)
- }
- }
-
- api := s.keeper.Store
-
- s.Run("initial conditions", func() {
- for _, tfdenom := range tfdenoms {
- // created denoms should be valid
- s.NoError(tfdenom.Validate(), tfdenom)
-
- // query by denom should fail for all denoms
- _, err := api.Denoms.Get(s.ctx, tfdenom.Denom().String())
- s.Error(err)
-
- // query by creator should fail for all addrs
- s.False(api.HasCreator(s.ctx, tfdenom.Creator))
- }
- })
-
- s.Run("insert to state", func() {
- // inserting should succeed
- for _, tfdenom := range tfdenoms {
- s.Require().NoError(api.InsertDenom(s.ctx, tfdenom))
- }
-
- allDenoms := api.Denoms.Iterate(
- s.ctx, collections.Range[string]{}).Values()
- s.Len(allDenoms, numCreators*len(subdenoms))
-
- for _, tfdenom := range tfdenoms {
- s.True(api.HasCreator(s.ctx, tfdenom.Creator))
- }
-
- // query by creator should fail for a random addr
- s.False(api.HasCreator(s.ctx, testutil.AccAddress().String()))
- })
-
- s.Run("inserting invalid denom should fail", func() {
- blankDenom := tftypes.TFDenom{}
- s.Error(blankDenom.Validate())
- s.Error(api.InsertDenom(s.ctx, blankDenom))
- })
-}
diff --git a/x/tokenfactory/keeper/wasm_test.go b/x/tokenfactory/keeper/wasm_test.go
deleted file mode 100644
index 8eb8666a4..000000000
--- a/x/tokenfactory/keeper/wasm_test.go
+++ /dev/null
@@ -1,317 +0,0 @@
-package keeper_test
-
-import (
- "encoding/json"
- "fmt"
- "os"
- "path"
- "strconv"
- "strings"
- "testing"
-
- "cosmossdk.io/math"
- wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
- "github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting"
- wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
-
- wasmvmtypes "github.com/CosmWasm/wasmvm/types"
- codec "github.com/cosmos/cosmos-sdk/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/app"
- "github.com/NibiruChain/nibiru/x/common/denoms"
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- "github.com/NibiruChain/nibiru/x/tokenfactory/fixture"
- tftypes "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-// Instantiate is a empty struct type with conventience functions for
-// instantiating specific smart contracts.
-var Instantiate = inst{}
-
-type inst struct{}
-
-func (i inst) ContractNibiStargate(
- t *testing.T, ctx sdk.Context, nibiru *app.NibiruApp, codeId uint64,
- sender sdk.AccAddress, deposit sdk.Coins,
-) (contractAddr sdk.AccAddress) {
- initMsg := []byte("{}")
- label := "token factory stargate message examples"
- return InstantiateContract(
- t, ctx, nibiru, codeId, initMsg, sender, label, deposit,
- )
-}
-
-func (s *TestSuite) ExecuteAgainstContract(
- contract LiveContract, execMsgJson string,
-) (contractRespBz []byte, err error) {
- execMsg := json.RawMessage([]byte(execMsgJson))
- return wasmkeeper.NewDefaultPermissionKeeper(s.app.WasmKeeper).Execute(
- s.ctx, contract.Addr, contract.Deployer, execMsg, sdk.Coins{},
- )
-}
-
-type LiveContract struct {
- CodeId uint64
- Addr sdk.AccAddress
- Deployer sdk.AccAddress
-}
-
-var LiveContracts = make(map[string]LiveContract)
-
-// SetupContracts stores and instantiates all of the CosmWasm smart contracts.
-func SetupContracts(
- t *testing.T, sender sdk.AccAddress, nibiru *app.NibiruApp, ctx sdk.Context,
-) map[string]LiveContract {
- wasmName := fixture.WASM_NIBI_STARGATE
- codeId := StoreContract(t, wasmName, ctx, nibiru, sender)
- deposit := sdk.NewCoins(sdk.NewCoin(denoms.NIBI, math.OneInt()))
- contract := Instantiate.ContractNibiStargate(t, ctx, nibiru, codeId, sender, deposit)
- LiveContracts[wasmName] = LiveContract{
- CodeId: codeId,
- Addr: contract,
- Deployer: sender,
- }
-
- return LiveContracts
-}
-
-// StoreContract submits Wasm bytecode for storage on the chain.
-func StoreContract(
- t *testing.T,
- wasmName string,
- ctx sdk.Context,
- nibiru *app.NibiruApp,
- sender sdk.AccAddress,
-) (codeId uint64) {
- // Read wasm bytecode from disk
- pkgDir, err := testutil.GetPackageDir()
- require.NoError(t, err)
- pathToModulePkg := path.Dir(pkgDir)
- require.Equal(t, tftypes.ModuleName, path.Base(pathToModulePkg))
- pathToWasmBin := pathToModulePkg + fmt.Sprintf("/fixture/%s", wasmName)
- wasmBytecode, err := os.ReadFile(pathToWasmBin)
- require.NoError(t, err)
-
- // The "Create" fn is private on the nibiru.WasmKeeper. By placing it as the
- // decorated keeper in PermissionedKeeper type, we can access "Create" as a
- // public fn.
- wasmPermissionedKeeper := wasmkeeper.NewDefaultPermissionKeeper(nibiru.WasmKeeper)
- instantiateAccess := &wasmtypes.AccessConfig{
- Permission: wasmtypes.AccessTypeEverybody,
- }
- codeId, _, err = wasmPermissionedKeeper.Create(
- ctx, sender, wasmBytecode, instantiateAccess,
- )
- require.NoError(t, err)
- return codeId
-}
-
-func InstantiateContract(
- t *testing.T, ctx sdk.Context, nibiru *app.NibiruApp, codeId uint64,
- initMsg []byte, sender sdk.AccAddress, label string, deposit sdk.Coins,
-) (contractAddr sdk.AccAddress) {
- wasmPermissionedKeeper := wasmkeeper.NewDefaultPermissionKeeper(nibiru.WasmKeeper)
- contractAddr, _, err := wasmPermissionedKeeper.Instantiate(
- ctx, codeId, sender, sender, initMsg, label, deposit,
- )
- require.NoError(t, err)
- return contractAddr
-}
-
-type WasmTestCase struct {
- ExecMsgJson string
- WantErr string
- TestCaseTx
-}
-
-// TestStargate: Showcases happy path examples for tokenfactory messages
-// executed as `CosmosMsg::Stargate` types built directly from protobuf.
-//
-// in the example smart contract.
-func (s *TestSuite) TestStargate() {
- s.T().Log("create contract deployer and fund account")
- deployer, err := sdk.AccAddressFromBech32("nibi18wcr5svu0dexdj2zwk44hcjfw6drcsfkn6hq9q")
- s.NoError(err)
- funds, err := sdk.ParseCoinsNormalized("69000000unibi") // just for gas
- s.NoError(err)
- s.NoError(
- testapp.FundAccount(s.app.BankKeeper, s.ctx, deployer, funds),
- )
-
- liveContracts := SetupContracts(s.T(), deployer, s.app, s.ctx)
- contract, isFound := liveContracts[fixture.WASM_NIBI_STARGATE]
- s.True(isFound)
-
- tfdenom := tftypes.TFDenom{
- Creator: contract.Addr.String(),
- Subdenom: "zzz",
- }
- s.Run("create denom from smart contract", func() {
- _, err := s.ExecuteAgainstContract(contract, strings.Trim(`
- {
- "create_denom": { "subdenom": "zzz" }
- }
- `, " "))
- s.NoError(err)
-
- // NOTE that the smart contract is the sender.
- denoms := s.app.TokenFactoryKeeper.QueryDenoms(s.ctx,
- contract.Addr.String(),
- )
- s.ElementsMatch(denoms, []string{tfdenom.Denom().String()})
- })
-
- someoneElse := testutil.AccAddress()
- s.Run("mint from smart contract", func() {
- execMsgJson := strings.Trim(fmt.Sprintf(`
- {
- "mint": {
- "coin": { "amount": "69420", "denom": "%s" },
- "mint_to": "%s"
- }
- }
- `, tfdenom.Denom(), someoneElse), " ")
- _, err := s.ExecuteAgainstContract(contract, execMsgJson)
- s.NoError(err, "execMsgJson: %v", execMsgJson)
-
- balance := s.app.BankKeeper.GetBalance(s.ctx, someoneElse, tfdenom.Denom().String())
- s.Equal(math.NewInt(69_420), balance.Amount)
- })
-
- s.Run("burn from smart contract", func() {
- execMsgJson := strings.Trim(fmt.Sprintf(`
- {
- "burn": {
- "coin": { "amount": "69000", "denom": "%s" },
- "burn_from": "%s"
- }
- }
- `, tfdenom.Denom(), someoneElse), " ")
- _, err := s.ExecuteAgainstContract(contract, execMsgJson)
- s.NoError(err, "execMsgJson: %v", execMsgJson)
-
- balance := s.app.BankKeeper.GetBalance(s.ctx, someoneElse, tfdenom.Denom().String())
- s.Equal(math.NewInt(420), balance.Amount)
- })
-
- s.Run("change admin from smart contract", func() {
- execMsgJson := strings.Trim(fmt.Sprintf(`
- {
- "change_admin": {
- "denom": "%s",
- "new_admin": "%s"
- }
- }
- `, tfdenom.Denom(), someoneElse), " ")
- _, err := s.ExecuteAgainstContract(contract, execMsgJson)
- s.NoError(err, "execMsgJson: %v", execMsgJson)
-
- denomInfo, err := s.app.TokenFactoryKeeper.QueryDenomInfo(
- s.ctx, tfdenom.Denom().String(),
- )
- s.NoError(err)
- s.Equal(someoneElse.String(), denomInfo.Admin)
- s.Equal(tfdenom.DefaultBankMetadata(), denomInfo.Metadata)
- })
-}
-
-/*
-TestStargateSerde: Compares marshaled bytes produced for an sdk.Msg against
-the equivalent encoding in Rust (`Vec`).
-Test values for the `wantBz` field can be reproduced for a
-`nibiru_std::proto::NibiruStargateMsg` by running the `to_bytes` function.
-
-Example:
-
- ```rust
- use nibiru_std::proto::nibiru;
- let pb_msg: NibiruProstMsg = nibiru::tokenfactory::MsgMint { ... }
- println!("{:?}", pb_msg.to_bytes())
- ```
-
-The printed vector corresponds one-to-one with what we'd get when marshaling
-that protobuf message to `[]byte` in Go.
-*/
-func (s *TestSuite) TestStargateSerde() {
- testCases := []struct {
- // sdkMsg: A protobuf message implementing both the sdk.Msg and
- // codec.ProtoMarshaler interfaces. Any transaction message will work here.
- // Note that you need the pointer to the message for encoding.
- sdkMsg any
- // A namespaced string identifier for the type of a serialized protobuf
- // message. Often associated with the `Any` type.
- typeUrl string
- wantBz string
- }{
- {
- typeUrl: "/nibiru.tokenfactory.v1.MsgCreateDenom",
- sdkMsg: &tftypes.MsgCreateDenom{
- Sender: "sender",
- Subdenom: "subdenom",
- },
- wantBz: "[10 6 115 101 110 100 101 114 18 8 115 117 98 100 101 110 111 109]",
- },
- {
- typeUrl: "/nibiru.tokenfactory.v1.MsgMint",
- sdkMsg: &tftypes.MsgMint{
- Sender: "sender",
- Coin: sdk.NewInt64Coin("abcxyz", 123),
- MintTo: "mint_to",
- },
- wantBz: fmt.Sprint([]byte{10, 6, 115, 101, 110, 100, 101, 114, 18, 13, 10, 6, 97, 98, 99, 120, 121, 122, 18, 3, 49, 50, 51, 26, 7, 109, 105, 110, 116, 95, 116, 111}),
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.typeUrl, func() {
- pbMsg, _ := (tc.sdkMsg).(codec.ProtoMarshaler)
- sgMsgValue := s.encConfig.Codec.MustMarshal(pbMsg)
- sgMsg := wasmvmtypes.StargateMsg{
- TypeURL: tc.typeUrl,
- Value: sgMsgValue,
- }
- if tc.wantBz != "" {
- bz, _ := parseByteList(tc.wantBz)
- s.Equal(bz, sgMsgValue)
- }
-
- ibcTransferPort := wasmtesting.MockIBCTransferKeeper{
- GetPortFn: func(ctx sdk.Context) string { return "myTransferPort" },
- }
- wasmEncoders := wasmkeeper.DefaultEncoders(s.encConfig.Codec, ibcTransferPort)
- mockContractAddr := testutil.AccAddress()
- sdkMsgs, err := wasmEncoders.Encode(s.ctx, mockContractAddr, "mock-ibc-port",
- wasmvmtypes.CosmosMsg{
- Stargate: &sgMsg,
- },
- )
-
- s.Require().NoError(err)
- sdkMsg, _ := (tc.sdkMsg).(sdk.Msg)
- s.EqualValues(sdkMsg, sdkMsgs[0])
- })
- }
-}
-
-// parseByteList: Parses the string version of a `[]byte` object when formatted
-// using methods like 'fmt.Sprintf' or 'fmt.Println' to recover the underlying
-// type again.
-func parseByteList(bzStr string) ([]byte, error) {
- bzStr = strings.TrimPrefix(bzStr, "[")
- bzStr = strings.TrimSuffix(bzStr, "]")
- parts := strings.Split(bzStr, " ")
-
- var result []byte
- for _, part := range parts {
- val, err := strconv.Atoi(part)
- if err != nil {
- return nil, err
- }
- result = append(result, byte(val))
- }
-
- return result, nil
-}
diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go
deleted file mode 100644
index 9cc05ec99..000000000
--- a/x/tokenfactory/module.go
+++ /dev/null
@@ -1,192 +0,0 @@
-package tokenfactory
-
-/*
-The tokenfactory module allows any account to create a new token with
-the name `factory/{creator address}/{subdenom}`.
-
-- Mint and burn user denom to and form any account
-- Create a transfer of their denom between any two accounts
-- Change the admin.
-*/
-
-import (
- "context"
- "encoding/json"
- "fmt"
-
- abci "github.com/cometbft/cometbft/abci/types"
- sdkclient "github.com/cosmos/cosmos-sdk/client"
- sdkcodec "github.com/cosmos/cosmos-sdk/codec"
- sdkcodectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
- simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
- authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/spf13/cobra"
-
- "github.com/NibiruChain/nibiru/x/tokenfactory/cli"
- "github.com/NibiruChain/nibiru/x/tokenfactory/keeper"
- "github.com/NibiruChain/nibiru/x/tokenfactory/simulation"
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-// type check to ensure the interface is properly implemented
-var (
- _ module.AppModuleBasic = AppModuleBasic{}
- _ module.AppModule = AppModule{}
- _ module.AppModuleSimulation = AppModule{}
- _ module.BeginBlockAppModule = AppModule{}
- _ module.EndBlockAppModule = AppModule{}
-)
-
-// ConsensusVersion defines the current module consensus version.
-const ConsensusVersion = 2
-
-// AppModuleBasic type for the fees module
-type AppModuleBasic struct{}
-
-// Name returns the fees module's name.
-func (AppModuleBasic) Name() string {
- return types.ModuleName
-}
-
-// RegisterLegacyAminoCodec performs a no-op as the fees do not support Amino
-// encoding.
-func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *sdkcodec.LegacyAmino) {
- types.RegisterLegacyAminoCodec(cdc)
-}
-
-// ConsensusVersion returns the consensus state-breaking version for the module.
-func (AppModuleBasic) ConsensusVersion() uint64 {
- return ConsensusVersion
-}
-
-// RegisterInterfaces registers interfaces and implementations of the fees
-// module.
-func (AppModuleBasic) RegisterInterfaces(
- interfaceRegistry sdkcodectypes.InterfaceRegistry,
-) {
- types.RegisterInterfaces(interfaceRegistry)
-}
-
-// DefaultGenesis returns default genesis state as raw bytes for the fees
-// module.
-func (AppModuleBasic) DefaultGenesis(cdc sdkcodec.JSONCodec) json.RawMessage {
- return cdc.MustMarshalJSON(types.DefaultGenesis())
-}
-
-// ValidateGenesis performs genesis state validation for the fees module.
-func (b AppModuleBasic) ValidateGenesis(
- cdc sdkcodec.JSONCodec, _ sdkclient.TxEncodingConfig, bz json.RawMessage,
-) error {
- var genesisState types.GenesisState
- if err := cdc.UnmarshalJSON(bz, &genesisState); err != nil {
- return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
- }
-
- return genesisState.Validate()
-}
-
-// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the fees
-// module.
-func (b AppModuleBasic) RegisterGRPCGatewayRoutes(
- c sdkclient.Context, serveMux *runtime.ServeMux,
-) {
- if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil {
- panic(err)
- }
-}
-
-// GetTxCmd returns the root tx command for the fees module.
-func (AppModuleBasic) GetTxCmd() *cobra.Command {
- return cli.NewTxCmd()
-}
-
-// GetQueryCmd returns the fees module's root query command.
-func (AppModuleBasic) GetQueryCmd() *cobra.Command {
- return cli.NewQueryCmd()
-}
-
-// ___________________________________________________________________________
-
-// AppModule implements the AppModule interface for the fees module.
-type AppModule struct {
- AppModuleBasic
- keeper keeper.Keeper
- ak authkeeper.AccountKeeper
-}
-
-// NewAppModule creates a new AppModule Object
-func NewAppModule(
- k keeper.Keeper,
- ak authkeeper.AccountKeeper,
-) AppModule {
- return AppModule{
- AppModuleBasic: AppModuleBasic{},
- keeper: k,
- ak: ak,
- }
-}
-
-// Name returns the fees module's name.
-func (AppModule) Name() string {
- return types.ModuleName
-}
-
-// RegisterInvariants registers the fees module's invariants.
-func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
-
-// QuerierRoute returns the module's query routing key.
-func (am AppModule) QuerierRoute() string {
- return types.RouterKey
-}
-
-// RegisterServices registers a GRPC query service to respond to the
-// module-specific GRPC queries.
-func (am AppModule) RegisterServices(cfg module.Configurator) {
- types.RegisterMsgServer(cfg.MsgServer(), am.keeper)
- types.RegisterQueryServer(
- cfg.QueryServer(), am.keeper.Querier(),
- )
-}
-
-// BeginBlock executes all ABCI BeginBlock logic respective to the fees module.
-func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {
-}
-
-// EndBlock executes all ABCI EndBlock logic respective to the fee-share module. It
-// returns no validator updates.
-func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
- return []abci.ValidatorUpdate{}
-}
-
-// InitGenesis performs the fees module's genesis initialization. It returns
-// no validator updates.
-func (am AppModule) InitGenesis(ctx sdk.Context, cdc sdkcodec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
- var genesisState types.GenesisState
-
- cdc.MustUnmarshalJSON(data, &genesisState)
- am.keeper.InitGenesis(ctx, genesisState)
- return []abci.ValidatorUpdate{}
-}
-
-// ExportGenesis returns the fees module's exported genesis state as raw JSON bytes.
-func (am AppModule) ExportGenesis(ctx sdk.Context, cdc sdkcodec.JSONCodec) json.RawMessage {
- gs := am.keeper.ExportGenesis(ctx)
- return cdc.MustMarshalJSON(gs)
-}
-
-// GenerateGenesisState implements module.AppModuleSimulation.
-func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
- simulation.RandomizedGenState(simState)
-}
-
-// RegisterStoreDecoder implements module.AppModuleSimulation.
-func (AppModule) RegisterStoreDecoder(sdk.StoreDecoderRegistry) {
-}
-
-// WeightedOperations implements module.AppModuleSimulation.
-func (AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
- return []simtypes.WeightedOperation{}
-}
diff --git a/x/tokenfactory/module_test.go b/x/tokenfactory/module_test.go
deleted file mode 100644
index f143c4296..000000000
--- a/x/tokenfactory/module_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package tokenfactory_test
-
-import (
- "testing"
-
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/stretchr/testify/suite"
-
- "github.com/NibiruChain/nibiru/app/codec"
- "github.com/NibiruChain/nibiru/x/common/testutil/testapp"
- module "github.com/NibiruChain/nibiru/x/tokenfactory"
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-type ModuleTestSuite struct{ suite.Suite }
-
-func TestModuleTestSuite(t *testing.T) {
- suite.Run(t, new(ModuleTestSuite))
-}
-
-func (s *ModuleTestSuite) TestAppModule() {
- bapp, ctx := testapp.NewNibiruTestAppAndContext()
- appModule := module.NewAppModule(
- bapp.TokenFactoryKeeper,
- bapp.AccountKeeper,
- )
-
- s.NotPanics(func() {
- s.T().Log("begin and end block")
- appModule.BeginBlock(ctx, abci.RequestBeginBlock{})
- appModule.EndBlock(ctx, abci.RequestEndBlock{})
-
- s.T().Log("AppModule.ExportGenesis")
- cdc := bapp.AppCodec()
- jsonBz := appModule.ExportGenesis(ctx, cdc)
-
- genesis := types.DefaultGenesis()
- genState := new(types.GenesisState)
- err := cdc.UnmarshalJSON(jsonBz, genState)
- s.NoError(err)
- s.EqualValues(*genesis, *genState, "exported (got): %s", jsonBz)
-
- s.T().Log("AppModuleBasic.ValidateGenesis")
- encCfg := codec.MakeEncodingConfig()
- err = appModule.AppModuleBasic.ValidateGenesis(cdc, encCfg.TxConfig, jsonBz)
- s.NoError(err)
-
- s.T().Log("CLI commands")
- s.NotNil(appModule.AppModuleBasic.GetTxCmd())
- s.NotNil(appModule.AppModuleBasic.GetQueryCmd())
- s.NotEmpty(appModule.QuerierRoute())
- })
-}
diff --git a/x/tokenfactory/simulation/genesis.go b/x/tokenfactory/simulation/genesis.go
deleted file mode 100644
index 40856bd06..000000000
--- a/x/tokenfactory/simulation/genesis.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package simulation
-
-// DONTCOVER
-
-import (
- "encoding/json"
- "fmt"
- "math/rand"
-
- "github.com/cosmos/cosmos-sdk/types/module"
-
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-const (
- DenomCreationGasConsume = "denom_creation_gas_consume"
-)
-
-func GenDenomCreationGasConsume(r *rand.Rand) uint64 {
- return uint64(r.Intn(4e6))
-}
-
-// RandomizedGenState generates a random GenesisState for distribution
-func RandomizedGenState(simState *module.SimulationState) {
- var denomCreationGasConsume uint64
- simState.AppParams.GetOrGenerate(
- simState.Cdc, DenomCreationGasConsume, &denomCreationGasConsume, simState.Rand,
- func(r *rand.Rand) { denomCreationGasConsume = GenDenomCreationGasConsume(r) },
- )
-
- tokenfactoryGenesis := types.GenesisState{
- Params: types.ModuleParams{
- DenomCreationGasConsume: denomCreationGasConsume,
- },
- FactoryDenoms: []types.GenesisDenom{},
- }
-
- bz, err := json.MarshalIndent(&tokenfactoryGenesis, "", " ")
- if err != nil {
- panic(err)
- }
- fmt.Printf("Selected randomly generated x/tokenfactory parameters:\n%s\n", bz)
- simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&tokenfactoryGenesis)
-}
diff --git a/x/tokenfactory/types/codec.go b/x/tokenfactory/types/codec.go
deleted file mode 100644
index e0e639c0d..000000000
--- a/x/tokenfactory/types/codec.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package types
-
-import (
- "github.com/cosmos/cosmos-sdk/codec"
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/msgservice"
- authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
-)
-
-var (
- legacyAminoCdc = codec.NewLegacyAmino()
- ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
-)
-
-// NOTE: This is required for the GetSignBytes function
-func init() {
- RegisterLegacyAminoCodec(legacyAminoCdc)
-
- sdk.RegisterLegacyAminoCodec(legacyAminoCdc)
-
- // Register all Amino interfaces and concrete types on the authz Amino codec
- // so that this can later be used to properly serialize MsgGrant and MsgExec
- // instances.
- RegisterLegacyAminoCodec(authzcodec.Amino)
-}
-
-// RegisterInterfaces register implementations
-func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- registry.RegisterImplementations(
- (*sdk.Msg)(nil),
- &MsgCreateDenom{},
- &MsgChangeAdmin{},
- &MsgUpdateModuleParams{},
- &MsgMint{},
- &MsgBurn{},
- &MsgBurnNative{},
- &MsgSetDenomMetadata{},
- )
-
- msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
-}
-
-func TX_MSG_TYPE_URLS() []string {
- return []string{
- "/nibiru.tokenfactory.v1.MsgCreateDenom",
- "/nibiru.tokenfactory.v1.MsgChangeAdmin",
- "/nibiru.tokenfactory.v1.MsgUpdateModuleParams",
- "/nibiru.tokenfactory.v1.MsgMint",
- "/nibiru.tokenfactory.v1.MsgBurn",
- "/nibiru.tokenfactory.v1.MsgBurnNative",
- "/nibiru.tokenfactory.v1.MsgSetDenomMetadata",
- }
-}
-
-// RegisterLegacyAminoCodec registers the necessary x/tokenfactory interfaces and
-// concrete types on the provided LegacyAmino codec. These types are used for
-// Amino JSON serialization and EIP-712 compatibility.
-func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
- for _, ele := range []struct {
- MsgType interface{}
- Name string
- }{
- {&MsgCreateDenom{}, "nibiru/tokenfactory/create-denom"},
- {&MsgChangeAdmin{}, "nibiru/tokenfactory/change-admin"},
- {&MsgUpdateModuleParams{}, "nibiru/tokenfactory/update-module-params"},
- {&MsgMint{}, "nibiru/tokenfactory/mint"},
- {&MsgBurn{}, "nibiru/tokenfactory/burn"},
- {&MsgSetDenomMetadata{}, "nibiru/tokenfactory/set-denom-metadata"},
- } {
- cdc.RegisterConcrete(ele.MsgType, ele.Name, nil)
- }
-}
diff --git a/x/tokenfactory/types/codec_test.go b/x/tokenfactory/types/codec_test.go
deleted file mode 100644
index 2e0300055..000000000
--- a/x/tokenfactory/types/codec_test.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package types_test
-
-import (
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-type CodecSuite struct {
- suite.Suite
-}
-
-func TestCodecSuite(t *testing.T) {
- suite.Run(t, new(CodecSuite))
-}
-
-func (suite *CodecSuite) TestRegisterInterfaces() {
- registry := codectypes.NewInterfaceRegistry()
- registry.RegisterInterface(sdk.MsgInterfaceProtoName, (*sdk.Msg)(nil))
- types.RegisterInterfaces(registry)
-
- impls := registry.ListImplementations(sdk.MsgInterfaceProtoName)
- suite.Require().ElementsMatch(types.TX_MSG_TYPE_URLS(), impls)
-}
diff --git a/x/tokenfactory/types/errors.go b/x/tokenfactory/types/errors.go
deleted file mode 100644
index aae1ec3b7..000000000
--- a/x/tokenfactory/types/errors.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package types
-
-import (
- sdkerrors "cosmossdk.io/errors"
-)
-
-var moduleErrorCodeIdx uint32 = 1
-
-func registerError(msg string) *sdkerrors.Error {
- moduleErrorCodeIdx += 1
- return sdkerrors.Register(ModuleName, moduleErrorCodeIdx, msg)
-}
-
-// Module "sentinel" errors
-var (
- ErrInvalidGenesis = registerError("invalid genesis")
- ErrInvalidDenom = registerError("invalid token factory denom")
- ErrInvalidCreator = registerError("invalid creator")
- ErrInvalidSubdenom = registerError("invalid subdenom")
- ErrInvalidAdmin = registerError("invalid denom admin")
- ErrDenomAlreadyRegistered = registerError("attempting to create denom that is already registered (has bank metadata)")
- ErrInvalidSender = registerError("invalid msg sender")
- ErrInvalidModuleParams = registerError("invalid module params")
- ErrGetAdmin = registerError("failed to find admin for denom")
- ErrGetMetadata = registerError("failed to find bank metadata for denom")
- ErrUnauthorized = registerError("sender must be admin")
- // ErrBlockedAddress: error when the x/bank keeper has an address
- // blocked.
- ErrBlockedAddress = registerError("blocked address")
-)
diff --git a/x/tokenfactory/types/event.pb.go b/x/tokenfactory/types/event.pb.go
deleted file mode 100644
index 808fb098d..000000000
--- a/x/tokenfactory/types/event.pb.go
+++ /dev/null
@@ -1,1483 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/tokenfactory/v1/event.proto
-
-package types
-
-import (
- fmt "fmt"
- types "github.com/cosmos/cosmos-sdk/types"
- types1 "github.com/cosmos/cosmos-sdk/x/bank/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-type EventCreateDenom struct {
- Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"`
- Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"`
-}
-
-func (m *EventCreateDenom) Reset() { *m = EventCreateDenom{} }
-func (m *EventCreateDenom) String() string { return proto.CompactTextString(m) }
-func (*EventCreateDenom) ProtoMessage() {}
-func (*EventCreateDenom) Descriptor() ([]byte, []int) {
- return fileDescriptor_a46c3c7b7d022093, []int{0}
-}
-func (m *EventCreateDenom) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventCreateDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventCreateDenom.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventCreateDenom) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventCreateDenom.Merge(m, src)
-}
-func (m *EventCreateDenom) XXX_Size() int {
- return m.Size()
-}
-func (m *EventCreateDenom) XXX_DiscardUnknown() {
- xxx_messageInfo_EventCreateDenom.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventCreateDenom proto.InternalMessageInfo
-
-func (m *EventCreateDenom) GetDenom() string {
- if m != nil {
- return m.Denom
- }
- return ""
-}
-
-func (m *EventCreateDenom) GetCreator() string {
- if m != nil {
- return m.Creator
- }
- return ""
-}
-
-type EventChangeAdmin struct {
- Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"`
- NewAdmin string `protobuf:"bytes,2,opt,name=new_admin,json=newAdmin,proto3" json:"new_admin,omitempty"`
- OldAdmin string `protobuf:"bytes,3,opt,name=old_admin,json=oldAdmin,proto3" json:"old_admin,omitempty"`
-}
-
-func (m *EventChangeAdmin) Reset() { *m = EventChangeAdmin{} }
-func (m *EventChangeAdmin) String() string { return proto.CompactTextString(m) }
-func (*EventChangeAdmin) ProtoMessage() {}
-func (*EventChangeAdmin) Descriptor() ([]byte, []int) {
- return fileDescriptor_a46c3c7b7d022093, []int{1}
-}
-func (m *EventChangeAdmin) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventChangeAdmin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventChangeAdmin.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventChangeAdmin) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventChangeAdmin.Merge(m, src)
-}
-func (m *EventChangeAdmin) XXX_Size() int {
- return m.Size()
-}
-func (m *EventChangeAdmin) XXX_DiscardUnknown() {
- xxx_messageInfo_EventChangeAdmin.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventChangeAdmin proto.InternalMessageInfo
-
-func (m *EventChangeAdmin) GetDenom() string {
- if m != nil {
- return m.Denom
- }
- return ""
-}
-
-func (m *EventChangeAdmin) GetNewAdmin() string {
- if m != nil {
- return m.NewAdmin
- }
- return ""
-}
-
-func (m *EventChangeAdmin) GetOldAdmin() string {
- if m != nil {
- return m.OldAdmin
- }
- return ""
-}
-
-type EventMint struct {
- Coin types.Coin `protobuf:"bytes,1,opt,name=coin,proto3" json:"coin" yaml:"coin"`
- ToAddr string `protobuf:"bytes,2,opt,name=to_addr,json=toAddr,proto3" json:"to_addr,omitempty"`
- Caller string `protobuf:"bytes,3,opt,name=caller,proto3" json:"caller,omitempty"`
-}
-
-func (m *EventMint) Reset() { *m = EventMint{} }
-func (m *EventMint) String() string { return proto.CompactTextString(m) }
-func (*EventMint) ProtoMessage() {}
-func (*EventMint) Descriptor() ([]byte, []int) {
- return fileDescriptor_a46c3c7b7d022093, []int{2}
-}
-func (m *EventMint) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventMint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventMint.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventMint) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventMint.Merge(m, src)
-}
-func (m *EventMint) XXX_Size() int {
- return m.Size()
-}
-func (m *EventMint) XXX_DiscardUnknown() {
- xxx_messageInfo_EventMint.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventMint proto.InternalMessageInfo
-
-func (m *EventMint) GetCoin() types.Coin {
- if m != nil {
- return m.Coin
- }
- return types.Coin{}
-}
-
-func (m *EventMint) GetToAddr() string {
- if m != nil {
- return m.ToAddr
- }
- return ""
-}
-
-func (m *EventMint) GetCaller() string {
- if m != nil {
- return m.Caller
- }
- return ""
-}
-
-type EventBurn struct {
- Coin types.Coin `protobuf:"bytes,1,opt,name=coin,proto3" json:"coin" yaml:"coin"`
- FromAddr string `protobuf:"bytes,2,opt,name=from_addr,json=fromAddr,proto3" json:"from_addr,omitempty"`
- Caller string `protobuf:"bytes,3,opt,name=caller,proto3" json:"caller,omitempty"`
-}
-
-func (m *EventBurn) Reset() { *m = EventBurn{} }
-func (m *EventBurn) String() string { return proto.CompactTextString(m) }
-func (*EventBurn) ProtoMessage() {}
-func (*EventBurn) Descriptor() ([]byte, []int) {
- return fileDescriptor_a46c3c7b7d022093, []int{3}
-}
-func (m *EventBurn) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventBurn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventBurn.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventBurn) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventBurn.Merge(m, src)
-}
-func (m *EventBurn) XXX_Size() int {
- return m.Size()
-}
-func (m *EventBurn) XXX_DiscardUnknown() {
- xxx_messageInfo_EventBurn.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventBurn proto.InternalMessageInfo
-
-func (m *EventBurn) GetCoin() types.Coin {
- if m != nil {
- return m.Coin
- }
- return types.Coin{}
-}
-
-func (m *EventBurn) GetFromAddr() string {
- if m != nil {
- return m.FromAddr
- }
- return ""
-}
-
-func (m *EventBurn) GetCaller() string {
- if m != nil {
- return m.Caller
- }
- return ""
-}
-
-type EventSetDenomMetadata struct {
- Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"`
- // Metadata: Official x/bank metadata for the denom. All token factory denoms
- // are standard, native assets. The "metadata.base" is the denom.
- Metadata types1.Metadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata"`
- Caller string `protobuf:"bytes,3,opt,name=caller,proto3" json:"caller,omitempty"`
-}
-
-func (m *EventSetDenomMetadata) Reset() { *m = EventSetDenomMetadata{} }
-func (m *EventSetDenomMetadata) String() string { return proto.CompactTextString(m) }
-func (*EventSetDenomMetadata) ProtoMessage() {}
-func (*EventSetDenomMetadata) Descriptor() ([]byte, []int) {
- return fileDescriptor_a46c3c7b7d022093, []int{4}
-}
-func (m *EventSetDenomMetadata) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EventSetDenomMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EventSetDenomMetadata.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *EventSetDenomMetadata) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EventSetDenomMetadata.Merge(m, src)
-}
-func (m *EventSetDenomMetadata) XXX_Size() int {
- return m.Size()
-}
-func (m *EventSetDenomMetadata) XXX_DiscardUnknown() {
- xxx_messageInfo_EventSetDenomMetadata.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EventSetDenomMetadata proto.InternalMessageInfo
-
-func (m *EventSetDenomMetadata) GetDenom() string {
- if m != nil {
- return m.Denom
- }
- return ""
-}
-
-func (m *EventSetDenomMetadata) GetMetadata() types1.Metadata {
- if m != nil {
- return m.Metadata
- }
- return types1.Metadata{}
-}
-
-func (m *EventSetDenomMetadata) GetCaller() string {
- if m != nil {
- return m.Caller
- }
- return ""
-}
-
-func init() {
- proto.RegisterType((*EventCreateDenom)(nil), "nibiru.tokenfactory.v1.EventCreateDenom")
- proto.RegisterType((*EventChangeAdmin)(nil), "nibiru.tokenfactory.v1.EventChangeAdmin")
- proto.RegisterType((*EventMint)(nil), "nibiru.tokenfactory.v1.EventMint")
- proto.RegisterType((*EventBurn)(nil), "nibiru.tokenfactory.v1.EventBurn")
- proto.RegisterType((*EventSetDenomMetadata)(nil), "nibiru.tokenfactory.v1.EventSetDenomMetadata")
-}
-
-func init() {
- proto.RegisterFile("nibiru/tokenfactory/v1/event.proto", fileDescriptor_a46c3c7b7d022093)
-}
-
-var fileDescriptor_a46c3c7b7d022093 = []byte{
- // 432 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xbf, 0x92, 0xd3, 0x30,
- 0x10, 0xc6, 0x6d, 0x38, 0x72, 0xb1, 0xd2, 0x30, 0xe6, 0x38, 0x02, 0x19, 0x7c, 0x8c, 0x2b, 0x2a,
- 0x69, 0x1c, 0x3a, 0x1a, 0xe6, 0x1c, 0xe8, 0x38, 0x8a, 0xd0, 0xd1, 0xdc, 0xc8, 0x96, 0xce, 0xd1,
- 0xc4, 0xd6, 0xde, 0xc8, 0x8a, 0x8f, 0x74, 0x14, 0x0c, 0x35, 0x8f, 0x95, 0x32, 0x25, 0x55, 0x86,
- 0x49, 0xde, 0x80, 0x27, 0x60, 0x24, 0xcb, 0x21, 0x14, 0xa1, 0xa2, 0xd3, 0xee, 0xb7, 0x7f, 0x7e,
- 0x9f, 0xbd, 0x28, 0x96, 0x22, 0x13, 0x6a, 0x41, 0x34, 0xcc, 0xb9, 0xbc, 0xa1, 0xb9, 0x06, 0xb5,
- 0x24, 0x4d, 0x42, 0x78, 0xc3, 0xa5, 0xc6, 0xb7, 0x0a, 0x34, 0x84, 0xe7, 0x6d, 0x0d, 0x3e, 0xac,
- 0xc1, 0x4d, 0xf2, 0x2c, 0xca, 0xa1, 0xae, 0xa0, 0x26, 0x19, 0x95, 0x73, 0xd2, 0x24, 0x19, 0xd7,
- 0x34, 0xb1, 0x41, 0xdb, 0x77, 0xa0, 0xd7, 0x7c, 0xaf, 0xe7, 0x20, 0xa4, 0xd3, 0xcf, 0x0a, 0x28,
- 0xc0, 0x3e, 0x89, 0x79, 0xb5, 0xd9, 0x38, 0x45, 0x0f, 0xdf, 0x99, 0xe5, 0x13, 0xc5, 0xa9, 0xe6,
- 0x6f, 0xb9, 0x84, 0x2a, 0x3c, 0x43, 0x0f, 0x98, 0x79, 0x0c, 0xfd, 0x17, 0xfe, 0xcb, 0x60, 0xda,
- 0x06, 0xe1, 0x10, 0x9d, 0xe6, 0xa6, 0x08, 0xd4, 0xf0, 0x9e, 0xcd, 0x77, 0x61, 0x9c, 0x75, 0x33,
- 0x66, 0x54, 0x16, 0xfc, 0x92, 0x55, 0x42, 0x1e, 0x99, 0x31, 0x42, 0x81, 0xe4, 0x77, 0xd7, 0xd4,
- 0x94, 0xb8, 0x29, 0x7d, 0xc9, 0xef, 0xda, 0x96, 0x11, 0x0a, 0xa0, 0x64, 0x4e, 0xbc, 0xdf, 0x8a,
- 0x50, 0x32, 0x2b, 0xc6, 0x5f, 0x7c, 0x14, 0xd8, 0x25, 0x57, 0x42, 0xea, 0x30, 0x45, 0x27, 0xc6,
- 0x99, 0x1d, 0x3e, 0x18, 0x3f, 0xc5, 0xad, 0x75, 0x6c, 0xac, 0x63, 0x67, 0x1d, 0x4f, 0x40, 0xc8,
- 0xf4, 0xd1, 0x6a, 0x73, 0xe1, 0xfd, 0xda, 0x5c, 0x0c, 0x96, 0xb4, 0x2a, 0x5f, 0xc7, 0xa6, 0x29,
- 0x9e, 0xda, 0xde, 0xf0, 0x09, 0x3a, 0xd5, 0x70, 0x4d, 0x19, 0xeb, 0xfc, 0xf4, 0x34, 0x5c, 0x32,
- 0xa6, 0xc2, 0x73, 0xd4, 0xcb, 0x69, 0x59, 0x72, 0xe5, 0x20, 0x5c, 0x14, 0x7f, 0xed, 0x10, 0xd2,
- 0x85, 0x92, 0xff, 0x05, 0x61, 0x84, 0x82, 0x1b, 0x05, 0xd5, 0x21, 0x44, 0xdf, 0x24, 0xfe, 0x89,
- 0xf1, 0xcd, 0x47, 0x8f, 0x2d, 0xc6, 0x47, 0xae, 0xed, 0xff, 0xba, 0xe2, 0x9a, 0x32, 0xaa, 0xe9,
- 0x91, 0x6f, 0xfe, 0x06, 0xf5, 0x2b, 0x57, 0x61, 0x77, 0x0c, 0xc6, 0xcf, 0xff, 0xc0, 0xca, 0xf9,
- 0x1e, 0xb6, 0x1b, 0x93, 0x9e, 0x18, 0xe0, 0xe9, 0xbe, 0xe9, 0x18, 0x48, 0xfa, 0x7e, 0xb5, 0x8d,
- 0xfc, 0xf5, 0x36, 0xf2, 0x7f, 0x6e, 0x23, 0xff, 0xfb, 0x2e, 0xf2, 0xd6, 0xbb, 0xc8, 0xfb, 0xb1,
- 0x8b, 0xbc, 0x4f, 0xe3, 0x42, 0xe8, 0xd9, 0x22, 0xc3, 0x39, 0x54, 0xe4, 0x83, 0xbd, 0xe6, 0xc9,
- 0x8c, 0x0a, 0x49, 0xdc, 0xf5, 0x7f, 0xfe, 0xfb, 0xfe, 0xf5, 0xf2, 0x96, 0xd7, 0x59, 0xcf, 0xde,
- 0xe3, 0xab, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x91, 0x31, 0x11, 0x4b, 0x23, 0x03, 0x00, 0x00,
-}
-
-func (m *EventCreateDenom) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventCreateDenom) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventCreateDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Creator) > 0 {
- i -= len(m.Creator)
- copy(dAtA[i:], m.Creator)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Creator)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Denom) > 0 {
- i -= len(m.Denom)
- copy(dAtA[i:], m.Denom)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Denom)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventChangeAdmin) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventChangeAdmin) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventChangeAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.OldAdmin) > 0 {
- i -= len(m.OldAdmin)
- copy(dAtA[i:], m.OldAdmin)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.OldAdmin)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.NewAdmin) > 0 {
- i -= len(m.NewAdmin)
- copy(dAtA[i:], m.NewAdmin)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.NewAdmin)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Denom) > 0 {
- i -= len(m.Denom)
- copy(dAtA[i:], m.Denom)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Denom)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *EventMint) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventMint) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventMint) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Caller) > 0 {
- i -= len(m.Caller)
- copy(dAtA[i:], m.Caller)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Caller)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.ToAddr) > 0 {
- i -= len(m.ToAddr)
- copy(dAtA[i:], m.ToAddr)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.ToAddr)))
- i--
- dAtA[i] = 0x12
- }
- {
- size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvent(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *EventBurn) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventBurn) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Caller) > 0 {
- i -= len(m.Caller)
- copy(dAtA[i:], m.Caller)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Caller)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.FromAddr) > 0 {
- i -= len(m.FromAddr)
- copy(dAtA[i:], m.FromAddr)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.FromAddr)))
- i--
- dAtA[i] = 0x12
- }
- {
- size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvent(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *EventSetDenomMetadata) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EventSetDenomMetadata) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EventSetDenomMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Caller) > 0 {
- i -= len(m.Caller)
- copy(dAtA[i:], m.Caller)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Caller)))
- i--
- dAtA[i] = 0x1a
- }
- {
- size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintEvent(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Denom) > 0 {
- i -= len(m.Denom)
- copy(dAtA[i:], m.Denom)
- i = encodeVarintEvent(dAtA, i, uint64(len(m.Denom)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintEvent(dAtA []byte, offset int, v uint64) int {
- offset -= sovEvent(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *EventCreateDenom) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Denom)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Creator)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func (m *EventChangeAdmin) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Denom)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.NewAdmin)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.OldAdmin)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func (m *EventMint) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Coin.Size()
- n += 1 + l + sovEvent(uint64(l))
- l = len(m.ToAddr)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Caller)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func (m *EventBurn) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Coin.Size()
- n += 1 + l + sovEvent(uint64(l))
- l = len(m.FromAddr)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = len(m.Caller)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func (m *EventSetDenomMetadata) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Denom)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- l = m.Metadata.Size()
- n += 1 + l + sovEvent(uint64(l))
- l = len(m.Caller)
- if l > 0 {
- n += 1 + l + sovEvent(uint64(l))
- }
- return n
-}
-
-func sovEvent(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozEvent(x uint64) (n int) {
- return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *EventCreateDenom) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventCreateDenom: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventCreateDenom: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Denom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Creator = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventChangeAdmin) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventChangeAdmin: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventChangeAdmin: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Denom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.NewAdmin = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field OldAdmin", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.OldAdmin = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventMint) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventMint: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventMint: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ToAddr", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ToAddr = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Caller", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Caller = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventBurn) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventBurn: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventBurn: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field FromAddr", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.FromAddr = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Caller", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Caller = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EventSetDenomMetadata) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EventSetDenomMetadata: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EventSetDenomMetadata: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Denom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Caller", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEvent
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthEvent
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Caller = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipEvent(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthEvent
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipEvent(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEvent
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthEvent
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupEvent
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthEvent
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/tokenfactory/types/expected_keepers.go b/x/tokenfactory/types/expected_keepers.go
deleted file mode 100644
index c25e9a489..000000000
--- a/x/tokenfactory/types/expected_keepers.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package types
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
-)
-
-type BankKeeper interface {
- // Methods imported from bank should be defined here
- GetDenomMetaData(ctx sdk.Context, denom string) (banktypes.Metadata, bool)
- SetDenomMetaData(ctx sdk.Context, denomMetaData banktypes.Metadata)
-
- GetSupply(ctx sdk.Context, denom string) sdk.Coin
- HasSupply(ctx sdk.Context, denom string) bool
- IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin) bool)
-
- SendCoinsFromModuleToAccount(
- ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins,
- ) error
- SendCoinsFromAccountToModule(
- ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins,
- ) error
- MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
- BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
-
- SendCoins(
- ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins,
- ) error
- HasBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin) bool
- GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
- SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
- GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
-
- BlockedAddr(addr sdk.AccAddress) bool
-}
-
-type AccountKeeper interface {
- SetModuleAccount(ctx sdk.Context, macc authtypes.ModuleAccountI)
- GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
-}
-
-// CommunityPoolKeeper defines the contract needed to be fulfilled for community pool interactions.
-type CommunityPoolKeeper interface {
- FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
-}
diff --git a/x/tokenfactory/types/export.go b/x/tokenfactory/types/export.go
deleted file mode 100644
index fb4b6e3b6..000000000
--- a/x/tokenfactory/types/export.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package types
-
-import (
- grpc "google.golang.org/grpc"
-)
-
-// GrpcQueryServiceDesc represents the query server's RPC service specification.
-// This gives access to the service name and method names needed for stargate
-// queries.
-func GrpcQueryServiceDesc() grpc.ServiceDesc {
- return _Query_serviceDesc
-}
diff --git a/x/tokenfactory/types/genesis.go b/x/tokenfactory/types/genesis.go
deleted file mode 100644
index d97990c3a..000000000
--- a/x/tokenfactory/types/genesis.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package types
-
-import (
- fmt "fmt"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/NibiruChain/nibiru/x/common/set"
-)
-
-// DefaultGenesis returns the default genesis state. This state is used for
-// upgrades and for the start of the chain (InitChain).
-func DefaultGenesis() *GenesisState {
- return &GenesisState{
- Params: DefaultModuleParams(),
- FactoryDenoms: []GenesisDenom{},
- }
-}
-
-// Validate performs basic genesis state validation.
-func (gs GenesisState) Validate() error {
- err := gs.Params.Validate()
- if err != nil {
- return err
- }
-
- seenDenoms := set.New[string]()
-
- for _, genesisDenom := range gs.GetFactoryDenoms() {
- denom := genesisDenom.GetDenom()
- if seenDenoms.Has(denom) {
- return ErrInvalidGenesis.Wrapf("duplicate denom: %s", denom)
- }
- seenDenoms.Add(denom)
-
- if err := genesisDenom.Validate(); err != nil {
- return ErrInvalidGenesis.Wrap(err.Error())
- }
-
- if admin := genesisDenom.AuthorityMetadata.Admin; admin != "" {
- _, err = sdk.AccAddressFromBech32(admin)
- if err != nil {
- return fmt.Errorf("%w: %s: admin address (%s): %s",
- ErrInvalidGenesis, ErrInvalidAdmin, admin, err,
- )
- }
- }
- }
-
- return nil
-}
diff --git a/x/tokenfactory/types/keys.go b/x/tokenfactory/types/keys.go
deleted file mode 100644
index db04de34d..000000000
--- a/x/tokenfactory/types/keys.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package types
-
-import (
- "github.com/NibiruChain/collections"
-)
-
-// constants
-const (
- // module name
- ModuleName = "tokenfactory"
-
- // StoreKey to be used when creating the KVStore
- StoreKey = ModuleName
-
- // RouterKey to be used for message routing
- RouterKey = ModuleName
-)
-
-// KVStore key and mutli-index prefixes
-// prefix bytes for the fees persistent store
-const (
- KeyPrefixDenom collections.Namespace = iota + 1
- KeyPrefixCreator
- KeyPrefixModuleParams
- KeyPrefixDenomAdmin
- KeyPrefixCreatorIndexer
-)
diff --git a/x/tokenfactory/types/query.pb.go b/x/tokenfactory/types/query.pb.go
deleted file mode 100644
index 63b808876..000000000
--- a/x/tokenfactory/types/query.pb.go
+++ /dev/null
@@ -1,1371 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/tokenfactory/v1/query.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- types "github.com/cosmos/cosmos-sdk/x/bank/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- _ "google.golang.org/genproto/googleapis/api/annotations"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// QueryParamsRequest is the request type for the Query/Params RPC method.
-type QueryParamsRequest struct {
-}
-
-func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} }
-func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryParamsRequest) ProtoMessage() {}
-func (*QueryParamsRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_b7d8bbc34d6c2a91, []int{0}
-}
-func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryParamsRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryParamsRequest.Merge(m, src)
-}
-func (m *QueryParamsRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryParamsRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo
-
-// QueryParamsResponse is the response type for the Query/Params RPC method.
-type QueryParamsResponse struct {
- // Module parameters stored in state
- Params ModuleParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
-}
-
-func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} }
-func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryParamsResponse) ProtoMessage() {}
-func (*QueryParamsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_b7d8bbc34d6c2a91, []int{1}
-}
-func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryParamsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryParamsResponse.Merge(m, src)
-}
-func (m *QueryParamsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryParamsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo
-
-func (m *QueryParamsResponse) GetParams() ModuleParams {
- if m != nil {
- return m.Params
- }
- return ModuleParams{}
-}
-
-// QueryDenomsRequest: gRPC query for all denoms registered for a creator
-type QueryDenomsRequest struct {
- Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"`
-}
-
-func (m *QueryDenomsRequest) Reset() { *m = QueryDenomsRequest{} }
-func (m *QueryDenomsRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryDenomsRequest) ProtoMessage() {}
-func (*QueryDenomsRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_b7d8bbc34d6c2a91, []int{2}
-}
-func (m *QueryDenomsRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryDenomsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryDenomsRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryDenomsRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryDenomsRequest.Merge(m, src)
-}
-func (m *QueryDenomsRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryDenomsRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryDenomsRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryDenomsRequest proto.InternalMessageInfo
-
-func (m *QueryDenomsRequest) GetCreator() string {
- if m != nil {
- return m.Creator
- }
- return ""
-}
-
-// QueryDenomsResponse: All registered denoms for a creator
-type QueryDenomsResponse struct {
- Denoms []string `protobuf:"bytes,1,rep,name=denoms,proto3" json:"denoms,omitempty"`
-}
-
-func (m *QueryDenomsResponse) Reset() { *m = QueryDenomsResponse{} }
-func (m *QueryDenomsResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryDenomsResponse) ProtoMessage() {}
-func (*QueryDenomsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_b7d8bbc34d6c2a91, []int{3}
-}
-func (m *QueryDenomsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryDenomsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryDenomsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryDenomsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryDenomsResponse.Merge(m, src)
-}
-func (m *QueryDenomsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryDenomsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryDenomsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryDenomsResponse proto.InternalMessageInfo
-
-func (m *QueryDenomsResponse) GetDenoms() []string {
- if m != nil {
- return m.Denoms
- }
- return nil
-}
-
-// QueryDenomInfoRequest: gRPC query for the denom admin and x/bank metadata
-type QueryDenomInfoRequest struct {
- Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"`
-}
-
-func (m *QueryDenomInfoRequest) Reset() { *m = QueryDenomInfoRequest{} }
-func (m *QueryDenomInfoRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryDenomInfoRequest) ProtoMessage() {}
-func (*QueryDenomInfoRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_b7d8bbc34d6c2a91, []int{4}
-}
-func (m *QueryDenomInfoRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryDenomInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryDenomInfoRequest.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryDenomInfoRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryDenomInfoRequest.Merge(m, src)
-}
-func (m *QueryDenomInfoRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryDenomInfoRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryDenomInfoRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryDenomInfoRequest proto.InternalMessageInfo
-
-func (m *QueryDenomInfoRequest) GetDenom() string {
- if m != nil {
- return m.Denom
- }
- return ""
-}
-
-// QueryDenomInfoResponse: All registered denoms for a creator
-type QueryDenomInfoResponse struct {
- // Admin of the token factory denom
- Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"`
- // Metadata: Official x/bank metadata for the denom. All token factory denoms
- // are standard, native assets.
- Metadata types.Metadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata"`
-}
-
-func (m *QueryDenomInfoResponse) Reset() { *m = QueryDenomInfoResponse{} }
-func (m *QueryDenomInfoResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryDenomInfoResponse) ProtoMessage() {}
-func (*QueryDenomInfoResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_b7d8bbc34d6c2a91, []int{5}
-}
-func (m *QueryDenomInfoResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryDenomInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryDenomInfoResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *QueryDenomInfoResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryDenomInfoResponse.Merge(m, src)
-}
-func (m *QueryDenomInfoResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryDenomInfoResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryDenomInfoResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryDenomInfoResponse proto.InternalMessageInfo
-
-func (m *QueryDenomInfoResponse) GetAdmin() string {
- if m != nil {
- return m.Admin
- }
- return ""
-}
-
-func (m *QueryDenomInfoResponse) GetMetadata() types.Metadata {
- if m != nil {
- return m.Metadata
- }
- return types.Metadata{}
-}
-
-func init() {
- proto.RegisterType((*QueryParamsRequest)(nil), "nibiru.tokenfactory.v1.QueryParamsRequest")
- proto.RegisterType((*QueryParamsResponse)(nil), "nibiru.tokenfactory.v1.QueryParamsResponse")
- proto.RegisterType((*QueryDenomsRequest)(nil), "nibiru.tokenfactory.v1.QueryDenomsRequest")
- proto.RegisterType((*QueryDenomsResponse)(nil), "nibiru.tokenfactory.v1.QueryDenomsResponse")
- proto.RegisterType((*QueryDenomInfoRequest)(nil), "nibiru.tokenfactory.v1.QueryDenomInfoRequest")
- proto.RegisterType((*QueryDenomInfoResponse)(nil), "nibiru.tokenfactory.v1.QueryDenomInfoResponse")
-}
-
-func init() {
- proto.RegisterFile("nibiru/tokenfactory/v1/query.proto", fileDescriptor_b7d8bbc34d6c2a91)
-}
-
-var fileDescriptor_b7d8bbc34d6c2a91 = []byte{
- // 495 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x31, 0x6f, 0x13, 0x31,
- 0x14, 0xc7, 0xe3, 0x96, 0x1c, 0xc4, 0x6c, 0x26, 0x44, 0x51, 0x04, 0x47, 0x64, 0x21, 0x14, 0x05,
- 0x62, 0x93, 0xf0, 0x01, 0x90, 0x02, 0x0b, 0x12, 0x45, 0x90, 0x0d, 0x36, 0x5f, 0xe2, 0x5c, 0x4f,
- 0xed, 0xf9, 0x5d, 0xcf, 0xbe, 0x88, 0xa8, 0xea, 0xc2, 0xc6, 0x86, 0xd4, 0x9d, 0xcf, 0x53, 0x31,
- 0x55, 0x62, 0x61, 0x42, 0x28, 0xe1, 0x83, 0xa0, 0xda, 0xbe, 0xd0, 0x00, 0x21, 0xdd, 0xfc, 0xec,
- 0x9f, 0xdf, 0xff, 0xef, 0xf7, 0xbf, 0xc3, 0x54, 0x25, 0x51, 0x92, 0x17, 0xdc, 0xc0, 0x81, 0x54,
- 0x53, 0x31, 0x36, 0x90, 0xcf, 0xf9, 0xac, 0xcf, 0x8f, 0x0a, 0x99, 0xcf, 0x59, 0x96, 0x83, 0x01,
- 0xd2, 0x70, 0x0c, 0xbb, 0xcc, 0xb0, 0x59, 0xbf, 0x55, 0x8f, 0x21, 0x06, 0x8b, 0xf0, 0x8b, 0x95,
- 0xa3, 0x5b, 0x77, 0x62, 0x80, 0xf8, 0x50, 0x72, 0x91, 0x25, 0x5c, 0x28, 0x05, 0x46, 0x98, 0x04,
- 0x94, 0xf6, 0xa7, 0xe1, 0x18, 0x74, 0x0a, 0x9a, 0x47, 0x42, 0x1d, 0xf0, 0x59, 0x3f, 0x92, 0x46,
- 0xf4, 0x6d, 0xe1, 0xcf, 0x37, 0xf9, 0xd1, 0x46, 0x18, 0xe9, 0x18, 0x5a, 0xc7, 0xe4, 0xcd, 0x85,
- 0xbd, 0xd7, 0x22, 0x17, 0xa9, 0x1e, 0xc9, 0xa3, 0x42, 0x6a, 0x43, 0xdf, 0xe2, 0x5b, 0x6b, 0xbb,
- 0x3a, 0x03, 0xa5, 0x25, 0x19, 0xe2, 0x20, 0xb3, 0x3b, 0x4d, 0xd4, 0x46, 0x9d, 0x9b, 0x83, 0xfb,
- 0xec, 0xdf, 0xaf, 0x61, 0x7b, 0x30, 0x29, 0x0e, 0xa5, 0xbb, 0x3d, 0xbc, 0x76, 0xf6, 0xfd, 0x5e,
- 0x65, 0xe4, 0x6f, 0x52, 0xe6, 0x05, 0x9f, 0x4b, 0x05, 0x2b, 0x41, 0xd2, 0xc4, 0xd7, 0xc7, 0xb9,
- 0x14, 0x06, 0x72, 0xdb, 0xba, 0x36, 0x2a, 0x4b, 0xda, 0xf3, 0x56, 0x4a, 0xde, 0x5b, 0x69, 0xe0,
- 0x60, 0x62, 0x77, 0x9a, 0xa8, 0xbd, 0xdb, 0xa9, 0x8d, 0x7c, 0x45, 0x7b, 0xf8, 0xf6, 0x6f, 0xfc,
- 0x85, 0x9a, 0x42, 0xa9, 0x50, 0xc7, 0x55, 0x8b, 0xf8, 0xfe, 0xae, 0xa0, 0x80, 0x1b, 0x7f, 0xe2,
- 0x5e, 0xa0, 0x8e, 0xab, 0x62, 0x92, 0x26, 0xaa, 0xe4, 0x6d, 0x41, 0x9e, 0xe2, 0x1b, 0xa9, 0x34,
- 0x62, 0x22, 0x8c, 0x68, 0xee, 0xd8, 0x19, 0xdc, 0x65, 0x2e, 0x05, 0x66, 0x07, 0xef, 0x53, 0x60,
- 0x7b, 0x1e, 0xf2, 0x8f, 0x5f, 0x5d, 0x1a, 0x7c, 0xd9, 0xc5, 0x55, 0xab, 0x48, 0x3e, 0x22, 0x1c,
- 0xb8, 0x09, 0x91, 0xee, 0xa6, 0x39, 0xfe, 0x1d, 0x4d, 0xeb, 0xe1, 0x95, 0x58, 0xf7, 0x08, 0xfa,
- 0xe0, 0xc3, 0xd7, 0x9f, 0xa7, 0x3b, 0x6d, 0x12, 0xf2, 0x0d, 0x9f, 0x82, 0x0b, 0x85, 0x9c, 0x22,
- 0x1c, 0xb8, 0x01, 0x6f, 0xf1, 0xb2, 0x96, 0xda, 0x16, 0x2f, 0xeb, 0x89, 0xd1, 0xc7, 0xd6, 0x4b,
- 0x97, 0x74, 0x36, 0x79, 0x71, 0x09, 0xf2, 0x63, 0x9f, 0xfc, 0x09, 0xf9, 0x8c, 0x70, 0x6d, 0x15,
- 0x0c, 0xe9, 0x6d, 0x17, 0xbb, 0x94, 0x77, 0x8b, 0x5d, 0x15, 0xf7, 0xf6, 0x06, 0xd6, 0xde, 0x23,
- 0xd2, 0xfd, 0xaf, 0xbd, 0x5e, 0xa2, 0xa6, 0xc0, 0x8f, 0xed, 0xfa, 0x64, 0xf8, 0xf2, 0x6c, 0x11,
- 0xa2, 0xf3, 0x45, 0x88, 0x7e, 0x2c, 0x42, 0xf4, 0x69, 0x19, 0x56, 0xce, 0x97, 0x61, 0xe5, 0xdb,
- 0x32, 0xac, 0xbc, 0x1b, 0xc4, 0x89, 0xd9, 0x2f, 0x22, 0x36, 0x86, 0x94, 0xbf, 0xb2, 0xfd, 0x9e,
- 0xed, 0x8b, 0x44, 0x95, 0xbd, 0xdf, 0xaf, 0x77, 0x37, 0xf3, 0x4c, 0xea, 0x28, 0xb0, 0x7f, 0xe4,
- 0x93, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xed, 0x27, 0xd8, 0x56, 0x47, 0x04, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// QueryClient is the client API for Query service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type QueryClient interface {
- // Params retrieves the module params
- Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
- // Denoms retrieves all registered denoms for a given creator
- Denoms(ctx context.Context, in *QueryDenomsRequest, opts ...grpc.CallOption) (*QueryDenomsResponse, error)
- // DenomInfo retrieves the denom metadata and admin info
- DenomInfo(ctx context.Context, in *QueryDenomInfoRequest, opts ...grpc.CallOption) (*QueryDenomInfoResponse, error)
-}
-
-type queryClient struct {
- cc grpc1.ClientConn
-}
-
-func NewQueryClient(cc grpc1.ClientConn) QueryClient {
- return &queryClient{cc}
-}
-
-func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) {
- out := new(QueryParamsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Query/Params", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) Denoms(ctx context.Context, in *QueryDenomsRequest, opts ...grpc.CallOption) (*QueryDenomsResponse, error) {
- out := new(QueryDenomsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Query/Denoms", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) DenomInfo(ctx context.Context, in *QueryDenomInfoRequest, opts ...grpc.CallOption) (*QueryDenomInfoResponse, error) {
- out := new(QueryDenomInfoResponse)
- err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Query/DenomInfo", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// QueryServer is the server API for Query service.
-type QueryServer interface {
- // Params retrieves the module params
- Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
- // Denoms retrieves all registered denoms for a given creator
- Denoms(context.Context, *QueryDenomsRequest) (*QueryDenomsResponse, error)
- // DenomInfo retrieves the denom metadata and admin info
- DenomInfo(context.Context, *QueryDenomInfoRequest) (*QueryDenomInfoResponse, error)
-}
-
-// UnimplementedQueryServer can be embedded to have forward compatible implementations.
-type UnimplementedQueryServer struct {
-}
-
-func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
-}
-func (*UnimplementedQueryServer) Denoms(ctx context.Context, req *QueryDenomsRequest) (*QueryDenomsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Denoms not implemented")
-}
-func (*UnimplementedQueryServer) DenomInfo(ctx context.Context, req *QueryDenomInfoRequest) (*QueryDenomInfoResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method DenomInfo not implemented")
-}
-
-func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
- s.RegisterService(&_Query_serviceDesc, srv)
-}
-
-func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryParamsRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Params(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.tokenfactory.v1.Query/Params",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_Denoms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryDenomsRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).Denoms(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.tokenfactory.v1.Query/Denoms",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).Denoms(ctx, req.(*QueryDenomsRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_DenomInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryDenomInfoRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).DenomInfo(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.tokenfactory.v1.Query/DenomInfo",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).DenomInfo(ctx, req.(*QueryDenomInfoRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Query_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.tokenfactory.v1.Query",
- HandlerType: (*QueryServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "Params",
- Handler: _Query_Params_Handler,
- },
- {
- MethodName: "Denoms",
- Handler: _Query_Denoms_Handler,
- },
- {
- MethodName: "DenomInfo",
- Handler: _Query_DenomInfo_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/tokenfactory/v1/query.proto",
-}
-
-func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *QueryDenomsRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryDenomsRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryDenomsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Creator) > 0 {
- i -= len(m.Creator)
- copy(dAtA[i:], m.Creator)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Creator)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryDenomsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryDenomsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryDenomsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Denoms) > 0 {
- for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- {
- i -= len(m.Denoms[iNdEx])
- copy(dAtA[i:], m.Denoms[iNdEx])
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Denoms[iNdEx])))
- i--
- dAtA[i] = 0xa
- }
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryDenomInfoRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryDenomInfoRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryDenomInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Denom) > 0 {
- i -= len(m.Denom)
- copy(dAtA[i:], m.Denom)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryDenomInfoResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *QueryDenomInfoResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryDenomInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintQuery(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Admin) > 0 {
- i -= len(m.Admin)
- copy(dAtA[i:], m.Admin)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Admin)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
- offset -= sovQuery(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *QueryParamsRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryParamsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Params.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func (m *QueryDenomsRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Creator)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryDenomsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Denoms) > 0 {
- for _, s := range m.Denoms {
- l = len(s)
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- return n
-}
-
-func (m *QueryDenomInfoRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Denom)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryDenomInfoResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Admin)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- l = m.Metadata.Size()
- n += 1 + l + sovQuery(uint64(l))
- return n
-}
-
-func sovQuery(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozQuery(x uint64) (n int) {
- return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryDenomsRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryDenomsRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryDenomsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Creator = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryDenomsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryDenomsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryDenomsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Denoms", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Denoms = append(m.Denoms, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryDenomInfoRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryDenomInfoRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryDenomInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Denom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryDenomInfoResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: QueryDenomInfoResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryDenomInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Admin = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthQuery
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthQuery
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipQuery(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthQuery
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupQuery
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthQuery
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/tokenfactory/types/query.pb.gw.go b/x/tokenfactory/types/query.pb.gw.go
deleted file mode 100644
index 47a7f0837..000000000
--- a/x/tokenfactory/types/query.pb.gw.go
+++ /dev/null
@@ -1,355 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: nibiru/tokenfactory/v1/query.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryParamsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryParamsRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.Params(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_Denoms_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryDenomsRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["creator"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "creator")
- }
-
- protoReq.Creator, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creator", err)
- }
-
- msg, err := client.Denoms(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_Denoms_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryDenomsRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["creator"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "creator")
- }
-
- protoReq.Creator, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creator", err)
- }
-
- msg, err := server.Denoms(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-func request_Query_DenomInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryDenomInfoRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["denom"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom")
- }
-
- protoReq.Denom, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err)
- }
-
- msg, err := client.DenomInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_DenomInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryDenomInfoRequest
- var metadata runtime.ServerMetadata
-
- var (
- val string
- ok bool
- err error
- _ = err
- )
-
- val, ok = pathParams["denom"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom")
- }
-
- protoReq.Denom, err = runtime.String(val)
-
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err)
- }
-
- msg, err := server.DenomInfo(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
-// UnaryRPC :call QueryServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
-func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
-
- mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Denoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_Denoms_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Denoms_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_DenomInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_DenomInfo_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_DenomInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterQueryHandler(ctx, mux, conn)
-}
-
-// RegisterQueryHandler registers the http handlers for service Query to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
-}
-
-// RegisterQueryHandlerClient registers the http handlers for service Query
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "QueryClient" to call the correct interceptors.
-func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
-
- mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_Denoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_Denoms_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_Denoms_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_DenomInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Query_DenomInfo_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_DenomInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "tokenfactory", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_Denoms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "tokenfactory", "v1", "denoms", "creator"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_DenomInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "tokenfactory", "v1", "denom-info", "denom"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Query_Params_0 = runtime.ForwardResponseMessage
-
- forward_Query_Denoms_0 = runtime.ForwardResponseMessage
-
- forward_Query_DenomInfo_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/tokenfactory/types/state.go b/x/tokenfactory/types/state.go
deleted file mode 100644
index 1a0f56b15..000000000
--- a/x/tokenfactory/types/state.go
+++ /dev/null
@@ -1,112 +0,0 @@
-package types
-
-import (
- "fmt"
- "strings"
-
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
-)
-
-// ----------------------------------------------------
-// ModuleParams functions
-// ----------------------------------------------------
-
-func DefaultModuleParams() ModuleParams {
- return ModuleParams{
- DenomCreationGasConsume: 4_000_000,
- }
-}
-
-func (params ModuleParams) Validate() error {
- if params.DenomCreationGasConsume < 1 {
- return ErrInvalidModuleParams.Wrap("cannot set gas creation cost to zero")
- }
- return nil
-}
-
-// ----------------------------------------------------
-// TFDenom functions
-// ----------------------------------------------------
-
-func (tfd TFDenom) Denom() DenomStr {
- return DenomStr(fmt.Sprintf("tf/%s/%s", tfd.Creator, tfd.Subdenom))
-}
-
-// // String: returns the standard string representation.
-// func (tfd TFDenom) DenomStr() string {
-// return fmt.Sprintf("tf/%s/%s", tfd.Creator, tfd.Subdenom)
-// }
-
-func (tfd TFDenom) Validate() error {
- return tfd.Denom().Validate()
-}
-
-func (tfd TFDenom) DefaultBankMetadata() banktypes.Metadata {
- denom := tfd.Denom()
- return banktypes.Metadata{
- DenomUnits: []*banktypes.DenomUnit{{
- Denom: denom.String(),
- Exponent: 0,
- }},
- Base: denom.String(),
- // The following is necessary for x/bank denom validation
- Display: denom.String(),
- Name: denom.String(),
- Symbol: denom.String(),
- }
-}
-
-func (tfd TFDenom) IsEqual(other TFDenom) bool {
- return tfd.Creator == other.Creator && tfd.Subdenom == other.Subdenom
-}
-
-// ----------------------------------------------------
-// DenomStr functions
-// ----------------------------------------------------
-
-// DenomStr: string identifier for a token factory denom (TFDenom)
-type DenomStr string
-
-func DenomFormatError(got string, msg ...string) error {
- errStr := fmt.Sprintf(`denom format error: expected "tf/{creator-bech32}/{subdenom}", got %v`, got)
- if len(msg) > 0 {
- errStr += fmt.Sprintf(": %v", msg)
- }
- return fmt.Errorf(errStr)
-}
-
-func (denomStr DenomStr) Validate() error {
- _, err := denomStr.ToStruct()
- return err
-}
-
-func (denomStr DenomStr) String() string { return string(denomStr) }
-
-func (genDenom GenesisDenom) Validate() error {
- return DenomStr(genDenom.Denom).Validate()
-}
-
-func (denomStr DenomStr) ToStruct() (res TFDenom, err error) {
- str := string(denomStr)
- parts := strings.Split(str, "/")
- switch {
- case len(parts) != 3:
- return res, DenomFormatError("denom has invalid number of sections separated by '/'")
- case parts[0] != "tf":
- return res, DenomFormatError(str, `missing denom prefix "tf"`)
- case len(parts[1]) < 1:
- return res, DenomFormatError(str, "empty creator address")
- case len(parts[2]) < 1:
- return res, DenomFormatError(str, "empty subdenom")
- }
-
- return TFDenom{
- Creator: parts[1],
- Subdenom: parts[2],
- }, nil
-}
-
-func (denomStr DenomStr) MustToStruct() TFDenom {
- out, _ := denomStr.ToStruct()
- return out
-}
diff --git a/x/tokenfactory/types/state.pb.go b/x/tokenfactory/types/state.pb.go
deleted file mode 100644
index 097e89c20..000000000
--- a/x/tokenfactory/types/state.pb.go
+++ /dev/null
@@ -1,1264 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/tokenfactory/v1/state.proto
-
-package types
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/cosmos-proto"
- _ "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// DenomAuthorityMetadata specifies metadata foraddresses that have specific
-// capabilities over a token factory denom. Right now there is only one Admin
-// permission, but is planned to be extended to the future.
-type DenomAuthorityMetadata struct {
- // Admin: Bech32 address of the admin for the tokefactory denom. Can be empty
- // for no admin.
- Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty" yaml:"admin"`
-}
-
-func (m *DenomAuthorityMetadata) Reset() { *m = DenomAuthorityMetadata{} }
-func (m *DenomAuthorityMetadata) String() string { return proto.CompactTextString(m) }
-func (*DenomAuthorityMetadata) ProtoMessage() {}
-func (*DenomAuthorityMetadata) Descriptor() ([]byte, []int) {
- return fileDescriptor_452ec984f7eef90f, []int{0}
-}
-func (m *DenomAuthorityMetadata) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *DenomAuthorityMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_DenomAuthorityMetadata.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *DenomAuthorityMetadata) XXX_Merge(src proto.Message) {
- xxx_messageInfo_DenomAuthorityMetadata.Merge(m, src)
-}
-func (m *DenomAuthorityMetadata) XXX_Size() int {
- return m.Size()
-}
-func (m *DenomAuthorityMetadata) XXX_DiscardUnknown() {
- xxx_messageInfo_DenomAuthorityMetadata.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_DenomAuthorityMetadata proto.InternalMessageInfo
-
-func (m *DenomAuthorityMetadata) GetAdmin() string {
- if m != nil {
- return m.Admin
- }
- return ""
-}
-
-// ModuleParams defines the parameters for the tokenfactory module.
-//
-// ### On Denom Creation Costs
-//
-// We'd like for fees to be paid by the user/signer of a ransaction, but in many
-// casess, token creation is abstracted away behind a smart contract. Setting a
-// nonzero `denom_creation_fee` would force each contract to handle collecting
-// and paying a fees for denom (factory/{contract-addr}/{subdenom}) creation on
-// behalf of the end user.
-//
-// For IBC token transfers, it's unclear who should pay the fee—the contract,
-// the relayer, or the original sender?
-// > "Charging fees will mess up composability, the same way Terra transfer tax
-//
-// caused all kinds of headaches for contract devs." - @ethanfrey
-//
-// ### Recommended Solution
-//
-// Have the end user (signer) pay fees directly in the form of higher gas costs.
-// This way, contracts won't need to handle collecting or paying fees. And for
-// IBC, the gas costs are already paid by the original sender and can be
-// estimated by the relayer. It's easier to tune gas costs to make spam
-// prohibitively expensive since there are per-transaction and per-block gas
-// limits.
-//
-// See https://github.com/CosmWasm/token-factory/issues/11 for the initial
-// discussion of the issue with @ethanfrey and @valardragon.
-type ModuleParams struct {
- // Adds gas consumption to the execution of `MsgCreateDenom` as a method of
- // spam prevention. Defaults to 10 NIBI.
- DenomCreationGasConsume uint64 `protobuf:"varint,1,opt,name=denom_creation_gas_consume,json=denomCreationGasConsume,proto3" json:"denom_creation_gas_consume,omitempty" yaml:"denom_creation_gas_consume"`
-}
-
-func (m *ModuleParams) Reset() { *m = ModuleParams{} }
-func (m *ModuleParams) String() string { return proto.CompactTextString(m) }
-func (*ModuleParams) ProtoMessage() {}
-func (*ModuleParams) Descriptor() ([]byte, []int) {
- return fileDescriptor_452ec984f7eef90f, []int{1}
-}
-func (m *ModuleParams) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *ModuleParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_ModuleParams.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *ModuleParams) XXX_Merge(src proto.Message) {
- xxx_messageInfo_ModuleParams.Merge(m, src)
-}
-func (m *ModuleParams) XXX_Size() int {
- return m.Size()
-}
-func (m *ModuleParams) XXX_DiscardUnknown() {
- xxx_messageInfo_ModuleParams.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ModuleParams proto.InternalMessageInfo
-
-func (m *ModuleParams) GetDenomCreationGasConsume() uint64 {
- if m != nil {
- return m.DenomCreationGasConsume
- }
- return 0
-}
-
-// TFDenom is a token factory (TF) denom. The canonical representation is
-// "tf/{creator}/{subdenom}", its unique denomination in the x/bank module.
-type TFDenom struct {
- // Creator: Bech32 address of the creator of the denom.
- Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"`
- // Subdenom: Unique suffix of a token factory denom. A subdenom is specific
- // to a given creator. It is the name given during a token factory "Mint".
- Subdenom string `protobuf:"bytes,2,opt,name=subdenom,proto3" json:"subdenom,omitempty"`
-}
-
-func (m *TFDenom) Reset() { *m = TFDenom{} }
-func (m *TFDenom) String() string { return proto.CompactTextString(m) }
-func (*TFDenom) ProtoMessage() {}
-func (*TFDenom) Descriptor() ([]byte, []int) {
- return fileDescriptor_452ec984f7eef90f, []int{2}
-}
-func (m *TFDenom) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *TFDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_TFDenom.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *TFDenom) XXX_Merge(src proto.Message) {
- xxx_messageInfo_TFDenom.Merge(m, src)
-}
-func (m *TFDenom) XXX_Size() int {
- return m.Size()
-}
-func (m *TFDenom) XXX_DiscardUnknown() {
- xxx_messageInfo_TFDenom.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_TFDenom proto.InternalMessageInfo
-
-func (m *TFDenom) GetCreator() string {
- if m != nil {
- return m.Creator
- }
- return ""
-}
-
-func (m *TFDenom) GetSubdenom() string {
- if m != nil {
- return m.Subdenom
- }
- return ""
-}
-
-// GenesisState for the Token Factory module.
-type GenesisState struct {
- Params ModuleParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
- FactoryDenoms []GenesisDenom `protobuf:"bytes,2,rep,name=factory_denoms,json=factoryDenoms,proto3" json:"factory_denoms" yaml:"factory_denoms"`
-}
-
-func (m *GenesisState) Reset() { *m = GenesisState{} }
-func (m *GenesisState) String() string { return proto.CompactTextString(m) }
-func (*GenesisState) ProtoMessage() {}
-func (*GenesisState) Descriptor() ([]byte, []int) {
- return fileDescriptor_452ec984f7eef90f, []int{3}
-}
-func (m *GenesisState) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *GenesisState) XXX_Merge(src proto.Message) {
- xxx_messageInfo_GenesisState.Merge(m, src)
-}
-func (m *GenesisState) XXX_Size() int {
- return m.Size()
-}
-func (m *GenesisState) XXX_DiscardUnknown() {
- xxx_messageInfo_GenesisState.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_GenesisState proto.InternalMessageInfo
-
-func (m *GenesisState) GetParams() ModuleParams {
- if m != nil {
- return m.Params
- }
- return ModuleParams{}
-}
-
-func (m *GenesisState) GetFactoryDenoms() []GenesisDenom {
- if m != nil {
- return m.FactoryDenoms
- }
- return nil
-}
-
-// GenesisDenom defines a tokenfactory denoms in the genesis state.
-type GenesisDenom struct {
- Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"`
- AuthorityMetadata DenomAuthorityMetadata `protobuf:"bytes,2,opt,name=authority_metadata,json=authorityMetadata,proto3" json:"authority_metadata" yaml:"authority_metadata"`
-}
-
-func (m *GenesisDenom) Reset() { *m = GenesisDenom{} }
-func (m *GenesisDenom) String() string { return proto.CompactTextString(m) }
-func (*GenesisDenom) ProtoMessage() {}
-func (*GenesisDenom) Descriptor() ([]byte, []int) {
- return fileDescriptor_452ec984f7eef90f, []int{4}
-}
-func (m *GenesisDenom) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *GenesisDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_GenesisDenom.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *GenesisDenom) XXX_Merge(src proto.Message) {
- xxx_messageInfo_GenesisDenom.Merge(m, src)
-}
-func (m *GenesisDenom) XXX_Size() int {
- return m.Size()
-}
-func (m *GenesisDenom) XXX_DiscardUnknown() {
- xxx_messageInfo_GenesisDenom.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_GenesisDenom proto.InternalMessageInfo
-
-func (m *GenesisDenom) GetDenom() string {
- if m != nil {
- return m.Denom
- }
- return ""
-}
-
-func (m *GenesisDenom) GetAuthorityMetadata() DenomAuthorityMetadata {
- if m != nil {
- return m.AuthorityMetadata
- }
- return DenomAuthorityMetadata{}
-}
-
-func init() {
- proto.RegisterType((*DenomAuthorityMetadata)(nil), "nibiru.tokenfactory.v1.DenomAuthorityMetadata")
- proto.RegisterType((*ModuleParams)(nil), "nibiru.tokenfactory.v1.ModuleParams")
- proto.RegisterType((*TFDenom)(nil), "nibiru.tokenfactory.v1.TFDenom")
- proto.RegisterType((*GenesisState)(nil), "nibiru.tokenfactory.v1.GenesisState")
- proto.RegisterType((*GenesisDenom)(nil), "nibiru.tokenfactory.v1.GenesisDenom")
-}
-
-func init() {
- proto.RegisterFile("nibiru/tokenfactory/v1/state.proto", fileDescriptor_452ec984f7eef90f)
-}
-
-var fileDescriptor_452ec984f7eef90f = []byte{
- // 490 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0x3f, 0x6f, 0xd3, 0x40,
- 0x14, 0xb7, 0x4b, 0xda, 0xc2, 0x35, 0x20, 0x38, 0x41, 0x49, 0x23, 0x61, 0xa7, 0x27, 0xa8, 0x98,
- 0x7c, 0x4a, 0xd8, 0xb2, 0xe1, 0x94, 0x76, 0xa1, 0x08, 0x19, 0x26, 0x16, 0xeb, 0xd9, 0x39, 0x92,
- 0x83, 0xfa, 0x2e, 0xf2, 0x9d, 0x23, 0xb2, 0xf5, 0x23, 0xf0, 0x11, 0xf8, 0x24, 0xb0, 0x76, 0xec,
- 0xc8, 0x80, 0x22, 0x94, 0x2c, 0xcc, 0xf9, 0x04, 0x28, 0x77, 0x57, 0x68, 0x69, 0xc3, 0xe6, 0xf7,
- 0x7e, 0xbf, 0xf7, 0xf3, 0xef, 0xfd, 0x39, 0x44, 0x04, 0xcf, 0x78, 0x59, 0x51, 0x2d, 0x3f, 0x32,
- 0xf1, 0x1e, 0x72, 0x2d, 0xcb, 0x09, 0x1d, 0xb7, 0xa9, 0xd2, 0xa0, 0x59, 0x34, 0x2a, 0xa5, 0x96,
- 0x78, 0xdb, 0x72, 0xa2, 0x8b, 0x9c, 0x68, 0xdc, 0x6e, 0xde, 0x1f, 0xc8, 0x81, 0x34, 0x14, 0xba,
- 0xfc, 0xb2, 0xec, 0xe6, 0x4e, 0x2e, 0x55, 0x21, 0x55, 0x6a, 0x01, 0x1b, 0x38, 0x28, 0xb0, 0x11,
- 0xcd, 0x40, 0x31, 0x3a, 0x6e, 0x67, 0x4c, 0x43, 0x9b, 0xe6, 0x92, 0x0b, 0x8b, 0x93, 0x03, 0xb4,
- 0xbd, 0xcf, 0x84, 0x2c, 0x9e, 0x57, 0x7a, 0x28, 0x4b, 0xae, 0x27, 0x47, 0x4c, 0x43, 0x1f, 0x34,
- 0xe0, 0x3d, 0xb4, 0x0e, 0xfd, 0x82, 0x8b, 0x86, 0xdf, 0xf2, 0x9f, 0xde, 0x8a, 0xef, 0x2e, 0xa6,
- 0x61, 0x7d, 0x02, 0xc5, 0x71, 0x97, 0x98, 0x34, 0x49, 0x2c, 0xdc, 0xad, 0xfd, 0xfa, 0x12, 0xfa,
- 0xa4, 0x44, 0xf5, 0x23, 0xd9, 0xaf, 0x8e, 0xd9, 0x6b, 0x28, 0xa1, 0x50, 0x38, 0x43, 0xcd, 0xfe,
- 0x52, 0x37, 0xcd, 0x4b, 0x06, 0x9a, 0x4b, 0x91, 0x0e, 0x40, 0xa5, 0xb9, 0x14, 0xaa, 0x2a, 0x98,
- 0x91, 0xac, 0xc5, 0x4f, 0x16, 0xd3, 0x70, 0xd7, 0x4a, 0xae, 0xe6, 0x92, 0xe4, 0xa1, 0x01, 0x7b,
- 0x0e, 0x3b, 0x04, 0xd5, 0x73, 0xc8, 0x0b, 0xb4, 0xf9, 0xf6, 0xc0, 0xb8, 0xc7, 0x0d, 0xb4, 0x69,
- 0x8a, 0x65, 0x69, 0xed, 0x26, 0xe7, 0x21, 0x6e, 0xa2, 0x9b, 0xaa, 0xca, 0x8c, 0x44, 0x63, 0xcd,
- 0x40, 0x7f, 0xe2, 0x6e, 0xed, 0xe4, 0x47, 0xcb, 0x23, 0x5f, 0x7d, 0x54, 0x3f, 0x64, 0x82, 0x29,
- 0xae, 0xde, 0x2c, 0x57, 0x80, 0x63, 0xb4, 0x31, 0x32, 0x5d, 0x18, 0xad, 0xad, 0xce, 0xe3, 0xe8,
- 0xfa, 0x6d, 0x44, 0x17, 0x3b, 0x8e, 0x6b, 0xa7, 0xd3, 0xd0, 0x4b, 0x5c, 0x25, 0xfe, 0x80, 0xee,
- 0x38, 0x62, 0x6a, 0xfe, 0xa5, 0x1a, 0x6b, 0xad, 0x1b, 0xff, 0xd3, 0x72, 0x0e, 0x4c, 0x3b, 0xf1,
- 0xa3, 0xa5, 0xd6, 0x62, 0x1a, 0x3e, 0xb0, 0xd3, 0xb9, 0xac, 0x44, 0x92, 0xdb, 0x2e, 0xb1, 0x6f,
- 0xe3, 0x6f, 0x7f, 0x1b, 0xb0, 0xd3, 0xd8, 0x43, 0xeb, 0xb6, 0xe1, 0x2b, 0xab, 0x33, 0x69, 0x92,
- 0x58, 0x18, 0x9f, 0xf8, 0x08, 0xc3, 0xf9, 0xe2, 0xd3, 0xc2, 0x6d, 0xde, 0x8c, 0x69, 0xab, 0x13,
- 0xad, 0x72, 0x7a, 0xfd, 0xbd, 0xc4, 0xbb, 0xce, 0xf3, 0x8e, 0x3b, 0x92, 0x2b, 0xba, 0x24, 0xb9,
- 0x07, 0xff, 0x56, 0xd9, 0xeb, 0x89, 0x5f, 0x9e, 0xce, 0x02, 0xff, 0x6c, 0x16, 0xf8, 0x3f, 0x67,
- 0x81, 0xff, 0x79, 0x1e, 0x78, 0x67, 0xf3, 0xc0, 0xfb, 0x3e, 0x0f, 0xbc, 0x77, 0x9d, 0x01, 0xd7,
- 0xc3, 0x2a, 0x8b, 0x72, 0x59, 0xd0, 0x57, 0xc6, 0x4f, 0x6f, 0x08, 0x5c, 0x50, 0xf7, 0x86, 0x3e,
- 0x5d, 0x7e, 0x45, 0x7a, 0x32, 0x62, 0x2a, 0xdb, 0x30, 0xa7, 0xfd, 0xec, 0x77, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x37, 0x74, 0x40, 0xb6, 0x69, 0x03, 0x00, 0x00,
-}
-
-func (this *DenomAuthorityMetadata) Equal(that interface{}) bool {
- if that == nil {
- return this == nil
- }
-
- that1, ok := that.(*DenomAuthorityMetadata)
- if !ok {
- that2, ok := that.(DenomAuthorityMetadata)
- if ok {
- that1 = &that2
- } else {
- return false
- }
- }
- if that1 == nil {
- return this == nil
- } else if this == nil {
- return false
- }
- if this.Admin != that1.Admin {
- return false
- }
- return true
-}
-func (this *GenesisDenom) Equal(that interface{}) bool {
- if that == nil {
- return this == nil
- }
-
- that1, ok := that.(*GenesisDenom)
- if !ok {
- that2, ok := that.(GenesisDenom)
- if ok {
- that1 = &that2
- } else {
- return false
- }
- }
- if that1 == nil {
- return this == nil
- } else if this == nil {
- return false
- }
- if this.Denom != that1.Denom {
- return false
- }
- if !this.AuthorityMetadata.Equal(&that1.AuthorityMetadata) {
- return false
- }
- return true
-}
-func (m *DenomAuthorityMetadata) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *DenomAuthorityMetadata) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *DenomAuthorityMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Admin) > 0 {
- i -= len(m.Admin)
- copy(dAtA[i:], m.Admin)
- i = encodeVarintState(dAtA, i, uint64(len(m.Admin)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *ModuleParams) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ModuleParams) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *ModuleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.DenomCreationGasConsume != 0 {
- i = encodeVarintState(dAtA, i, uint64(m.DenomCreationGasConsume))
- i--
- dAtA[i] = 0x8
- }
- return len(dAtA) - i, nil
-}
-
-func (m *TFDenom) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *TFDenom) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *TFDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Subdenom) > 0 {
- i -= len(m.Subdenom)
- copy(dAtA[i:], m.Subdenom)
- i = encodeVarintState(dAtA, i, uint64(len(m.Subdenom)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Creator) > 0 {
- i -= len(m.Creator)
- copy(dAtA[i:], m.Creator)
- i = encodeVarintState(dAtA, i, uint64(len(m.Creator)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *GenesisState) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.FactoryDenoms) > 0 {
- for iNdEx := len(m.FactoryDenoms) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.FactoryDenoms[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintState(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- }
- }
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintState(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- return len(dAtA) - i, nil
-}
-
-func (m *GenesisDenom) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *GenesisDenom) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *GenesisDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.AuthorityMetadata.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintState(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Denom) > 0 {
- i -= len(m.Denom)
- copy(dAtA[i:], m.Denom)
- i = encodeVarintState(dAtA, i, uint64(len(m.Denom)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func encodeVarintState(dAtA []byte, offset int, v uint64) int {
- offset -= sovState(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *DenomAuthorityMetadata) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Admin)
- if l > 0 {
- n += 1 + l + sovState(uint64(l))
- }
- return n
-}
-
-func (m *ModuleParams) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.DenomCreationGasConsume != 0 {
- n += 1 + sovState(uint64(m.DenomCreationGasConsume))
- }
- return n
-}
-
-func (m *TFDenom) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Creator)
- if l > 0 {
- n += 1 + l + sovState(uint64(l))
- }
- l = len(m.Subdenom)
- if l > 0 {
- n += 1 + l + sovState(uint64(l))
- }
- return n
-}
-
-func (m *GenesisState) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = m.Params.Size()
- n += 1 + l + sovState(uint64(l))
- if len(m.FactoryDenoms) > 0 {
- for _, e := range m.FactoryDenoms {
- l = e.Size()
- n += 1 + l + sovState(uint64(l))
- }
- }
- return n
-}
-
-func (m *GenesisDenom) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Denom)
- if l > 0 {
- n += 1 + l + sovState(uint64(l))
- }
- l = m.AuthorityMetadata.Size()
- n += 1 + l + sovState(uint64(l))
- return n
-}
-
-func sovState(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozState(x uint64) (n int) {
- return sovState(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *DenomAuthorityMetadata) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: DenomAuthorityMetadata: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: DenomAuthorityMetadata: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Admin = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipState(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthState
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *ModuleParams) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ModuleParams: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ModuleParams: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field DenomCreationGasConsume", wireType)
- }
- m.DenomCreationGasConsume = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.DenomCreationGasConsume |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipState(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthState
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *TFDenom) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: TFDenom: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: TFDenom: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Creator = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Subdenom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Subdenom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipState(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthState
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *GenesisState) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field FactoryDenoms", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.FactoryDenoms = append(m.FactoryDenoms, GenesisDenom{})
- if err := m.FactoryDenoms[len(m.FactoryDenoms)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipState(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthState
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *GenesisDenom) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: GenesisDenom: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: GenesisDenom: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Denom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthorityMetadata", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowState
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthState
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthState
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.AuthorityMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipState(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthState
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipState(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowState
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthState
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupState
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthState
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthState = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowState = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupState = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/tokenfactory/types/state_test.go b/x/tokenfactory/types/state_test.go
deleted file mode 100644
index 614bc3794..000000000
--- a/x/tokenfactory/types/state_test.go
+++ /dev/null
@@ -1,147 +0,0 @@
-package types_test
-
-import (
- fmt "fmt"
- "testing"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-func TestDenomStr_Validate(t *testing.T) {
- testCases := []struct {
- denom types.DenomStr
- wantErr string
- }{
- {"tf/creator123/subdenom", ""},
- {"tf//subdenom", "empty creator"},
- {"tf/creator123/", "empty subdenom"},
- {"creator123/subdenom", "invalid number of sections"},
- {"tf/creator123/subdenom/extra", "invalid number of sections"},
- {"/creator123/subdenom", "missing denom prefix"},
- }
-
- for _, tc := range testCases {
- t.Run(string(tc.denom), func(t *testing.T) {
- tfDenom, err := tc.denom.ToStruct()
-
- if tc.wantErr != "" {
- require.Error(t, err)
- require.Contains(t, err.Error(), tc.wantErr)
- return
- }
- require.NoError(t, err)
- assert.Equal(t, tfDenom.Denom(), tc.denom)
- assert.Equal(t, tfDenom.Denom().String(), string(tc.denom))
-
- assert.NoError(t, tfDenom.Validate())
- assert.NotPanics(t, func() {
- _ = tfDenom.DefaultBankMetadata()
- _ = tc.denom.MustToStruct()
- })
-
- assert.NoError(t, types.GenesisDenom{
- Denom: tc.denom.String(),
- AuthorityMetadata: types.DenomAuthorityMetadata{},
- }.Validate())
- })
- }
-}
-
-func TestModuleParamsValidate(t *testing.T) {
- params := types.DefaultModuleParams()
- require.NoError(t, params.Validate())
-
- params.DenomCreationGasConsume = 0
- require.Error(t, params.Validate())
-}
-
-func TestGenesisState(t *testing.T) {
- var happyGenDenoms []types.GenesisDenom
- for i := 0; i < 5; i++ {
- creator := testutil.AccAddress()
- lettersIdx := i * 2
- happyGenDenoms = append(happyGenDenoms, types.GenesisDenom{
- Denom: types.TFDenom{
- Creator: creator.String(),
- Subdenom: testutil.Latin.Letters[lettersIdx : lettersIdx+4],
- }.Denom().String(),
- AuthorityMetadata: types.DenomAuthorityMetadata{
- Admin: creator.String(),
- },
- })
- }
-
- for idx, tc := range []struct {
- name string
- genState types.GenesisState
- wantErr string
- }{
- {name: "default", wantErr: "", genState: *types.DefaultGenesis()},
- {
- name: "sad: params", wantErr: types.ErrInvalidModuleParams.Error(),
- genState: types.GenesisState{
- Params: types.ModuleParams{
- DenomCreationGasConsume: 0,
- },
- FactoryDenoms: happyGenDenoms,
- },
- },
- {
- name: "sad: duplicate",
- wantErr: "duplicate denom",
- genState: types.GenesisState{
- Params: types.DefaultModuleParams(),
- FactoryDenoms: []types.GenesisDenom{
- happyGenDenoms[0], happyGenDenoms[0], happyGenDenoms[1],
- },
- },
- },
- {
- name: "sad: invalid admin",
- wantErr: types.ErrInvalidAdmin.Error(),
- genState: types.GenesisState{
- Params: types.DefaultModuleParams(),
- FactoryDenoms: []types.GenesisDenom{
- happyGenDenoms[0],
- {
- Denom: happyGenDenoms[1].Denom,
- AuthorityMetadata: types.DenomAuthorityMetadata{
- Admin: "not_an_address",
- },
- },
- },
- },
- },
-
- {
- name: "sad: invalid genesis denom",
- wantErr: types.ErrInvalidGenesis.Error(),
- genState: types.GenesisState{
- Params: types.DefaultModuleParams(),
- FactoryDenoms: []types.GenesisDenom{
- happyGenDenoms[0],
- {
- Denom: "sad denom",
- AuthorityMetadata: types.DenomAuthorityMetadata{
- Admin: happyGenDenoms[1].AuthorityMetadata.Admin,
- },
- },
- },
- },
- },
- } {
- t.Run(fmt.Sprintf("%v %s", idx, tc.name), func(t *testing.T) {
- err := tc.genState.Validate()
- if tc.wantErr != "" {
- assert.Error(t, err)
- require.Contains(t, err.Error(), tc.wantErr)
- return
- }
- require.NoError(t, err)
- })
- }
-}
diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go
deleted file mode 100644
index 25a92dacf..000000000
--- a/x/tokenfactory/types/tx.pb.go
+++ /dev/null
@@ -1,3177 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: nibiru/tokenfactory/v1/tx.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- _ "github.com/cosmos/cosmos-proto"
- types "github.com/cosmos/cosmos-sdk/types"
- _ "github.com/cosmos/cosmos-sdk/types/msgservice"
- types1 "github.com/cosmos/cosmos-sdk/x/bank/types"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/proto"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- io "io"
- math "math"
- math_bits "math/bits"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
-
-// MsgCreateDenom: sdk.Msg that registers an a token factory denom.
-// A denom has the form "tf/[creatorAddr]/[subdenom]".
-// - Denoms become unique x/bank tokens, so the creator-subdenom pair that
-// defines a denom cannot be reused.
-// - The resulting denom's admin is originally set to be the creator, but the
-// admin can be changed later.
-type MsgCreateDenom struct {
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"`
- // subdenom can be up to 44 "alphanumeric" characters long.
- Subdenom string `protobuf:"bytes,2,opt,name=subdenom,proto3" json:"subdenom,omitempty" yaml:"subdenom"`
-}
-
-func (m *MsgCreateDenom) Reset() { *m = MsgCreateDenom{} }
-func (m *MsgCreateDenom) String() string { return proto.CompactTextString(m) }
-func (*MsgCreateDenom) ProtoMessage() {}
-func (*MsgCreateDenom) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{0}
-}
-func (m *MsgCreateDenom) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgCreateDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgCreateDenom.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgCreateDenom) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgCreateDenom.Merge(m, src)
-}
-func (m *MsgCreateDenom) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgCreateDenom) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgCreateDenom.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgCreateDenom proto.InternalMessageInfo
-
-func (m *MsgCreateDenom) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-func (m *MsgCreateDenom) GetSubdenom() string {
- if m != nil {
- return m.Subdenom
- }
- return ""
-}
-
-// MsgCreateDenomResponse is the return value of MsgCreateDenom
-type MsgCreateDenomResponse struct {
- // NewTokenDenom: identifier for the newly created token factory denom.
- NewTokenDenom string `protobuf:"bytes,1,opt,name=new_token_denom,json=newTokenDenom,proto3" json:"new_token_denom,omitempty" yaml:"new_token_denom"`
-}
-
-func (m *MsgCreateDenomResponse) Reset() { *m = MsgCreateDenomResponse{} }
-func (m *MsgCreateDenomResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgCreateDenomResponse) ProtoMessage() {}
-func (*MsgCreateDenomResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{1}
-}
-func (m *MsgCreateDenomResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgCreateDenomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgCreateDenomResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgCreateDenomResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgCreateDenomResponse.Merge(m, src)
-}
-func (m *MsgCreateDenomResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgCreateDenomResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgCreateDenomResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgCreateDenomResponse proto.InternalMessageInfo
-
-func (m *MsgCreateDenomResponse) GetNewTokenDenom() string {
- if m != nil {
- return m.NewTokenDenom
- }
- return ""
-}
-
-// MsgChangeAdmin is the sdk.Msg type for allowing an admin account to change
-// admin of a denom to a new account
-type MsgChangeAdmin struct {
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"`
- Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"`
- NewAdmin string `protobuf:"bytes,3,opt,name=new_admin,json=newAdmin,proto3" json:"new_admin,omitempty" yaml:"new_admin"`
-}
-
-func (m *MsgChangeAdmin) Reset() { *m = MsgChangeAdmin{} }
-func (m *MsgChangeAdmin) String() string { return proto.CompactTextString(m) }
-func (*MsgChangeAdmin) ProtoMessage() {}
-func (*MsgChangeAdmin) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{2}
-}
-func (m *MsgChangeAdmin) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgChangeAdmin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgChangeAdmin.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgChangeAdmin) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgChangeAdmin.Merge(m, src)
-}
-func (m *MsgChangeAdmin) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgChangeAdmin) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgChangeAdmin.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgChangeAdmin proto.InternalMessageInfo
-
-func (m *MsgChangeAdmin) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-func (m *MsgChangeAdmin) GetDenom() string {
- if m != nil {
- return m.Denom
- }
- return ""
-}
-
-func (m *MsgChangeAdmin) GetNewAdmin() string {
- if m != nil {
- return m.NewAdmin
- }
- return ""
-}
-
-// MsgChangeAdminResponse is the gRPC response for the MsgChangeAdmin TxMsg.
-type MsgChangeAdminResponse struct {
-}
-
-func (m *MsgChangeAdminResponse) Reset() { *m = MsgChangeAdminResponse{} }
-func (m *MsgChangeAdminResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgChangeAdminResponse) ProtoMessage() {}
-func (*MsgChangeAdminResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{3}
-}
-func (m *MsgChangeAdminResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgChangeAdminResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgChangeAdminResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgChangeAdminResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgChangeAdminResponse.Merge(m, src)
-}
-func (m *MsgChangeAdminResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgChangeAdminResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgChangeAdminResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgChangeAdminResponse proto.InternalMessageInfo
-
-// MsgUpdateModuleParams: sdk.Msg for updating the x/tokenfactory module params
-type MsgUpdateModuleParams struct {
- // Authority: Address of the governance module account.
- Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"`
- Params ModuleParams `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
-}
-
-func (m *MsgUpdateModuleParams) Reset() { *m = MsgUpdateModuleParams{} }
-func (m *MsgUpdateModuleParams) String() string { return proto.CompactTextString(m) }
-func (*MsgUpdateModuleParams) ProtoMessage() {}
-func (*MsgUpdateModuleParams) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{4}
-}
-func (m *MsgUpdateModuleParams) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgUpdateModuleParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgUpdateModuleParams.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgUpdateModuleParams) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgUpdateModuleParams.Merge(m, src)
-}
-func (m *MsgUpdateModuleParams) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgUpdateModuleParams) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgUpdateModuleParams.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgUpdateModuleParams proto.InternalMessageInfo
-
-func (m *MsgUpdateModuleParams) GetAuthority() string {
- if m != nil {
- return m.Authority
- }
- return ""
-}
-
-func (m *MsgUpdateModuleParams) GetParams() ModuleParams {
- if m != nil {
- return m.Params
- }
- return ModuleParams{}
-}
-
-// MsgUpdateModuleParamsResponse is the gRPC response for the
-// MsgUpdateModuleParams TxMsg.
-type MsgUpdateModuleParamsResponse struct {
-}
-
-func (m *MsgUpdateModuleParamsResponse) Reset() { *m = MsgUpdateModuleParamsResponse{} }
-func (m *MsgUpdateModuleParamsResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgUpdateModuleParamsResponse) ProtoMessage() {}
-func (*MsgUpdateModuleParamsResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{5}
-}
-func (m *MsgUpdateModuleParamsResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgUpdateModuleParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgUpdateModuleParamsResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgUpdateModuleParamsResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgUpdateModuleParamsResponse.Merge(m, src)
-}
-func (m *MsgUpdateModuleParamsResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgUpdateModuleParamsResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgUpdateModuleParamsResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgUpdateModuleParamsResponse proto.InternalMessageInfo
-
-// MsgMint: sdk.Msg (TxMsg) where an denom admin mints more of the token.
-type MsgMint struct {
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"`
- // coin: The denom identifier and amount to mint.
- Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin" yaml:"coin"`
- // mint_to_addr: An address to which tokens will be minted. If blank,
- // tokens are minted to the "sender".
- MintTo string `protobuf:"bytes,3,opt,name=mint_to,json=mintTo,proto3" json:"mint_to,omitempty" yaml:"mint_to"`
-}
-
-func (m *MsgMint) Reset() { *m = MsgMint{} }
-func (m *MsgMint) String() string { return proto.CompactTextString(m) }
-func (*MsgMint) ProtoMessage() {}
-func (*MsgMint) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{6}
-}
-func (m *MsgMint) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgMint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgMint.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgMint) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgMint.Merge(m, src)
-}
-func (m *MsgMint) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgMint) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgMint.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgMint proto.InternalMessageInfo
-
-func (m *MsgMint) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-func (m *MsgMint) GetCoin() types.Coin {
- if m != nil {
- return m.Coin
- }
- return types.Coin{}
-}
-
-func (m *MsgMint) GetMintTo() string {
- if m != nil {
- return m.MintTo
- }
- return ""
-}
-
-type MsgMintResponse struct {
- MintTo string `protobuf:"bytes,1,opt,name=mint_to,json=mintTo,proto3" json:"mint_to,omitempty"`
-}
-
-func (m *MsgMintResponse) Reset() { *m = MsgMintResponse{} }
-func (m *MsgMintResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgMintResponse) ProtoMessage() {}
-func (*MsgMintResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{7}
-}
-func (m *MsgMintResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgMintResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgMintResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgMintResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgMintResponse.Merge(m, src)
-}
-func (m *MsgMintResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgMintResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgMintResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgMintResponse proto.InternalMessageInfo
-
-func (m *MsgMintResponse) GetMintTo() string {
- if m != nil {
- return m.MintTo
- }
- return ""
-}
-
-// MsgBurn: sdk.Msg (TxMsg) where a denom admin burns some of the token.
-// The reason that the sender isn't automatically the "burn_from" address
-// is to support smart contracts (primary use case). In this situation, the
-// contract is the message signer and sender, while "burn_from" is based on the
-// contract logic.
-type MsgBurn struct {
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"`
- // coin: The denom identifier and amount to burn.
- Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin" yaml:"coin"`
- // burn_from: The address from which tokens will be burned.
- BurnFrom string `protobuf:"bytes,3,opt,name=burn_from,json=burnFrom,proto3" json:"burn_from,omitempty" yaml:"burn_from"`
-}
-
-func (m *MsgBurn) Reset() { *m = MsgBurn{} }
-func (m *MsgBurn) String() string { return proto.CompactTextString(m) }
-func (*MsgBurn) ProtoMessage() {}
-func (*MsgBurn) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{8}
-}
-func (m *MsgBurn) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgBurn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgBurn.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgBurn) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgBurn.Merge(m, src)
-}
-func (m *MsgBurn) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgBurn) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgBurn.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgBurn proto.InternalMessageInfo
-
-func (m *MsgBurn) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-func (m *MsgBurn) GetCoin() types.Coin {
- if m != nil {
- return m.Coin
- }
- return types.Coin{}
-}
-
-func (m *MsgBurn) GetBurnFrom() string {
- if m != nil {
- return m.BurnFrom
- }
- return ""
-}
-
-type MsgBurnResponse struct {
-}
-
-func (m *MsgBurnResponse) Reset() { *m = MsgBurnResponse{} }
-func (m *MsgBurnResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgBurnResponse) ProtoMessage() {}
-func (*MsgBurnResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{9}
-}
-func (m *MsgBurnResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgBurnResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgBurnResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgBurnResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgBurnResponse.Merge(m, src)
-}
-func (m *MsgBurnResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgBurnResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgBurnResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgBurnResponse proto.InternalMessageInfo
-
-// MsgSetDenomMetadata: sdk.Msg (TxMsg) enabling the denom admin to change its
-// bank metadata.
-type MsgSetDenomMetadata struct {
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"`
- // Metadata: Official x/bank metadata for the denom. All token factory denoms
- // are standard, native assets. The "metadata.base" is the denom.
- Metadata types1.Metadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata"`
-}
-
-func (m *MsgSetDenomMetadata) Reset() { *m = MsgSetDenomMetadata{} }
-func (m *MsgSetDenomMetadata) String() string { return proto.CompactTextString(m) }
-func (*MsgSetDenomMetadata) ProtoMessage() {}
-func (*MsgSetDenomMetadata) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{10}
-}
-func (m *MsgSetDenomMetadata) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgSetDenomMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgSetDenomMetadata.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgSetDenomMetadata) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgSetDenomMetadata.Merge(m, src)
-}
-func (m *MsgSetDenomMetadata) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgSetDenomMetadata) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgSetDenomMetadata.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgSetDenomMetadata proto.InternalMessageInfo
-
-func (m *MsgSetDenomMetadata) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-func (m *MsgSetDenomMetadata) GetMetadata() types1.Metadata {
- if m != nil {
- return m.Metadata
- }
- return types1.Metadata{}
-}
-
-type MsgSetDenomMetadataResponse struct {
-}
-
-func (m *MsgSetDenomMetadataResponse) Reset() { *m = MsgSetDenomMetadataResponse{} }
-func (m *MsgSetDenomMetadataResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgSetDenomMetadataResponse) ProtoMessage() {}
-func (*MsgSetDenomMetadataResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{11}
-}
-func (m *MsgSetDenomMetadataResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgSetDenomMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgSetDenomMetadataResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgSetDenomMetadataResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgSetDenomMetadataResponse.Merge(m, src)
-}
-func (m *MsgSetDenomMetadataResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgSetDenomMetadataResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgSetDenomMetadataResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgSetDenomMetadataResponse proto.InternalMessageInfo
-
-// Burn a native token such as unibi
-type MsgBurnNative struct {
- Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"`
- Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin" yaml:"coin"`
-}
-
-func (m *MsgBurnNative) Reset() { *m = MsgBurnNative{} }
-func (m *MsgBurnNative) String() string { return proto.CompactTextString(m) }
-func (*MsgBurnNative) ProtoMessage() {}
-func (*MsgBurnNative) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{12}
-}
-func (m *MsgBurnNative) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgBurnNative) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgBurnNative.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgBurnNative) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgBurnNative.Merge(m, src)
-}
-func (m *MsgBurnNative) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgBurnNative) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgBurnNative.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgBurnNative proto.InternalMessageInfo
-
-func (m *MsgBurnNative) GetSender() string {
- if m != nil {
- return m.Sender
- }
- return ""
-}
-
-func (m *MsgBurnNative) GetCoin() types.Coin {
- if m != nil {
- return m.Coin
- }
- return types.Coin{}
-}
-
-type MsgBurnNativeResponse struct {
-}
-
-func (m *MsgBurnNativeResponse) Reset() { *m = MsgBurnNativeResponse{} }
-func (m *MsgBurnNativeResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgBurnNativeResponse) ProtoMessage() {}
-func (*MsgBurnNativeResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_4c78bacd179e004d, []int{13}
-}
-func (m *MsgBurnNativeResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *MsgBurnNativeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_MsgBurnNativeResponse.Marshal(b, m, deterministic)
- } else {
- b = b[:cap(b)]
- n, err := m.MarshalToSizedBuffer(b)
- if err != nil {
- return nil, err
- }
- return b[:n], nil
- }
-}
-func (m *MsgBurnNativeResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgBurnNativeResponse.Merge(m, src)
-}
-func (m *MsgBurnNativeResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *MsgBurnNativeResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgBurnNativeResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_MsgBurnNativeResponse proto.InternalMessageInfo
-
-func init() {
- proto.RegisterType((*MsgCreateDenom)(nil), "nibiru.tokenfactory.v1.MsgCreateDenom")
- proto.RegisterType((*MsgCreateDenomResponse)(nil), "nibiru.tokenfactory.v1.MsgCreateDenomResponse")
- proto.RegisterType((*MsgChangeAdmin)(nil), "nibiru.tokenfactory.v1.MsgChangeAdmin")
- proto.RegisterType((*MsgChangeAdminResponse)(nil), "nibiru.tokenfactory.v1.MsgChangeAdminResponse")
- proto.RegisterType((*MsgUpdateModuleParams)(nil), "nibiru.tokenfactory.v1.MsgUpdateModuleParams")
- proto.RegisterType((*MsgUpdateModuleParamsResponse)(nil), "nibiru.tokenfactory.v1.MsgUpdateModuleParamsResponse")
- proto.RegisterType((*MsgMint)(nil), "nibiru.tokenfactory.v1.MsgMint")
- proto.RegisterType((*MsgMintResponse)(nil), "nibiru.tokenfactory.v1.MsgMintResponse")
- proto.RegisterType((*MsgBurn)(nil), "nibiru.tokenfactory.v1.MsgBurn")
- proto.RegisterType((*MsgBurnResponse)(nil), "nibiru.tokenfactory.v1.MsgBurnResponse")
- proto.RegisterType((*MsgSetDenomMetadata)(nil), "nibiru.tokenfactory.v1.MsgSetDenomMetadata")
- proto.RegisterType((*MsgSetDenomMetadataResponse)(nil), "nibiru.tokenfactory.v1.MsgSetDenomMetadataResponse")
- proto.RegisterType((*MsgBurnNative)(nil), "nibiru.tokenfactory.v1.MsgBurnNative")
- proto.RegisterType((*MsgBurnNativeResponse)(nil), "nibiru.tokenfactory.v1.MsgBurnNativeResponse")
-}
-
-func init() { proto.RegisterFile("nibiru/tokenfactory/v1/tx.proto", fileDescriptor_4c78bacd179e004d) }
-
-var fileDescriptor_4c78bacd179e004d = []byte{
- // 826 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0xe3, 0x44,
- 0x14, 0x8f, 0xd9, 0x6e, 0x36, 0x99, 0xd2, 0x3f, 0xeb, 0x96, 0x34, 0x6b, 0xd4, 0x18, 0x8d, 0x60,
- 0x81, 0x45, 0xb5, 0x95, 0xae, 0xe0, 0xb0, 0x17, 0xb4, 0x2e, 0xe2, 0x84, 0x57, 0x2b, 0x6f, 0xb9,
- 0x20, 0xa4, 0x68, 0x12, 0x4f, 0x1d, 0xab, 0xf5, 0x4c, 0xe4, 0x99, 0xa4, 0x0d, 0x07, 0x24, 0xf8,
- 0x04, 0x9c, 0xf8, 0x02, 0x9c, 0x10, 0x17, 0x0e, 0x7c, 0x88, 0xde, 0xa8, 0x38, 0x71, 0xb2, 0x50,
- 0x7b, 0xe0, 0x9e, 0x4f, 0xb0, 0x9a, 0x3f, 0xb5, 0xdd, 0x26, 0x4d, 0x9b, 0x4b, 0x6f, 0x63, 0xbf,
- 0xdf, 0xfb, 0xbd, 0xdf, 0xcf, 0x7e, 0xef, 0x69, 0x80, 0x4d, 0xe2, 0x6e, 0x9c, 0x0e, 0x5d, 0x4e,
- 0x0f, 0x31, 0x39, 0x40, 0x3d, 0x4e, 0xd3, 0xb1, 0x3b, 0x6a, 0xbb, 0xfc, 0xc4, 0x19, 0xa4, 0x94,
- 0x53, 0xb3, 0xa1, 0x00, 0x4e, 0x19, 0xe0, 0x8c, 0xda, 0xd6, 0x66, 0x44, 0x23, 0x2a, 0x21, 0xae,
- 0x38, 0x29, 0xb4, 0xd5, 0xea, 0x51, 0x96, 0x50, 0xe6, 0x76, 0x11, 0xc3, 0xee, 0xa8, 0xdd, 0xc5,
- 0x1c, 0xb5, 0xdd, 0x1e, 0x8d, 0x89, 0x8e, 0x6f, 0xe9, 0x78, 0xc2, 0x22, 0x51, 0x25, 0x61, 0x91,
- 0x0e, 0x3c, 0x51, 0x81, 0x8e, 0x62, 0x54, 0x0f, 0x53, 0x9c, 0xe4, 0x30, 0xe7, 0x14, 0x0f, 0x3a,
- 0x0e, 0x6f, 0xb0, 0xc0, 0x38, 0xe2, 0x58, 0x61, 0xe0, 0x11, 0x58, 0xf5, 0x59, 0xb4, 0x97, 0x62,
- 0xc4, 0xf1, 0x57, 0x98, 0xd0, 0xc4, 0xfc, 0x14, 0x54, 0x19, 0x26, 0x21, 0x4e, 0x9b, 0xc6, 0x07,
- 0xc6, 0x27, 0x75, 0xef, 0xf1, 0x24, 0xb3, 0x57, 0xc6, 0x28, 0x39, 0x7a, 0x01, 0xd5, 0x7b, 0x18,
- 0x68, 0x80, 0xe9, 0x82, 0x1a, 0x1b, 0x76, 0x43, 0x91, 0xd6, 0x7c, 0x47, 0x82, 0x37, 0x26, 0x99,
- 0xbd, 0xa6, 0xc1, 0x3a, 0x02, 0x83, 0x1c, 0x04, 0xbf, 0x07, 0x8d, 0xab, 0xd5, 0x02, 0xcc, 0x06,
- 0x94, 0x30, 0x6c, 0x7a, 0x60, 0x8d, 0xe0, 0xe3, 0x8e, 0x94, 0xda, 0x51, 0x8c, 0xaa, 0xbc, 0x35,
- 0xc9, 0xec, 0x86, 0x62, 0xbc, 0x06, 0x80, 0xc1, 0x0a, 0xc1, 0xc7, 0xfb, 0xe2, 0x85, 0xe4, 0x82,
- 0xbf, 0x1a, 0xca, 0x4c, 0x1f, 0x91, 0x08, 0xbf, 0x0c, 0x93, 0x98, 0x2c, 0x62, 0xe6, 0x29, 0x78,
- 0x58, 0x76, 0xb2, 0x3e, 0xc9, 0xec, 0x77, 0x15, 0x52, 0x57, 0x53, 0x61, 0xb3, 0x0d, 0xea, 0x42,
- 0x08, 0x12, 0xfc, 0xcd, 0x07, 0x12, 0xbb, 0x39, 0xc9, 0xec, 0xf5, 0x42, 0xa3, 0x0c, 0xc1, 0xa0,
- 0x46, 0xf0, 0xb1, 0x54, 0x01, 0x9b, 0xca, 0x76, 0xa1, 0xeb, 0xd2, 0x36, 0xfc, 0xcd, 0x00, 0xef,
- 0xf9, 0x2c, 0xfa, 0x76, 0x10, 0x22, 0x8e, 0x7d, 0x1a, 0x0e, 0x8f, 0xf0, 0x6b, 0x94, 0xa2, 0x84,
- 0x99, 0x5f, 0x80, 0x3a, 0x1a, 0xf2, 0x3e, 0x4d, 0x63, 0x3e, 0xd6, 0xe2, 0x9b, 0xff, 0xfc, 0xb5,
- 0xb3, 0xa9, 0x3b, 0xe0, 0x65, 0x18, 0xa6, 0x98, 0xb1, 0x37, 0x3c, 0x8d, 0x49, 0x14, 0x14, 0x50,
- 0xd3, 0x03, 0xd5, 0x81, 0x64, 0x90, 0x3e, 0x96, 0x77, 0x3f, 0x74, 0x66, 0xf7, 0xa9, 0x53, 0xae,
- 0xe6, 0x2d, 0x9d, 0x66, 0x76, 0x25, 0xd0, 0x99, 0x2f, 0x56, 0x7f, 0xfe, 0xff, 0xcf, 0x67, 0x05,
- 0x27, 0xb4, 0xc1, 0xf6, 0x4c, 0x91, 0xb9, 0x8d, 0xdf, 0x0d, 0xf0, 0xc8, 0x67, 0x91, 0x1f, 0x13,
- 0xbe, 0xc8, 0x27, 0xf7, 0xc0, 0x92, 0x18, 0x01, 0xad, 0xf4, 0x89, 0xa3, 0xbd, 0x89, 0x19, 0x71,
- 0x74, 0x3f, 0x3b, 0x7b, 0x34, 0x26, 0xde, 0x86, 0x90, 0x37, 0xc9, 0xec, 0x65, 0xc5, 0x23, 0x92,
- 0x60, 0x20, 0x73, 0x4d, 0x17, 0x3c, 0x4a, 0x62, 0xc2, 0x3b, 0x9c, 0xea, 0x9f, 0xd1, 0x38, 0xcd,
- 0x6c, 0x63, 0x92, 0xd9, 0xab, 0x0a, 0xab, 0x83, 0x30, 0xa8, 0x8a, 0xd3, 0x3e, 0x85, 0xcf, 0xc0,
- 0x9a, 0x96, 0x9a, 0x37, 0xdf, 0x56, 0xc1, 0x21, 0x35, 0xe7, 0xd8, 0x3f, 0x94, 0x2f, 0x6f, 0x98,
- 0x92, 0xfb, 0xf6, 0xd5, 0x06, 0xf5, 0xee, 0x30, 0x25, 0x9d, 0x83, 0x94, 0x26, 0xd3, 0x6d, 0x96,
- 0x87, 0x60, 0x50, 0x13, 0xe7, 0xaf, 0xc5, 0xf1, 0xb1, 0x74, 0x26, 0xc4, 0xe6, 0x3f, 0xe6, 0x27,
- 0x03, 0x6c, 0xf8, 0x2c, 0x7a, 0x83, 0xb9, 0x1c, 0x11, 0x1f, 0x73, 0x14, 0x22, 0x8e, 0x16, 0x31,
- 0xf3, 0x25, 0xa8, 0x25, 0x3a, 0x4d, 0x1b, 0xda, 0x2e, 0x0c, 0x91, 0xc3, 0xdc, 0xd0, 0x25, 0xb7,
- 0xee, 0xa5, 0x3c, 0x09, 0x6e, 0x83, 0xf7, 0x67, 0x48, 0xc8, 0x25, 0xfe, 0x08, 0x56, 0xb4, 0xea,
- 0x57, 0x88, 0xc7, 0x23, 0x7c, 0xcf, 0x1f, 0x1a, 0x6e, 0xc9, 0x09, 0x2c, 0xea, 0x5f, 0x0a, 0xdb,
- 0xfd, 0xfb, 0x21, 0x78, 0xe0, 0xb3, 0xc8, 0xc4, 0x60, 0xb9, 0xbc, 0x1f, 0x9f, 0xde, 0x38, 0x50,
- 0x57, 0x36, 0x9b, 0xe5, 0xdc, 0x0d, 0x97, 0x37, 0xa1, 0x28, 0x53, 0xda, 0x5c, 0x73, 0xcb, 0x14,
- 0xb8, 0xf9, 0x65, 0xa6, 0x37, 0x8e, 0xf9, 0x03, 0x30, 0x67, 0x6c, 0x9b, 0x9d, 0x39, 0x2c, 0xd3,
- 0x70, 0xeb, 0xf3, 0x85, 0xe0, 0x79, 0xed, 0xd7, 0x60, 0x49, 0xae, 0x08, 0x7b, 0x4e, 0xba, 0x00,
- 0x58, 0x1f, 0xdf, 0x02, 0x28, 0x33, 0xca, 0xe1, 0x9c, 0xc7, 0x28, 0x00, 0x73, 0x19, 0xcb, 0x13,
- 0x63, 0x72, 0xb0, 0x3e, 0x35, 0x2d, 0x9f, 0xcd, 0x49, 0xbe, 0x0e, 0xb6, 0x9e, 0x2f, 0x00, 0xce,
- 0xab, 0x86, 0x00, 0x94, 0x26, 0xe0, 0xa3, 0x5b, 0xc4, 0x2a, 0x98, 0xb5, 0x73, 0x27, 0x58, 0x3e,
- 0x68, 0x15, 0xef, 0x9b, 0xd3, 0xf3, 0x96, 0x71, 0x76, 0xde, 0x32, 0xfe, 0x3b, 0x6f, 0x19, 0xbf,
- 0x5c, 0xb4, 0x2a, 0x67, 0x17, 0xad, 0xca, 0xbf, 0x17, 0xad, 0xca, 0x77, 0xbb, 0x51, 0xcc, 0xfb,
- 0xc3, 0xae, 0xd3, 0xa3, 0x89, 0xfb, 0x4a, 0x92, 0xee, 0xf5, 0x51, 0x4c, 0x5c, 0x7d, 0x83, 0x38,
- 0xb9, 0x7a, 0x87, 0xe0, 0xe3, 0x01, 0x66, 0xdd, 0xaa, 0xbc, 0x41, 0x3c, 0x7f, 0x1b, 0x00, 0x00,
- 0xff, 0xff, 0xb6, 0x28, 0x76, 0x66, 0x2a, 0x09, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// MsgClient is the client API for Msg service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type MsgClient interface {
- // CreateDenom: registers a token factory denom.
- CreateDenom(ctx context.Context, in *MsgCreateDenom, opts ...grpc.CallOption) (*MsgCreateDenomResponse, error)
- ChangeAdmin(ctx context.Context, in *MsgChangeAdmin, opts ...grpc.CallOption) (*MsgChangeAdminResponse, error)
- // UpdateModuleParams: A governance operation for updating the x/tokenfactory
- // module parameters.
- UpdateModuleParams(ctx context.Context, in *MsgUpdateModuleParams, opts ...grpc.CallOption) (*MsgUpdateModuleParamsResponse, error)
- Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error)
- Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error)
- SetDenomMetadata(ctx context.Context, in *MsgSetDenomMetadata, opts ...grpc.CallOption) (*MsgSetDenomMetadataResponse, error)
- // burns a native token such as unibi
- BurnNative(ctx context.Context, in *MsgBurnNative, opts ...grpc.CallOption) (*MsgBurnNativeResponse, error)
-}
-
-type msgClient struct {
- cc grpc1.ClientConn
-}
-
-func NewMsgClient(cc grpc1.ClientConn) MsgClient {
- return &msgClient{cc}
-}
-
-func (c *msgClient) CreateDenom(ctx context.Context, in *MsgCreateDenom, opts ...grpc.CallOption) (*MsgCreateDenomResponse, error) {
- out := new(MsgCreateDenomResponse)
- err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/CreateDenom", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) ChangeAdmin(ctx context.Context, in *MsgChangeAdmin, opts ...grpc.CallOption) (*MsgChangeAdminResponse, error) {
- out := new(MsgChangeAdminResponse)
- err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/ChangeAdmin", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) UpdateModuleParams(ctx context.Context, in *MsgUpdateModuleParams, opts ...grpc.CallOption) (*MsgUpdateModuleParamsResponse, error) {
- out := new(MsgUpdateModuleParamsResponse)
- err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/UpdateModuleParams", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) {
- out := new(MsgMintResponse)
- err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/Mint", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) {
- out := new(MsgBurnResponse)
- err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/Burn", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) SetDenomMetadata(ctx context.Context, in *MsgSetDenomMetadata, opts ...grpc.CallOption) (*MsgSetDenomMetadataResponse, error) {
- out := new(MsgSetDenomMetadataResponse)
- err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/SetDenomMetadata", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *msgClient) BurnNative(ctx context.Context, in *MsgBurnNative, opts ...grpc.CallOption) (*MsgBurnNativeResponse, error) {
- out := new(MsgBurnNativeResponse)
- err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/BurnNative", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// MsgServer is the server API for Msg service.
-type MsgServer interface {
- // CreateDenom: registers a token factory denom.
- CreateDenom(context.Context, *MsgCreateDenom) (*MsgCreateDenomResponse, error)
- ChangeAdmin(context.Context, *MsgChangeAdmin) (*MsgChangeAdminResponse, error)
- // UpdateModuleParams: A governance operation for updating the x/tokenfactory
- // module parameters.
- UpdateModuleParams(context.Context, *MsgUpdateModuleParams) (*MsgUpdateModuleParamsResponse, error)
- Mint(context.Context, *MsgMint) (*MsgMintResponse, error)
- Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error)
- SetDenomMetadata(context.Context, *MsgSetDenomMetadata) (*MsgSetDenomMetadataResponse, error)
- // burns a native token such as unibi
- BurnNative(context.Context, *MsgBurnNative) (*MsgBurnNativeResponse, error)
-}
-
-// UnimplementedMsgServer can be embedded to have forward compatible implementations.
-type UnimplementedMsgServer struct {
-}
-
-func (*UnimplementedMsgServer) CreateDenom(ctx context.Context, req *MsgCreateDenom) (*MsgCreateDenomResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method CreateDenom not implemented")
-}
-func (*UnimplementedMsgServer) ChangeAdmin(ctx context.Context, req *MsgChangeAdmin) (*MsgChangeAdminResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ChangeAdmin not implemented")
-}
-func (*UnimplementedMsgServer) UpdateModuleParams(ctx context.Context, req *MsgUpdateModuleParams) (*MsgUpdateModuleParamsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method UpdateModuleParams not implemented")
-}
-func (*UnimplementedMsgServer) Mint(ctx context.Context, req *MsgMint) (*MsgMintResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Mint not implemented")
-}
-func (*UnimplementedMsgServer) Burn(ctx context.Context, req *MsgBurn) (*MsgBurnResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method Burn not implemented")
-}
-func (*UnimplementedMsgServer) SetDenomMetadata(ctx context.Context, req *MsgSetDenomMetadata) (*MsgSetDenomMetadataResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method SetDenomMetadata not implemented")
-}
-func (*UnimplementedMsgServer) BurnNative(ctx context.Context, req *MsgBurnNative) (*MsgBurnNativeResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method BurnNative not implemented")
-}
-
-func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
- s.RegisterService(&_Msg_serviceDesc, srv)
-}
-
-func _Msg_CreateDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgCreateDenom)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).CreateDenom(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.tokenfactory.v1.Msg/CreateDenom",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).CreateDenom(ctx, req.(*MsgCreateDenom))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_ChangeAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgChangeAdmin)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).ChangeAdmin(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.tokenfactory.v1.Msg/ChangeAdmin",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).ChangeAdmin(ctx, req.(*MsgChangeAdmin))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_UpdateModuleParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgUpdateModuleParams)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).UpdateModuleParams(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.tokenfactory.v1.Msg/UpdateModuleParams",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).UpdateModuleParams(ctx, req.(*MsgUpdateModuleParams))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_Mint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgMint)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).Mint(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.tokenfactory.v1.Msg/Mint",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).Mint(ctx, req.(*MsgMint))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_Burn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgBurn)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).Burn(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.tokenfactory.v1.Msg/Burn",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).Burn(ctx, req.(*MsgBurn))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_SetDenomMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgSetDenomMetadata)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).SetDenomMetadata(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.tokenfactory.v1.Msg/SetDenomMetadata",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).SetDenomMetadata(ctx, req.(*MsgSetDenomMetadata))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Msg_BurnNative_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgBurnNative)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MsgServer).BurnNative(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/nibiru.tokenfactory.v1.Msg/BurnNative",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).BurnNative(ctx, req.(*MsgBurnNative))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Msg_serviceDesc = grpc.ServiceDesc{
- ServiceName: "nibiru.tokenfactory.v1.Msg",
- HandlerType: (*MsgServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "CreateDenom",
- Handler: _Msg_CreateDenom_Handler,
- },
- {
- MethodName: "ChangeAdmin",
- Handler: _Msg_ChangeAdmin_Handler,
- },
- {
- MethodName: "UpdateModuleParams",
- Handler: _Msg_UpdateModuleParams_Handler,
- },
- {
- MethodName: "Mint",
- Handler: _Msg_Mint_Handler,
- },
- {
- MethodName: "Burn",
- Handler: _Msg_Burn_Handler,
- },
- {
- MethodName: "SetDenomMetadata",
- Handler: _Msg_SetDenomMetadata_Handler,
- },
- {
- MethodName: "BurnNative",
- Handler: _Msg_BurnNative_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "nibiru/tokenfactory/v1/tx.proto",
-}
-
-func (m *MsgCreateDenom) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgCreateDenom) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgCreateDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Subdenom) > 0 {
- i -= len(m.Subdenom)
- copy(dAtA[i:], m.Subdenom)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Subdenom)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgCreateDenomResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgCreateDenomResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgCreateDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.NewTokenDenom) > 0 {
- i -= len(m.NewTokenDenom)
- copy(dAtA[i:], m.NewTokenDenom)
- i = encodeVarintTx(dAtA, i, uint64(len(m.NewTokenDenom)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgChangeAdmin) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgChangeAdmin) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgChangeAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.NewAdmin) > 0 {
- i -= len(m.NewAdmin)
- copy(dAtA[i:], m.NewAdmin)
- i = encodeVarintTx(dAtA, i, uint64(len(m.NewAdmin)))
- i--
- dAtA[i] = 0x1a
- }
- if len(m.Denom) > 0 {
- i -= len(m.Denom)
- copy(dAtA[i:], m.Denom)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Denom)))
- i--
- dAtA[i] = 0x12
- }
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgChangeAdminResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgChangeAdminResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgChangeAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgUpdateModuleParams) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgUpdateModuleParams) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgUpdateModuleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Authority) > 0 {
- i -= len(m.Authority)
- copy(dAtA[i:], m.Authority)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Authority)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgUpdateModuleParamsResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgUpdateModuleParamsResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgUpdateModuleParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgMint) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgMint) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgMint) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.MintTo) > 0 {
- i -= len(m.MintTo)
- copy(dAtA[i:], m.MintTo)
- i = encodeVarintTx(dAtA, i, uint64(len(m.MintTo)))
- i--
- dAtA[i] = 0x1a
- }
- {
- size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgMintResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgMintResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgMintResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.MintTo) > 0 {
- i -= len(m.MintTo)
- copy(dAtA[i:], m.MintTo)
- i = encodeVarintTx(dAtA, i, uint64(len(m.MintTo)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgBurn) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgBurn) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.BurnFrom) > 0 {
- i -= len(m.BurnFrom)
- copy(dAtA[i:], m.BurnFrom)
- i = encodeVarintTx(dAtA, i, uint64(len(m.BurnFrom)))
- i--
- dAtA[i] = 0x1a
- }
- {
- size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgBurnResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgBurnResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgBurnResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgSetDenomMetadata) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgSetDenomMetadata) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgSetDenomMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgSetDenomMetadataResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgSetDenomMetadataResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgSetDenomMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *MsgBurnNative) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgBurnNative) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgBurnNative) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- {
- size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x12
- if len(m.Sender) > 0 {
- i -= len(m.Sender)
- copy(dAtA[i:], m.Sender)
- i = encodeVarintTx(dAtA, i, uint64(len(m.Sender)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *MsgBurnNativeResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalToSizedBuffer(dAtA[:size])
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MsgBurnNativeResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *MsgBurnNativeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
- offset -= sovTx(v)
- base := offset
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return base
-}
-func (m *MsgCreateDenom) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.Subdenom)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgCreateDenomResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.NewTokenDenom)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgChangeAdmin) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.Denom)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = len(m.NewAdmin)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgChangeAdminResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgUpdateModuleParams) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Authority)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = m.Params.Size()
- n += 1 + l + sovTx(uint64(l))
- return n
-}
-
-func (m *MsgUpdateModuleParamsResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgMint) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = m.Coin.Size()
- n += 1 + l + sovTx(uint64(l))
- l = len(m.MintTo)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgMintResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.MintTo)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgBurn) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = m.Coin.Size()
- n += 1 + l + sovTx(uint64(l))
- l = len(m.BurnFrom)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- return n
-}
-
-func (m *MsgBurnResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgSetDenomMetadata) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = m.Metadata.Size()
- n += 1 + l + sovTx(uint64(l))
- return n
-}
-
-func (m *MsgSetDenomMetadataResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *MsgBurnNative) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Sender)
- if l > 0 {
- n += 1 + l + sovTx(uint64(l))
- }
- l = m.Coin.Size()
- n += 1 + l + sovTx(uint64(l))
- return n
-}
-
-func (m *MsgBurnNativeResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func sovTx(x uint64) (n int) {
- return (math_bits.Len64(x|1) + 6) / 7
-}
-func sozTx(x uint64) (n int) {
- return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *MsgCreateDenom) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgCreateDenom: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgCreateDenom: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Subdenom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Subdenom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgCreateDenomResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgCreateDenomResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgCreateDenomResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field NewTokenDenom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.NewTokenDenom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgChangeAdmin) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgChangeAdmin: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgChangeAdmin: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Denom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.NewAdmin = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgChangeAdminResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgChangeAdminResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgChangeAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgUpdateModuleParams) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgUpdateModuleParams: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgUpdateModuleParams: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Authority = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgUpdateModuleParamsResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgUpdateModuleParamsResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgUpdateModuleParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgMint) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgMint: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgMint: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field MintTo", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.MintTo = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgMintResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgMintResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgMintResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field MintTo", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.MintTo = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgBurn) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgBurn: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgBurn: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field BurnFrom", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.BurnFrom = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgBurnResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgBurnResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgBurnResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgSetDenomMetadata) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgSetDenomMetadata: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgSetDenomMetadata: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgSetDenomMetadataResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgSetDenomMetadataResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgSetDenomMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgBurnNative) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgBurnNative: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgBurnNative: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Sender = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthTx
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthTx
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MsgBurnNativeResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowTx
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MsgBurnNativeResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgBurnNativeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipTx(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthTx
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipTx(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- depth := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- case 1:
- iNdEx += 8
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowTx
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if length < 0 {
- return 0, ErrInvalidLengthTx
- }
- iNdEx += length
- case 3:
- depth++
- case 4:
- if depth == 0 {
- return 0, ErrUnexpectedEndOfGroupTx
- }
- depth--
- case 5:
- iNdEx += 4
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- if iNdEx < 0 {
- return 0, ErrInvalidLengthTx
- }
- if depth == 0 {
- return iNdEx, nil
- }
- }
- return 0, io.ErrUnexpectedEOF
-}
-
-var (
- ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowTx = fmt.Errorf("proto: integer overflow")
- ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
-)
diff --git a/x/tokenfactory/types/tx_msgs.go b/x/tokenfactory/types/tx_msgs.go
deleted file mode 100644
index 2cfa4099c..000000000
--- a/x/tokenfactory/types/tx_msgs.go
+++ /dev/null
@@ -1,298 +0,0 @@
-package types
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
- "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
-)
-
-// ----------------------------------------------------------------
-// MsgCreateDenom
-
-var (
- _ legacytx.LegacyMsg = &MsgCreateDenom{}
- _ legacytx.LegacyMsg = &MsgChangeAdmin{}
- _ legacytx.LegacyMsg = &MsgUpdateModuleParams{}
- _ legacytx.LegacyMsg = &MsgMint{}
- _ legacytx.LegacyMsg = &MsgBurn{}
- _ legacytx.LegacyMsg = &MsgSetDenomMetadata{}
- _ legacytx.LegacyMsg = &MsgBurnNative{}
-)
-
-// ValidateBasic performs stateless validation checks. Impl sdk.Msg.
-func (m MsgCreateDenom) ValidateBasic() error {
- _, err := sdk.AccAddressFromBech32(m.Sender)
- if err != nil {
- return ErrInvalidCreator.Wrapf("%s: sender address (%s)", err.Error(), m.Sender)
- }
-
- denom := TFDenom{
- Creator: m.Sender,
- Subdenom: m.Subdenom,
- }
- err = denom.Validate()
- if err != nil {
- return ErrInvalidDenom.Wrap(err.Error())
- }
-
- return nil
-}
-
-// GetSigners: Impl sdk.Msg.
-func (m MsgCreateDenom) GetSigners() []sdk.AccAddress {
- sender, _ := sdk.AccAddressFromBech32(m.Sender)
- return []sdk.AccAddress{sender}
-}
-
-// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty.
-func (m MsgCreateDenom) Route() string { return RouterKey }
-
-// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message,
-// intended for utilization within tags
-func (m MsgCreateDenom) Type() string { return "create_denom" }
-
-// GetSignBytes: Get the canonical byte representation of the Msg. Impl
-// legacytx.LegacyMsg.
-func (m MsgCreateDenom) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
-
-// ----------------------------------------------------------------
-// MsgChangeAdmin
-
-// ValidateBasic performs stateless validation checks. Impl sdk.Msg.
-func (m MsgChangeAdmin) ValidateBasic() error {
- _, err := sdk.AccAddressFromBech32(m.Sender)
- if err != nil {
- return sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid sender (%s): %s", m.Sender, err)
- }
-
- _, err = sdk.AccAddressFromBech32(m.NewAdmin)
- if err != nil {
- return sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid new admin (%s): %s", m.NewAdmin, err)
- }
-
- return DenomStr(m.Denom).Validate()
-}
-
-// GetSigners: Impl sdk.Msg.
-func (m MsgChangeAdmin) GetSigners() []sdk.AccAddress {
- sender, _ := sdk.AccAddressFromBech32(m.Sender)
- return []sdk.AccAddress{sender}
-}
-
-// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty.
-func (m MsgChangeAdmin) Route() string { return RouterKey }
-
-// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message,
-// intended for utilization within tags
-func (m MsgChangeAdmin) Type() string { return "create_denom" }
-
-// GetSignBytes: Get the canonical byte representation of the Msg. Impl
-// legacytx.LegacyMsg.
-func (m MsgChangeAdmin) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
-
-// ----------------------------------------------------------------
-// MsgMint
-
-// ValidateBasic performs stateless validation checks. Impl sdk.Msg.
-func (m MsgMint) ValidateBasic() error {
- _, err := sdk.AccAddressFromBech32(m.Sender)
- if err != nil {
- return sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid sender (%s): %s", m.Sender, err)
- }
-
- if err := validateCoin(m.Coin); err != nil {
- return err
- } else if err := DenomStr(m.Coin.Denom).Validate(); err != nil {
- return err
- }
-
- if m.MintTo != "" {
- _, err = sdk.AccAddressFromBech32(m.MintTo)
- if err != nil {
- return sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid mint_to (%s): %s", m.MintTo, err)
- }
- }
-
- return err
-}
-
-// GetSigners: Impl sdk.Msg.
-func (m MsgMint) GetSigners() []sdk.AccAddress {
- sender, _ := sdk.AccAddressFromBech32(m.Sender)
- return []sdk.AccAddress{sender}
-}
-
-func validateCoin(coin sdk.Coin) error {
- if !coin.IsValid() || coin.IsZero() {
- return sdkerrors.ErrInvalidCoins.Wrap(coin.String())
- }
- return nil
-}
-
-// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty.
-func (m MsgMint) Route() string { return RouterKey }
-
-// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message,
-// intended for utilization within tags
-func (m MsgMint) Type() string { return "mint" }
-
-// GetSignBytes: Get the canonical byte representation of the Msg. Impl
-// legacytx.LegacyMsg.
-func (m MsgMint) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
-
-// ----------------------------------------------------------------
-// MsgBurn
-
-// ValidateBasic performs stateless validation checks. Impl sdk.Msg.
-func (m MsgBurn) ValidateBasic() error {
- _, err := sdk.AccAddressFromBech32(m.Sender)
- if err != nil {
- return sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid sender (%s): %s", m.Sender, err)
- }
-
- if err := validateCoin(m.Coin); err != nil {
- return err
- } else if err := DenomStr(m.Coin.Denom).Validate(); err != nil {
- return err
- }
-
- if m.BurnFrom != "" {
- _, err = sdk.AccAddressFromBech32(m.BurnFrom)
- if err != nil {
- return sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid burn_from (%s): %s", m.BurnFrom, err)
- }
- }
-
- return nil
-}
-
-// GetSigners: Impl sdk.Msg.
-func (m MsgBurn) GetSigners() []sdk.AccAddress {
- sender, _ := sdk.AccAddressFromBech32(m.Sender)
- return []sdk.AccAddress{sender}
-}
-
-// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty.
-func (m MsgBurn) Route() string { return RouterKey }
-
-// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message,
-// intended for utilization within tags
-func (m MsgBurn) Type() string { return "burn" }
-
-// GetSignBytes: Get the canonical byte representation of the Msg. Impl
-// legacytx.LegacyMsg.
-func (m MsgBurn) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
-
-// ----------------------------------------------------------------
-// MsgUpdateModuleParams
-
-// ValidateBasic performs stateless validation checks. Impl sdk.Msg.
-func (m MsgUpdateModuleParams) ValidateBasic() error {
- if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
- return sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid authority (%s): %s", m.Authority, err)
- }
- return m.Params.Validate()
-}
-
-// GetSigners: Impl sdk.Msg.
-func (m MsgUpdateModuleParams) GetSigners() []sdk.AccAddress {
- sender, _ := sdk.AccAddressFromBech32(m.Authority)
- return []sdk.AccAddress{sender}
-}
-
-// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty.
-func (m MsgUpdateModuleParams) Route() string { return RouterKey }
-
-// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message,
-// intended for utilization within tags
-func (m MsgUpdateModuleParams) Type() string { return "update_module_params" }
-
-// GetSignBytes: Get the canonical byte representation of the Msg. Impl
-// legacytx.LegacyMsg.
-func (m MsgUpdateModuleParams) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
-
-// ----------------------------------------------------------------
-// MsgSetDenomMetadata
-
-// ValidateBasic performs stateless validation checks. Impl sdk.Msg.
-func (m MsgSetDenomMetadata) ValidateBasic() error {
- _, err := sdk.AccAddressFromBech32(m.Sender)
- if err != nil {
- return sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid sender (%s): %s", m.Sender, err)
- }
- return m.Metadata.Validate()
-}
-
-// GetSigners: Impl sdk.Msg.
-func (m MsgSetDenomMetadata) GetSigners() []sdk.AccAddress {
- sender, _ := sdk.AccAddressFromBech32(m.Sender)
- return []sdk.AccAddress{sender}
-}
-
-// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty.
-func (m MsgSetDenomMetadata) Route() string { return RouterKey }
-
-// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message,
-// intended for utilization within tags
-func (m MsgSetDenomMetadata) Type() string { return "set_denom_metadata" }
-
-// GetSignBytes: Get the canonical byte representation of the Msg. Impl
-// legacytx.LegacyMsg.
-func (m MsgSetDenomMetadata) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
-
-// ----------------------------------------------------------------
-// MsgBurnNative
-
-// ValidateBasic performs stateless validation checks. Impl sdk.Msg.
-func (m MsgBurnNative) ValidateBasic() error {
- _, err := sdk.AccAddressFromBech32(m.Sender)
- if err != nil {
- return sdkerrors.ErrInvalidAddress.Wrapf(
- "invalid sender (%s): %s", m.Sender, err)
- }
-
- if err := validateCoin(m.Coin); err != nil {
- return err
- }
-
- return nil
-}
-
-// GetSigners: Impl sdk.Msg.
-func (m MsgBurnNative) GetSigners() []sdk.AccAddress {
- sender, _ := sdk.AccAddressFromBech32(m.Sender)
- return []sdk.AccAddress{sender}
-}
-
-// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty.
-func (m MsgBurnNative) Route() string { return RouterKey }
-
-// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message,
-// intended for utilization within tags
-func (m MsgBurnNative) Type() string { return "burn_native" }
-
-// GetSignBytes: Get the canonical byte representation of the Msg. Impl
-// legacytx.LegacyMsg.
-func (m MsgBurnNative) GetSignBytes() []byte {
- return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
-}
diff --git a/x/tokenfactory/types/tx_msgs_test.go b/x/tokenfactory/types/tx_msgs_test.go
deleted file mode 100644
index 31d39fb07..000000000
--- a/x/tokenfactory/types/tx_msgs_test.go
+++ /dev/null
@@ -1,366 +0,0 @@
-package types_test
-
-import (
- fmt "fmt"
- "testing"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
-
- "cosmossdk.io/math"
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
-
- "github.com/NibiruChain/nibiru/x/common/testutil"
- "github.com/NibiruChain/nibiru/x/tokenfactory/types"
-)
-
-type ValidateBasicTest struct {
- name string
- msg sdk.Msg
- wantErr string
-}
-
-func (vbt ValidateBasicTest) test() func(t *testing.T) {
- var msg sdk.Msg = vbt.msg
- var wantErr string = vbt.wantErr
- return func(t *testing.T) {
- err := msg.ValidateBasic()
- if wantErr != "" {
- assert.Error(t, err)
- require.ErrorContains(t, err, wantErr)
- } else {
- require.NoError(t, err)
- }
- }
-}
-
-// TestMsgMint_ValidateBasic: Tests if MsgCreateDenom is properly validated.
-func TestMsgCreateDenom_ValidateBasic(t *testing.T) {
- addr := testutil.AccAddress().String()
- for _, tc := range []ValidateBasicTest{
- {
- name: "happy",
- msg: &types.MsgCreateDenom{
- Sender: addr,
- Subdenom: "subdenom",
- },
- wantErr: "",
- },
- {
- name: "sad subdenom",
- msg: &types.MsgCreateDenom{
- Sender: addr,
- Subdenom: "",
- },
- wantErr: "empty subdenom",
- },
- {
- name: "sad creator",
- msg: &types.MsgCreateDenom{
- Sender: "creator",
- Subdenom: "subdenom",
- },
- wantErr: "invalid creator",
- },
- } {
- t.Run(tc.name, tc.test())
- }
-}
-
-// TestMsgMint_ValidateBasic: Tests if MsgChangeAdmin is properly validated.
-func TestMsgChangeAdmin_ValidateBasic(t *testing.T) {
- sbf := testutil.AccAddress().String()
- validDenom := fmt.Sprintf("tf/%s/ftt", sbf)
- for _, tc := range []ValidateBasicTest{
- {
- name: "happy",
- msg: &types.MsgChangeAdmin{
- Sender: sbf,
- Denom: validDenom,
- NewAdmin: testutil.AccAddress().String(),
- },
- wantErr: "",
- },
- {
- name: "invalid sender",
- msg: &types.MsgChangeAdmin{
- Sender: "sender",
- Denom: validDenom,
- NewAdmin: testutil.AccAddress().String(),
- },
- wantErr: "invalid sender",
- },
- {
- name: "invalid new admin",
- msg: &types.MsgChangeAdmin{
- Sender: sbf,
- Denom: validDenom,
- NewAdmin: "new-admin",
- },
- wantErr: "invalid new admin",
- },
- {
- name: "invalid denom",
- msg: &types.MsgChangeAdmin{
- Sender: sbf,
- Denom: "tf/",
- NewAdmin: testutil.AccAddress().String(),
- },
- wantErr: "denom format error",
- },
- } {
- t.Run(tc.name, tc.test())
- }
-}
-
-func TestMsgUpdateModuleParams_ValidateBasic(t *testing.T) {
- for _, tc := range []ValidateBasicTest{
- {
- name: "happy",
- msg: &types.MsgUpdateModuleParams{
- Authority: testutil.AccAddress().String(),
- Params: types.DefaultModuleParams(),
- },
- wantErr: "",
- },
- {
- name: "sad authority",
- msg: &types.MsgUpdateModuleParams{
- Authority: "authority",
- Params: types.DefaultModuleParams(),
- },
- wantErr: "invalid authority",
- },
- } {
- t.Run(tc.name, tc.test())
- }
-}
-
-func TestTxMsgInterface(t *testing.T) {
- creator := testutil.AccAddress().String()
- subdenom := testutil.RandLetters(4)
- denomStr := fmt.Sprintf("tf/%s/%s", creator, subdenom)
- for _, msg := range []legacytx.LegacyMsg{
- &types.MsgCreateDenom{
- Sender: creator,
- Subdenom: subdenom,
- },
- &types.MsgChangeAdmin{
- Sender: creator,
- Denom: denomStr,
- NewAdmin: testutil.AccAddress().String(),
- },
- } {
- t.Run(msg.Type(), func(t *testing.T) {
- require.NotPanics(t, func() {
- _ = msg.GetSigners()
- _ = msg.Route()
- _ = msg.Type()
- _ = msg.GetSignBytes()
- })
- })
- }
-
- for _, msg := range []sdk.Msg{
- &types.MsgUpdateModuleParams{
- Authority: testutil.GovModuleAddr().String(),
- Params: types.DefaultModuleParams(),
- },
- &types.MsgMint{
- Sender: creator,
- Coin: sdk.NewInt64Coin(denomStr, 420),
- MintTo: "",
- },
- &types.MsgBurn{
- Sender: creator,
- Coin: sdk.NewInt64Coin(denomStr, 420),
- BurnFrom: "",
- },
- } {
- require.NotPanics(t, func() {
- _ = msg.GetSigners()
- })
- }
-}
-
-// TestMsgMint_ValidateBasic: Tests if tx msgs MsgMint and MsgBurn are properly
-// validated.
-func TestMsgMint_ValidateBasic(t *testing.T) {
- sbf := testutil.AccAddress().String()
- validDenom := fmt.Sprintf("tf/%s/ftt", sbf)
- validCoin := sdk.NewInt64Coin(validDenom, 420)
- for _, tc := range []ValidateBasicTest{
- {
- name: "happy",
- msg: &types.MsgMint{
- Sender: sbf,
- Coin: validCoin,
- MintTo: "",
- },
- wantErr: "",
- },
- {
- name: "invalid sender",
- msg: &types.MsgMint{
- Sender: "sender",
- Coin: validCoin,
- MintTo: "",
- },
- wantErr: "invalid address",
- },
- {
- name: "invalid denom",
- msg: &types.MsgMint{
- Sender: sbf,
- Coin: sdk.Coin{Denom: "tf/", Amount: math.NewInt(420)},
- MintTo: "",
- },
- wantErr: "denom format error",
- },
- {
- name: "invalid mint to addr",
- msg: &types.MsgMint{
- Sender: sbf,
- Coin: validCoin,
- MintTo: "mintto",
- },
- wantErr: "invalid mint_to",
- },
- {
- name: "invalid coin",
- msg: &types.MsgMint{
- Sender: sbf,
- Coin: sdk.Coin{Amount: math.NewInt(-420)},
- MintTo: "",
- },
- wantErr: "invalid coin",
- },
- } {
- t.Run(tc.name, tc.test())
- }
-}
-
-func TestMsgBurn_ValidateBasic(t *testing.T) {
- sbf := testutil.AccAddress().String()
- validDenom := fmt.Sprintf("tf/%s/ftt", sbf)
- validCoin := sdk.NewInt64Coin(validDenom, 420)
- for _, tc := range []ValidateBasicTest{
- {
- name: "happy",
- msg: &types.MsgBurn{
- Sender: sbf,
- Coin: validCoin,
- BurnFrom: "",
- },
- wantErr: "",
- },
- {
- name: "invalid sender",
- msg: &types.MsgBurn{
- Sender: "sender",
- Coin: validCoin,
- BurnFrom: "",
- },
- wantErr: "invalid address",
- },
- {
- name: "invalid denom",
- msg: &types.MsgBurn{
- Sender: sbf,
- Coin: sdk.Coin{Denom: "tf/", Amount: math.NewInt(420)},
- BurnFrom: "",
- },
- wantErr: "denom format error",
- },
- {
- name: "invalid burn from addr",
- msg: &types.MsgBurn{
- Sender: sbf,
- Coin: validCoin,
- BurnFrom: "mintto",
- },
- wantErr: "invalid burn_from",
- },
- {
- name: "invalid coin",
- msg: &types.MsgBurn{
- Sender: sbf,
- Coin: sdk.Coin{Amount: math.NewInt(-420)},
- BurnFrom: "",
- },
- wantErr: "invalid coin",
- },
- } {
- t.Run(tc.name, tc.test())
- }
-}
-
-func TestMsgSetDenomMetadata_ValidateBasic(t *testing.T) {
- sbf := testutil.AccAddress().String()
- satoshi := testutil.AccAddress().String()
- ubtcDenom := fmt.Sprintf("tf/%s/ubtc", satoshi)
- for _, tc := range []ValidateBasicTest{
- {
- name: "happy: satoshi nakamoto",
- msg: &types.MsgSetDenomMetadata{
- Sender: satoshi,
- Metadata: banktypes.Metadata{
- Description: "satoshi nakamoto bitcoin",
- DenomUnits: []*banktypes.DenomUnit{
- {Denom: ubtcDenom, Exponent: 0},
- {Denom: "btc", Exponent: 6},
- },
- Base: ubtcDenom,
- Display: "btc",
- Name: "bitcoin",
- Symbol: "BTC",
- },
- },
- wantErr: "",
- },
-
- {
- name: "happy: SBF",
- msg: &types.MsgSetDenomMetadata{
- Sender: sbf,
- Metadata: types.DenomStr(fmt.Sprintf("tf/%s/ftt", sbf)).
- MustToStruct().DefaultBankMetadata(),
- },
- wantErr: "",
- },
-
- {
- name: "invalid sender",
- msg: &types.MsgSetDenomMetadata{
- Sender: "notAnAddr",
- Metadata: types.TFDenom{Creator: "notAnAddr", Subdenom: "abc"}.
- DefaultBankMetadata(),
- },
- wantErr: "invalid address",
- },
-
- {
- name: "sad: base denom doesn't match",
- msg: &types.MsgSetDenomMetadata{
- Sender: satoshi,
- Metadata: banktypes.Metadata{
- Description: "satoshi nakamoto bitcoin",
- DenomUnits: []*banktypes.DenomUnit{
- {Denom: ubtcDenom, Exponent: 0},
- {Denom: "wbtc", Exponent: 6}, // must be first
- },
- Base: "wbtc",
- Display: "wbtc",
- Name: "bitcoin",
- Symbol: "BTC",
- },
- },
- wantErr: "metadata's first denomination unit must be the one with base denom",
- },
- } {
- t.Run(tc.name, tc.test())
- }
-}