diff --git a/pkg/coins.go b/pkg/coins.go index e470cdc8..98b22c43 100644 --- a/pkg/coins.go +++ b/pkg/coins.go @@ -13,7 +13,7 @@ func SplitCoins(coins sdk.Coins, ratio sdk.Dec) (stack1, stack2 sdk.Coins) { for _, coin := range coins { stack1Coin := sdk.Coin{ Denom: coin.Denom, - Amount: coin.Amount.ToDec().Mul(ratio).TruncateInt(), + Amount: sdk.NewDecFromInt(coin.Amount).Mul(ratio).TruncateInt(), } stack2Coin := coin.Sub(stack1Coin) diff --git a/proto/archway/genmsg/v1/genmsg.proto b/proto/archway/genmsg/v1/genmsg.proto index 6a66cba6..93f2de4c 100644 --- a/proto/archway/genmsg/v1/genmsg.proto +++ b/proto/archway/genmsg/v1/genmsg.proto @@ -4,7 +4,7 @@ package archway.genmsg.v1; import "google/protobuf/any.proto"; -option go_package = "github.com/archway-network/archway/x/genmsg/v1"; +option go_package = "github.com/archway-network/archway/x/genmsg/types"; // GenesisState represents the messages to be processed during genesis by the genmsg module. message GenesisState { diff --git a/wasmbinding/gov/query_handler.go b/wasmbinding/gov/query_handler.go index 956054e4..d42c4083 100644 --- a/wasmbinding/gov/query_handler.go +++ b/wasmbinding/gov/query_handler.go @@ -6,9 +6,10 @@ import ( 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/cosmos/cosmos-sdk/x/gov/types" + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/archway-network/archway/wasmbinding/gov/types" + wasmTypes "github.com/archway-network/archway/wasmbinding/gov/types" ) // KeeperReaderExpected defines the x/gov keeper expected read operations. @@ -29,16 +30,16 @@ func NewQueryHandler(gk KeeperReaderExpected) QueryHandler { } // GetVote returns the vote weighted options for a given proposal and voter. -func (h QueryHandler) GetVote(ctx sdk.Context, req types.VoteRequest) (types.VoteResponse, error) { +func (h QueryHandler) GetVote(ctx sdk.Context, req wasmTypes.VoteRequest) (wasmTypes.VoteResponse, error) { if err := req.Validate(); err != nil { - return types.VoteResponse{}, fmt.Errorf("vote: %w", err) + return wasmTypes.VoteResponse{}, fmt.Errorf("vote: %w", err) } vote, found := h.govKeeper.GetVote(ctx, req.ProposalID, req.MustGetVoter()) if !found { - err := sdkErrors.Wrap(govTypes.ErrInvalidVote, fmt.Errorf("vote not found for proposal %d and voter %s", req.ProposalID, req.Voter).Error()) - return types.VoteResponse{}, err + err := sdkErrors.Wrap(types.ErrInvalidVote, fmt.Errorf("vote not found for proposal %d and voter %s", req.ProposalID, req.Voter).Error()) + return wasmTypes.VoteResponse{}, err } - return types.NewVoteResponse(vote), nil + return wasmTypes.NewVoteResponse(vote), nil } diff --git a/wasmbinding/gov/query_test.go b/wasmbinding/gov/query_test.go index 3c48221d..71eb7d00 100644 --- a/wasmbinding/gov/query_test.go +++ b/wasmbinding/gov/query_test.go @@ -2,12 +2,13 @@ package gov_test import ( "testing" - "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + legacyGovTypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" e2eTesting "github.com/archway-network/archway/e2e/testing" "github.com/archway-network/archway/wasmbinding/gov" @@ -27,11 +28,17 @@ func TestGovWASMBindings(t *testing.T) { depositor := accAddrs[0] voter := accAddrs[1] + govAccount := keeper.GetGovernanceAccount(ctx) + params := keeper.GetParams(ctx) + // Store a proposal proposalId := govTypes.DefaultStartingProposalID - textProposal := govTypes.NewTextProposal("foo", "bar") - proposal, pErr := govTypes.NewProposal(textProposal, proposalId, time.Now().UTC(), time.Now().UTC()) + textProposal := legacyGovTypes.NewTextProposal("foo", "bar") + proposalContentMsg, pErr := govTypes.NewLegacyContent(textProposal, govAccount.String()) require.NoError(t, pErr) + + proposal, err := govTypes.NewProposal([]sdk.Msg{proposalContentMsg}, proposalId, ctx.BlockHeader().Time, ctx.BlockHeader().Time.Add(*params.MaxDepositPeriod), "", "Text Proposal", "Description", depositor) + require.NoError(t, err) keeper.SetProposal(ctx, proposal) // Make a deposit @@ -40,7 +47,7 @@ func TestGovWASMBindings(t *testing.T) { // Vote keeper.ActivateVotingPeriod(ctx, proposal) - vote := govTypes.NewVote(proposalId, voter, govTypes.NewNonSplitVoteOption(govTypes.OptionYes)) + vote := govTypes.NewVote(proposalId, voter, govTypes.NewNonSplitVoteOption(govTypes.OptionYes), "") keeper.SetVote(ctx, vote) t.Run("Query vote on proposal", func(t *testing.T) { diff --git a/wasmbinding/gov/types/query.go b/wasmbinding/gov/types/query.go index abe7e0b3..899a02bb 100644 --- a/wasmbinding/gov/types/query.go +++ b/wasmbinding/gov/types/query.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" ) type VoteRequest struct { @@ -119,7 +119,7 @@ func NewVoteResponse(vote govTypes.Vote) VoteResponse { } for _, option := range vote.Options { - resp.Vote.Options = append(resp.Vote.Options, NewWeightedVoteOption(option)) + resp.Vote.Options = append(resp.Vote.Options, NewWeightedVoteOption(*option)) } return resp @@ -141,6 +141,6 @@ func NewWeightedVoteOption(voteOption govTypes.WeightedVoteOption) WeightedVoteO return WeightedVoteOption{ Option: option, - Weight: voteOption.Weight.String(), + Weight: voteOption.Weight, } } diff --git a/wasmbinding/integration_test.go b/wasmbinding/integration_test.go index e352a608..bce0c470 100644 --- a/wasmbinding/integration_test.go +++ b/wasmbinding/integration_test.go @@ -9,7 +9,7 @@ import ( wasmdTypes "github.com/CosmWasm/wasmd/x/wasm/types" voterTypes "github.com/archway-network/voter/src/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkGov "github.com/cosmos/cosmos-sdk/x/gov/types" + sdkGov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/stretchr/testify/require" e2eTesting "github.com/archway-network/archway/e2e/testing" @@ -22,8 +22,8 @@ func TestGovQuerier(t *testing.T) { chain.GetApp().GovKeeper.SetVote(chain.GetContext(), sdkGov.Vote{ ProposalId: 1, Voter: chain.GetAccount(1).Address.String(), - Option: 0, Options: nil, + Metadata: "", }) acc := chain.GetAccount(0) codeID := chain.UploadContract(acc, "../contracts/go/voter/code.wasm", wasmdTypes.DefaultUploadAccess) diff --git a/wasmbinding/plugin_test.go b/wasmbinding/plugin_test.go index 7478e03c..ab2caa72 100644 --- a/wasmbinding/plugin_test.go +++ b/wasmbinding/plugin_test.go @@ -6,8 +6,10 @@ import ( "time" wasmVmTypes "github.com/CosmWasm/wasmvm/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" + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + legacyGovTypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -58,22 +60,25 @@ func TestWASMBindingPlugins(t *testing.T) { }) t.Run("Query gov vote", func(t *testing.T) { + govAccount := govKeeper.GetGovernanceAccount(ctx) proposalId := govTypes.DefaultStartingProposalID - textProposal := govTypes.NewTextProposal("foo", "bar") + accAddrs, _ := e2eTesting.GenAccounts(2) + depositor := accAddrs[0] + textProposal := legacyGovTypes.NewTextProposal("foo", "bar") anyTime := time.Now().UTC() - proposal, pErr := govTypes.NewProposal(textProposal, proposalId, anyTime, anyTime) + proposalContentMsg, pErr := govTypes.NewLegacyContent(textProposal, govAccount.String()) + require.NoError(t, pErr) + proposal, pErr := govTypes.NewProposal([]sdk.Msg{proposalContentMsg}, proposalId, anyTime, anyTime, "", "Text Proposal", "Description", depositor) require.NoError(t, pErr) govKeeper.SetProposal(ctx, proposal) - accAddrs, _ := e2eTesting.GenAccounts(2) - depositor := accAddrs[0] deposit := govTypes.NewDeposit(proposalId, depositor, nil) govKeeper.SetDeposit(ctx, deposit) voter := accAddrs[1] govKeeper.ActivateVotingPeriod(ctx, proposal) - vote := govTypes.NewVote(proposalId, voter, govTypes.NewNonSplitVoteOption(govTypes.OptionYes)) + vote := govTypes.NewVote(proposalId, voter, govTypes.NewNonSplitVoteOption(govTypes.OptionYes), "") govKeeper.SetVote(ctx, vote) _, err := queryPlugin.Custom(ctx, []byte(fmt.Sprintf("{\"gov_vote\": {\"proposal_id\": %d, \"voter\": \"%s\"}}", proposalId, voter))) diff --git a/x/genmsg/genesis.go b/x/genmsg/genesis.go index 406a2fab..cb8ce51f 100644 --- a/x/genmsg/genesis.go +++ b/x/genmsg/genesis.go @@ -4,13 +4,13 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - v1 "github.com/archway-network/archway/x/genmsg/v1" + "github.com/archway-network/archway/x/genmsg/types" ) -func anyToMsg(ir types.InterfaceRegistry, anyMsg *types.Any) (sdk.Msg, error) { +func anyToMsg(ir codectypes.InterfaceRegistry, anyMsg *codectypes.Any) (sdk.Msg, error) { var sdkMsg sdk.Msg err := ir.UnpackAny(anyMsg, &sdkMsg) if err != nil { @@ -22,9 +22,9 @@ func anyToMsg(ir types.InterfaceRegistry, anyMsg *types.Any) (sdk.Msg, error) { return sdkMsg, nil } -func validateGenesis(cdc codec.JSONCodec, genesis *v1.GenesisState) error { +func validateGenesis(cdc codec.JSONCodec, genesis *types.GenesisState) error { interfaceRegistryProvider, ok := cdc.(interface { - InterfaceRegistry() types.InterfaceRegistry + InterfaceRegistry() codectypes.InterfaceRegistry }) if !ok { return fmt.Errorf("codec does not implement InterfaceRegistry") @@ -39,9 +39,9 @@ func validateGenesis(cdc codec.JSONCodec, genesis *v1.GenesisState) error { return nil } -func initGenesis(context sdk.Context, cdc codec.JSONCodec, router MessageRouter, genesis *v1.GenesisState) error { +func initGenesis(context sdk.Context, cdc codec.JSONCodec, router MessageRouter, genesis *types.GenesisState) error { interfaceRegistryProvider, ok := cdc.(interface { - InterfaceRegistry() types.InterfaceRegistry + InterfaceRegistry() codectypes.InterfaceRegistry }) if !ok { return fmt.Errorf("codec does not implement InterfaceRegistry") diff --git a/x/genmsg/genesis_test.go b/x/genmsg/genesis_test.go index 78feb452..fae77877 100644 --- a/x/genmsg/genesis_test.go +++ b/x/genmsg/genesis_test.go @@ -5,13 +5,13 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/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/gogo/protobuf/proto" "github.com/stretchr/testify/require" - v1 "github.com/archway-network/archway/x/genmsg/v1" + "github.com/archway-network/archway/x/genmsg/types" ) type mockRouter struct { @@ -21,22 +21,22 @@ type mockRouter struct { func (m mockRouter) Handler(msg sdk.Msg) baseapp.MsgServiceHandler { return m.handler(msg) } func makeCodec(_ *testing.T) codec.JSONCodec { - ir := types.NewInterfaceRegistry() + ir := codectypes.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) +func newGenesisFromMsgs(t *testing.T, cdc codec.JSONCodec, msgs ...proto.Message) *types.GenesisState { + genesis := new(types.GenesisState) for _, msg := range msgs { - anyProto, err := types.NewAnyWithValue(msg) + anyProto, err := codectypes.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) + genesis = new(types.GenesisState) require.NoError(t, cdc.UnmarshalJSON(genesisJSON, genesis)) return genesis } @@ -91,7 +91,7 @@ func Test_initGenesis(t *testing.T) { func Test_validateGenesis(t *testing.T) { cdc := makeCodec(t) t.Run("works - empty", func(t *testing.T) { - err := validateGenesis(cdc, &v1.GenesisState{}) + err := validateGenesis(cdc, &types.GenesisState{}) require.NoError(t, err) }) t.Run("works - with messages", func(t *testing.T) { diff --git a/x/genmsg/integration_test.go b/x/genmsg/integration_test.go index f3d9256d..e9f045fd 100644 --- a/x/genmsg/integration_test.go +++ b/x/genmsg/integration_test.go @@ -12,7 +12,7 @@ import ( "github.com/archway-network/archway/app" e2eTesting "github.com/archway-network/archway/e2e/testing" "github.com/archway-network/archway/x/genmsg" - v1 "github.com/archway-network/archway/x/genmsg/v1" + "github.com/archway-network/archway/x/genmsg/types" ) func TestIntegration(t *testing.T) { @@ -25,7 +25,7 @@ func TestIntegration(t *testing.T) { } anyMsg, err := codectypes.NewAnyWithValue(testMsg) require.NoError(t, err) - genesis[genmsg.ModuleName] = cdc.MustMarshalJSON(&v1.GenesisState{Messages: []*codectypes.Any{anyMsg}}) + genesis[genmsg.ModuleName] = cdc.MustMarshalJSON(&types.GenesisState{Messages: []*codectypes.Any{anyMsg}}) })) bankQuery := banktypes.NewQueryClient(chain.Client()) resp, err := bankQuery.Balance(sdk.WrapSDKContext(chain.GetContext()), &banktypes.QueryBalanceRequest{ diff --git a/x/genmsg/module.go b/x/genmsg/module.go index cdd8be6f..2c0d57d6 100644 --- a/x/genmsg/module.go +++ b/x/genmsg/module.go @@ -8,14 +8,14 @@ import ( "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" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - v1 "github.com/archway-network/archway/x/genmsg/v1" + "github.com/archway-network/archway/x/genmsg/types" ) const ( @@ -40,11 +40,11 @@ type AppModule struct { func (a AppModule) Name() string { return ModuleName } func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(new(v1.GenesisState)) + return cdc.MustMarshalJSON(new(types.GenesisState)) } func (AppModule) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - state := new(v1.GenesisState) + state := new(types.GenesisState) if err := cdc.UnmarshalJSON(bz, state); err != nil { return fmt.Errorf("failed to unmarshal x/%s genesis state: %w", ModuleName, err) } @@ -52,7 +52,7 @@ func (AppModule) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingCo } func (a AppModule) InitGenesis(context sdk.Context, codec codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate { - state := new(v1.GenesisState) + state := new(types.GenesisState) codec.MustUnmarshalJSON(message, state) err := initGenesis(context, codec, a.router, state) if err != nil { @@ -62,7 +62,7 @@ func (a AppModule) InitGenesis(context sdk.Context, codec codec.JSONCodec, messa } func (a AppModule) ExportGenesis(_ sdk.Context, codec codec.JSONCodec) json.RawMessage { - return codec.MustMarshalJSON(new(v1.GenesisState)) + return codec.MustMarshalJSON(new(types.GenesisState)) } func (a AppModule) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} @@ -81,4 +81,4 @@ func (a AppModule) ConsensusVersion() uint64 { return 0 } func (a AppModule) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} -func (a AppModule) RegisterInterfaces(_ types.InterfaceRegistry) {} +func (a AppModule) RegisterInterfaces(_ codectypes.InterfaceRegistry) {} diff --git a/x/genmsg/v1/genmsg.pb.go b/x/genmsg/types/genmsg.pb.go similarity index 94% rename from x/genmsg/v1/genmsg.pb.go rename to x/genmsg/types/genmsg.pb.go index d42d012a..7e94afa3 100644 --- a/x/genmsg/v1/genmsg.pb.go +++ b/x/genmsg/types/genmsg.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: archway/genmsg/v1/genmsg.proto -package v1 +package types import ( fmt "fmt" @@ -75,7 +75,7 @@ func init() { func init() { proto.RegisterFile("archway/genmsg/v1/genmsg.proto", fileDescriptor_dd2163a5764fa63d) } var fileDescriptor_dd2163a5764fa63d = []byte{ - // 190 bytes of a gzipped FileDescriptorProto + // 195 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0x2c, 0x4a, 0xce, 0x28, 0x4f, 0xac, 0xd4, 0x4f, 0x4f, 0xcd, 0xcb, 0x2d, 0x4e, 0xd7, 0x2f, 0x33, 0x84, 0xb2, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0xa1, 0xf2, 0x7a, 0x50, 0xd1, 0x32, 0x43, 0x29, 0xc9, @@ -83,11 +83,12 @@ var fileDescriptor_dd2163a5764fa63d = []byte{ 0x88, 0x6a, 0x25, 0x07, 0x2e, 0x1e, 0xf7, 0xd4, 0xbc, 0xd4, 0xe2, 0xcc, 0xe2, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x03, 0x2e, 0x8e, 0xdc, 0xd4, 0xe2, 0xe2, 0xc4, 0xf4, 0xd4, 0x62, 0x09, 0x46, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x11, 0x3d, 0x88, 0x6e, 0x3d, 0x98, 0x6e, 0x3d, 0xc7, 0xbc, 0xca, - 0x20, 0xb8, 0x2a, 0x27, 0x8f, 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, 0xd2, - 0x4b, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x3a, 0x4a, 0x37, 0x2f, - 0xb5, 0xa4, 0x3c, 0xbf, 0x28, 0x1b, 0xc6, 0xd7, 0xaf, 0x40, 0x78, 0x23, 0x89, 0x0d, 0x6c, 0x83, - 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x8e, 0x05, 0x66, 0xe2, 0x00, 0x00, 0x00, + 0x20, 0xb8, 0x2a, 0x27, 0xef, 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, 0x32, + 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x3a, 0x4a, 0x37, 0x2f, + 0xb5, 0xa4, 0x3c, 0xbf, 0x28, 0x1b, 0xc6, 0xd7, 0xaf, 0x80, 0x79, 0xa3, 0xa4, 0xb2, 0x20, 0xb5, + 0x38, 0x89, 0x0d, 0x6c, 0x89, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xa9, 0x0d, 0xc2, 0x8c, 0xe5, + 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/genmsg/v1/genmsgs.pb.go b/x/genmsg/v1/genmsgs.pb.go deleted file mode 100644 index ebd01868..00000000 --- a/x/genmsg/v1/genmsgs.pb.go +++ /dev/null @@ -1,330 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: archway/genmsgs/v1/genmsgs.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_6774c92ce42c05da, []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), "archway.genmsg.v1.GenesisState") -} - -func init() { proto.RegisterFile("archway/genmsgs/v1/genmsgs.proto", fileDescriptor_6774c92ce42c05da) } - -var fileDescriptor_6774c92ce42c05da = []byte{ - // 196 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0x2c, 0x4a, 0xce, - 0x28, 0x4f, 0xac, 0xd4, 0x4f, 0x4f, 0xcd, 0xcb, 0x2d, 0x4e, 0x2f, 0xd6, 0x2f, 0x33, 0x84, 0x31, - 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0xa1, 0x2a, 0xf4, 0x20, 0xc2, 0x7a, 0x65, 0x86, - 0x52, 0x92, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x60, 0x05, 0x49, 0xa5, 0x69, 0xfa, 0x89, - 0x79, 0x95, 0x10, 0xd5, 0x4a, 0x0e, 0x5c, 0x3c, 0xee, 0xa9, 0x79, 0xa9, 0xc5, 0x99, 0xc5, 0xc1, - 0x25, 0x89, 0x25, 0xa9, 0x42, 0x06, 0x5c, 0x1c, 0xb9, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0xa9, 0xc5, - 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x22, 0x7a, 0x10, 0xdd, 0x7a, 0x30, 0xdd, 0x7a, 0x8e, - 0x79, 0x95, 0x41, 0x70, 0x55, 0x4e, 0x1e, 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, 0x97, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x75, 0x94, - 0x6e, 0x5e, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0x36, 0x8c, 0xaf, 0x5f, 0x01, 0x75, 0xbd, 0x7e, 0x99, - 0x61, 0x12, 0x1b, 0xd8, 0x06, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x4e, 0x49, 0xee, - 0xe4, 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 = encodeVarintGenmsgs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintGenmsgs(dAtA []byte, offset int, v uint64) int { - offset -= sovGenmsgs(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 + sovGenmsgs(uint64(l)) - } - } - return n -} - -func sovGenmsgs(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenmsgs(x uint64) (n int) { - return sovGenmsgs(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 ErrIntOverflowGenmsgs - } - 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 ErrIntOverflowGenmsgs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenmsgs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenmsgs - } - 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 := skipGenmsgs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenmsgs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenmsgs(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, ErrIntOverflowGenmsgs - } - 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, ErrIntOverflowGenmsgs - } - 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, ErrIntOverflowGenmsgs - } - 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, ErrInvalidLengthGenmsgs - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGenmsgs - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGenmsgs - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGenmsgs = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenmsgs = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGenmsgs = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/rewards/ante/fee_deduction.go b/x/rewards/ante/fee_deduction.go index cb82a70a..d128b458 100644 --- a/x/rewards/ante/fee_deduction.go +++ b/x/rewards/ante/fee_deduction.go @@ -133,7 +133,7 @@ func (dfd DeductFeeDecorator) deductFees(ctx sdk.Context, tx sdk.Tx, acc authTyp if err := dfd.bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), rewardsTypes.ContractRewardCollector, flatFees); err != nil { return sdkErrors.Wrapf(sdkErrors.ErrInsufficientFunds, err.Error()) } - fees = fees.Sub(flatFees) // reduce flatfees from the sent fees amount + fees = fees.Sub(flatFees...) // reduce flatfees from the sent fees amount } // Split the fees between the fee collector account and the rewards collector account diff --git a/x/rewards/ante/fee_deduction_test.go b/x/rewards/ante/fee_deduction_test.go index 8c8bde39..e497d35a 100644 --- a/x/rewards/ante/fee_deduction_test.go +++ b/x/rewards/ante/fee_deduction_test.go @@ -146,8 +146,8 @@ func TestRewardsFeeDeductionAnteHandler(t *testing.T) { feeCollectorBalanceAfter := chain.GetModuleBalance(authTypes.FeeCollectorName) rewardsBalanceAfter := chain.GetModuleBalance(rewardsTypes.ContractRewardCollector) - feeCollectorBalanceDiffReceived := feeCollectorBalanceAfter.Sub(feeCollectorBalanceBefore) // positive - rewardsBalanceDiffReceived := rewardsBalanceAfter.Sub(rewardsBalanceBefore) // positive + feeCollectorBalanceDiffReceived := feeCollectorBalanceAfter.Sub(feeCollectorBalanceBefore...) // positive + rewardsBalanceDiffReceived := rewardsBalanceAfter.Sub(rewardsBalanceBefore...) // positive feeCollectorBalanceDiffExpected, err := sdk.ParseCoinsNormalized(tc.feeCollectorBalanceDiffExpected) require.NoError(t, err) diff --git a/x/rewards/keeper/common_test.go b/x/rewards/keeper/common_test.go index 317b6310..2252ef60 100644 --- a/x/rewards/keeper/common_test.go +++ b/x/rewards/keeper/common_test.go @@ -76,7 +76,7 @@ func (s *KeeperTestSuite) CheckWithdrawResults(rewardsAddr sdk.AccAddress, recor // Check the account balance diff accBalanceAfter := s.chain.GetBalance(rewardsAddr) - s.Assert().Equal(totalRewardsExpected.String(), accBalanceAfter.Sub(accBalanceBefore).String()) + s.Assert().Equal(totalRewardsExpected.String(), accBalanceAfter.Sub(accBalanceBefore...).String()) // Check records pruning recordsState := s.chain.GetApp().RewardsKeeper.GetState().RewardsRecord(s.chain.GetContext()) diff --git a/x/rewards/keeper/distribution.go b/x/rewards/keeper/distribution.go index 0a913324..a05fbcaa 100644 --- a/x/rewards/keeper/distribution.go +++ b/x/rewards/keeper/distribution.go @@ -139,7 +139,7 @@ func (k Keeper) estimateBlockRewards(ctx sdk.Context, blockDistrState *blockRewa inflationRewards := sdk.NewCoin( blockRewards.InflationRewards.Denom, - blockRewards.InflationRewards.Amount.ToDec().Mul(rewardsShare).TruncateInt(), + sdk.NewDecFromInt(blockRewards.InflationRewards.Amount).Mul(rewardsShare).TruncateInt(), ) contractDistrState.InflationaryRewards = inflationRewards } @@ -158,7 +158,7 @@ func (k Keeper) estimateBlockRewards(ctx sdk.Context, blockDistrState *blockRewa for _, feeCoin := range txFees { feeRewards := sdk.NewCoin( feeCoin.Denom, - feeCoin.Amount.ToDec().Mul(rewardsShare).TruncateInt(), + sdk.NewDecFromInt(feeCoin.Amount).Mul(rewardsShare).TruncateInt(), ) contractDistrState.FeeRewards = contractDistrState.FeeRewards.Add(feeRewards) } @@ -240,7 +240,7 @@ func (k Keeper) cleanupTracking(ctx sdk.Context, height int64) { // cleanupRewardsPool transfers all undistributed block rewards to the treasury pool. func (k Keeper) cleanupRewardsPool(ctx sdk.Context, blockDistrState *blockRewardsDistributionState) { - rewardsLeftovers := blockDistrState.RewardsTotal.Sub(blockDistrState.RewardsDistributed) + rewardsLeftovers := blockDistrState.RewardsTotal.Sub(blockDistrState.RewardsDistributed...) if rewardsLeftovers.Empty() { return } diff --git a/x/rewards/keeper/keeper.go b/x/rewards/keeper/keeper.go index 0397cab2..6f6b362f 100644 --- a/x/rewards/keeper/keeper.go +++ b/x/rewards/keeper/keeper.go @@ -4,6 +4,7 @@ import ( wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types" "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" sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" @@ -51,7 +52,7 @@ type Keeper struct { } // NewKeeper creates a new Keeper instance. -func NewKeeper(cdc codec.Codec, key sdk.StoreKey, contractInfoReader ContractInfoReaderExpected, trackingKeeper TrackingKeeperExpected, ak AuthKeeperExpected, bk BankKeeperExpected, ps paramTypes.Subspace) Keeper { +func NewKeeper(cdc codec.Codec, key storetypes.StoreKey, contractInfoReader ContractInfoReaderExpected, trackingKeeper TrackingKeeperExpected, ak AuthKeeperExpected, bk BankKeeperExpected, ps paramTypes.Subspace) Keeper { if !ps.HasKeyTable() { ps = ps.WithKeyTable(types.ParamKeyTable()) } diff --git a/x/rewards/keeper/min_cons_fee.go b/x/rewards/keeper/min_cons_fee.go index de62d6e6..c2962afa 100644 --- a/x/rewards/keeper/min_cons_fee.go +++ b/x/rewards/keeper/min_cons_fee.go @@ -14,7 +14,8 @@ func (k Keeper) UpdateMinConsensusFee(ctx sdk.Context, inflationRewards sdk.Coin k.Logger(ctx).Info("Minimum consensus fee update skipped: inflation rewards are zero") return } - inflationRewardsAmt := inflationRewards.Amount.ToDec() + + inflationRewardsAmt := sdk.NewDecFromInt(inflationRewards.Amount) blockGasLimit := pkg.NewDecFromUint64(ctx.BlockGasMeter().Limit()) if blockGasLimit.IsZero() { diff --git a/x/rewards/keeper/state.go b/x/rewards/keeper/state.go index a5e724c4..74501fc0 100644 --- a/x/rewards/keeper/state.go +++ b/x/rewards/keeper/state.go @@ -3,6 +3,7 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/archway-network/archway/x/rewards/types" @@ -10,12 +11,12 @@ import ( // State is a wrapper around the module storage state. type State struct { - key sdk.StoreKey + key storetypes.StoreKey cdc codec.Codec } // NewState creates a new State instance. -func NewState(cdc codec.Codec, key sdk.StoreKey) State { +func NewState(cdc codec.Codec, key storetypes.StoreKey) State { return State{ key: key, cdc: cdc, diff --git a/x/rewards/mintbankkeeper/keeper_test.go b/x/rewards/mintbankkeeper/keeper_test.go index 7d88ddf6..8ee2a215 100644 --- a/x/rewards/mintbankkeeper/keeper_test.go +++ b/x/rewards/mintbankkeeper/keeper_test.go @@ -154,9 +154,9 @@ func TestMintBankKeeper(t *testing.T) { dstBalanceAfter := chain.GetModuleBalance(tc.dstModule) rewardsBalanceAfter := chain.GetModuleBalance(rewardsTypes.ContractRewardCollector) - srcBalanceDiffReceived := srcBalanceBefore.Sub(srcBalanceAfter) // negative - dstBalanceDiffReceived := dstBalanceAfter.Sub(dstBalanceBefore) // positive - rewardsBalanceDiffReceived := rewardsBalanceAfter.Sub(rewardsBalanceBefore) // positive + srcBalanceDiffReceived := srcBalanceBefore.Sub(srcBalanceAfter...) // negative + dstBalanceDiffReceived := dstBalanceAfter.Sub(dstBalanceBefore...) // positive + rewardsBalanceDiffReceived := rewardsBalanceAfter.Sub(rewardsBalanceBefore...) // positive dstBalanceDiffExpected, err := sdk.ParseCoinsNormalized(tc.dstBalanceDiffExpected) require.NoError(t, err) @@ -193,7 +193,7 @@ func TestMintBankKeeper(t *testing.T) { minConsFeeExpected := sdk.DecCoin{ Denom: sdk.DefaultBondDenom, - Amount: rewardsDiffExpected[0].Amount.ToDec().Quo( + Amount: sdk.NewDecCoinFromCoin(rewardsDiffExpected[0]).Amount.Quo( pkg.NewDecFromUint64(maxGasExpected).Mul( chain.GetApp().RewardsKeeper.TxFeeRebateRatio(ctx).Sub(sdk.OneDec()), ), diff --git a/x/tracking/keeper/keeper.go b/x/tracking/keeper/keeper.go index a98d4b33..aa1b6b08 100644 --- a/x/tracking/keeper/keeper.go +++ b/x/tracking/keeper/keeper.go @@ -4,6 +4,7 @@ import ( 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/archway-network/archway/x/tracking/types" @@ -18,7 +19,7 @@ type Keeper struct { } // NewKeeper creates a new Keeper instance. -func NewKeeper(cdc codec.Codec, key sdk.StoreKey, gasRegister wasmKeeper.GasRegister) Keeper { +func NewKeeper(cdc codec.Codec, key storetypes.StoreKey, gasRegister wasmKeeper.GasRegister) Keeper { return Keeper{ cdc: cdc, WasmGasRegister: gasRegister, diff --git a/x/tracking/keeper/state.go b/x/tracking/keeper/state.go index 997582ab..97db85d1 100644 --- a/x/tracking/keeper/state.go +++ b/x/tracking/keeper/state.go @@ -3,6 +3,7 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/archway-network/archway/x/tracking/types" @@ -10,12 +11,12 @@ import ( // State is a wrapper around the module storage state. type State struct { - key sdk.StoreKey + key storetypes.StoreKey cdc codec.Codec } // NewState creates a new State instance. -func NewState(cdc codec.Codec, key sdk.StoreKey) State { +func NewState(cdc codec.Codec, key storetypes.StoreKey) State { return State{ key: key, cdc: cdc,