From 736ecbc8fff97e6c45118fb850bbb446a12efff7 Mon Sep 17 00:00:00 2001 From: Duong Minh Ngoc <153509244+minhngoc274@users.noreply.github.com> Date: Fri, 26 Apr 2024 01:16:27 +0700 Subject: [PATCH] refactor: remove token factory (#1490) * update to ibc v6 * fix test and bump pfm v6 * remove wasmd and cosmwasm and delete store key * add deployment * update to ibc v6 * update to ibc v6 * fix test and bump pfm v6 * remove wasmd and cosmwasm and delete store key * add deployment * linting * refactor: remove token factory * remove tokenfactory proto * fix channel capability issue, and remove wasm from Dockerfile * lint --------- Co-authored-by: Jacob Gadikian Co-authored-by: Tuan Tran Co-authored-by: Joe Bowman --- Dockerfile | 16 +- Makefile | 8 +- app/keepers/keepers.go | 12 - app/keepers/keys.go | 2 - app/modules.go | 9 - .../v1beta1/authorityMetadata.proto | 16 - .../tokenfactory/v1beta1/genesis.proto | 32 - .../tokenfactory/v1beta1/params.proto | 16 - .../tokenfactory/v1beta1/query.proto | 66 - .../quicksilver/tokenfactory/v1beta1/tx.proto | 106 - x/interchainquery/types/query.pb.go | 2 +- x/interchainstaking/keeper/receipt.go | 14 +- x/tokenfactory/README.md | 155 -- x/tokenfactory/client/cli/query.go | 117 - x/tokenfactory/client/cli/tx.go | 188 -- x/tokenfactory/keeper/admins.go | 50 - x/tokenfactory/keeper/admins_test.go | 406 --- x/tokenfactory/keeper/bankactions.go | 73 - x/tokenfactory/keeper/createdenom.go | 86 - x/tokenfactory/keeper/createdenom_test.go | 162 -- x/tokenfactory/keeper/creators.go | 27 - x/tokenfactory/keeper/genesis.go | 58 - x/tokenfactory/keeper/genesis_test.go | 59 - x/tokenfactory/keeper/grpc_query.go | 35 - x/tokenfactory/keeper/keeper.go | 81 - x/tokenfactory/keeper/keeper_test.go | 134 - x/tokenfactory/keeper/msg_server.go | 191 -- x/tokenfactory/keeper/msg_server_test.go | 267 -- x/tokenfactory/keeper/params.go | 18 - x/tokenfactory/module.go | 207 -- x/tokenfactory/simulation/genesis.go | 35 - x/tokenfactory/simulation/operations.go | 379 --- x/tokenfactory/types/authorityMetadata.go | 15 - x/tokenfactory/types/authorityMetadata.pb.go | 349 --- x/tokenfactory/types/codec.go | 43 - x/tokenfactory/types/denoms.go | 85 - x/tokenfactory/types/denoms_test.go | 133 - x/tokenfactory/types/errors.go | 22 - x/tokenfactory/types/events.go | 18 - x/tokenfactory/types/expected_keepers.go | 38 - x/tokenfactory/types/genesis.go | 48 - x/tokenfactory/types/genesis.pb.go | 649 ----- x/tokenfactory/types/genesis_test.go | 139 - x/tokenfactory/types/keys.go | 49 - x/tokenfactory/types/msgs.go | 248 -- x/tokenfactory/types/msgs_test.go | 402 --- x/tokenfactory/types/params.go | 59 - x/tokenfactory/types/params.pb.go | 339 --- x/tokenfactory/types/query.pb.go | 1331 ---------- x/tokenfactory/types/query.pb.gw.go | 355 --- x/tokenfactory/types/tx.pb.go | 2238 ----------------- 51 files changed, 14 insertions(+), 9573 deletions(-) delete mode 100644 proto/quicksilver/tokenfactory/v1beta1/authorityMetadata.proto delete mode 100644 proto/quicksilver/tokenfactory/v1beta1/genesis.proto delete mode 100644 proto/quicksilver/tokenfactory/v1beta1/params.proto delete mode 100644 proto/quicksilver/tokenfactory/v1beta1/query.proto delete mode 100644 proto/quicksilver/tokenfactory/v1beta1/tx.proto delete mode 100644 x/tokenfactory/README.md delete mode 100644 x/tokenfactory/client/cli/query.go delete mode 100644 x/tokenfactory/client/cli/tx.go delete mode 100644 x/tokenfactory/keeper/admins.go delete mode 100644 x/tokenfactory/keeper/admins_test.go delete mode 100644 x/tokenfactory/keeper/bankactions.go delete mode 100644 x/tokenfactory/keeper/createdenom.go delete mode 100644 x/tokenfactory/keeper/createdenom_test.go delete mode 100644 x/tokenfactory/keeper/creators.go delete mode 100644 x/tokenfactory/keeper/genesis.go delete mode 100644 x/tokenfactory/keeper/genesis_test.go delete mode 100644 x/tokenfactory/keeper/grpc_query.go delete mode 100644 x/tokenfactory/keeper/keeper.go delete mode 100644 x/tokenfactory/keeper/keeper_test.go delete mode 100644 x/tokenfactory/keeper/msg_server.go delete mode 100644 x/tokenfactory/keeper/msg_server_test.go delete mode 100644 x/tokenfactory/keeper/params.go delete mode 100644 x/tokenfactory/module.go delete mode 100644 x/tokenfactory/simulation/genesis.go delete mode 100644 x/tokenfactory/simulation/operations.go delete mode 100644 x/tokenfactory/types/authorityMetadata.go delete mode 100644 x/tokenfactory/types/authorityMetadata.pb.go delete mode 100644 x/tokenfactory/types/codec.go delete mode 100644 x/tokenfactory/types/denoms.go delete mode 100644 x/tokenfactory/types/denoms_test.go delete mode 100644 x/tokenfactory/types/errors.go delete mode 100644 x/tokenfactory/types/events.go delete mode 100644 x/tokenfactory/types/expected_keepers.go delete mode 100644 x/tokenfactory/types/genesis.go delete mode 100644 x/tokenfactory/types/genesis.pb.go delete mode 100644 x/tokenfactory/types/genesis_test.go delete mode 100644 x/tokenfactory/types/keys.go delete mode 100644 x/tokenfactory/types/msgs.go delete mode 100644 x/tokenfactory/types/msgs_test.go delete mode 100644 x/tokenfactory/types/params.go delete mode 100644 x/tokenfactory/types/params.pb.go delete mode 100644 x/tokenfactory/types/query.pb.go delete mode 100644 x/tokenfactory/types/query.pb.gw.go delete mode 100644 x/tokenfactory/types/tx.pb.go diff --git a/Dockerfile b/Dockerfile index a7e40bb30..deada6aea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.2-alpine3.18 AS builder +FROM golang:1.22.2-alpine3.19 AS builder RUN apk add --no-cache git musl-dev openssl-dev linux-headers ca-certificates build-base WORKDIR /src/app/ @@ -9,12 +9,12 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ go mod download -RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \ - wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ - -O /lib/libwasmvm_muslc.a && \ - # verify checksum - wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ - sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) +#RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \ +# wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ +# -O /lib/libwasmvm_muslc.a && \ +# # verify checksum +# wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ +# sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) COPY . . RUN --mount=type=cache,target=/root/.cache/go-build \ @@ -22,7 +22,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ LINK_STATICALLY=true make build # Add to a distroless container -FROM alpine:3.18 +FROM alpine:3.19 COPY --from=builder /src/app/build/quicksilverd /usr/local/bin/quicksilverd RUN adduser -S -h /quicksilver -D quicksilver -u 1000 USER quicksilver diff --git a/Makefile b/Makefile index ca5c07ec1..aa189b913 100755 --- a/Makefile +++ b/Makefile @@ -505,10 +505,10 @@ proto-breaking-check: bufbuild/buf:$(BUF_VERSION) breaking --against '.git#branch=develop' @echo "✅ Completed protobuf breaking check!" -proto-setup: - @echo "🤖 Setting up protobuf environment..." - @$(DOCKER) build --rm --tag quicksilver-proto:latest --file proto/Dockerfile . - @echo "✅ Setup protobuf environment!" +# proto-setup: +# @echo "🤖 Setting up protobuf environment..." +# @$(DOCKER) build --rm --tag quicksilver-proto:latest --file proto/Dockerfile . +# @echo "✅ Setup protobuf environment!" ### Other tools .PHONY: hermes-build diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 7f4a56cee..b19a59308 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -78,8 +78,6 @@ import ( participationrewardskeeper "github.com/quicksilver-zone/quicksilver/x/participationrewards/keeper" participationrewardstypes "github.com/quicksilver-zone/quicksilver/x/participationrewards/types" supplykeeper "github.com/quicksilver-zone/quicksilver/x/supply/keeper" - tokenfactorykeeper "github.com/quicksilver-zone/quicksilver/x/tokenfactory/keeper" - tokenfactorytypes "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" ) type AppKeepers struct { @@ -114,7 +112,6 @@ type AppKeepers struct { InterchainQueryKeeper interchainquerykeeper.Keeper ParticipationRewardsKeeper *participationrewardskeeper.Keeper AirdropKeeper *airdropkeeper.Keeper - TokenFactoryKeeper tokenfactorykeeper.Keeper SupplyKeeper supplykeeper.Keeper // IBC keepers @@ -426,14 +423,6 @@ func (appKeepers *AppKeepers) InitKeepers( panic(err) } - appKeepers.TokenFactoryKeeper = tokenfactorykeeper.NewKeeper( - appKeepers.keys[tokenfactorytypes.StoreKey], - appKeepers.GetSubspace(tokenfactorytypes.ModuleName), - appKeepers.AccountKeeper, - appKeepers.BankKeeper.WithMintCoinsRestriction(tokenfactorytypes.NewTokenFactoryDenomMintCoinsRestriction()), - appKeepers.DistrKeeper, - ) - // Quicksilver Keepers appKeepers.EpochsKeeper = epochskeeper.NewKeeper(appCodec, appKeepers.keys[epochstypes.StoreKey]) appKeepers.ParticipationRewardsKeeper.SetEpochsKeeper(appKeepers.EpochsKeeper) @@ -547,7 +536,6 @@ func (*AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *cod paramsKeeper.Subspace(interchainquerytypes.ModuleName) paramsKeeper.Subspace(participationrewardstypes.ModuleName) paramsKeeper.Subspace(airdroptypes.ModuleName) - paramsKeeper.Subspace(tokenfactorytypes.ModuleName) return paramsKeeper } diff --git a/app/keepers/keys.go b/app/keepers/keys.go index c5a884a4d..56d3e5a70 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -31,7 +31,6 @@ import ( minttypes "github.com/quicksilver-zone/quicksilver/x/mint/types" participationrewardstypes "github.com/quicksilver-zone/quicksilver/x/participationrewards/types" supplytypes "github.com/quicksilver-zone/quicksilver/x/supply/types" - tokenfactorytypes "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" ) // TODO: We need to automate this, by bundling with a module struct... @@ -64,7 +63,6 @@ func KVStoreKeys() []string { interchainquerytypes.StoreKey, participationrewardstypes.StoreKey, airdroptypes.StoreKey, - tokenfactorytypes.StoreKey, supplytypes.StoreKey, } } diff --git a/app/modules.go b/app/modules.go index dadbd655d..da72dbb27 100644 --- a/app/modules.go +++ b/app/modules.go @@ -67,8 +67,6 @@ import ( participationrewardstypes "github.com/quicksilver-zone/quicksilver/x/participationrewards/types" "github.com/quicksilver-zone/quicksilver/x/supply" supplytypes "github.com/quicksilver-zone/quicksilver/x/supply/types" - "github.com/quicksilver-zone/quicksilver/x/tokenfactory" - tokenfactorytypes "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" ) var ( @@ -108,7 +106,6 @@ var ( interchainquery.AppModuleBasic{}, participationrewards.AppModuleBasic{}, airdrop.AppModuleBasic{}, - tokenfactory.AppModuleBasic{}, supply.AppModuleBasic{}, ) @@ -129,7 +126,6 @@ var ( participationrewardstypes.ModuleName: nil, airdroptypes.ModuleName: nil, packetforwardtypes.ModuleName: nil, - tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } ) @@ -175,7 +171,6 @@ func appModules( interchainquery.NewAppModule(appCodec, app.InterchainQueryKeeper), participationrewards.NewAppModule(appCodec, app.ParticipationRewardsKeeper), airdrop.NewAppModule(appCodec, app.AirdropKeeper), - tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper), supply.NewAppModule(appCodec, app.SupplyKeeper), } } @@ -214,7 +209,6 @@ func simulationModules( interchainquery.NewAppModule(appCodec, app.InterchainQueryKeeper), participationrewards.NewAppModule(appCodec, app.ParticipationRewardsKeeper), airdrop.NewAppModule(appCodec, app.AirdropKeeper), - tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper), // supply.NewAppModule(appCodec, app.SupplyKeeper), } } @@ -260,7 +254,6 @@ func orderBeginBlockers() []string { feegrant.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, - tokenfactorytypes.ModuleName, supplytypes.ModuleName, } } @@ -303,7 +296,6 @@ func orderEndBlockers() []string { interchainstakingtypes.ModuleName, participationrewardstypes.ModuleName, airdroptypes.ModuleName, - tokenfactorytypes.ModuleName, supplytypes.ModuleName, // currently no-op. } @@ -346,7 +338,6 @@ func orderInitBlockers() []string { interchainquerytypes.ModuleName, participationrewardstypes.ModuleName, airdroptypes.ModuleName, - tokenfactorytypes.ModuleName, supplytypes.ModuleName, // NOTE: crisis module must go at the end to check for invariants on each module crisistypes.ModuleName, diff --git a/proto/quicksilver/tokenfactory/v1beta1/authorityMetadata.proto b/proto/quicksilver/tokenfactory/v1beta1/authorityMetadata.proto deleted file mode 100644 index 421c9f3b4..000000000 --- a/proto/quicksilver/tokenfactory/v1beta1/authorityMetadata.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; -package quicksilver.tokenfactory.v1beta1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types"; - -// DenomAuthorityMetadata specifies metadata for addresses 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. -message DenomAuthorityMetadata { - option (gogoproto.equal) = true; - - // Can be empty for no admin, or a valid quicksilver address - string admin = 1 [(gogoproto.moretags) = "yaml:\"admin\""]; -} diff --git a/proto/quicksilver/tokenfactory/v1beta1/genesis.proto b/proto/quicksilver/tokenfactory/v1beta1/genesis.proto deleted file mode 100644 index 82d408082..000000000 --- a/proto/quicksilver/tokenfactory/v1beta1/genesis.proto +++ /dev/null @@ -1,32 +0,0 @@ -syntax = "proto3"; -package quicksilver.tokenfactory.v1beta1; - -import "gogoproto/gogo.proto"; -import "quicksilver/tokenfactory/v1beta1/authorityMetadata.proto"; -import "quicksilver/tokenfactory/v1beta1/params.proto"; - -option go_package = "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types"; - -// GenesisState defines the tokenfactory module's genesis state. -message GenesisState { - // params defines the paramaters of the module. - Params params = 1 [(gogoproto.nullable) = false]; - - repeated GenesisDenom factory_denoms = 2 [ - (gogoproto.moretags) = "yaml:\"factory_denoms\"", - (gogoproto.nullable) = false - ]; -} - -// GenesisDenom defines a tokenfactory denom that is defined within genesis -// state. The structure contains DenomAuthorityMetadata which defines the -// denom's admin. -message GenesisDenom { - option (gogoproto.equal) = true; - - string denom = 1 [(gogoproto.moretags) = "yaml:\"denom\""]; - DenomAuthorityMetadata authority_metadata = 2 [ - (gogoproto.moretags) = "yaml:\"authority_metadata\"", - (gogoproto.nullable) = false - ]; -} diff --git a/proto/quicksilver/tokenfactory/v1beta1/params.proto b/proto/quicksilver/tokenfactory/v1beta1/params.proto deleted file mode 100644 index 8d1fd0636..000000000 --- a/proto/quicksilver/tokenfactory/v1beta1/params.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; -package quicksilver.tokenfactory.v1beta1; - -import "cosmos/base/v1beta1/coin.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types"; - -// Params defines the parameters for the tokenfactory module. -message Params { - repeated cosmos.base.v1beta1.Coin denom_creation_fee = 1 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"denom_creation_fee\"", - (gogoproto.nullable) = false - ]; -} diff --git a/proto/quicksilver/tokenfactory/v1beta1/query.proto b/proto/quicksilver/tokenfactory/v1beta1/query.proto deleted file mode 100644 index d66716c76..000000000 --- a/proto/quicksilver/tokenfactory/v1beta1/query.proto +++ /dev/null @@ -1,66 +0,0 @@ -syntax = "proto3"; -package quicksilver.tokenfactory.v1beta1; - -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "quicksilver/tokenfactory/v1beta1/authorityMetadata.proto"; -import "quicksilver/tokenfactory/v1beta1/params.proto"; - -option go_package = "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types"; - -// Query defines the gRPC querier service. -service Query { - // Params defines a gRPC query method that returns the tokenfactory module's - // parameters. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/quicksilver/tokenfactory/v1beta1/params"; - } - - // DenomAuthorityMetadata defines a gRPC query method for fetching - // DenomAuthorityMetadata for a particular denom. - rpc DenomAuthorityMetadata(QueryDenomAuthorityMetadataRequest) returns (QueryDenomAuthorityMetadataResponse) { - option (google.api.http).get = "/quicksilver/tokenfactory/v1beta1/denoms/{denom}/authority_metadata"; - } - - // DenomsFromCreator defines a gRPC query method for fetching all - // denominations created by a specific admin/creator. - rpc DenomsFromCreator(QueryDenomsFromCreatorRequest) returns (QueryDenomsFromCreatorResponse) { - option (google.api.http).get = "/quicksilver/tokenfactory/v1beta1/denoms_from_creator/{creator}"; - } -} - -// QueryParamsRequest is the request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is the response type for the Query/Params RPC method. -message QueryParamsResponse { - // params defines the parameters of the module. - Params params = 1 [(gogoproto.nullable) = false]; -} - -// QueryDenomAuthorityMetadataRequest defines the request structure for the -// DenomAuthorityMetadata gRPC query. -message QueryDenomAuthorityMetadataRequest { - string denom = 1 [(gogoproto.moretags) = "yaml:\"denom\""]; -} - -// QueryDenomAuthorityMetadataResponse defines the response structure for the -// DenomAuthorityMetadata gRPC query. -message QueryDenomAuthorityMetadataResponse { - DenomAuthorityMetadata authority_metadata = 1 [ - (gogoproto.moretags) = "yaml:\"authority_metadata\"", - (gogoproto.nullable) = false - ]; -} - -// QueryDenomsFromCreatorRequest defines the request structure for the -// DenomsFromCreator gRPC query. -message QueryDenomsFromCreatorRequest { - string creator = 1 [(gogoproto.moretags) = "yaml:\"creator\""]; -} - -// QueryDenomsFromCreatorRequest defines the response structure for the -// DenomsFromCreator gRPC query. -message QueryDenomsFromCreatorResponse { - repeated string denoms = 1 [(gogoproto.moretags) = "yaml:\"denoms\""]; -} diff --git a/proto/quicksilver/tokenfactory/v1beta1/tx.proto b/proto/quicksilver/tokenfactory/v1beta1/tx.proto deleted file mode 100644 index 5dd773160..000000000 --- a/proto/quicksilver/tokenfactory/v1beta1/tx.proto +++ /dev/null @@ -1,106 +0,0 @@ -syntax = "proto3"; -package quicksilver.tokenfactory.v1beta1; - -import "cosmos/bank/v1beta1/bank.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types"; - -// Msg defines the tokefactory module's gRPC message service. -service Msg { - rpc CreateDenom(MsgCreateDenom) returns (MsgCreateDenomResponse); - rpc Mint(MsgMint) returns (MsgMintResponse); - rpc Burn(MsgBurn) returns (MsgBurnResponse); - rpc ChangeAdmin(MsgChangeAdmin) returns (MsgChangeAdminResponse); - rpc SetDenomMetadata(MsgSetDenomMetadata) returns (MsgSetDenomMetadataResponse); - - // ForceTransfer is deactivated for now because we need to think through edge - // cases rpc ForceTransfer(MsgForceTransfer) returns - // (MsgForceTransferResponse); -} - -// MsgCreateDenom defines the message structure for the CreateDenom gRPC service -// method. It allows an account to create a new denom. It requires a sender -// address and a sub denomination. The (sender_address, sub_denomination) tuple -// must be unique and cannot be re-used. -// -// The resulting denom created is defined as -// . The resulting denom's admin is -// originally set to be the creator, but this can be changed later. The token -// denom does not indicate the current admin. -message MsgCreateDenom { - string sender = 1 [(gogoproto.moretags) = "yaml:\"sender\""]; - // subdenom can be up to 44 "alphanumeric" characters long. - string subdenom = 2 [(gogoproto.moretags) = "yaml:\"subdenom\""]; -} - -// MsgCreateDenomResponse is the return value of MsgCreateDenom -// It returns the full string of the newly created denom -message MsgCreateDenomResponse { - string new_token_denom = 1 [(gogoproto.moretags) = "yaml:\"new_token_denom\""]; -} - -// MsgMint is the sdk.Msg type for allowing an admin account to mint -// more of a token. For now, we only support minting to the sender account -message MsgMint { - string sender = 1 [(gogoproto.moretags) = "yaml:\"sender\""]; - cosmos.base.v1beta1.Coin amount = 2 [ - (gogoproto.moretags) = "yaml:\"amount\"", - (gogoproto.nullable) = false - ]; -} - -message MsgMintResponse {} - -// MsgBurn is the sdk.Msg type for allowing an admin account to burn -// a token. For now, we only support burning from the sender account. -message MsgBurn { - string sender = 1 [(gogoproto.moretags) = "yaml:\"sender\""]; - cosmos.base.v1beta1.Coin amount = 2 [ - (gogoproto.moretags) = "yaml:\"amount\"", - (gogoproto.nullable) = false - ]; -} - -message MsgBurnResponse {} - -// MsgChangeAdmin is the sdk.Msg type for allowing an admin account to reassign -// adminship of a denom to a new account -message MsgChangeAdmin { - string sender = 1 [(gogoproto.moretags) = "yaml:\"sender\""]; - string denom = 2 [(gogoproto.moretags) = "yaml:\"denom\""]; - string new_admin = 3 [(gogoproto.moretags) = "yaml:\"new_admin\""]; -} - -// MsgChangeAdminResponse defines the response structure for an executed -// MsgChangeAdmin message. -message MsgChangeAdminResponse {} - -// message MsgForceTransfer { -// string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; -// cosmos.base.v1beta1.Coin amount = 2 [ -// (gogoproto.moretags) = "yaml:\"amount\"", -// (gogoproto.nullable) = false -// ]; -// string transferFromAddress = 3 -// [ (gogoproto.moretags) = "yaml:\"transfer_from_address\"" ]; -// string transferToAddress = 4 -// [ (gogoproto.moretags) = "yaml:\"transfer_to_address\"" ]; -// } - -// message MsgForceTransferResponse {} - -// MsgSetDenomMetadata is the sdk.Msg type for allowing an admin account to set -// the denom's bank metadata -message MsgSetDenomMetadata { - string sender = 1 [(gogoproto.moretags) = "yaml:\"sender\""]; - cosmos.bank.v1beta1.Metadata metadata = 2 [ - (gogoproto.moretags) = "yaml:\"metadata\"", - (gogoproto.nullable) = false - ]; -} - -// MsgSetDenomMetadataResponse defines the response structure for an executed -// MsgSetDenomMetadata message. -message MsgSetDenomMetadataResponse {} diff --git a/x/interchainquery/types/query.pb.go b/x/interchainquery/types/query.pb.go index a3d893d72..1b7b69744 100644 --- a/x/interchainquery/types/query.pb.go +++ b/x/interchainquery/types/query.pb.go @@ -10,7 +10,7 @@ import ( query "github.com/cosmos/cosmos-sdk/types/query" tx "github.com/cosmos/cosmos-sdk/types/tx" _ "github.com/cosmos/gogoproto/gogoproto" - _07_tendermint "github.com/cosmos/ibc-go/v6/modules/light-clients/07-tendermint" + _07_tendermint "github.com/cosmos/ibc-go/v6/modules/light-clients/07-tendermint/types" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" types1 "github.com/tendermint/tendermint/proto/tendermint/types" diff --git a/x/interchainstaking/keeper/receipt.go b/x/interchainstaking/keeper/receipt.go index 137301dcf..9e2191ad9 100644 --- a/x/interchainstaking/keeper/receipt.go +++ b/x/interchainstaking/keeper/receipt.go @@ -7,8 +7,6 @@ import ( "github.com/gogo/protobuf/proto" - sdkioerrors "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" @@ -18,7 +16,6 @@ import ( transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v6/modules/core/24-host" "github.com/quicksilver-zone/quicksilver/utils/addressutils" "github.com/quicksilver-zone/quicksilver/x/interchainstaking/types" @@ -268,15 +265,6 @@ func ProdSubmitTx(ctx sdk.Context, k *Keeper, msgs []sdk.Msg, account *types.ICA if err != nil { return err } - channelID, found := k.ICAControllerKeeper.GetActiveChannelID(ctx, connectionID, portID) - if !found { - return sdkioerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s in submittx", portID) - } - - chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(portID, channelID)) - if !found { - return sdkioerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") - } chunkSize := int(messagesPerTx) if chunkSize < 1 { @@ -317,7 +305,7 @@ func ProdSubmitTx(ctx sdk.Context, k *Keeper, msgs []sdk.Msg, account *types.ICA Memo: memo, } - _, err = k.ICAControllerKeeper.SendTx(ctx, chanCap, connectionID, portID, packetData, timeoutTimestamp) // nolint:staticcheck + _, err = k.ICAControllerKeeper.SendTx(ctx, nil, connectionID, portID, packetData, timeoutTimestamp) // nolint:staticcheck if err != nil { return err } diff --git a/x/tokenfactory/README.md b/x/tokenfactory/README.md deleted file mode 100644 index 2c940c349..000000000 --- a/x/tokenfactory/README.md +++ /dev/null @@ -1,155 +0,0 @@ -# Token Factory - -The tokenfactory module allows any account to create a new token with -the name `factory/{creator address}/{subdenom}`. Because tokens are -namespaced by creator address, this allows token minting to be -permissionless, due to not needing to resolve name collisions. A single -account can create multiple denoms, by providing a unique subdenom for each -created denom. Once a denom is created, the original creator is given -"admin" privileges over the asset. This allows them to: - -- Mint their denom to any account -- Burn their denom from any account -- Create a transfer of their denom between any two accounts -- Change the admin. In the future, more admin capabilities may be added. Admins - can choose to share admin privileges with other accounts using the authz - module. The `ChangeAdmin` functionality, allows changing the master admin - account, or even setting it to `""`, meaning no account has admin privileges - of the asset. - -## Messages - -### CreateDenom - -Creates a denom of `factory/{creator address}/{subdenom}` given the denom creator -address and the subdenom. Subdenoms can contain `[a-zA-Z0-9./]`. - -```protobuf -message MsgCreateDenom { - string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; - string subdenom = 2 [ (gogoproto.moretags) = "yaml:\"subdenom\"" ]; -} -``` - -**State Modifications:** - -- Fund community pool with the denom creation fee from the creator address, set - in `Params`. -- Set `DenomMetaData` via bank keeper. -- Set `AuthorityMetadata` for the given denom to store the admin for the created - denom `factory/{creator address}/{subdenom}`. Admin is automatically set as the - Msg sender. -- Add denom to the `CreatorPrefixStore`, where a state of denoms created per - creator is kept. - -### Mint - -Minting of a specific denom is only allowed for the current admin. -Note, the current admin is defaulted to the creator of the denom. - -```protobuf -message MsgMint { - string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; - cosmos.base.v1beta1.Coin amount = 2 [ - (gogoproto.moretags) = "yaml:\"amount\"", - (gogoproto.nullable) = false - ]; -} -``` - -**State Modifications:** - -- Safety check the following - - Check that the denom minting is created via `tokenfactory` module - - Check that the sender of the message is the admin of the denom -- Mint designated amount of tokens for the denom via `bank` module - -### Burn - -Burning of a specific denom is only allowed for the current admin. -Note, the current admin is defaulted to the creator of the denom. - -```protobuf -message MsgBurn { - string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; - cosmos.base.v1beta1.Coin amount = 2 [ - (gogoproto.moretags) = "yaml:\"amount\"", - (gogoproto.nullable) = false - ]; -} -``` - -**State Modifications:** - -- Saftey check the following - - Check that the denom minting is created via `tokenfactory` module - - Check that the sender of the message is the admin of the denom -- Burn designated amount of tokens for the denom via `bank` module - -### ChangeAdmin - -Change the admin of a denom. Note, this is only allowed to be called by the current admin of the denom. - -```protobuf -message MsgChangeAdmin { - string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; - string denom = 2 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; - string newAdmin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ]; -} -``` - -### SetDenomMetadata - -Setting of metadata for a specific denom is only allowed for the admin of the denom. -It allows the overwriting of the denom metadata in the bank module. - -```protobuf -message MsgChangeAdmin { - string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; - cosmos.bank.v1beta1.Metadata metadata = 2 [ (gogoproto.moretags) = "yaml:\"metadata\"", (gogoproto.nullable) = false ]; -} -``` - -**State Modifications:** - -- Check that sender of the message is the admin of denom -- Modify `AuthorityMetadata` state entry to change the admin of the denom - -## Expectations from the chain - -The chain's bech32 prefix for addresses can be at most 16 characters long. - -This comes from denoms having a 128 byte maximum length, enforced from the SDK, -and us setting longest_subdenom to be 44 bytes. - -A token factory token's denom is: `factory/{creator address}/{subdenom}` - -Splitting up into sub-components, this has: - -- `len(factory) = 7` -- `2 * len("/") = 2` -- `len(longest_subdenom)` -- `len(creator_address) = len(bech32(longest_addr_length, chain_addr_prefix))`. - -Longest addr length at the moment is `32 bytes`. Due to SDK error correction -settings, this means `len(bech32(32, chain_addr_prefix)) = len(chain_addr_prefix) + 1 + 58`. -Adding this all, we have a total length constraint of `128 = 7 + 2 + len(longest_subdenom) + len(longest_chain_addr_prefix) + 1 + 58`. -Therefore `len(longest_subdenom) + len(longest_chain_addr_prefix) = 128 - (7 + 2 + 1 + 58) = 60`. - -The choice between how we standardized the split these 60 bytes between maxes -from longest_subdenom and longest_chain_addr_prefix is somewhat arbitrary. -Considerations going into this: - -- Per [BIP-0173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32) - the technically longest HRP for a 32 byte address ('data field') is 31 bytes. - (Comes from encode(data) = 59 bytes, and max length = 90 bytes) -- subdenom should be at least 32 bytes so hashes can go into it -- longer subdenoms are very helpful for creating human readable denoms -- chain addresses should prefer being smaller. The longest HRP in cosmos to date is 11 bytes. (`persistence`) - -For explicitness, its currently set to `len(longest_subdenom) = 44` and `len(longest_chain_addr_prefix) = 16`. - -Please note, if the SDK increases the maximum length of a denom from 128 bytes, -these caps should increase. - -So please don't make code rely on these max lengths for parsing. diff --git a/x/tokenfactory/client/cli/query.go b/x/tokenfactory/client/cli/query.go deleted file mode 100644 index 90ee7b298..000000000 --- a/x/tokenfactory/client/cli/query.go +++ /dev/null @@ -1,117 +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/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -// GetQueryCmd returns the cli query commands for this module. -func GetQueryCmd() *cobra.Command { - // Group tokenfactory 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( - GetParams(), - GetCmdDenomAuthorityMetadata(), - GetCmdDenomsFromCreator(), - ) - - return cmd -} - -// GetParams returns the params for the module. -func GetParams() *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 -} - -// GetCmdDenomAuthorityMetadata returns the authority metadata for a queried denom. -func GetCmdDenomAuthorityMetadata() *cobra.Command { - cmd := &cobra.Command{ - Use: "denom-authority-metadata [denom] [flags]", - Short: "Get the authority metadata for a specific 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.DenomAuthorityMetadata(cmd.Context(), &types.QueryDenomAuthorityMetadataRequest{ - Denom: args[0], - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -// GetCmdDenomsFromCreator a command to get a list of all tokens created by a specific creator address. -func GetCmdDenomsFromCreator() *cobra.Command { - cmd := &cobra.Command{ - Use: "denoms-from-creator [creator address] [flags]", - Short: "Returns a list of all tokens created by a specific 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.DenomsFromCreator(cmd.Context(), &types.QueryDenomsFromCreatorRequest{ - Creator: args[0], - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/tokenfactory/client/cli/tx.go b/x/tokenfactory/client/cli/tx.go deleted file mode 100644 index bf19ba9d2..000000000 --- a/x/tokenfactory/client/cli/tx.go +++ /dev/null @@ -1,188 +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/quicksilver-zone/quicksilver/x/tokenfactory/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, - } - - cmd.AddCommand( - NewCreateDenomCmd(), - NewMintCmd(), - NewBurnCmd(), - // NewForceTransferCmd(), - NewChangeAdminCmd(), - ) - - return cmd -} - -// NewCreateDenomCmd broadcast MsgCreateDenom. -func NewCreateDenomCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "create-denom [subdenom] [flags]", - Short: "create a new denom from an account", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - - msg := types.NewMsgCreateDenom( - clientCtx.GetFromAddress().String(), - args[0], - ) - - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} - -// NewMintCmd broadcast MsgMint. -func NewMintCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "mint [amount] [flags]", - Short: "Mint a denom to an address. Must have admin authority to do so.", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - - amount, err := sdk.ParseCoinNormalized(args[0]) - if err != nil { - return err - } - - msg := types.NewMsgMint( - clientCtx.GetFromAddress().String(), - amount, - ) - - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} - -// NewBurnCmd broadcast MsgBurn. -func NewBurnCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "burn [amount] [flags]", - Short: "Burn tokens from an address. Must have admin authority to do so.", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - - amount, err := sdk.ParseCoinNormalized(args[0]) - if err != nil { - return err - } - - msg := types.NewMsgBurn( - clientCtx.GetFromAddress().String(), - amount, - ) - - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} - -// // NewForceTransferCmd broadcast MsgForceTransfer -// func NewForceTransferCmd() *cobra.Command { -// cmd := &cobra.Command{ -// Use: "force-transfer [amount] [transfer-from-address] [transfer-to-address] [flags]", -// Short: "Force transfer tokens from one address to another address. Must have admin authority to do so.", -// Args: cobra.ExactArgs(3), -// RunE: func(cmd *cobra.Command, args []string) error { -// clientCtx, err := client.GetClientTxContext(cmd) -// if err != nil { -// return err -// } - -// txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - -// amount, err := sdk.ParseCoinNormalized(args[0]) -// if err != nil { -// return err -// } - -// msg := types.NewMsgForceTransfer( -// clientCtx.GetFromAddress().String(), -// amount, -// args[1], -// args[2], -// ) - -// return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) -// }, -// } - -// flags.AddTxFlagsToCmd(cmd) -// return cmd -// } - -// NewChangeAdminCmd broadcast MsgChangeAdmin. -func NewChangeAdminCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "change-admin [denom] [new-admin-address] [flags]", - Short: "Changes the admin address for a factory-created 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 - } - - txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - - msg := types.NewMsgChangeAdmin( - clientCtx.GetFromAddress().String(), - args[0], - args[1], - ) - - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} diff --git a/x/tokenfactory/keeper/admins.go b/x/tokenfactory/keeper/admins.go deleted file mode 100644 index 86b1fae3b..000000000 --- a/x/tokenfactory/keeper/admins.go +++ /dev/null @@ -1,50 +0,0 @@ -package keeper - -import ( - "github.com/gogo/protobuf/proto" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -// GetAuthorityMetadata returns the authority metadata for a specific denom. -func (k Keeper) GetAuthorityMetadata(ctx sdk.Context, denom string) (types.DenomAuthorityMetadata, error) { - bz := k.GetDenomPrefixStore(ctx, denom).Get([]byte(types.DenomAuthorityMetadataKey)) - - metadata := types.DenomAuthorityMetadata{} - err := proto.Unmarshal(bz, &metadata) - if err != nil { - return types.DenomAuthorityMetadata{}, err - } - return metadata, nil -} - -// setAuthorityMetadata stores authority metadata for a specific denom. -func (k Keeper) setAuthorityMetadata(ctx sdk.Context, denom string, metadata types.DenomAuthorityMetadata) error { - err := metadata.Validate() - if err != nil { - return err - } - - store := k.GetDenomPrefixStore(ctx, denom) - - bz, err := proto.Marshal(&metadata) - if err != nil { - return err - } - - store.Set([]byte(types.DenomAuthorityMetadataKey), bz) - return nil -} - -func (k Keeper) setAdmin(ctx sdk.Context, denom, admin string) error { - metadata, err := k.GetAuthorityMetadata(ctx, denom) - if err != nil { - return err - } - - metadata.Admin = admin - - return k.setAuthorityMetadata(ctx, denom, metadata) -} diff --git a/x/tokenfactory/keeper/admins_test.go b/x/tokenfactory/keeper/admins_test.go deleted file mode 100644 index b08ca9407..000000000 --- a/x/tokenfactory/keeper/admins_test.go +++ /dev/null @@ -1,406 +0,0 @@ -package keeper_test - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -func (suite *KeeperTestSuite) TestAdminMsgs() { - addr0bal := int64(0) - addr1bal := int64(0) - - bankKeeper := suite.App.BankKeeper - - suite.CreateDefaultDenom() - // Make sure that the admin is set correctly - queryRes, err := suite.queryClient.DenomAuthorityMetadata(suite.Ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ - Denom: suite.defaultDenom, - }) - suite.Require().NoError(err) - suite.Require().Equal(suite.TestAccs[0].String(), queryRes.AuthorityMetadata.Admin) - - // Test minting to admins own account - _, err = suite.msgServer.Mint(sdk.WrapSDKContext(suite.Ctx), types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(suite.defaultDenom, 10))) - addr0bal += 10 - suite.Require().NoError(err) - suite.Require().True(bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], suite.defaultDenom).Amount.Int64() == addr0bal, bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], suite.defaultDenom)) - - // // Test force transferring - // _, err = suite.msgServer.ForceTransfer(sdk.WrapSDKContext(suite.Ctx), types.NewMsgForceTransfer(suite.TestAccs[0].String(), sdk.NewInt64Coin(denom, 5), suite.TestAccs[1].String(), suite.TestAccs[0].String())) - // suite.NoError(err) - // suite.True(bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], denom).IsEqual(sdk.NewInt64Coin(denom, 15))) - // suite.True(bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[1], denom).IsEqual(sdk.NewInt64Coin(denom, 5))) - - // Test burning from own account - _, err = suite.msgServer.Burn(sdk.WrapSDKContext(suite.Ctx), types.NewMsgBurn(suite.TestAccs[0].String(), sdk.NewInt64Coin(suite.defaultDenom, 5))) - suite.Require().NoError(err) - suite.Require().True(bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[1], suite.defaultDenom).Amount.Int64() == addr1bal) - - // Test Change Admin - _, err = suite.msgServer.ChangeAdmin(sdk.WrapSDKContext(suite.Ctx), types.NewMsgChangeAdmin(suite.TestAccs[0].String(), suite.defaultDenom, suite.TestAccs[1].String())) - suite.Require().NoError(err) - queryRes, err = suite.queryClient.DenomAuthorityMetadata(suite.Ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ - Denom: suite.defaultDenom, - }) - suite.Require().NoError(err) - suite.Require().Equal(suite.TestAccs[1].String(), queryRes.AuthorityMetadata.Admin) - - // Make sure old admin can no longer do actions - _, err = suite.msgServer.Burn(sdk.WrapSDKContext(suite.Ctx), types.NewMsgBurn(suite.TestAccs[0].String(), sdk.NewInt64Coin(suite.defaultDenom, 5))) - suite.Require().Error(err) - - // Make sure the new admin works - _, err = suite.msgServer.Mint(sdk.WrapSDKContext(suite.Ctx), types.NewMsgMint(suite.TestAccs[1].String(), sdk.NewInt64Coin(suite.defaultDenom, 5))) - addr1bal += 5 - suite.Require().NoError(err) - suite.Require().True(bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[1], suite.defaultDenom).Amount.Int64() == addr1bal) - - // Try setting admin to empty - _, err = suite.msgServer.ChangeAdmin(sdk.WrapSDKContext(suite.Ctx), types.NewMsgChangeAdmin(suite.TestAccs[1].String(), suite.defaultDenom, "")) - suite.Require().NoError(err) - queryRes, err = suite.queryClient.DenomAuthorityMetadata(suite.Ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ - Denom: suite.defaultDenom, - }) - suite.Require().NoError(err) - suite.Require().Equal("", queryRes.AuthorityMetadata.Admin) -} - -// TestMintDenom ensures the following properties of the MintMessage: -// * Noone can mint tokens for a denom that doesn't exist. -// * Only the admin of a denom can mint tokens for it. -// * The admin of a denom can mint tokens for it. -func (suite *KeeperTestSuite) TestMintDenom() { - var addr0bal int64 - - // Create a denom - suite.CreateDefaultDenom() - - for _, tc := range []struct { - desc string - amount int64 - mintDenom string - admin string - valid bool - }{ - { - desc: "denom does not exist", - amount: 10, - mintDenom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/evmos", - admin: suite.TestAccs[0].String(), - valid: false, - }, - { - desc: "mint is not by the admin", - amount: 10, - mintDenom: suite.defaultDenom, - admin: suite.TestAccs[1].String(), - valid: false, - }, - { - desc: "success case", - amount: 10, - mintDenom: suite.defaultDenom, - admin: suite.TestAccs[0].String(), - valid: true, - }, - } { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - // Test minting to admins own account - bankKeeper := suite.App.BankKeeper - _, err := suite.msgServer.Mint(sdk.WrapSDKContext(suite.Ctx), types.NewMsgMint(tc.admin, sdk.NewInt64Coin(tc.mintDenom, 10))) - if tc.valid { - addr0bal += 10 - suite.Require().NoError(err) - suite.Require().Equal(bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], suite.defaultDenom).Amount.Int64(), addr0bal, bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], suite.defaultDenom)) - } else { - suite.Require().Error(err) - } - }) - } -} - -func (suite *KeeperTestSuite) TestBurnDenom() { - var addr0bal int64 - - // Create a denom. - suite.CreateDefaultDenom() - - // mint 10 default token for testAcc[0] - _, err := suite.msgServer.Mint(sdk.WrapSDKContext(suite.Ctx), types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(suite.defaultDenom, 10))) - suite.Require().NoError(err) - - addr0bal += 10 - - for _, tc := range []struct { - desc string - amount int64 - burnDenom string - admin string - valid bool - }{ - { - desc: "denom does not exist", - amount: 10, - burnDenom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/evmos", - admin: suite.TestAccs[0].String(), - valid: false, - }, - { - desc: "burn is not by the admin", - amount: 10, - burnDenom: suite.defaultDenom, - admin: suite.TestAccs[1].String(), - valid: false, - }, - { - desc: "burn amount is bigger than minted amount", - amount: 1000, - burnDenom: suite.defaultDenom, - admin: suite.TestAccs[1].String(), - valid: false, - }, - { - desc: "success case", - amount: 10, - burnDenom: suite.defaultDenom, - admin: suite.TestAccs[0].String(), - valid: true, - }, - } { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - // Test minting to admins own account - bankKeeper := suite.App.BankKeeper - _, err := suite.msgServer.Burn(sdk.WrapSDKContext(suite.Ctx), types.NewMsgBurn(tc.admin, sdk.NewInt64Coin(tc.burnDenom, 10))) - if tc.valid { - addr0bal -= 10 - suite.Require().NoError(err) - suite.Require().True(bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], suite.defaultDenom).Amount.Int64() == addr0bal, bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], suite.defaultDenom)) - } else { - suite.Require().Error(err) - suite.Require().True(bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], suite.defaultDenom).Amount.Int64() == addr0bal, bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], suite.defaultDenom)) - } - }) - } -} - -func (suite *KeeperTestSuite) TestChangeAdminDenom() { - for _, tc := range []struct { - desc string - msgChangeAdmin func(denom string) *types.MsgChangeAdmin - expectedChangeAdminPass bool - expectedAdminIndex int - msgMint func(denom string) *types.MsgMint - expectedMintPass bool - }{ - { - desc: "creator admin can't mint after setting to '' ", - msgChangeAdmin: func(denom string) *types.MsgChangeAdmin { - return types.NewMsgChangeAdmin(suite.TestAccs[0].String(), denom, "") - }, - expectedChangeAdminPass: true, - expectedAdminIndex: -1, - msgMint: func(denom string) *types.MsgMint { - return types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(denom, 5)) - }, - expectedMintPass: false, - }, - { - desc: "non-admins can't change the existing admin", - msgChangeAdmin: func(denom string) *types.MsgChangeAdmin { - return types.NewMsgChangeAdmin(suite.TestAccs[1].String(), denom, suite.TestAccs[2].String()) - }, - expectedChangeAdminPass: false, - expectedAdminIndex: 0, - }, - { - desc: "success change admin", - msgChangeAdmin: func(denom string) *types.MsgChangeAdmin { - return types.NewMsgChangeAdmin(suite.TestAccs[0].String(), denom, suite.TestAccs[1].String()) - }, - expectedAdminIndex: 1, - expectedChangeAdminPass: true, - msgMint: func(denom string) *types.MsgMint { - return types.NewMsgMint(suite.TestAccs[1].String(), sdk.NewInt64Coin(denom, 5)) - }, - expectedMintPass: true, - }, - } { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - // setup test - suite.SetupTest() - - // Create a denom and mint - res, err := suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), "bitcoin")) - suite.Require().NoError(err) - - testDenom := res.GetNewTokenDenom() - - _, err = suite.msgServer.Mint(sdk.WrapSDKContext(suite.Ctx), types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(testDenom, 10))) - suite.Require().NoError(err) - - _, err = suite.msgServer.ChangeAdmin(sdk.WrapSDKContext(suite.Ctx), tc.msgChangeAdmin(testDenom)) - if tc.expectedChangeAdminPass { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - } - - queryRes, err := suite.queryClient.DenomAuthorityMetadata(suite.Ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ - Denom: testDenom, - }) - suite.Require().NoError(err) - - // expectedAdminIndex with negative value is assumed as admin with value of "" - const emptyStringAdminIndexFlag = -1 - if tc.expectedAdminIndex == emptyStringAdminIndexFlag { - suite.Require().Equal("", queryRes.AuthorityMetadata.Admin) - } else { - suite.Require().Equal(suite.TestAccs[tc.expectedAdminIndex].String(), queryRes.AuthorityMetadata.Admin) - } - - // we test mint to test if admin authority is performed properly after admin change. - if tc.msgMint != nil { - _, err := suite.msgServer.Mint(sdk.WrapSDKContext(suite.Ctx), tc.msgMint(testDenom)) - if tc.expectedMintPass { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - } - } - }) - } -} - -func (suite *KeeperTestSuite) TestSetDenomMetaData() { - // setup test - suite.SetupTest() - suite.CreateDefaultDenom() - - for _, tc := range []struct { - desc string - msgSetDenomMetadata types.MsgSetDenomMetadata - expectedPass bool - }{ - { - desc: "successful set denom metadata", - msgSetDenomMetadata: *types.NewMsgSetDenomMetadata(suite.TestAccs[0].String(), banktypes.Metadata{ - Description: "yeehaw", - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: suite.defaultDenom, - Exponent: 0, - }, - { - Denom: "uqck", - Exponent: 6, - }, - }, - Base: suite.defaultDenom, - Display: "uqck", - Name: "OSMO", - Symbol: "OSMO", - }), - expectedPass: true, - }, - { - desc: "non existent factory denom name", - msgSetDenomMetadata: *types.NewMsgSetDenomMetadata(suite.TestAccs[0].String(), banktypes.Metadata{ - Description: "yeehaw", - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: fmt.Sprintf("factory/%s/litecoin", suite.TestAccs[0].String()), - Exponent: 0, - }, - { - Denom: "uqck", - Exponent: 6, - }, - }, - Base: fmt.Sprintf("factory/%s/litecoin", suite.TestAccs[0].String()), - Display: "uqck", - Name: "OSMO", - Symbol: "OSMO", - }), - expectedPass: false, - }, - { - desc: "non-factory denom", - msgSetDenomMetadata: *types.NewMsgSetDenomMetadata(suite.TestAccs[0].String(), banktypes.Metadata{ - Description: "yeehaw", - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: "uqck", - Exponent: 0, - }, - { - Denom: "uqcko", - Exponent: 6, - }, - }, - Base: "uqck", - Display: "uqcko", - Name: "OSMO", - Symbol: "OSMO", - }), - expectedPass: false, - }, - { - desc: "wrong admin", - msgSetDenomMetadata: *types.NewMsgSetDenomMetadata(suite.TestAccs[1].String(), banktypes.Metadata{ - Description: "yeehaw", - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: suite.defaultDenom, - Exponent: 0, - }, - { - Denom: "uqck", - Exponent: 6, - }, - }, - Base: suite.defaultDenom, - Display: "uqck", - Name: "OSMO", - Symbol: "OSMO", - }), - expectedPass: false, - }, - { - desc: "invalid metadata (missing display denom unit)", - msgSetDenomMetadata: *types.NewMsgSetDenomMetadata(suite.TestAccs[0].String(), banktypes.Metadata{ - Description: "yeehaw", - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: suite.defaultDenom, - Exponent: 0, - }, - }, - Base: suite.defaultDenom, - Display: "uqck", - Name: "OSMO", - Symbol: "OSMO", - }), - expectedPass: false, - }, - } { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - tc := tc - bankKeeper := suite.App.BankKeeper - res, err := suite.msgServer.SetDenomMetadata(sdk.WrapSDKContext(suite.Ctx), &tc.msgSetDenomMetadata) - if tc.expectedPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - md, found := bankKeeper.GetDenomMetaData(suite.Ctx, suite.defaultDenom) - suite.Require().True(found) - suite.Require().Equal(tc.msgSetDenomMetadata.Metadata.Name, md.Name) - } else { - suite.Require().Error(err) - } - }) - } -} diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go deleted file mode 100644 index 01a0b7307..000000000 --- a/x/tokenfactory/keeper/bankactions.go +++ /dev/null @@ -1,73 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -func (k Keeper) mintTo(ctx sdk.Context, amount sdk.Coin, mintTo string) error { - // verify that denom is an x/tokenfactory denom - _, _, err := types.DeconstructDenom(amount.Denom) - if err != nil { - return err - } - - err = k.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(amount)) - if err != nil { - return err - } - - addr, err := sdk.AccAddressFromBech32(mintTo) - if err != nil { - return err - } - - return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, - addr, - sdk.NewCoins(amount)) -} - -func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) error { - // verify that denom is an x/tokenfactory denom - _, _, err := types.DeconstructDenom(amount.Denom) - if err != nil { - return err - } - - addr, err := sdk.AccAddressFromBech32(burnFrom) - if err != nil { - return err - } - - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, - addr, - types.ModuleName, - sdk.NewCoins(amount)) - if err != nil { - return err - } - - return k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(amount)) -} - -func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr, toAddr string) error { // nolint:unused - - // verify that denom is an x/tokenfactory denom - _, _, err := types.DeconstructDenom(amount.Denom) - if err != nil { - return err - } - - fromSdkAddr, err := sdk.AccAddressFromBech32(fromAddr) - if err != nil { - return err - } - - toSdkAddr, err := sdk.AccAddressFromBech32(toAddr) - if err != nil { - return err - } - - return k.bankKeeper.SendCoins(ctx, fromSdkAddr, toSdkAddr, sdk.NewCoins(amount)) -} diff --git a/x/tokenfactory/keeper/createdenom.go b/x/tokenfactory/keeper/createdenom.go deleted file mode 100644 index 17280dc98..000000000 --- a/x/tokenfactory/keeper/createdenom.go +++ /dev/null @@ -1,86 +0,0 @@ -package keeper - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -// CreateDenom converts a fee amount in a whitelisted fee token to the base fee token amount. -func (k Keeper) CreateDenom(ctx sdk.Context, creatorAddr, subdenom string) (newTokenDenom string, err error) { - denom, err := k.validateCreateDenom(ctx, creatorAddr, subdenom) - if err != nil { - return "", err - } - - err = k.chargeForCreateDenom(ctx, creatorAddr) - if err != nil { - return "", err - } - - err = k.createDenomAfterValidation(ctx, creatorAddr, denom) - return denom, err -} - -// Runs CreateDenom logic after the charge and all denom validation has been handled. -// Made into a second function for genesis initialization. -func (k Keeper) createDenomAfterValidation(ctx sdk.Context, creatorAddr, denom string) (err error) { - denomMetaData := banktypes.Metadata{ - DenomUnits: []*banktypes.DenomUnit{{ - Denom: denom, - Exponent: 0, - }}, - Base: denom, - } - - k.bankKeeper.SetDenomMetaData(ctx, denomMetaData) - - authorityMetadata := types.DenomAuthorityMetadata{ - Admin: creatorAddr, - } - err = k.setAuthorityMetadata(ctx, denom, authorityMetadata) - if err != nil { - return err - } - - k.addDenomFromCreator(ctx, creatorAddr, denom) - return nil -} - -func (k Keeper) validateCreateDenom(ctx sdk.Context, creatorAddr, subdenom string) (newTokenDenom string, err error) { - // Temporary check until IBC bug is sorted out - if k.bankKeeper.HasSupply(ctx, subdenom) { - return "", fmt.Errorf("temporary error until IBC bug is sorted out, " + - "can't create subdenoms that are the same as a native denom") - } - - denom, err := types.GetTokenDenom(creatorAddr, subdenom) - if err != nil { - return "", err - } - - _, found := k.bankKeeper.GetDenomMetaData(ctx, denom) - if found { - return "", types.ErrDenomExists - } - - return denom, nil -} - -func (k Keeper) chargeForCreateDenom(ctx sdk.Context, creatorAddr string) (err error) { - // Send creation fee to community pool - creationFee := k.GetParams(ctx).DenomCreationFee - accAddr, err := sdk.AccAddressFromBech32(creatorAddr) - if err != nil { - return err - } - if creationFee != nil { - if err := k.communityPoolKeeper.FundCommunityPool(ctx, creationFee, accAddr); err != nil { - return err - } - } - return nil -} diff --git a/x/tokenfactory/keeper/createdenom_test.go b/x/tokenfactory/keeper/createdenom_test.go deleted file mode 100644 index 1b28e04dd..000000000 --- a/x/tokenfactory/keeper/createdenom_test.go +++ /dev/null @@ -1,162 +0,0 @@ -package keeper_test - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -func (suite *KeeperTestSuite) TestMsgCreateDenom() { - var ( - tokenFactoryKeeper = suite.App.TokenFactoryKeeper - bankKeeper = suite.App.BankKeeper - denomCreationFee = tokenFactoryKeeper.GetParams(suite.Ctx).DenomCreationFee - ) - - // Get balance of acc 0 before creating a denom - preCreateBalance := bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], denomCreationFee[0].Denom) - - // Creating a denom should work - res, err := suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), "bitcoin")) - suite.Require().NoError(err) - suite.Require().NotEmpty(res.GetNewTokenDenom()) - - // Make sure that the admin is set correctly - queryRes, err := suite.queryClient.DenomAuthorityMetadata(suite.Ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ - Denom: res.GetNewTokenDenom(), - }) - suite.Require().NoError(err) - suite.Require().Equal(suite.TestAccs[0].String(), queryRes.AuthorityMetadata.Admin) - - // Make sure that creation fee was deducted - postCreateBalance := bankKeeper.GetBalance(suite.Ctx, suite.TestAccs[0], tokenFactoryKeeper.GetParams(suite.Ctx).DenomCreationFee[0].Denom) - suite.Require().True(preCreateBalance.Sub(postCreateBalance).IsEqual(denomCreationFee[0])) - - // Make sure that a second version of the same denom can't be recreated - _, err = suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), "bitcoin")) - suite.Require().Error(err) - - // Creating a second denom should work - res, err = suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), "litecoin")) - suite.Require().NoError(err) - suite.Require().NotEmpty(res.GetNewTokenDenom()) - - // Try querying all the denoms created by suite.TestAccs[0] - queryRes2, err := suite.queryClient.DenomsFromCreator(suite.Ctx.Context(), &types.QueryDenomsFromCreatorRequest{ - Creator: suite.TestAccs[0].String(), - }) - suite.Require().NoError(err) - suite.Require().Len(queryRes2.Denoms, 2) - - // Make sure that a second account can create a denom with the same subdenom - res, err = suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom(suite.TestAccs[1].String(), "bitcoin")) - suite.Require().NoError(err) - suite.Require().NotEmpty(res.GetNewTokenDenom()) - - // Make sure that an address with a "/" in it can't create denoms - _, err = suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom("quick.eth/creator", "bitcoin")) - suite.Require().Error(err) -} - -func (suite *KeeperTestSuite) TestCreateDenom() { - var ( - primaryDenom = types.DefaultParams().DenomCreationFee[0].Denom - secondaryDenom = SecondaryDenom - defaultDenomCreationFee = types.Params{DenomCreationFee: sdk.NewCoins(sdk.NewCoin(primaryDenom, sdk.NewInt(50000000)))} - twoDenomCreationFee = types.Params{DenomCreationFee: sdk.NewCoins(sdk.NewCoin(primaryDenom, sdk.NewInt(50000000)), sdk.NewCoin(secondaryDenom, sdk.NewInt(50000000)))} - nilCreationFee = types.Params{DenomCreationFee: nil} - largeCreationFee = types.Params{DenomCreationFee: sdk.NewCoins(sdk.NewCoin(primaryDenom, sdk.NewInt(5000000000)))} - ) - - for _, tc := range []struct { - desc string - denomCreationFee types.Params - setup func() - subdenom string - valid bool - }{ - { - desc: "subdenom too long", - denomCreationFee: defaultDenomCreationFee, - subdenom: "assadsadsadasdasdsadsadsadsadsadsadsklkadaskkkdasdasedskhanhassyeunganassfnlksdflksafjlkasd", - valid: false, - }, - { - desc: "subdenom and creator pair already exists", - denomCreationFee: defaultDenomCreationFee, - setup: func() { - _, err := suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), "bitcoin")) - suite.Require().NoError(err) - }, - subdenom: "bitcoin", - valid: false, - }, - { - desc: "success case: defaultDenomCreationFee", - denomCreationFee: defaultDenomCreationFee, - subdenom: "evmos", - valid: true, - }, - { - desc: "success case: twoDenomCreationFee", - denomCreationFee: twoDenomCreationFee, - subdenom: "catcoin", - valid: true, - }, - { - desc: "success case: nilCreationFee", - denomCreationFee: nilCreationFee, - subdenom: "czcoin", - valid: true, - }, - { - desc: "account doesn't have enough to pay for denom creation fee", - denomCreationFee: largeCreationFee, - subdenom: "tooexpensive", - valid: false, - }, - { - desc: "subdenom having invalid characters", - denomCreationFee: defaultDenomCreationFee, - subdenom: "bit/***///&&&/coin", - valid: false, - }, - } { - suite.SetupTest() - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - if tc.setup != nil { - tc.setup() - } - tokenFactoryKeeper := suite.App.TokenFactoryKeeper - bankKeeper := suite.App.BankKeeper - // Set denom creation fee in params - tokenFactoryKeeper.SetParams(suite.Ctx, tc.denomCreationFee) - denomCreationFee := tokenFactoryKeeper.GetParams(suite.Ctx).DenomCreationFee - suite.Require().Equal(tc.denomCreationFee.DenomCreationFee, denomCreationFee) - - // note balance, create a tokenfactory denom, then note balance again - preCreateBalance := bankKeeper.GetAllBalances(suite.Ctx, suite.TestAccs[0]) - res, err := suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), tc.subdenom)) - postCreateBalance := bankKeeper.GetAllBalances(suite.Ctx, suite.TestAccs[0]) - if tc.valid { - suite.Require().NoError(err) - suite.Require().True(preCreateBalance.Sub(postCreateBalance...).IsEqual(denomCreationFee)) - - // Make sure that the admin is set correctly - queryRes, err := suite.queryClient.DenomAuthorityMetadata(suite.Ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ - Denom: res.GetNewTokenDenom(), - }) - - suite.Require().NoError(err) - suite.Require().Equal(suite.TestAccs[0].String(), queryRes.AuthorityMetadata.Admin) - - } else { - suite.Require().Error(err) - // Ensure we don't charge if we expect an error - suite.Require().True(preCreateBalance.IsEqual(postCreateBalance)) - } - }) - } -} diff --git a/x/tokenfactory/keeper/creators.go b/x/tokenfactory/keeper/creators.go deleted file mode 100644 index c3145474e..000000000 --- a/x/tokenfactory/keeper/creators.go +++ /dev/null @@ -1,27 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (k Keeper) addDenomFromCreator(ctx sdk.Context, creator, denom string) { - store := k.GetCreatorPrefixStore(ctx, creator) - store.Set([]byte(denom), []byte(denom)) -} - -func (k Keeper) getDenomsFromCreator(ctx sdk.Context, creator string) []string { - store := k.GetCreatorPrefixStore(ctx, creator) - - iterator := store.Iterator(nil, nil) - defer iterator.Close() - - denoms := []string{} - for ; iterator.Valid(); iterator.Next() { - denoms = append(denoms, string(iterator.Key())) - } - return denoms -} - -func (k Keeper) GetAllDenomsIterator(ctx sdk.Context) sdk.Iterator { - return k.GetCreatorsPrefixStore(ctx).Iterator(nil, nil) -} diff --git a/x/tokenfactory/keeper/genesis.go b/x/tokenfactory/keeper/genesis.go deleted file mode 100644 index f387304a2..000000000 --- a/x/tokenfactory/keeper/genesis.go +++ /dev/null @@ -1,58 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/quicksilver-zone/quicksilver/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 genState.Params.DenomCreationFee == nil { - genState.Params.DenomCreationFee = sdk.NewCoins() - } - k.SetParams(ctx, genState.Params) - - for _, genDenom := range genState.GetFactoryDenoms() { - creator, _, err := types.DeconstructDenom(genDenom.GetDenom()) - if err != nil { - panic(err) - } - err = k.createDenomAfterValidation(ctx, creator, genDenom.GetDenom()) - if err != nil { - panic(err) - } - err = k.setAuthorityMetadata(ctx, genDenom.GetDenom(), genDenom.GetAuthorityMetadata()) - if err != nil { - panic(err) - } - } -} - -// ExportGenesis returns the tokenfactory module's exported genesis. -func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - genDenoms := []types.GenesisDenom{} - iterator := k.GetAllDenomsIterator(ctx) - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - denom := string(iterator.Value()) - - authorityMetadata, err := k.GetAuthorityMetadata(ctx, denom) - if err != nil { - panic(err) - } - - genDenoms = append(genDenoms, types.GenesisDenom{ - Denom: denom, - AuthorityMetadata: authorityMetadata, - }) - } - - return &types.GenesisState{ - FactoryDenoms: genDenoms, - Params: k.GetParams(ctx), - } -} diff --git a/x/tokenfactory/keeper/genesis_test.go b/x/tokenfactory/keeper/genesis_test.go deleted file mode 100644 index a4baf0531..000000000 --- a/x/tokenfactory/keeper/genesis_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package keeper_test - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -func (suite *KeeperTestSuite) TestGenesis() { - genesisState := types.GenesisState{ - FactoryDenoms: []types.GenesisDenom{ - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf", - }, - }, - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/diff-admin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf", - }, - }, - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/litecoin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf", - }, - }, - }, - } - - suite.SetupTestForInitGenesis() - app := suite.App - - // Test both with bank denom metadata set, and not set. - for i, denom := range genesisState.FactoryDenoms { - // hacky, sets bank metadata to exist if i != 0, to cover both cases. - if i != 0 { - app.BankKeeper.SetDenomMetaData(suite.Ctx, banktypes.Metadata{Base: denom.GetDenom()}) - } - } - - // check before initGenesis that the module account is nil - tokenfactoryModuleAccount := app.AccountKeeper.GetAccount(suite.Ctx, app.AccountKeeper.GetModuleAddress(types.ModuleName)) - suite.Require().Nil(tokenfactoryModuleAccount) - - app.TokenFactoryKeeper.SetParams(suite.Ctx, types.Params{DenomCreationFee: sdk.Coins{sdk.NewInt64Coin("uqck", 100)}}) - app.TokenFactoryKeeper.InitGenesis(suite.Ctx, genesisState) - - // check that the module account is now initialized - tokenfactoryModuleAccount = app.AccountKeeper.GetAccount(suite.Ctx, app.AccountKeeper.GetModuleAddress(types.ModuleName)) - suite.Require().NotNil(tokenfactoryModuleAccount) - - exportedGenesis := app.TokenFactoryKeeper.ExportGenesis(suite.Ctx) - suite.Require().NotNil(exportedGenesis) - suite.Require().Equal(genesisState, *exportedGenesis) -} diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go deleted file mode 100644 index 10de7ba2b..000000000 --- a/x/tokenfactory/keeper/grpc_query.go +++ /dev/null @@ -1,35 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -var _ types.QueryServer = Keeper{} - -func (k Keeper) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - params := k.GetParams(sdkCtx) - - return &types.QueryParamsResponse{Params: params}, nil -} - -func (k Keeper) DenomAuthorityMetadata(ctx context.Context, req *types.QueryDenomAuthorityMetadataRequest) (*types.QueryDenomAuthorityMetadataResponse, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - - authorityMetadata, err := k.GetAuthorityMetadata(sdkCtx, req.GetDenom()) - if err != nil { - return nil, err - } - - return &types.QueryDenomAuthorityMetadataResponse{AuthorityMetadata: authorityMetadata}, nil -} - -func (k Keeper) DenomsFromCreator(ctx context.Context, req *types.QueryDenomsFromCreatorRequest) (*types.QueryDenomsFromCreatorResponse, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - denoms := k.getDenomsFromCreator(sdkCtx, req.GetCreator()) - return &types.QueryDenomsFromCreatorResponse{Denoms: denoms}, nil -} diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go deleted file mode 100644 index c85478b09..000000000 --- a/x/tokenfactory/keeper/keeper.go +++ /dev/null @@ -1,81 +0,0 @@ -package keeper - -import ( - "fmt" - - "github.com/tendermint/tendermint/libs/log" - - "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -type ( - Keeper struct { - storeKey storetypes.StoreKey - - paramSpace paramtypes.Subspace - - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper - communityPoolKeeper types.CommunityPoolKeeper - } -) - -// NewKeeper returns a new instance of the x/tokenfactory keeper. -func NewKeeper( - storeKey storetypes.StoreKey, - paramSpace paramtypes.Subspace, - accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, - communityPoolKeeper types.CommunityPoolKeeper, -) Keeper { - if !paramSpace.HasKeyTable() { - paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) - } - - return Keeper{ - storeKey: storeKey, - paramSpace: paramSpace, - - accountKeeper: accountKeeper, - bankKeeper: bankKeeper, - communityPoolKeeper: communityPoolKeeper, - } -} - -// Logger returns a logger for the x/tokenfactory module. -func (Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) -} - -// GetDenomPrefixStore returns the substore for a specific denom. -func (k Keeper) GetDenomPrefixStore(ctx sdk.Context, denom string) sdk.KVStore { - store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, types.GetDenomPrefixStore(denom)) -} - -// GetCreatorPrefixStore returns the substore for a specific creator address. -func (k Keeper) GetCreatorPrefixStore(ctx sdk.Context, creator string) sdk.KVStore { - store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, types.GetCreatorPrefix(creator)) -} - -// GetCreatorsPrefixStore returns the substore that contains a list of creators. -func (k Keeper) GetCreatorsPrefixStore(ctx sdk.Context) sdk.KVStore { - store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, types.GetCreatorsPrefix()) -} - -// 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/keeper_test.go b/x/tokenfactory/keeper/keeper_test.go deleted file mode 100644 index 48770aefc..000000000 --- a/x/tokenfactory/keeper/keeper_test.go +++ /dev/null @@ -1,134 +0,0 @@ -package keeper_test - -import ( - "testing" - "time" - - "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto/ed25519" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/baseapp" - sdk "github.com/cosmos/cosmos-sdk/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - - "github.com/quicksilver-zone/quicksilver/app" - cmdcfg "github.com/quicksilver-zone/quicksilver/cmd/config" - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/keeper" - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -var ( - SecondaryDenom = "ura" - SecondaryAmount = sdk.NewInt(100000000) -) - -type KeeperTestSuite struct { - suite.Suite - - App *app.Quicksilver - Ctx sdk.Context - - queryClient types.QueryClient - msgServer types.MsgServer - QueryHelper *baseapp.QueryServiceTestHelper - // defaultDenom is on the suite, as it depends on the creator test address. - defaultDenom string - TestAccs []sdk.AccAddress -} - -// Setup sets up basic environment for suite (App, Ctx, and test accounts). -func (suite *KeeperTestSuite) Setup() { - cmdcfg.SetBech32Prefixes(sdk.GetConfig()) - suite.App = app.Setup(suite.T(), false) - suite.Ctx = suite.App.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "quick-1", Time: time.Now().UTC()}) - suite.QueryHelper = &baseapp.QueryServiceTestHelper{ - GRPCQueryRouter: suite.App.GRPCQueryRouter(), - Ctx: suite.Ctx, - } - - suite.TestAccs = CreateRandomAccounts(3) -} - -// CreateRandomAccounts is a function return a list of randomly generated AccAddresses. -func CreateRandomAccounts(numAccts int) []sdk.AccAddress { - testAddrs := make([]sdk.AccAddress, numAccts) - for i := 0; i < numAccts; i++ { - pk := ed25519.GenPrivKey().PubKey() - testAddrs[i] = sdk.AccAddress(pk.Address()) - } - - return testAddrs -} - -// FundAcc funds target address with specified amount. -func (suite *KeeperTestSuite) FundAcc(acc sdk.AccAddress, amounts sdk.Coins) { - err := suite.App.BankKeeper.MintCoins(suite.Ctx, minttypes.ModuleName, amounts) - suite.NoError(err) - err = suite.App.BankKeeper.SendCoinsFromModuleToAccount(suite.Ctx, minttypes.ModuleName, acc, amounts) - suite.NoError(err) -} - -func (suite *KeeperTestSuite) SetupTestForInitGenesis() { - // Setting to True, leads to init genesis not running - suite.App = app.Setup(suite.T(), true) - suite.Ctx = suite.App.BaseApp.NewContext(true, tmproto.Header{}) -} - -// AssertEventEmitted asserts that ctx's event manager has emitted the given number of events -// of the given type. -func (suite *KeeperTestSuite) AssertEventEmitted(ctx sdk.Context, eventTypeExpected string, numEventsExpected int) { - allEvents := ctx.EventManager().Events() - // filter out other events - actualEvents := make([]sdk.Event, 0) - for _, event := range allEvents { - if event.Type == eventTypeExpected { - actualEvents = append(actualEvents, event) - } - } - suite.Equal(numEventsExpected, len(actualEvents)) -} - -func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) -} - -func (suite *KeeperTestSuite) SetupTest() { - suite.Setup() - // Fund every TestAcc with two denoms, one of which is the denom creation fee - fundAccsAmount := sdk.NewCoins(sdk.NewCoin(types.DefaultParams().DenomCreationFee[0].Denom, types.DefaultParams().DenomCreationFee[0].Amount.MulRaw(100)), sdk.NewCoin(SecondaryDenom, SecondaryAmount)) - for _, acc := range suite.TestAccs { - suite.FundAcc(acc, fundAccsAmount) - } - - suite.queryClient = types.NewQueryClient(suite.QueryHelper) - suite.msgServer = keeper.NewMsgServerImpl(suite.App.TokenFactoryKeeper) -} - -func (suite *KeeperTestSuite) CreateDefaultDenom() { - suite.T().Helper() - - res, err := suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), "bitcoin")) - suite.Require().NoError(err) - suite.defaultDenom = res.GetNewTokenDenom() -} - -func (suite *KeeperTestSuite) TestCreateModuleAccount() { - quicksilver := suite.App - - // remove module account - tokenfactoryModuleAccount := quicksilver.AccountKeeper.GetAccount(suite.Ctx, quicksilver.AccountKeeper.GetModuleAddress(types.ModuleName)) - quicksilver.AccountKeeper.RemoveAccount(suite.Ctx, tokenfactoryModuleAccount) - - // ensure module account was removed - suite.Ctx = quicksilver.BaseApp.NewContext(false, tmproto.Header{}) - tokenfactoryModuleAccount = quicksilver.AccountKeeper.GetAccount(suite.Ctx, quicksilver.AccountKeeper.GetModuleAddress(types.ModuleName)) - suite.Require().Nil(tokenfactoryModuleAccount) - - // create module account - quicksilver.TokenFactoryKeeper.CreateModuleAccount(suite.Ctx) - - // check that the module account is now initialized - tokenfactoryModuleAccount = quicksilver.AccountKeeper.GetAccount(suite.Ctx, quicksilver.AccountKeeper.GetModuleAddress(types.ModuleName)) - suite.Require().NotNil(tokenfactoryModuleAccount) -} diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go deleted file mode 100644 index 8e913ecf8..000000000 --- a/x/tokenfactory/keeper/msg_server.go +++ /dev/null @@ -1,191 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -type msgServer struct { - Keeper -} - -// NewMsgServerImpl returns an implementation of the MsgServer interface -// for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { - return &msgServer{Keeper: keeper} -} - -var _ types.MsgServer = msgServer{} - -func (server msgServer) CreateDenom(goCtx context.Context, msg *types.MsgCreateDenom) (*types.MsgCreateDenomResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - denom, err := server.Keeper.CreateDenom(ctx, msg.Sender, msg.Subdenom) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeMsgCreateDenom, - sdk.NewAttribute(types.AttributeCreator, msg.Sender), - sdk.NewAttribute(types.AttributeNewTokenDenom, denom), - ), - }) - - return &types.MsgCreateDenomResponse{ - NewTokenDenom: denom, - }, nil -} - -func (server msgServer) Mint(goCtx context.Context, msg *types.MsgMint) (*types.MsgMintResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - // pay some extra gas cost to give a better error here. - _, denomExists := server.bankKeeper.GetDenomMetaData(ctx, msg.Amount.Denom) - if !denomExists { - return nil, types.ErrDenomDoesNotExist.Wrapf("denom: %s", msg.Amount.Denom) - } - - authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Amount.GetDenom()) - if err != nil { - return nil, err - } - - if msg.Sender != authorityMetadata.GetAdmin() { - return nil, types.ErrUnauthorized - } - - err = server.Keeper.mintTo(ctx, msg.Amount, msg.Sender) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeMsgMint, - sdk.NewAttribute(types.AttributeMintToAddress, msg.Sender), - sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()), - ), - }) - - return &types.MsgMintResponse{}, nil -} - -func (server msgServer) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.MsgBurnResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Amount.GetDenom()) - if err != nil { - return nil, err - } - - if msg.Sender != authorityMetadata.GetAdmin() { - return nil, types.ErrUnauthorized - } - - err = server.Keeper.burnFrom(ctx, msg.Amount, msg.Sender) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeMsgBurn, - sdk.NewAttribute(types.AttributeBurnFromAddress, msg.Sender), - sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()), - ), - }) - - return &types.MsgBurnResponse{}, nil -} - -// func (server msgServer) ForceTransfer(goCtx context.Context, msg *types.MsgForceTransfer) (*types.MsgForceTransferResponse, error) { -// ctx := sdk.UnwrapSDKContext(goCtx) - -// authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Amount.GetDenom()) -// if err != nil { -// return nil, err -// } - -// if msg.Sender != authorityMetadata.GetAdmin() { -// return nil, types.ErrUnauthorized -// } - -// err = server.Keeper.forceTransfer(ctx, msg.Amount, msg.TransferFromAddress, msg.TransferToAddress) -// if err != nil { -// return nil, err -// } - -// ctx.EventManager().EmitEvents(sdk.Events{ -// sdk.NewEvent( -// types.TypeMsgForceTransfer, -// sdk.NewAttribute(types.AttributeTransferFromAddress, msg.TransferFromAddress), -// sdk.NewAttribute(types.AttributeTransferToAddress, msg.TransferToAddress), -// sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()), -// ), -// }) - -// return &types.MsgForceTransferResponse{}, nil -// } - -func (server msgServer) ChangeAdmin(goCtx context.Context, msg *types.MsgChangeAdmin) (*types.MsgChangeAdminResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Denom) - if err != nil { - return nil, err - } - - if msg.Sender != authorityMetadata.GetAdmin() { - return nil, types.ErrUnauthorized - } - - err = server.Keeper.setAdmin(ctx, msg.Denom, msg.NewAdmin) - if err != nil { - return nil, err - } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeMsgChangeAdmin, - sdk.NewAttribute(types.AttributeDenom, msg.GetDenom()), - sdk.NewAttribute(types.AttributeNewAdmin, msg.NewAdmin), - ), - }) - - return &types.MsgChangeAdminResponse{}, nil -} - -func (server msgServer) SetDenomMetadata(goCtx context.Context, msg *types.MsgSetDenomMetadata) (*types.MsgSetDenomMetadataResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - // Defense in depth validation of metadata - err := msg.Metadata.Validate() - if err != nil { - return nil, err - } - - authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Metadata.Base) - if err != nil { - return nil, err - } - - if msg.Sender != authorityMetadata.GetAdmin() { - return nil, types.ErrUnauthorized - } - - server.Keeper.bankKeeper.SetDenomMetaData(ctx, msg.Metadata) - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeMsgSetDenomMetadata, - sdk.NewAttribute(types.AttributeDenom, msg.Metadata.Base), - sdk.NewAttribute(types.AttributeDenomMetadata, msg.Metadata.String()), - ), - }) - - return &types.MsgSetDenomMetadataResponse{}, nil -} diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go deleted file mode 100644 index e7af08d77..000000000 --- a/x/tokenfactory/keeper/msg_server_test.go +++ /dev/null @@ -1,267 +0,0 @@ -package keeper_test - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -// TestMintDenomMsg tests TypeMsgMint message is emitted on a successful mint. -func (suite *KeeperTestSuite) TestMintDenomMsg() { - // Create a denom - suite.CreateDefaultDenom() - - for _, tc := range []struct { - desc string - amount int64 - mintDenom string - admin string - valid bool - expectedError error - expectedMessageEvents int - }{ - { - desc: "denom does not exist", - amount: 10, - mintDenom: "factory/QCK1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/evmos", - admin: suite.TestAccs[0].String(), - valid: false, - expectedError: types.ErrDenomDoesNotExist, - }, - { - desc: "success case", - amount: 10, - mintDenom: suite.defaultDenom, - admin: suite.TestAccs[0].String(), - valid: true, - expectedMessageEvents: 1, - }, - } { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - ctx := suite.Ctx.WithEventManager(sdk.NewEventManager()) - suite.Require().Equal(0, len(ctx.EventManager().Events())) - // Test mint message - _, err := suite.msgServer.Mint(sdk.WrapSDKContext(ctx), types.NewMsgMint(tc.admin, sdk.NewInt64Coin(tc.mintDenom, 10))) - suite.Require().ErrorIs(err, tc.expectedError) - // Ensure current number and type of event is emitted - suite.AssertEventEmitted(ctx, types.TypeMsgMint, tc.expectedMessageEvents) - }) - } -} - -// TestBurnDenomMsg test TypeMsgBurn message is emitted on a successful burn. -func (suite *KeeperTestSuite) TestBurnDenomMsg() { - // Create a denom. - suite.CreateDefaultDenom() - // mint 10 default token for testAcc[0] - _, err := suite.msgServer.Mint(sdk.WrapSDKContext(suite.Ctx), types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(suite.defaultDenom, 10))) - suite.Require().NoError(err) - - for _, tc := range []struct { - desc string - amount int64 - burnDenom string - admin string - valid bool - expectedError error - expectedMessageEvents int - }{ - { - desc: "denom does not exist", - burnDenom: "factory/quick1vprpg84y4c50fxpf9ngza2y0p0q3k7yrw2q8tf/evmos", - admin: suite.TestAccs[0].String(), - valid: false, - expectedError: types.ErrUnauthorized, - }, - { - desc: "success case", - burnDenom: suite.defaultDenom, - admin: suite.TestAccs[0].String(), - valid: true, - expectedMessageEvents: 1, - }, - } { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - ctx := suite.Ctx.WithEventManager(sdk.NewEventManager()) - suite.Require().Equal(0, len(ctx.EventManager().Events())) - // Test burn message - _, err := suite.msgServer.Burn(sdk.WrapSDKContext(ctx), types.NewMsgBurn(tc.admin, sdk.NewInt64Coin(tc.burnDenom, 10))) - suite.Require().ErrorIs(err, tc.expectedError) - // Ensure current number and type of event is emitted - suite.AssertEventEmitted(ctx, types.TypeMsgBurn, tc.expectedMessageEvents) - }) - } -} - -// TestCreateDenomMsg test TypeMsgCreateDenom message is emitted on a successful denom creation. -func (suite *KeeperTestSuite) TestCreateDenomMsg() { - defaultDenomCreationFee := types.Params{DenomCreationFee: sdk.NewCoins(sdk.NewCoin("uqck", sdk.NewInt(50000000)))} - for _, tc := range []struct { - desc string - denomCreationFee types.Params - subdenom string - valid bool - expectedError error - expectedMessageEvents int - }{ - { - desc: "subdenom too long", - denomCreationFee: defaultDenomCreationFee, - subdenom: "assadsadsadasdasdsadsadsadsadsadsadsklkadaskkkdasdasedskhanhassyeunganassfnlksdflksafjlkasd", - valid: false, - expectedError: types.ErrSubdenomTooLong, - }, - { - desc: "success case: defaultDenomCreationFee", - denomCreationFee: defaultDenomCreationFee, - subdenom: "evmos", - valid: true, - expectedMessageEvents: 1, - }, - } { - suite.SetupTest() - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - tokenFactoryKeeper := suite.App.TokenFactoryKeeper - ctx := suite.Ctx.WithEventManager(sdk.NewEventManager()) - suite.Require().Equal(0, len(ctx.EventManager().Events())) - // Set denom creation fee in params - tokenFactoryKeeper.SetParams(suite.Ctx, tc.denomCreationFee) - // Test create denom message - _, err := suite.msgServer.CreateDenom(sdk.WrapSDKContext(ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), tc.subdenom)) - suite.Require().ErrorIs(err, tc.expectedError) - // Ensure current number and type of event is emitted - suite.AssertEventEmitted(ctx, types.TypeMsgCreateDenom, tc.expectedMessageEvents) - }) - } -} - -// TestChangeAdminDenomMsg test TypeMsgChangeAdmin message is emitted on a successful admin change. -func (suite *KeeperTestSuite) TestChangeAdminDenomMsg() { - for _, tc := range []struct { - desc string - msgChangeAdmin func(denom string) *types.MsgChangeAdmin - expectedChangeAdminPass bool - expectedAdminIndex int - msgMint func(denom string) *types.MsgMint - expectedMintPass bool - expectedError error - expectedMessageEvents int - }{ - { - desc: "non-admins can't change the existing admin", - msgChangeAdmin: func(denom string) *types.MsgChangeAdmin { - return types.NewMsgChangeAdmin(suite.TestAccs[1].String(), denom, suite.TestAccs[2].String()) - }, - expectedChangeAdminPass: false, - expectedError: types.ErrUnauthorized, - expectedAdminIndex: 0, - }, - { - desc: "success change admin", - msgChangeAdmin: func(denom string) *types.MsgChangeAdmin { - return types.NewMsgChangeAdmin(suite.TestAccs[0].String(), denom, suite.TestAccs[1].String()) - }, - expectedAdminIndex: 1, - expectedChangeAdminPass: true, - expectedMessageEvents: 1, - msgMint: func(denom string) *types.MsgMint { - return types.NewMsgMint(suite.TestAccs[1].String(), sdk.NewInt64Coin(denom, 5)) - }, - expectedMintPass: true, - }, - } { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - // setup test - suite.SetupTest() - ctx := suite.Ctx.WithEventManager(sdk.NewEventManager()) - suite.Require().Equal(0, len(ctx.EventManager().Events())) - // Create a denom and mint - res, err := suite.msgServer.CreateDenom(sdk.WrapSDKContext(ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), "bitcoin")) - suite.Require().NoError(err) - testDenom := res.GetNewTokenDenom() - _, err = suite.msgServer.Mint(sdk.WrapSDKContext(ctx), types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(testDenom, 10))) - suite.Require().NoError(err) - - // Test change admin message - _, err = suite.msgServer.ChangeAdmin(sdk.WrapSDKContext(ctx), tc.msgChangeAdmin(testDenom)) - suite.Require().ErrorIs(err, tc.expectedError) - - // Ensure current number and type of event is emitted - suite.AssertEventEmitted(ctx, types.TypeMsgChangeAdmin, tc.expectedMessageEvents) - }) - } -} - -// TestSetDenomMetaDataMsg test TypeMsgSetDenomMetadata message is emitted on a successful denom metadata change. -func (suite *KeeperTestSuite) TestSetDenomMetaDataMsg() { - // setup test - suite.SetupTest() - suite.CreateDefaultDenom() - - for _, tc := range []struct { - desc string - msgSetDenomMetadata types.MsgSetDenomMetadata - expectedPass bool - expectedError error - expectedMessageEvents int - }{ - { - desc: "successful set denom metadata", - msgSetDenomMetadata: *types.NewMsgSetDenomMetadata(suite.TestAccs[0].String(), banktypes.Metadata{ - Description: "yeehaw", - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: suite.defaultDenom, - Exponent: 0, - }, - { - Denom: "uqck", - Exponent: 6, - }, - }, - Base: suite.defaultDenom, - Display: "uqck", - Name: "QCK", - Symbol: "QCK", - }), - expectedPass: true, - expectedMessageEvents: 1, - }, - { - desc: "non existent factory denom name", - msgSetDenomMetadata: *types.NewMsgSetDenomMetadata(suite.TestAccs[0].String(), banktypes.Metadata{ - Description: "yeehaw", - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: fmt.Sprintf("factory/%s/litecoin", suite.TestAccs[0].String()), - Exponent: 0, - }, - { - Denom: "uqck", - Exponent: 6, - }, - }, - Base: fmt.Sprintf("factory/%s/litecoin", suite.TestAccs[0].String()), - Display: "uqck", - Name: "QCK", - Symbol: "QCK", - }), - expectedPass: false, - expectedError: types.ErrUnauthorized, - }, - } { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - tc := tc - ctx := suite.Ctx.WithEventManager(sdk.NewEventManager()) - suite.Require().Equal(0, len(ctx.EventManager().Events())) - // Test set denom metadata message - _, err := suite.msgServer.SetDenomMetadata(sdk.WrapSDKContext(ctx), &tc.msgSetDenomMetadata) - suite.Require().ErrorIs(err, tc.expectedError) - // Ensure current number and type of event is emitted - suite.AssertEventEmitted(ctx, types.TypeMsgSetDenomMetadata, tc.expectedMessageEvents) - }) - } -} diff --git a/x/tokenfactory/keeper/params.go b/x/tokenfactory/keeper/params.go deleted file mode 100644 index 8f8f74508..000000000 --- a/x/tokenfactory/keeper/params.go +++ /dev/null @@ -1,18 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -// GetParams returns the total set params. -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - k.paramSpace.GetParamSet(ctx, ¶ms) - return params -} - -// SetParams sets the total set of params. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramSpace.SetParamSet(ctx, ¶ms) -} diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go deleted file mode 100644 index e35cec764..000000000 --- a/x/tokenfactory/module.go +++ /dev/null @@ -1,207 +0,0 @@ -/* -Package tokenfactory 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. In the future, more admin capabilities may be added. -*/ -package tokenfactory - -import ( - "context" - "encoding/json" - "fmt" - "math/rand" - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/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/quicksilver-zone/quicksilver/x/tokenfactory/client/cli" - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/keeper" - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/simulation" - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -var ( - _ module.AppModuleBasic = AppModuleBasic{} - _ module.AppModule = AppModule{} - _ module.AppModuleSimulation = AppModule{} -) - -// ---------------------------------------------------------------------------- -// AppModuleBasic -// ---------------------------------------------------------------------------- - -// AppModuleBasic implements the AppModuleBasic interface for the capability module. -type AppModuleBasic struct{} - -func NewAppModuleBasic() AppModuleBasic { - return AppModuleBasic{} -} - -// Name returns the x/tokenfactory module's name. -func (AppModuleBasic) Name() string { - return types.ModuleName -} - -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) -} - -// RegisterInterfaces registers the module's interface types. -func (AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { - types.RegisterInterfaces(reg) -} - -// DefaultGenesis returns the x/tokenfactory 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 x/tokenfactory 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) { - _ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) -} - -// GetTxCmd returns the x/tokenfactory module's root tx command. -func (AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd() -} - -// GetQueryCmd returns the x/tokenfactory 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 - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper -} - -func NewAppModule( - k keeper.Keeper, - ak types.AccountKeeper, - bk types.BankKeeper, -) AppModule { - return AppModule{ - AppModuleBasic: NewAppModuleBasic(), - keeper: k, - accountKeeper: ak, - bankKeeper: bk, - } -} - -// Name returns the x/tokenfactory module's name. -func (am AppModule) Name() string { - return am.AppModuleBasic.Name() -} - -// Route returns the x/tokenfactory module's message routing key. -func (AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns the x/tokenfactory module's query routing key. -func (AppModule) QuerierRoute() string { return types.QuerierRoute } - -// LegacyQuerierHandler returns the x/tokenfactory module's Querier. -func (AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { - return nil -} - -// 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(), keeper.NewMsgServerImpl(am.keeper)) - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) -} - -// RegisterInvariants registers the x/tokenfactory module's invariants. -func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} - -// InitGenesis performs the x/tokenfactory 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 - cdc.MustUnmarshalJSON(gs, &genState) - - am.keeper.InitGenesis(ctx, genState) - - return []abci.ValidatorUpdate{} -} - -// ExportGenesis returns the x/tokenfactory module's exported genesis state as raw -// JSON bytes. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - genState := am.keeper.ExportGenesis(ctx) - return cdc.MustMarshalJSON(genState) -} - -// BeginBlock executes all ABCI BeginBlock logic respective to the tokenfactory module. -func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} - -// EndBlock executes all ABCI EndBlock logic respective to the tokenfactory module. It -// returns no validator updates. -func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} - -// ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 1 } - -// ___________________________________________________________________________ - -// AppModuleSimulation functions - -// GenerateGenesisState creates a randomized GenState of the mint module. -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - simulation.RandomizedGenState(simState) -} - -// ProposalContents doesn't return any content functions for governance proposals. -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return nil -} - -// RandomizedParams creates randomized mint param changes for the simulator. -func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { - return []simtypes.ParamChange{} -} - -// RegisterStoreDecoder registers a decoder for mint module's types. -func (AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { -} - -// WeightedOperations doesn't return any mint module operation. -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/tokenfactory/simulation/genesis.go b/x/tokenfactory/simulation/genesis.go deleted file mode 100644 index dfb35b799..000000000 --- a/x/tokenfactory/simulation/genesis.go +++ /dev/null @@ -1,35 +0,0 @@ -package simulation - -// DONTCOVER - -import ( - "encoding/json" - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -// RandomizedGenState generates a random GenesisState for tokenfactory. -func RandomizedGenState(simState *module.SimulationState) { - // random fee - feeAmt := simState.Rand.Int63n(5_000_000) + 7_500_000 // [7_500_000, 12_500_000) - - tokenfactoryGenesis := types.DefaultGenesis() - // use bond denom for simulation - tokenfactoryGenesis.Params.DenomCreationFee = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, feeAmt)) - err := tokenfactoryGenesis.Validate() - if err != nil { - panic(err) - } - - bz, err := json.MarshalIndent(&tokenfactoryGenesis, "", " ") - if err != nil { - panic(err) - } - - fmt.Printf("Selected deterministically generated tokenfactory parameters:\n%s\n", bz) - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(tokenfactoryGenesis) -} diff --git a/x/tokenfactory/simulation/operations.go b/x/tokenfactory/simulation/operations.go deleted file mode 100644 index 47056e515..000000000 --- a/x/tokenfactory/simulation/operations.go +++ /dev/null @@ -1,379 +0,0 @@ -package simulation - -import ( - "math/rand" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" - sdk "github.com/cosmos/cosmos-sdk/types" - sdksimtypes "github.com/cosmos/cosmos-sdk/types/simulation" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/simulation" - - "github.com/quicksilver-zone/quicksilver/test/simulation/simtypes" - "github.com/quicksilver-zone/quicksilver/third-party-chains/osmosis-types/osmoutils" - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/keeper" - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -const ( - OpWeightMsgCreateDenom = "op_weight_msg_create_denom" // nolint:gosec // not credentials - OpWeightMsgMint = "op_weight_msg_mint" // nolint:gosec // not credentials - OpWeightMsgBurn = "op_weight_msg_burn" // nolint:gosec // not credentials - OpWeightMsgChangeAdmin = "op_weight_msg_change_admin" // nolint:gosec // not credentials - OpWeightMsgSetDenomMetadata = "op_weight_msg_set_denom_metadata" // nolint:gosec // not credentials - DefaultWeightMsgCreateDenom int = 50 - DefaultWeightMsgMint int = 10 - DefaultWeightMsgBurn int = 10 - DefaultWeightMsgChangeAdmin int = 5 - DefaultWeightMsgSetDenomMetadata int = 5 -) - -var ( - TypeMsgCreateDenom = sdk.MsgTypeURL(&types.MsgCreateDenom{}) - TypeMsgMint = sdk.MsgTypeURL(&types.MsgMint{}) - TypeMsgBurn = sdk.MsgTypeURL(&types.MsgBurn{}) - TypeMsgChangeAdmin = sdk.MsgTypeURL(&types.MsgChangeAdmin{}) - TypeMsgSetDenomMetadata = sdk.MsgTypeURL(&types.MsgSetDenomMetadata{}) -) - -func WeightedOperations( - appParams sdksimtypes.AppParams, - cdc codec.JSONCodec, - ak types.AccountKeeper, - bk types.BankKeeper, - k keeper.Keeper, -) simulation.WeightedOperations { - var ( - weightMsgCreateDenom int - weightMsgMint int - weightMsgBurn int - weightMsgChangeAdmin int - weightMsgSetDenomMetadata int - ) - - appParams.GetOrGenerate(cdc, OpWeightMsgCreateDenom, &weightMsgCreateDenom, nil, - func(_ *rand.Rand) { - weightMsgCreateDenom = DefaultWeightMsgCreateDenom - }, - ) - - appParams.GetOrGenerate(cdc, OpWeightMsgMint, &weightMsgMint, nil, - func(_ *rand.Rand) { - weightMsgMint = DefaultWeightMsgMint - }, - ) - - appParams.GetOrGenerate(cdc, OpWeightMsgBurn, &weightMsgBurn, nil, - func(_ *rand.Rand) { - weightMsgBurn = DefaultWeightMsgBurn - }, - ) - - appParams.GetOrGenerate(cdc, OpWeightMsgChangeAdmin, &weightMsgChangeAdmin, nil, - func(_ *rand.Rand) { - weightMsgChangeAdmin = DefaultWeightMsgChangeAdmin - }, - ) - - appParams.GetOrGenerate(cdc, OpWeightMsgSetDenomMetadata, &weightMsgSetDenomMetadata, nil, - func(_ *rand.Rand) { - weightMsgSetDenomMetadata = DefaultWeightMsgSetDenomMetadata - }, - ) - - return simulation.WeightedOperations{ - simulation.NewWeightedOperation( - weightMsgCreateDenom, - SimulateMsgCreateDenom(ak, bk, k), - ), - simulation.NewWeightedOperation( - weightMsgMint, - SimulateMsgMint(ak, bk, k), - ), - simulation.NewWeightedOperation( - weightMsgBurn, - SimulateMsgBurn(ak, bk, k), - ), - simulation.NewWeightedOperation( - weightMsgChangeAdmin, - SimulateMsgChangeAdmin(ak, bk, k), - ), - simulation.NewWeightedOperation( - weightMsgSetDenomMetadata, - SimulateMsgSetDenomMetadata(ak, bk, k), - ), - } -} - -// SimulateMsgCreateDenom generates a MsgCreateDenom with random values. -func SimulateMsgCreateDenom(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) sdksimtypes.Operation { - return func( - r *rand.Rand, bApp *baseapp.BaseApp, ctx sdk.Context, accs []sdksimtypes.Account, chainID string, - ) (sdksimtypes.OperationMsg, []sdksimtypes.FutureOperation, error) { - minCoins := k.GetParams(ctx).DenomCreationFee - acc, err := simtypes.RandomSimAccountWithMinCoins(ctx, r, accs, minCoins, bk) - if err != nil { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgCreateDenom, "no account with balance found"), nil, nil - } - - msg := &types.MsgCreateDenom{ - Sender: acc.Address.String(), - Subdenom: simtypes.RandStringOfLength(r, types.MaxSubdenomLength), - } - - txCtx := simulation.OperationInput{ - R: r, - App: bApp, - TxGen: simappparams.MakeTestEncodingConfig().TxConfig, - Cdc: nil, - Msg: msg, - MsgType: TypeMsgCreateDenom, - CoinsSpentInMsg: minCoins, - Context: ctx, - SimAccount: acc, - AccountKeeper: ak, - Bankkeeper: bk, - ModuleName: types.ModuleName, - } - - return simulation.GenAndDeliverTxWithRandFees(txCtx) - } -} - -// SimulateMsgMint generates a MsgMint with random values. -func SimulateMsgMint(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) sdksimtypes.Operation { - return func( - r *rand.Rand, bApp *baseapp.BaseApp, ctx sdk.Context, accs []sdksimtypes.Account, chainID string, - ) (sdksimtypes.OperationMsg, []sdksimtypes.FutureOperation, error) { - acc, senderExists := simtypes.RandomSimAccountWithConstraint(r, accountCreatedTokenFactoryDenom(k, ctx), accs) - if !senderExists { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgMint, "no account with tokenfactory denom found"), nil, nil - } - - denom, addr, err := getTokenFactoryDenomAndItsAdmin(k, ctx, r, acc) - if err != nil { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgMint, "error finding denom and admin"), nil, err - } - if addr == nil || addr.String() != acc.Address.String() { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgMint, "account is not admin"), nil, nil - } - - mintAmount, err := simtypes.RandPositiveInt(r, sdk.NewIntFromUint64(1000_000000)) - if err != nil { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgMint, "error creating random sdkmath.Int"), nil, err - } - - msg := &types.MsgMint{ - Sender: addr.String(), - Amount: sdk.NewCoin(denom, mintAmount), - } - - txCtx := simulation.OperationInput{ - R: r, - App: bApp, - TxGen: simappparams.MakeTestEncodingConfig().TxConfig, - Cdc: nil, - Msg: msg, - MsgType: TypeMsgMint, - CoinsSpentInMsg: nil, - Context: ctx, - SimAccount: acc, - AccountKeeper: ak, - Bankkeeper: bk, - ModuleName: types.ModuleName, - } - - return simulation.GenAndDeliverTxWithRandFees(txCtx) - } -} - -// SimulateMsgBurn generates a MsgBurn with random values. -func SimulateMsgBurn(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) sdksimtypes.Operation { - return func( - r *rand.Rand, bApp *baseapp.BaseApp, ctx sdk.Context, accs []sdksimtypes.Account, chainID string, - ) (sdksimtypes.OperationMsg, []sdksimtypes.FutureOperation, error) { - acc, senderExists := simtypes.RandomSimAccountWithConstraint(r, accountCreatedTokenFactoryDenom(k, ctx), accs) - if !senderExists { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgBurn, "no account with tokenfactory denom found"), nil, nil - } - - denom, addr, err := getTokenFactoryDenomAndItsAdmin(k, ctx, r, acc) - if err != nil { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgBurn, "error finding denom and admin"), nil, err - } - if addr == nil || addr.String() != acc.Address.String() { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgBurn, "account is not admin"), nil, nil - } - - spendable := bk.SpendableCoins(ctx, addr) - denomBal := spendable.AmountOf(denom) - - if denomBal.IsZero() { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgBurn, "addr does not have enough balance to burn"), nil, nil - } - - burnAmount, err := simtypes.RandPositiveInt(r, denomBal) - if err != nil { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgMint, "error creating random sdkmath.Int"), nil, err - } - - burnCoin := sdk.NewCoin(denom, burnAmount) - msg := &types.MsgBurn{ - Sender: addr.String(), - Amount: burnCoin, - } - - txCtx := simulation.OperationInput{ - R: r, - App: bApp, - TxGen: simappparams.MakeTestEncodingConfig().TxConfig, - Cdc: nil, - Msg: msg, - MsgType: TypeMsgBurn, - CoinsSpentInMsg: sdk.NewCoins(burnCoin), - Context: ctx, - SimAccount: acc, - AccountKeeper: ak, - Bankkeeper: bk, - ModuleName: types.ModuleName, - } - - return simulation.GenAndDeliverTxWithRandFees(txCtx) - } -} - -// SimulateMsgChangeAdmin generates a MsgChangeAdmin with random values. -func SimulateMsgChangeAdmin(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) sdksimtypes.Operation { - return func( - r *rand.Rand, bApp *baseapp.BaseApp, ctx sdk.Context, accs []sdksimtypes.Account, chainID string, - ) (sdksimtypes.OperationMsg, []sdksimtypes.FutureOperation, error) { - acc, senderExists := simtypes.RandomSimAccountWithConstraint(r, accountCreatedTokenFactoryDenom(k, ctx), accs) - if !senderExists { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgChangeAdmin, "no account with tokenfactory denom found"), nil, nil - } - - denom, addr, err := getTokenFactoryDenomAndItsAdmin(k, ctx, r, acc) - if err != nil { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgChangeAdmin, "error finding denom and admin"), nil, err - } - if addr == nil || addr.String() != acc.Address.String() { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgChangeAdmin, "account is not admin"), nil, nil - } - - newAdmin := simtypes.RandomSimAccount(r, accs) - if newAdmin.Address.String() == addr.String() { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgChangeAdmin, "denom has no admin"), nil, nil - } - - msg := &types.MsgChangeAdmin{ - Sender: addr.String(), - Denom: denom, - NewAdmin: newAdmin.Address.String(), - } - - txCtx := simulation.OperationInput{ - R: r, - App: bApp, - TxGen: simappparams.MakeTestEncodingConfig().TxConfig, - Cdc: nil, - Msg: msg, - MsgType: TypeMsgChangeAdmin, - CoinsSpentInMsg: nil, - Context: ctx, - SimAccount: acc, - AccountKeeper: ak, - Bankkeeper: bk, - ModuleName: types.ModuleName, - } - - return simulation.GenAndDeliverTxWithRandFees(txCtx) - } -} - -// SimulateMsgSetDenomMetadata generates a MsgSetDenomMetadata with random values. -func SimulateMsgSetDenomMetadata(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) sdksimtypes.Operation { - return func( - r *rand.Rand, bApp *baseapp.BaseApp, ctx sdk.Context, accs []sdksimtypes.Account, chainID string, - ) (sdksimtypes.OperationMsg, []sdksimtypes.FutureOperation, error) { - acc, senderExists := simtypes.RandomSimAccountWithConstraint(r, accountCreatedTokenFactoryDenom(k, ctx), accs) - if !senderExists { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgChangeAdmin, "no account with tokenfactory denom found"), nil, nil - } - - denom, addr, err := getTokenFactoryDenomAndItsAdmin(k, ctx, r, acc) - if err != nil { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgChangeAdmin, "error finding denom and admin"), nil, err - } - if addr == nil || addr.String() != acc.Address.String() { - return sdksimtypes.NoOpMsg(types.ModuleName, TypeMsgChangeAdmin, "account is not admin"), nil, nil - } - - msg := &types.MsgSetDenomMetadata{ - Sender: addr.String(), - Metadata: banktypes.Metadata{ - Description: simtypes.RandStringOfLength(r, 10), - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: denom, - Exponent: 0, - Aliases: []string{ - simtypes.RandStringOfLength(r, 4), - simtypes.RandStringOfLength(r, 4), - }, - }, - }, - Base: denom, - Display: denom, - Name: simtypes.RandStringOfLength(r, 10), - Symbol: simtypes.RandStringOfLength(r, 4), - URI: "", - URIHash: "", - }, - } - - txCtx := simulation.OperationInput{ - R: r, - App: bApp, - TxGen: simappparams.MakeTestEncodingConfig().TxConfig, - Cdc: nil, - Msg: msg, - MsgType: TypeMsgSetDenomMetadata, - CoinsSpentInMsg: nil, - Context: ctx, - SimAccount: acc, - AccountKeeper: ak, - Bankkeeper: bk, - ModuleName: types.ModuleName, - } - - return simulation.GenAndDeliverTxWithRandFees(txCtx) - } -} - -func accountCreatedTokenFactoryDenom(k keeper.Keeper, ctx sdk.Context) simtypes.SimAccountConstraint { - return func(acc sdksimtypes.Account) bool { - store := k.GetCreatorPrefixStore(ctx, acc.Address.String()) - iterator := store.Iterator(nil, nil) - defer iterator.Close() - return iterator.Valid() - } -} - -func getTokenFactoryDenomAndItsAdmin(k keeper.Keeper, ctx sdk.Context, r *rand.Rand, acc sdksimtypes.Account) (string, sdk.AccAddress, error) { - store := k.GetCreatorPrefixStore(ctx, acc.Address.String()) - denoms := osmoutils.GatherAllKeysFromStore(store) - denom := simtypes.RandSelect(r, denoms...) - - authData, err := k.GetAuthorityMetadata(ctx, denom) - if err != nil { - return "", nil, err - } - admin := authData.Admin - addr, err := sdk.AccAddressFromBech32(admin) - if err != nil { - return "", nil, err - } - return denom, addr, nil -} diff --git a/x/tokenfactory/types/authorityMetadata.go b/x/tokenfactory/types/authorityMetadata.go deleted file mode 100644 index b45bffcab..000000000 --- a/x/tokenfactory/types/authorityMetadata.go +++ /dev/null @@ -1,15 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (metadata DenomAuthorityMetadata) Validate() error { - if metadata.Admin != "" { - _, err := sdk.AccAddressFromBech32(metadata.Admin) - if err != nil { - return err - } - } - return nil -} diff --git a/x/tokenfactory/types/authorityMetadata.pb.go b/x/tokenfactory/types/authorityMetadata.pb.go deleted file mode 100644 index 2b190cada..000000000 --- a/x/tokenfactory/types/authorityMetadata.pb.go +++ /dev/null @@ -1,349 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: quicksilver/tokenfactory/v1beta1/authorityMetadata.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/gogo/protobuf/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 for addresses 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 { - // Can be empty for no admin, or a valid quicksilver address - 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_c9ff2afb43053125, []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 "" -} - -func init() { - proto.RegisterType((*DenomAuthorityMetadata)(nil), "quicksilver.tokenfactory.v1beta1.DenomAuthorityMetadata") -} - -func init() { - proto.RegisterFile("quicksilver/tokenfactory/v1beta1/authorityMetadata.proto", fileDescriptor_c9ff2afb43053125) -} - -var fileDescriptor_c9ff2afb43053125 = []byte{ - // 221 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x28, 0x2c, 0xcd, 0x4c, - 0xce, 0x2e, 0xce, 0xcc, 0x29, 0x4b, 0x2d, 0xd2, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, - 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x2c, 0x2d, - 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0xf4, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0xd4, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x40, 0xd2, 0xa9, 0x87, 0xac, 0x53, 0x0f, 0xaa, 0x53, 0x4a, - 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xac, 0x58, 0x1f, 0xc4, 0x82, 0xe8, 0x53, 0x72, 0xe3, 0x12, 0x73, - 0x49, 0xcd, 0xcb, 0xcf, 0x75, 0x44, 0x37, 0x57, 0x48, 0x8d, 0x8b, 0x35, 0x31, 0x25, 0x37, 0x33, - 0x4f, 0x82, 0x51, 0x81, 0x51, 0x83, 0xd3, 0x49, 0xe0, 0xd3, 0x3d, 0x79, 0x9e, 0xca, 0xc4, 0xdc, - 0x1c, 0x2b, 0x25, 0xb0, 0xb0, 0x52, 0x10, 0x44, 0xda, 0x8a, 0xe5, 0xc5, 0x02, 0x79, 0x46, 0xa7, - 0xb0, 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, 0xb2, 0x49, 0xcf, 0x2c, 0xc9, - 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0x72, 0xa4, 0x6e, 0x55, 0x7e, 0x5e, 0x2a, 0xb2, - 0x80, 0x7e, 0x05, 0xaa, 0x8f, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xce, 0x34, 0x06, - 0x04, 0x00, 0x00, 0xff, 0xff, 0xb1, 0x43, 0x54, 0x2b, 0x1a, 0x01, 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 (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 = encodeVarintAuthorityMetadata(dAtA, i, uint64(len(m.Admin))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintAuthorityMetadata(dAtA []byte, offset int, v uint64) int { - offset -= sovAuthorityMetadata(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 + sovAuthorityMetadata(uint64(l)) - } - return n -} - -func sovAuthorityMetadata(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozAuthorityMetadata(x uint64) (n int) { - return sovAuthorityMetadata(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 ErrIntOverflowAuthorityMetadata - } - 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 ErrIntOverflowAuthorityMetadata - } - 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 ErrInvalidLengthAuthorityMetadata - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuthorityMetadata - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Admin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAuthorityMetadata(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAuthorityMetadata - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipAuthorityMetadata(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, ErrIntOverflowAuthorityMetadata - } - 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, ErrIntOverflowAuthorityMetadata - } - 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, ErrIntOverflowAuthorityMetadata - } - 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, ErrInvalidLengthAuthorityMetadata - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupAuthorityMetadata - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthAuthorityMetadata - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthAuthorityMetadata = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowAuthorityMetadata = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupAuthorityMetadata = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/tokenfactory/types/codec.go b/x/tokenfactory/types/codec.go deleted file mode 100644 index 26b001fe1..000000000 --- a/x/tokenfactory/types/codec.go +++ /dev/null @@ -1,43 +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" - authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" -) - -func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgCreateDenom{}, "quicksilver/tokenfactory/create-denom", nil) - cdc.RegisterConcrete(&MsgMint{}, "quicksilver/tokenfactory/mint", nil) - cdc.RegisterConcrete(&MsgBurn{}, "quicksilver/tokenfactory/burn", nil) - cdc.RegisterConcrete(&MsgChangeAdmin{}, "quicksilver/tokenfactory/change-admin", nil) -} - -func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - registry.RegisterImplementations( - (*sdk.Msg)(nil), - &MsgCreateDenom{}, - &MsgMint{}, - &MsgBurn{}, - // &MsgForceTransfer{}, - &MsgChangeAdmin{}, - ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) -} - -var ( - amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) -) - -func init() { - RegisterCodec(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 - sdk.RegisterLegacyAminoCodec(amino) - RegisterCodec(authzcodec.Amino) - - amino.Seal() -} diff --git a/x/tokenfactory/types/denoms.go b/x/tokenfactory/types/denoms.go deleted file mode 100644 index a5033c9ca..000000000 --- a/x/tokenfactory/types/denoms.go +++ /dev/null @@ -1,85 +0,0 @@ -package types - -import ( - "fmt" - "strings" - - sdkioerrors "cosmossdk.io/errors" - - sdk "github.com/cosmos/cosmos-sdk/types" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" -) - -const ( - ModuleDenomPrefix = "factory" - // See the TokenFactory readme for a derivation of these. - // TL;DR, MaxSubdenomLength + MaxHrpLength = 60 comes from SDK max denom length = 128 - // and the structure of tokenfactory denoms. - MaxSubdenomLength = 44 - MaxHrpLength = 16 - // MaxCreatorLength = 59 + MaxHrpLength. - MaxCreatorLength = 59 + MaxHrpLength -) - -// GetTokenDenom constructs a denom string for tokens created by tokenfactory -// based on an input creator address and a subdenom. -// The denom constructed is factory/{creator}/{subdenom}. -func GetTokenDenom(creator, subdenom string) (string, error) { - if len(subdenom) > MaxSubdenomLength { - return "", ErrSubdenomTooLong - } - if len(creator) > MaxCreatorLength { - return "", ErrCreatorTooLong - } - if strings.Contains(creator, "/") { - return "", ErrInvalidCreator - } - denom := strings.Join([]string{ModuleDenomPrefix, creator, subdenom}, "/") - return denom, sdk.ValidateDenom(denom) -} - -// DeconstructDenom takes a token denom string and verifies that it is a valid -// denom of the tokenfactory module, and is of the form `factory/{creator}/{subdenom}`. -// If valid, it returns the creator address and subdenom. -func DeconstructDenom(denom string) (creator, subdenom string, err error) { - err = sdk.ValidateDenom(denom) - if err != nil { - return "", "", err - } - - strParts := strings.Split(denom, "/") - if len(strParts) < 3 { - return "", "", sdkioerrors.Wrapf(ErrInvalidDenom, "not enough parts of denom %s", denom) - } - - if strParts[0] != ModuleDenomPrefix { - return "", "", sdkioerrors.Wrapf(ErrInvalidDenom, "denom prefix is incorrect. Is: %s. Should be: %s", strParts[0], ModuleDenomPrefix) - } - - creator = strParts[1] - creatorAddr, err := sdk.AccAddressFromBech32(creator) - if err != nil { - return "", "", sdkioerrors.Wrapf(ErrInvalidDenom, "Invalid creator address (%s)", err) - } - - // Handle the case where a denom has a slash in its subdenom. For example, - // when we did the split, we'd turn factory/accaddr/atomderivative/sikka into ["factory", "accaddr", "atomderivative", "sikka"] - // So we have to join [2:] with a "/" as the delimiter to get back the correct subdenom which should be "atomderivative/sikka" - subdenom = strings.Join(strParts[2:], "/") - - return creatorAddr.String(), subdenom, nil -} - -// NewTokenFactoryDenomMintCoinsRestriction creates and returns a BankMintingRestrictionFn that only allows minting of -// valid tokenfactory denoms. -func NewTokenFactoryDenomMintCoinsRestriction() bankkeeper.MintingRestrictionFn { - return func(ctx sdk.Context, coinsToMint sdk.Coins) error { - for _, coin := range coinsToMint { - _, _, err := DeconstructDenom(coin.Denom) - if err != nil { - return fmt.Errorf("does not have permission to mint %s", coin.Denom) - } - } - return nil - } -} diff --git a/x/tokenfactory/types/denoms_test.go b/x/tokenfactory/types/denoms_test.go deleted file mode 100644 index bd0a6109b..000000000 --- a/x/tokenfactory/types/denoms_test.go +++ /dev/null @@ -1,133 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" - - cmdcfg "github.com/quicksilver-zone/quicksilver/cmd/config" - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -func TestDeconstructDenom(t *testing.T) { - config := sdk.GetConfig() - cmdcfg.SetBech32Prefixes(config) - - for _, tc := range []struct { - desc string - denom string - expectedSubdenom string - err error - }{ - { - desc: "empty is invalid", - denom: "", - err: types.ErrInvalidDenom, - }, - { - desc: "normal", - denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - expectedSubdenom: "bitcoin", - }, - { - desc: "multiple slashes in subdenom", - denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin/1", - expectedSubdenom: "bitcoin/1", - }, - { - desc: "no subdenom", - denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/", - expectedSubdenom: "", - }, - { - desc: "incorrect prefix", - denom: "ibc/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - err: types.ErrInvalidDenom, - }, - { - desc: "subdenom of only slashes", - denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/////", - expectedSubdenom: "////", - }, - { - desc: "too long name", - denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/adsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsf", - err: types.ErrInvalidDenom, - }, - } { - t.Run(tc.desc, func(t *testing.T) { - expectedCreator := "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf" - creator, subdenom, err := types.DeconstructDenom(tc.denom) - if tc.err != nil { - require.ErrorContains(t, err, tc.err.Error()) - } else { - require.NoError(t, err) - require.Equal(t, expectedCreator, creator) - require.Equal(t, tc.expectedSubdenom, subdenom) - } - }) - } -} - -func TestGetTokenDenom(t *testing.T) { - for _, tc := range []struct { - desc string - creator string - subdenom string - valid bool - }{ - { - desc: "normal", - creator: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf", - subdenom: "bitcoin", - valid: true, - }, - { - desc: "multiple slashes in subdenom", - creator: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf", - subdenom: "bitcoin/1", - valid: true, - }, - { - desc: "no subdenom", - creator: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf", - subdenom: "", - valid: true, - }, - { - desc: "subdenom of only slashes", - creator: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf", - subdenom: "/////", - valid: true, - }, - { - desc: "too long name", - creator: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppfffffffffffffffffffffffffffffffffff", - subdenom: ".", - valid: false, - }, - { - desc: "subdenom is exactly max length", - creator: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf", - subdenom: "bitcoinfsadfsdfeadfsafwefsefsefsdfsdafasefsf", - valid: true, - }, - { - desc: "creator is exactly max length", - creator: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppfkhanhanchaucascascascas", - subdenom: "bitcoin", - valid: true, - }, - } { - t.Run(tc.desc, func(t *testing.T) { - _, err := types.GetTokenDenom(tc.creator, tc.subdenom) - if tc.valid { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) - } -} diff --git a/x/tokenfactory/types/errors.go b/x/tokenfactory/types/errors.go deleted file mode 100644 index 34f6151bb..000000000 --- a/x/tokenfactory/types/errors.go +++ /dev/null @@ -1,22 +0,0 @@ -package types - -// DONTCOVER - -import ( - "fmt" - - sdkioerrors "cosmossdk.io/errors" -) - -// x/tokenfactory module sentinel errors. -var ( - ErrDenomExists = sdkioerrors.Register(ModuleName, 2, "attempting to create a denom that already exists (has bank metadata)") - ErrUnauthorized = sdkioerrors.Register(ModuleName, 3, "unauthorized account") - ErrInvalidDenom = sdkioerrors.Register(ModuleName, 4, "invalid denom") - ErrInvalidCreator = sdkioerrors.Register(ModuleName, 5, "invalid creator") - ErrInvalidAuthorityMetadata = sdkioerrors.Register(ModuleName, 6, "invalid authority metadata") - ErrInvalidGenesis = sdkioerrors.Register(ModuleName, 7, "invalid genesis") - ErrSubdenomTooLong = sdkioerrors.Register(ModuleName, 8, fmt.Sprintf("subdenom too long, max length is %d bytes", MaxSubdenomLength)) - ErrCreatorTooLong = sdkioerrors.Register(ModuleName, 9, fmt.Sprintf("creator too long, max length is %d bytes", MaxCreatorLength)) - ErrDenomDoesNotExist = sdkioerrors.Register(ModuleName, 10, "denom does not exist") -) diff --git a/x/tokenfactory/types/events.go b/x/tokenfactory/types/events.go deleted file mode 100644 index c69c645e4..000000000 --- a/x/tokenfactory/types/events.go +++ /dev/null @@ -1,18 +0,0 @@ -package types - -// event types - -// nolint:gosec -const ( - AttributeAmount = "amount" - AttributeCreator = "creator" - AttributeSubdenom = "subdenom" - AttributeNewTokenDenom = "new_token_denom" - AttributeMintToAddress = "mint_to_address" - AttributeBurnFromAddress = "burn_from_address" - AttributeTransferFromAddress = "transfer_from_address" - AttributeTransferToAddress = "transfer_to_address" - AttributeDenom = "denom" - AttributeNewAdmin = "new_admin" - AttributeDenomMetadata = "denom_metadata" -) diff --git a/x/tokenfactory/types/expected_keepers.go b/x/tokenfactory/types/expected_keepers.go deleted file mode 100644 index a564fb013..000000000 --- a/x/tokenfactory/types/expected_keepers.go +++ /dev/null @@ -1,38 +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) - - HasSupply(ctx sdk.Context, denom string) 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 - SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, 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 - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - - SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins -} - -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/genesis.go b/x/tokenfactory/types/genesis.go deleted file mode 100644 index 2bbeea9a2..000000000 --- a/x/tokenfactory/types/genesis.go +++ /dev/null @@ -1,48 +0,0 @@ -package types - -import ( - sdkioerrors "cosmossdk.io/errors" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// DefaultGenesis returns the default Capability genesis state. -func DefaultGenesis() *GenesisState { - return &GenesisState{ - Params: DefaultParams(), - FactoryDenoms: []GenesisDenom{}, - } -} - -// Validate performs basic genesis state validation returning an error upon any -// failure. -func (gs GenesisState) Validate() error { - err := gs.Params.Validate() - if err != nil { - return err - } - - seenDenoms := map[string]bool{} - - for _, denom := range gs.GetFactoryDenoms() { - if seenDenoms[denom.GetDenom()] { - return sdkioerrors.Wrapf(ErrInvalidGenesis, "duplicate denom: %s", denom.GetDenom()) - } - - seenDenoms[denom.GetDenom()] = true - - _, _, err := DeconstructDenom(denom.GetDenom()) - if err != nil { - return err - } - - if denom.AuthorityMetadata.Admin != "" { - _, err = sdk.AccAddressFromBech32(denom.AuthorityMetadata.Admin) - if err != nil { - return sdkioerrors.Wrapf(ErrInvalidAuthorityMetadata, "Invalid admin address (%s)", err) - } - } - } - - return nil -} diff --git a/x/tokenfactory/types/genesis.pb.go b/x/tokenfactory/types/genesis.pb.go deleted file mode 100644 index bcfb0f0a6..000000000 --- a/x/tokenfactory/types/genesis.pb.go +++ /dev/null @@ -1,649 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: quicksilver/tokenfactory/v1beta1/genesis.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/gogo/protobuf/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 tokenfactory module's genesis state. -type GenesisState struct { - // params defines the paramaters of the module. - Params Params `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_ec8c23d19841526d, []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) GetFactoryDenoms() []GenesisDenom { - if m != nil { - return m.FactoryDenoms - } - return nil -} - -// GenesisDenom defines a tokenfactory denom that is defined within genesis -// state. The structure contains DenomAuthorityMetadata which defines the -// denom's admin. -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_ec8c23d19841526d, []int{1} -} -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((*GenesisState)(nil), "quicksilver.tokenfactory.v1beta1.GenesisState") - proto.RegisterType((*GenesisDenom)(nil), "quicksilver.tokenfactory.v1beta1.GenesisDenom") -} - -func init() { - proto.RegisterFile("quicksilver/tokenfactory/v1beta1/genesis.proto", fileDescriptor_ec8c23d19841526d) -} - -var fileDescriptor_ec8c23d19841526d = []byte{ - // 366 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2b, 0x2c, 0xcd, 0x4c, - 0xce, 0x2e, 0xce, 0xcc, 0x29, 0x4b, 0x2d, 0xd2, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, - 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, - 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x40, 0x52, 0xaf, 0x87, - 0xac, 0x5e, 0x0f, 0xaa, 0x5e, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xac, 0x58, 0x1f, 0xc4, 0x82, - 0xe8, 0x93, 0xb2, 0x20, 0x68, 0x4f, 0x62, 0x69, 0x49, 0x46, 0x7e, 0x51, 0x66, 0x49, 0xa5, 0x6f, - 0x6a, 0x49, 0x62, 0x4a, 0x62, 0x49, 0x22, 0x54, 0xa7, 0x2e, 0x41, 0x9d, 0x05, 0x89, 0x45, 0x89, - 0xb9, 0x50, 0x07, 0x2a, 0x9d, 0x61, 0xe4, 0xe2, 0x71, 0x87, 0x38, 0x39, 0xb8, 0x24, 0xb1, 0x24, - 0x55, 0xc8, 0x8d, 0x8b, 0x0d, 0xa2, 0x40, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x43, 0x8f, - 0x90, 0x17, 0xf4, 0x02, 0xc0, 0xea, 0x9d, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0xea, 0x16, - 0x2a, 0xe1, 0xe2, 0x83, 0xaa, 0x8b, 0x4f, 0x49, 0xcd, 0xcb, 0xcf, 0x2d, 0x96, 0x60, 0x52, 0x60, - 0xd6, 0xe0, 0x36, 0xd2, 0x23, 0x6c, 0x1e, 0xd4, 0x3d, 0x2e, 0x20, 0x6d, 0x4e, 0xb2, 0x20, 0x53, - 0x3f, 0xdd, 0x93, 0x17, 0xad, 0x4c, 0xcc, 0xcd, 0xb1, 0x52, 0x42, 0x35, 0x53, 0x29, 0x88, 0x17, - 0x2a, 0xe0, 0x02, 0xe1, 0x9f, 0x44, 0x78, 0x07, 0x2c, 0x22, 0xa4, 0xc6, 0xc5, 0x0a, 0x56, 0x0a, - 0xf6, 0x0d, 0xa7, 0x93, 0xc0, 0xa7, 0x7b, 0xf2, 0x3c, 0x10, 0x93, 0xc0, 0xc2, 0x4a, 0x41, 0x10, - 0x69, 0xa1, 0x2e, 0x46, 0x2e, 0x21, 0x78, 0x90, 0xc6, 0xe7, 0x42, 0xc3, 0x54, 0x82, 0x09, 0x1c, - 0x06, 0x16, 0x84, 0xdd, 0x0c, 0xb6, 0xcd, 0x11, 0x3d, 0x4e, 0x9c, 0x14, 0xa1, 0xae, 0x97, 0x84, - 0xd8, 0x89, 0x69, 0x83, 0x52, 0x90, 0x20, 0x46, 0x4c, 0x5a, 0xb1, 0xbc, 0x58, 0x20, 0xcf, 0xe8, - 0x14, 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, 0x36, 0xe9, 0x99, 0x25, - 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x48, 0x2e, 0xd3, 0xad, 0xca, 0xcf, 0x4b, 0x45, - 0x16, 0xd0, 0xaf, 0x40, 0x4d, 0x01, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x98, 0x37, - 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x71, 0x6d, 0x69, 0xe7, 0xcc, 0x02, 0x00, 0x00, -} - -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 *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 = 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 *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 = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Denom))) - 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.FactoryDenoms) > 0 { - for _, e := range m.FactoryDenoms { - l = e.Size() - n += 1 + l + sovGenesis(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 + sovGenesis(uint64(l)) - } - l = m.AuthorityMetadata.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 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 FactoryDenoms", 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.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 := 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 *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 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: 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 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.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 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.AuthorityMetadata.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/tokenfactory/types/genesis_test.go b/x/tokenfactory/types/genesis_test.go deleted file mode 100644 index ccaa6a2c9..000000000 --- a/x/tokenfactory/types/genesis_test.go +++ /dev/null @@ -1,139 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -func TestGenesisState_Validate(t *testing.T) { - for _, tc := range []struct { - desc string - genState *types.GenesisState - valid bool - }{ - { - desc: "default is valid", - genState: types.DefaultGenesis(), - valid: true, - }, - { - desc: "valid genesis state", - genState: &types.GenesisState{ - FactoryDenoms: []types.GenesisDenom{ - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf", - }, - }, - }, - }, - valid: true, - }, - { - desc: "different admin from creator", - genState: &types.GenesisState{ - FactoryDenoms: []types.GenesisDenom{ - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf", - }, - }, - }, - }, - valid: true, - }, - { - desc: "empty admin", - genState: &types.GenesisState{ - FactoryDenoms: []types.GenesisDenom{ - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "", - }, - }, - }, - }, - valid: true, - }, - { - desc: "no admin", - genState: &types.GenesisState{ - FactoryDenoms: []types.GenesisDenom{ - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - }, - }, - }, - valid: true, - }, - { - desc: "invalid admin", - genState: &types.GenesisState{ - FactoryDenoms: []types.GenesisDenom{ - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "moose", - }, - }, - }, - }, - valid: false, - }, - { - desc: "multiple denoms", - genState: &types.GenesisState{ - FactoryDenoms: []types.GenesisDenom{ - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "", - }, - }, - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/litecoin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "", - }, - }, - }, - }, - valid: true, - }, - { - desc: "duplicate denoms", - genState: &types.GenesisState{ - FactoryDenoms: []types.GenesisDenom{ - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "", - }, - }, - { - Denom: "factory/quick1ve2nremzdnu7e55khlrt2282qhh98dh4708ppf/bitcoin", - AuthorityMetadata: types.DenomAuthorityMetadata{ - Admin: "", - }, - }, - }, - }, - valid: false, - }, - } { - t.Run(tc.desc, func(t *testing.T) { - err := tc.genState.Validate() - if tc.valid { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) - } -} diff --git a/x/tokenfactory/types/keys.go b/x/tokenfactory/types/keys.go deleted file mode 100644 index 417f7dd72..000000000 --- a/x/tokenfactory/types/keys.go +++ /dev/null @@ -1,49 +0,0 @@ -package types - -import ( - "strings" -) - -const ( - // ModuleName defines the module name. - ModuleName = "tokenfactory" - - // 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 - - // MemStoreKey defines the in-memory store key. - MemStoreKey = "mem_tokenfactory" -) - -// KeySeparator is used to combine parts of the keys in the store. -const KeySeparator = "|" - -var ( - DenomAuthorityMetadataKey = "authoritymetadata" - DenomsPrefixKey = "denoms" - CreatorPrefixKey = "creator" - AdminPrefixKey = "admin" -) - -// GetDenomPrefixStore returns the store prefix where all the data associated with a specific denom -// is stored. -func GetDenomPrefixStore(denom string) []byte { - return []byte(strings.Join([]string{DenomsPrefixKey, denom, ""}, KeySeparator)) -} - -// GetCreatorPrefix returns the store prefix where the list of the denoms created by a specific -// creator are stored. -func GetCreatorPrefix(creator string) []byte { - return []byte(strings.Join([]string{CreatorPrefixKey, creator, ""}, KeySeparator)) -} - -// GetCreatorsPrefix returns the store prefix where a list of all creator addresses are stored. -func GetCreatorsPrefix() []byte { - return []byte(CreatorPrefixKey + KeySeparator + "") -} diff --git a/x/tokenfactory/types/msgs.go b/x/tokenfactory/types/msgs.go deleted file mode 100644 index fa8f5753b..000000000 --- a/x/tokenfactory/types/msgs.go +++ /dev/null @@ -1,248 +0,0 @@ -package types - -import ( - sdkioerrors "cosmossdk.io/errors" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" -) - -// constants. -const ( - TypeMsgCreateDenom = "create_denom" - TypeMsgMint = "tf_mint" - TypeMsgBurn = "tf_burn" - TypeMsgForceTransfer = "force_transfer" - TypeMsgChangeAdmin = "change_admin" - TypeMsgSetDenomMetadata = "set_denom_metadata" -) - -var _ sdk.Msg = &MsgCreateDenom{} - -// NewMsgCreateDenom creates a msg to create a new denom. -func NewMsgCreateDenom(sender, subdenom string) *MsgCreateDenom { - return &MsgCreateDenom{ - Sender: sender, - Subdenom: subdenom, - } -} - -func (MsgCreateDenom) Route() string { return RouterKey } -func (MsgCreateDenom) Type() string { return TypeMsgCreateDenom } -func (m MsgCreateDenom) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%v)", err) - } - - _, err = GetTokenDenom(m.Sender, m.Subdenom) - if err != nil { - return sdkioerrors.Wrap(ErrInvalidDenom, err.Error()) - } - - return nil -} - -func (m MsgCreateDenom) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -func (m MsgCreateDenom) GetSigners() []sdk.AccAddress { - sender, _ := sdk.AccAddressFromBech32(m.Sender) - return []sdk.AccAddress{sender} -} - -var _ sdk.Msg = &MsgMint{} - -// NewMsgMint creates a message to mint tokens. -func NewMsgMint(sender string, amount sdk.Coin) *MsgMint { - return &MsgMint{ - Sender: sender, - Amount: amount, - } -} - -func (MsgMint) Route() string { return RouterKey } -func (MsgMint) Type() string { return TypeMsgMint } -func (m MsgMint) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) - } - - if !m.Amount.IsValid() || m.Amount.Amount.Equal(sdk.ZeroInt()) { - return sdkioerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) - } - - return nil -} - -func (m MsgMint) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -func (m MsgMint) GetSigners() []sdk.AccAddress { - sender, _ := sdk.AccAddressFromBech32(m.Sender) - return []sdk.AccAddress{sender} -} - -var _ sdk.Msg = &MsgBurn{} - -// NewMsgBurn creates a message to burn tokens. -func NewMsgBurn(sender string, amount sdk.Coin) *MsgBurn { - return &MsgBurn{ - Sender: sender, - Amount: amount, - } -} - -func (MsgBurn) Route() string { return RouterKey } -func (MsgBurn) Type() string { return TypeMsgBurn } -func (m MsgBurn) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) - } - - if !m.Amount.IsValid() || m.Amount.Amount.Equal(sdk.ZeroInt()) { - return sdkioerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) - } - - return nil -} - -func (m MsgBurn) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -func (m MsgBurn) GetSigners() []sdk.AccAddress { - sender, _ := sdk.AccAddressFromBech32(m.Sender) - return []sdk.AccAddress{sender} -} - -// var _ sdk.Msg = &MsgForceTransfer{} - -// // NewMsgForceTransfer creates a transfer funds from one account to another -// func NewMsgForceTransfer(sender string, amount sdk.Coin, fromAddr, toAddr string) *MsgForceTransfer { -// return &MsgForceTransfer{ -// Sender: sender, -// Amount: amount, -// TransferFromAddress: fromAddr, -// TransferToAddress: toAddr, -// } -// } - -// func (m MsgForceTransfer) Route() string { return RouterKey } -// func (m MsgForceTransfer) Type() string { return TypeMsgForceTransfer } -// func (m MsgForceTransfer) ValidateBasic() error { -// _, err := sdk.AccAddressFromBech32(m.Sender) -// if err != nil { -// return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) -// } - -// _, err = sdk.AccAddressFromBech32(m.TransferFromAddress) -// if err != nil { -// return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) -// } -// _, err = sdk.AccAddressFromBech32(m.TransferToAddress) -// if err != nil { -// return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) -// } - -// if !m.Amount.IsValid() { -// return sdkioerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) -// } - -// return nil -// } - -// func (m MsgForceTransfer) GetSignBytes() []byte { -// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -// } - -// func (m MsgForceTransfer) GetSigners() []sdk.AccAddress { -// sender, _ := sdk.AccAddressFromBech32(m.Sender) -// return []sdk.AccAddress{sender} -// } - -var _ sdk.Msg = &MsgChangeAdmin{} - -// NewMsgChangeAdmin creates a message to burn tokens. -func NewMsgChangeAdmin(sender, denom, newAdmin string) *MsgChangeAdmin { - return &MsgChangeAdmin{ - Sender: sender, - Denom: denom, - NewAdmin: newAdmin, - } -} - -func (MsgChangeAdmin) Route() string { return RouterKey } -func (MsgChangeAdmin) Type() string { return TypeMsgChangeAdmin } -func (m MsgChangeAdmin) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) - } - - _, err = sdk.AccAddressFromBech32(m.NewAdmin) - if err != nil { - return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) - } - - _, _, err = DeconstructDenom(m.Denom) - if err != nil { - return err - } - - return nil -} - -func (m MsgChangeAdmin) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -func (m MsgChangeAdmin) GetSigners() []sdk.AccAddress { - sender, _ := sdk.AccAddressFromBech32(m.Sender) - return []sdk.AccAddress{sender} -} - -var _ sdk.Msg = &MsgSetDenomMetadata{} - -// NewMsgSetDenomMetadata creates a message to set denom metadata. -func NewMsgSetDenomMetadata(sender string, metadata banktypes.Metadata) *MsgSetDenomMetadata { - return &MsgSetDenomMetadata{ - Sender: sender, - Metadata: metadata, - } -} - -func (MsgSetDenomMetadata) Route() string { return RouterKey } -func (MsgSetDenomMetadata) Type() string { return TypeMsgSetDenomMetadata } -func (m MsgSetDenomMetadata) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) - } - - err = m.Metadata.Validate() - if err != nil { - return err - } - - _, _, err = DeconstructDenom(m.Metadata.Base) - if err != nil { - return err - } - - return nil -} - -func (m MsgSetDenomMetadata) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -func (m MsgSetDenomMetadata) GetSigners() []sdk.AccAddress { - sender, _ := sdk.AccAddressFromBech32(m.Sender) - return []sdk.AccAddress{sender} -} diff --git a/x/tokenfactory/types/msgs_test.go b/x/tokenfactory/types/msgs_test.go deleted file mode 100644 index 347813174..000000000 --- a/x/tokenfactory/types/msgs_test.go +++ /dev/null @@ -1,402 +0,0 @@ -package types_test - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" - - sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - "github.com/quicksilver-zone/quicksilver/x/tokenfactory/types" -) - -// TestMsgCreateDenom tests if valid/invalid create denom messages are properly validated/invalidated. -func TestMsgCreateDenom(t *testing.T) { - // generate a private/public key pair and get the respective address - pk1 := ed25519.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pk1.Address()) - - // make a proper createDenom message - createMsg := func(after func(msg types.MsgCreateDenom) types.MsgCreateDenom) types.MsgCreateDenom { - properMsg := *types.NewMsgCreateDenom( - addr1.String(), - "bitcoin", - ) - - return after(properMsg) - } - - // validate createDenom message was created as intended - msg := createMsg(func(msg types.MsgCreateDenom) types.MsgCreateDenom { - return msg - }) - require.Equal(t, msg.Route(), types.RouterKey) - require.Equal(t, msg.Type(), "create_denom") - signers := msg.GetSigners() - require.Equal(t, len(signers), 1) - require.Equal(t, signers[0].String(), addr1.String()) - - tests := []struct { - name string - msg types.MsgCreateDenom - expectPass bool - }{ - { - name: "proper msg", - msg: createMsg(func(msg types.MsgCreateDenom) types.MsgCreateDenom { - return msg - }), - expectPass: true, - }, - { - name: "empty sender", - msg: createMsg(func(msg types.MsgCreateDenom) types.MsgCreateDenom { - msg.Sender = "" - return msg - }), - expectPass: false, - }, - { - name: "invalid subdenom", - msg: createMsg(func(msg types.MsgCreateDenom) types.MsgCreateDenom { - msg.Subdenom = "thissubdenomismuchtoolongasdkfjaasdfdsafsdlkfnmlksadmflksmdlfmlsakmfdsafasdfasdf" - return msg - }), - expectPass: false, - }, - } - - for _, test := range tests { - if test.expectPass { - require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) - } else { - require.Error(t, test.msg.ValidateBasic(), "test: %v", test.name) - } - } -} - -// TestMsgMint test if valid/invalid create denom messages are properly validated/invalidated. -func TestMsgMint(t *testing.T) { - // generate a private/public key pair and get the respective address - pk1 := ed25519.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pk1.Address()) - - // make a proper mint message - createMsg := func(after func(msg types.MsgMint) types.MsgMint) types.MsgMint { - properMsg := *types.NewMsgMint( - addr1.String(), - sdk.NewCoin("bitcoin", sdk.NewInt(500000000)), - ) - - return after(properMsg) - } - - // validate mint message was created as intended - msg := createMsg(func(msg types.MsgMint) types.MsgMint { - return msg - }) - require.Equal(t, msg.Route(), types.RouterKey) - require.Equal(t, msg.Type(), "tf_mint") - signers := msg.GetSigners() - require.Equal(t, len(signers), 1) - require.Equal(t, signers[0].String(), addr1.String()) - - tests := []struct { - name string - msg types.MsgMint - expectPass bool - }{ - { - name: "proper msg", - msg: createMsg(func(msg types.MsgMint) types.MsgMint { - return msg - }), - expectPass: true, - }, - { - name: "empty sender", - msg: createMsg(func(msg types.MsgMint) types.MsgMint { - msg.Sender = "" - return msg - }), - expectPass: false, - }, - { - name: "zero amount", - msg: createMsg(func(msg types.MsgMint) types.MsgMint { - msg.Amount = sdk.NewCoin("bitcoin", sdk.ZeroInt()) - return msg - }), - expectPass: false, - }, - { - name: "negative amount", - msg: createMsg(func(msg types.MsgMint) types.MsgMint { - msg.Amount.Amount = sdk.NewInt(-10000000) - return msg - }), - expectPass: false, - }, - } - - for _, test := range tests { - if test.expectPass { - require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) - } else { - require.Error(t, test.msg.ValidateBasic(), "test: %v", test.name) - } - } -} - -// TestMsgBurn test if valid/invalid create denom messages are properly validated/invalidated. -func TestMsgBurn(t *testing.T) { - // generate a private/public key pair and get the respective address - pk1 := ed25519.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pk1.Address()) - - // make a proper burn message - baseMsg := types.NewMsgBurn( - addr1.String(), - sdk.NewCoin("bitcoin", sdk.NewInt(500000000)), - ) - - // validate burn message was created as intended - require.Equal(t, baseMsg.Route(), types.RouterKey) - require.Equal(t, baseMsg.Type(), "tf_burn") - signers := baseMsg.GetSigners() - require.Equal(t, len(signers), 1) - require.Equal(t, signers[0].String(), addr1.String()) - - tests := []struct { - name string - msg func() *types.MsgBurn - expectPass bool - }{ - { - name: "proper msg", - msg: func() *types.MsgBurn { - msg := baseMsg - return msg - }, - expectPass: true, - }, - { - name: "empty sender", - msg: func() *types.MsgBurn { - msg := baseMsg - msg.Sender = "" - return msg - }, - expectPass: false, - }, - { - name: "zero amount", - msg: func() *types.MsgBurn { - msg := baseMsg - msg.Amount.Amount = sdk.ZeroInt() - return msg - }, - expectPass: false, - }, - { - name: "negative amount", - msg: func() *types.MsgBurn { - msg := baseMsg - msg.Amount.Amount = sdk.NewInt(-10000000) - return msg - }, - expectPass: false, - }, - } - - for _, test := range tests { - if test.expectPass { - require.NoError(t, test.msg().ValidateBasic(), "test: %v", test.name) - } else { - require.Error(t, test.msg().ValidateBasic(), "test: %v", test.name) - } - } -} - -// TestMsgChangeAdmin test if valid/invalid create denom messages are properly validated/invalidated. -func TestMsgChangeAdmin(t *testing.T) { - // generate a private/public key pair and get the respective address - pk1 := ed25519.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pk1.Address()) - pk2 := ed25519.GenPrivKey().PubKey() - addr2 := sdk.AccAddress(pk2.Address()) - tokenFactoryDenom := fmt.Sprintf("factory/%s/bitcoin", addr1.String()) - - // make a proper changeAdmin message - baseMsg := types.NewMsgChangeAdmin( - addr1.String(), - tokenFactoryDenom, - addr2.String(), - ) - - // validate changeAdmin message was created as intended - require.Equal(t, baseMsg.Route(), types.RouterKey) - require.Equal(t, baseMsg.Type(), "change_admin") - signers := baseMsg.GetSigners() - require.Equal(t, len(signers), 1) - require.Equal(t, signers[0].String(), addr1.String()) - - tests := []struct { - name string - msg func() *types.MsgChangeAdmin - expectPass bool - }{ - { - name: "proper msg", - msg: func() *types.MsgChangeAdmin { - msg := baseMsg - return msg - }, - expectPass: true, - }, - { - name: "empty sender", - msg: func() *types.MsgChangeAdmin { - msg := baseMsg - msg.Sender = "" - return msg - }, - expectPass: false, - }, - { - name: "empty newAdmin", - msg: func() *types.MsgChangeAdmin { - msg := baseMsg - msg.NewAdmin = "" - return msg - }, - expectPass: false, - }, - { - name: "invalid denom", - msg: func() *types.MsgChangeAdmin { - msg := baseMsg - msg.Denom = "bitcoin" - return msg - }, - expectPass: false, - }, - } - - for _, test := range tests { - if test.expectPass { - require.NoError(t, test.msg().ValidateBasic(), "test: %v", test.name) - } else { - require.Error(t, test.msg().ValidateBasic(), "test: %v", test.name) - } - } -} - -// TestMsgSetDenomMetadata test if valid/invalid create denom messages are properly validated/invalidated. -func TestMsgSetDenomMetadata(t *testing.T) { - // generate a private/public key pair and get the respective address - pk1 := ed25519.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pk1.Address()) - tokenFactoryDenom := fmt.Sprintf("factory/%s/bitcoin", addr1.String()) - denomMetadata := banktypes.Metadata{ - Description: "nakamoto", - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: tokenFactoryDenom, - Exponent: 0, - }, - { - Denom: "sats", - Exponent: 6, - }, - }, - Display: "sats", - Base: tokenFactoryDenom, - Name: "bitcoin", - Symbol: "BTC", - } - invalidDenomMetadata := banktypes.Metadata{ - Description: "nakamoto", - DenomUnits: []*banktypes.DenomUnit{ - { - Denom: "bitcoin", - Exponent: 0, - }, - { - Denom: "sats", - Exponent: 6, - }, - }, - Display: "sats", - Base: "bitcoin", - Name: "bitcoin", - Symbol: "BTC", - } - - // make a proper setDenomMetadata message - baseMsg := types.NewMsgSetDenomMetadata( - addr1.String(), - denomMetadata, - ) - - // validate setDenomMetadata message was created as intended - require.Equal(t, baseMsg.Route(), types.RouterKey) - require.Equal(t, baseMsg.Type(), "set_denom_metadata") - signers := baseMsg.GetSigners() - require.Equal(t, len(signers), 1) - require.Equal(t, signers[0].String(), addr1.String()) - - tests := []struct { - name string - msg func() *types.MsgSetDenomMetadata - expectPass bool - }{ - { - name: "proper msg", - msg: func() *types.MsgSetDenomMetadata { - msg := baseMsg - return msg - }, - expectPass: true, - }, - { - name: "empty sender", - msg: func() *types.MsgSetDenomMetadata { - msg := baseMsg - msg.Sender = "" - return msg - }, - expectPass: false, - }, - { - name: "invalid metadata", - msg: func() *types.MsgSetDenomMetadata { - msg := baseMsg - msg.Metadata.Name = "" - return msg - }, - - expectPass: false, - }, - { - name: "invalid base", - msg: func() *types.MsgSetDenomMetadata { - msg := baseMsg - msg.Metadata = invalidDenomMetadata - return msg - }, - expectPass: false, - }, - } - - for _, test := range tests { - if test.expectPass { - require.NoError(t, test.msg().ValidateBasic(), "test: %v", test.name) - } else { - require.Error(t, test.msg().ValidateBasic(), "test: %v", test.name) - } - } -} diff --git a/x/tokenfactory/types/params.go b/x/tokenfactory/types/params.go deleted file mode 100644 index 1e0dcb63d..000000000 --- a/x/tokenfactory/types/params.go +++ /dev/null @@ -1,59 +0,0 @@ -package types - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -) - -const ( - BaseCoinUnit = "uqck" -) - -// Parameter store keys. -var ( - KeyDenomCreationFee = []byte("DenomCreationFee") -) - -// ParamKeyTable returns KeyTable for tokenfactory module. -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -func NewParams(denomCreationFee sdk.Coins) Params { - return Params{ - DenomCreationFee: denomCreationFee, - } -} - -// Validate validates params. -func (p Params) Validate() error { - return validateDenomCreationFee(p.DenomCreationFee) -} - -// ParamSetPairs implements params.ParamSet. -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyDenomCreationFee, &p.DenomCreationFee, validateDenomCreationFee), - } -} - -func validateDenomCreationFee(i interface{}) error { - v, ok := i.(sdk.Coins) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.Validate() != nil { - return fmt.Errorf("invalid denom creation fee: %+v", i) - } - - return nil -} - -func DefaultParams() Params { - return NewParams( - sdk.NewCoins(sdk.NewInt64Coin(BaseCoinUnit, 10_000_000)), - ) -} diff --git a/x/tokenfactory/types/params.pb.go b/x/tokenfactory/types/params.pb.go deleted file mode 100644 index ca6f43874..000000000 --- a/x/tokenfactory/types/params.pb.go +++ /dev/null @@ -1,339 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: quicksilver/tokenfactory/v1beta1/params.proto - -package types - -import ( - 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" - proto "github.com/gogo/protobuf/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 parameters for the tokenfactory module. -type Params struct { - DenomCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=denom_creation_fee,json=denomCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"denom_creation_fee" yaml:"denom_creation_fee"` -} - -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_69624024392a3c59, []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) GetDenomCreationFee() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.DenomCreationFee - } - return nil -} - -func init() { - proto.RegisterType((*Params)(nil), "quicksilver.tokenfactory.v1beta1.Params") -} - -func init() { - proto.RegisterFile("quicksilver/tokenfactory/v1beta1/params.proto", fileDescriptor_69624024392a3c59) -} - -var fileDescriptor_69624024392a3c59 = []byte{ - // 283 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2d, 0x2c, 0xcd, 0x4c, - 0xce, 0x2e, 0xce, 0xcc, 0x29, 0x4b, 0x2d, 0xd2, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, - 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x48, 0x2c, - 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x40, 0x52, 0xae, 0x87, 0xac, - 0x5c, 0x0f, 0xaa, 0x5c, 0x4a, 0x2e, 0x39, 0xbf, 0x38, 0x37, 0xbf, 0x58, 0x3f, 0x29, 0xb1, 0x38, - 0x15, 0x6e, 0x46, 0x72, 0x7e, 0x66, 0x1e, 0xc4, 0x04, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x30, - 0x53, 0x1f, 0xc4, 0x82, 0x88, 0x2a, 0x2d, 0x64, 0xe4, 0x62, 0x0b, 0x00, 0x5b, 0x24, 0x34, 0x8d, - 0x91, 0x4b, 0x28, 0x25, 0x35, 0x2f, 0x3f, 0x37, 0x3e, 0xb9, 0x28, 0x35, 0xb1, 0x24, 0x33, 0x3f, - 0x2f, 0x3e, 0x2d, 0x35, 0x55, 0x82, 0x51, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x52, 0x0f, 0x62, 0xbc, - 0x1e, 0xc8, 0x78, 0x98, 0x9d, 0x7a, 0xce, 0xf9, 0x99, 0x79, 0x4e, 0xbe, 0x27, 0xee, 0xc9, 0x33, - 0x7c, 0xba, 0x27, 0x2f, 0x59, 0x99, 0x98, 0x9b, 0x63, 0xa5, 0x84, 0x69, 0x84, 0xd2, 0xaa, 0xfb, - 0xf2, 0x1a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x50, 0x87, 0x42, - 0x28, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x92, 0xca, 0x82, 0xd4, 0x62, 0xb0, 0x69, 0xc5, 0x41, 0x02, - 0x60, 0x03, 0x9c, 0xa1, 0xfa, 0xdd, 0x52, 0x53, 0x9d, 0xc2, 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, 0xca, 0x06, 0xc9, 0x54, 0xa4, 0x00, 0xd2, 0xad, 0xca, 0xcf, 0x4b, 0x45, - 0x16, 0xd0, 0xaf, 0x40, 0x0d, 0x62, 0xb0, 0x7d, 0x49, 0x6c, 0xe0, 0x20, 0x30, 0x06, 0x04, 0x00, - 0x00, 0xff, 0xff, 0x3f, 0x80, 0x31, 0x47, 0x8b, 0x01, 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.DenomCreationFee) > 0 { - for iNdEx := len(m.DenomCreationFee) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DenomCreationFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(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 len(m.DenomCreationFee) > 0 { - for _, e := range m.DenomCreationFee { - l = e.Size() - n += 1 + l + sovParams(uint64(l)) - } - } - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozParams(x uint64) (n int) { - return sovParams(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 ErrIntOverflowParams - } - 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 DenomCreationFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DenomCreationFee = append(m.DenomCreationFee, types.Coin{}) - if err := m.DenomCreationFee[len(m.DenomCreationFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(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, ErrIntOverflowParams - } - 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, ErrIntOverflowParams - } - 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, ErrIntOverflowParams - } - 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, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/tokenfactory/types/query.pb.go b/x/tokenfactory/types/query.pb.go deleted file mode 100644 index a6d9ad30b..000000000 --- a/x/tokenfactory/types/query.pb.go +++ /dev/null @@ -1,1331 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: quicksilver/tokenfactory/v1beta1/query.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/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_63d586e2371f0a34, []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 { - // 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_63d586e2371f0a34, []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() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// QueryDenomAuthorityMetadataRequest defines the request structure for the -// DenomAuthorityMetadata gRPC query. -type QueryDenomAuthorityMetadataRequest struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` -} - -func (m *QueryDenomAuthorityMetadataRequest) Reset() { *m = QueryDenomAuthorityMetadataRequest{} } -func (m *QueryDenomAuthorityMetadataRequest) String() string { return proto.CompactTextString(m) } -func (*QueryDenomAuthorityMetadataRequest) ProtoMessage() {} -func (*QueryDenomAuthorityMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_63d586e2371f0a34, []int{2} -} -func (m *QueryDenomAuthorityMetadataRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryDenomAuthorityMetadataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryDenomAuthorityMetadataRequest.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 *QueryDenomAuthorityMetadataRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDenomAuthorityMetadataRequest.Merge(m, src) -} -func (m *QueryDenomAuthorityMetadataRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryDenomAuthorityMetadataRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDenomAuthorityMetadataRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryDenomAuthorityMetadataRequest proto.InternalMessageInfo - -func (m *QueryDenomAuthorityMetadataRequest) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -// QueryDenomAuthorityMetadataResponse defines the response structure for the -// DenomAuthorityMetadata gRPC query. -type QueryDenomAuthorityMetadataResponse struct { - AuthorityMetadata DenomAuthorityMetadata `protobuf:"bytes,1,opt,name=authority_metadata,json=authorityMetadata,proto3" json:"authority_metadata" yaml:"authority_metadata"` -} - -func (m *QueryDenomAuthorityMetadataResponse) Reset() { *m = QueryDenomAuthorityMetadataResponse{} } -func (m *QueryDenomAuthorityMetadataResponse) String() string { return proto.CompactTextString(m) } -func (*QueryDenomAuthorityMetadataResponse) ProtoMessage() {} -func (*QueryDenomAuthorityMetadataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_63d586e2371f0a34, []int{3} -} -func (m *QueryDenomAuthorityMetadataResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryDenomAuthorityMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryDenomAuthorityMetadataResponse.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 *QueryDenomAuthorityMetadataResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDenomAuthorityMetadataResponse.Merge(m, src) -} -func (m *QueryDenomAuthorityMetadataResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryDenomAuthorityMetadataResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDenomAuthorityMetadataResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryDenomAuthorityMetadataResponse proto.InternalMessageInfo - -func (m *QueryDenomAuthorityMetadataResponse) GetAuthorityMetadata() DenomAuthorityMetadata { - if m != nil { - return m.AuthorityMetadata - } - return DenomAuthorityMetadata{} -} - -// QueryDenomsFromCreatorRequest defines the request structure for the -// DenomsFromCreator gRPC query. -type QueryDenomsFromCreatorRequest struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty" yaml:"creator"` -} - -func (m *QueryDenomsFromCreatorRequest) Reset() { *m = QueryDenomsFromCreatorRequest{} } -func (m *QueryDenomsFromCreatorRequest) String() string { return proto.CompactTextString(m) } -func (*QueryDenomsFromCreatorRequest) ProtoMessage() {} -func (*QueryDenomsFromCreatorRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_63d586e2371f0a34, []int{4} -} -func (m *QueryDenomsFromCreatorRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryDenomsFromCreatorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryDenomsFromCreatorRequest.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 *QueryDenomsFromCreatorRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDenomsFromCreatorRequest.Merge(m, src) -} -func (m *QueryDenomsFromCreatorRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryDenomsFromCreatorRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDenomsFromCreatorRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryDenomsFromCreatorRequest proto.InternalMessageInfo - -func (m *QueryDenomsFromCreatorRequest) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -// QueryDenomsFromCreatorRequest defines the response structure for the -// DenomsFromCreator gRPC query. -type QueryDenomsFromCreatorResponse struct { - Denoms []string `protobuf:"bytes,1,rep,name=denoms,proto3" json:"denoms,omitempty" yaml:"denoms"` -} - -func (m *QueryDenomsFromCreatorResponse) Reset() { *m = QueryDenomsFromCreatorResponse{} } -func (m *QueryDenomsFromCreatorResponse) String() string { return proto.CompactTextString(m) } -func (*QueryDenomsFromCreatorResponse) ProtoMessage() {} -func (*QueryDenomsFromCreatorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_63d586e2371f0a34, []int{5} -} -func (m *QueryDenomsFromCreatorResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryDenomsFromCreatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryDenomsFromCreatorResponse.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 *QueryDenomsFromCreatorResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDenomsFromCreatorResponse.Merge(m, src) -} -func (m *QueryDenomsFromCreatorResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryDenomsFromCreatorResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDenomsFromCreatorResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryDenomsFromCreatorResponse proto.InternalMessageInfo - -func (m *QueryDenomsFromCreatorResponse) GetDenoms() []string { - if m != nil { - return m.Denoms - } - return nil -} - -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "quicksilver.tokenfactory.v1beta1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "quicksilver.tokenfactory.v1beta1.QueryParamsResponse") - proto.RegisterType((*QueryDenomAuthorityMetadataRequest)(nil), "quicksilver.tokenfactory.v1beta1.QueryDenomAuthorityMetadataRequest") - proto.RegisterType((*QueryDenomAuthorityMetadataResponse)(nil), "quicksilver.tokenfactory.v1beta1.QueryDenomAuthorityMetadataResponse") - proto.RegisterType((*QueryDenomsFromCreatorRequest)(nil), "quicksilver.tokenfactory.v1beta1.QueryDenomsFromCreatorRequest") - proto.RegisterType((*QueryDenomsFromCreatorResponse)(nil), "quicksilver.tokenfactory.v1beta1.QueryDenomsFromCreatorResponse") -} - -func init() { - proto.RegisterFile("quicksilver/tokenfactory/v1beta1/query.proto", fileDescriptor_63d586e2371f0a34) -} - -var fileDescriptor_63d586e2371f0a34 = []byte{ - // 561 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0xcf, 0x6b, 0x13, 0x41, - 0x14, 0xc7, 0x33, 0x6a, 0x22, 0x1d, 0x7f, 0x60, 0xc6, 0x22, 0x1a, 0x74, 0x53, 0x47, 0x90, 0x28, - 0xed, 0x8e, 0xad, 0x0a, 0x45, 0x84, 0xda, 0xf4, 0x87, 0x87, 0x5a, 0xd0, 0x3d, 0x78, 0x10, 0x24, - 0x4c, 0xd2, 0x69, 0xba, 0x34, 0xbb, 0x93, 0xcc, 0x4e, 0x8a, 0x6b, 0xe9, 0xc5, 0x93, 0x78, 0x12, - 0xfc, 0x23, 0xbc, 0xfb, 0x57, 0xf4, 0x58, 0xf0, 0xe2, 0x69, 0x95, 0xc4, 0xbf, 0x60, 0xff, 0x02, - 0xd9, 0x99, 0xa9, 0x26, 0x6e, 0xec, 0xa6, 0xf6, 0x94, 0x65, 0xde, 0x7b, 0xdf, 0xf7, 0xfd, 0xbc, - 0xf7, 0x08, 0x9c, 0xee, 0x74, 0xdd, 0xc6, 0x76, 0xe0, 0xb6, 0x76, 0x98, 0x20, 0x92, 0x6f, 0x33, - 0x7f, 0x93, 0x36, 0x24, 0x17, 0x21, 0xd9, 0x99, 0xad, 0x33, 0x49, 0x67, 0x49, 0xa7, 0xcb, 0x44, - 0x68, 0xb7, 0x05, 0x97, 0x1c, 0x4d, 0x0d, 0x64, 0xdb, 0x83, 0xd9, 0xb6, 0xc9, 0x2e, 0x4d, 0x36, - 0x79, 0x93, 0xab, 0x64, 0x92, 0x7c, 0xe9, 0xba, 0xd2, 0xf5, 0x26, 0xe7, 0xcd, 0x16, 0x23, 0xb4, - 0xed, 0x12, 0xea, 0xfb, 0x5c, 0x52, 0xe9, 0x72, 0x3f, 0x30, 0xd1, 0xf9, 0x4c, 0x0f, 0xb4, 0x2b, - 0xb7, 0xb8, 0x70, 0x65, 0xb8, 0xce, 0x24, 0xdd, 0xa0, 0x92, 0x9a, 0xca, 0x99, 0xcc, 0xca, 0x36, - 0x15, 0xd4, 0x33, 0x8d, 0xf0, 0x24, 0x44, 0x2f, 0x12, 0x9a, 0xe7, 0xea, 0xd1, 0x61, 0x9d, 0x2e, - 0x0b, 0x24, 0x7e, 0x0d, 0x2f, 0x0f, 0xbd, 0x06, 0x6d, 0xee, 0x07, 0x0c, 0xad, 0xc2, 0x82, 0x2e, - 0xbe, 0x0a, 0xa6, 0x40, 0xe5, 0xdc, 0x5c, 0xc5, 0xce, 0x82, 0xb7, 0xb5, 0x42, 0xf5, 0xcc, 0x7e, - 0x54, 0xce, 0x39, 0xa6, 0x1a, 0x3f, 0x83, 0x58, 0xc9, 0x2f, 0x33, 0x9f, 0x7b, 0x8b, 0x7f, 0x83, - 0x18, 0x13, 0xe8, 0x36, 0xcc, 0x6f, 0x24, 0x09, 0xaa, 0xd9, 0x44, 0xf5, 0x52, 0x1c, 0x95, 0xcf, - 0x87, 0xd4, 0x6b, 0x3d, 0xc2, 0xea, 0x19, 0x3b, 0x3a, 0x8c, 0xbf, 0x00, 0x78, 0xeb, 0x48, 0x39, - 0xe3, 0xfe, 0x03, 0x80, 0xe8, 0xf7, 0xd4, 0x6a, 0x9e, 0x09, 0x1b, 0x94, 0xf9, 0x6c, 0x94, 0xd1, - 0xf2, 0xd5, 0x9b, 0x09, 0x5a, 0x1c, 0x95, 0xaf, 0x69, 0x6f, 0xe9, 0x0e, 0xd8, 0x29, 0xa6, 0x96, - 0x85, 0xd7, 0xe1, 0x8d, 0x3f, 0x9e, 0x83, 0x55, 0xc1, 0xbd, 0x25, 0xc1, 0xa8, 0xe4, 0xe2, 0x90, - 0x7e, 0x1a, 0x9e, 0x6d, 0xe8, 0x17, 0xc3, 0x8f, 0xe2, 0xa8, 0x7c, 0x51, 0xf7, 0x30, 0x01, 0xec, - 0x1c, 0xa6, 0xe0, 0x35, 0x68, 0xfd, 0x4b, 0xce, 0xd0, 0xdf, 0x81, 0x05, 0x35, 0xae, 0x64, 0x77, - 0xa7, 0x2b, 0x13, 0xd5, 0x62, 0x1c, 0x95, 0x2f, 0x0c, 0x8c, 0x33, 0xc0, 0x8e, 0x49, 0x98, 0x7b, - 0x9f, 0x87, 0x79, 0xa5, 0x86, 0x3e, 0x03, 0x58, 0xd0, 0x1b, 0x44, 0x0f, 0xb2, 0x07, 0x94, 0x3e, - 0xa4, 0xd2, 0xc3, 0x63, 0x56, 0x69, 0xb3, 0xf8, 0xde, 0xbb, 0xaf, 0x3f, 0x3f, 0x9d, 0xba, 0x8b, - 0x2a, 0x64, 0xcc, 0x6b, 0x46, 0x31, 0x80, 0x57, 0x46, 0x2f, 0x08, 0x2d, 0x8f, 0xe9, 0xe1, 0xc8, - 0x6b, 0x2c, 0xad, 0x9c, 0x50, 0xc5, 0x90, 0xad, 0x29, 0xb2, 0x15, 0xb4, 0x94, 0x4d, 0xa6, 0xb7, - 0x41, 0x76, 0xd5, 0xef, 0x1e, 0x49, 0x1f, 0x16, 0xfa, 0x0e, 0x60, 0x31, 0xb5, 0x71, 0xb4, 0x70, - 0x1c, 0xa7, 0x23, 0x4e, 0xaf, 0xf4, 0xe4, 0xff, 0x05, 0x0c, 0xe5, 0x53, 0x45, 0xb9, 0x88, 0x16, - 0xc6, 0xa5, 0xac, 0x6d, 0x0a, 0xee, 0xd5, 0xcc, 0x35, 0x93, 0x5d, 0xf3, 0xb1, 0x57, 0x7d, 0xb9, - 0xdf, 0xb3, 0xc0, 0x41, 0xcf, 0x02, 0x3f, 0x7a, 0x16, 0xf8, 0xd8, 0xb7, 0x72, 0x07, 0x7d, 0x2b, - 0xf7, 0xad, 0x6f, 0xe5, 0x5e, 0x3d, 0x6e, 0xba, 0x72, 0xab, 0x5b, 0xb7, 0x1b, 0xdc, 0x1b, 0x6c, - 0x32, 0xf3, 0x96, 0xfb, 0x6c, 0xa8, 0xeb, 0x9b, 0xe1, 0xbe, 0x32, 0x6c, 0xb3, 0xa0, 0x5e, 0x50, - 0xff, 0x7e, 0xf7, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0xc5, 0xad, 0x08, 0xec, 0xec, 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 { - // Params defines a gRPC query method that returns the tokenfactory module's - // parameters. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // DenomAuthorityMetadata defines a gRPC query method for fetching - // DenomAuthorityMetadata for a particular denom. - DenomAuthorityMetadata(ctx context.Context, in *QueryDenomAuthorityMetadataRequest, opts ...grpc.CallOption) (*QueryDenomAuthorityMetadataResponse, error) - // DenomsFromCreator defines a gRPC query method for fetching all - // denominations created by a specific admin/creator. - DenomsFromCreator(ctx context.Context, in *QueryDenomsFromCreatorRequest, opts ...grpc.CallOption) (*QueryDenomsFromCreatorResponse, 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, "/quicksilver.tokenfactory.v1beta1.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) DenomAuthorityMetadata(ctx context.Context, in *QueryDenomAuthorityMetadataRequest, opts ...grpc.CallOption) (*QueryDenomAuthorityMetadataResponse, error) { - out := new(QueryDenomAuthorityMetadataResponse) - err := c.cc.Invoke(ctx, "/quicksilver.tokenfactory.v1beta1.Query/DenomAuthorityMetadata", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) DenomsFromCreator(ctx context.Context, in *QueryDenomsFromCreatorRequest, opts ...grpc.CallOption) (*QueryDenomsFromCreatorResponse, error) { - out := new(QueryDenomsFromCreatorResponse) - err := c.cc.Invoke(ctx, "/quicksilver.tokenfactory.v1beta1.Query/DenomsFromCreator", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Params defines a gRPC query method that returns the tokenfactory module's - // parameters. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // DenomAuthorityMetadata defines a gRPC query method for fetching - // DenomAuthorityMetadata for a particular denom. - DenomAuthorityMetadata(context.Context, *QueryDenomAuthorityMetadataRequest) (*QueryDenomAuthorityMetadataResponse, error) - // DenomsFromCreator defines a gRPC query method for fetching all - // denominations created by a specific admin/creator. - DenomsFromCreator(context.Context, *QueryDenomsFromCreatorRequest) (*QueryDenomsFromCreatorResponse, 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) DenomAuthorityMetadata(ctx context.Context, req *QueryDenomAuthorityMetadataRequest) (*QueryDenomAuthorityMetadataResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DenomAuthorityMetadata not implemented") -} -func (*UnimplementedQueryServer) DenomsFromCreator(ctx context.Context, req *QueryDenomsFromCreatorRequest) (*QueryDenomsFromCreatorResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DenomsFromCreator 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: "/quicksilver.tokenfactory.v1beta1.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_DenomAuthorityMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryDenomAuthorityMetadataRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).DenomAuthorityMetadata(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/quicksilver.tokenfactory.v1beta1.Query/DenomAuthorityMetadata", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).DenomAuthorityMetadata(ctx, req.(*QueryDenomAuthorityMetadataRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_DenomsFromCreator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryDenomsFromCreatorRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).DenomsFromCreator(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/quicksilver.tokenfactory.v1beta1.Query/DenomsFromCreator", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).DenomsFromCreator(ctx, req.(*QueryDenomsFromCreatorRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "quicksilver.tokenfactory.v1beta1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - { - MethodName: "DenomAuthorityMetadata", - Handler: _Query_DenomAuthorityMetadata_Handler, - }, - { - MethodName: "DenomsFromCreator", - Handler: _Query_DenomsFromCreator_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "quicksilver/tokenfactory/v1beta1/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 *QueryDenomAuthorityMetadataRequest) 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 *QueryDenomAuthorityMetadataRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryDenomAuthorityMetadataRequest) 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 *QueryDenomAuthorityMetadataResponse) 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 *QueryDenomAuthorityMetadataResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryDenomAuthorityMetadataResponse) 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 = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryDenomsFromCreatorRequest) 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 *QueryDenomsFromCreatorRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryDenomsFromCreatorRequest) 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 *QueryDenomsFromCreatorResponse) 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 *QueryDenomsFromCreatorResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryDenomsFromCreatorResponse) 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 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 *QueryDenomAuthorityMetadataRequest) 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 *QueryDenomAuthorityMetadataResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.AuthorityMetadata.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryDenomsFromCreatorRequest) 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 *QueryDenomsFromCreatorResponse) 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 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 *QueryDenomAuthorityMetadataRequest) 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: QueryDenomAuthorityMetadataRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDenomAuthorityMetadataRequest: 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 *QueryDenomAuthorityMetadataResponse) 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: QueryDenomAuthorityMetadataResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDenomAuthorityMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 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.AuthorityMetadata.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 *QueryDenomsFromCreatorRequest) 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: QueryDenomsFromCreatorRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDenomsFromCreatorRequest: 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 *QueryDenomsFromCreatorResponse) 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: QueryDenomsFromCreatorResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDenomsFromCreatorResponse: 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 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 a28af5f31..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: quicksilver/tokenfactory/v1beta1/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_DenomAuthorityMetadata_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDenomAuthorityMetadataRequest - 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.DenomAuthorityMetadata(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_DenomAuthorityMetadata_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDenomAuthorityMetadataRequest - 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.DenomAuthorityMetadata(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_DenomsFromCreator_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDenomsFromCreatorRequest - 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.DenomsFromCreator(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_DenomsFromCreator_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDenomsFromCreatorRequest - 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.DenomsFromCreator(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_DenomAuthorityMetadata_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_DenomAuthorityMetadata_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_DenomAuthorityMetadata_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_DenomsFromCreator_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_DenomsFromCreator_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_DenomsFromCreator_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_DenomAuthorityMetadata_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_DenomAuthorityMetadata_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_DenomAuthorityMetadata_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_DenomsFromCreator_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_DenomsFromCreator_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_DenomsFromCreator_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{"quicksilver", "tokenfactory", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_DenomAuthorityMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"quicksilver", "tokenfactory", "v1beta1", "denoms", "denom", "authority_metadata"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_DenomsFromCreator_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"quicksilver", "tokenfactory", "v1beta1", "denoms_from_creator", "creator"}, "", runtime.AssumeColonVerbOpt(true))) -) - -var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage - - forward_Query_DenomAuthorityMetadata_0 = runtime.ForwardResponseMessage - - forward_Query_DenomsFromCreator_0 = runtime.ForwardResponseMessage -) diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go deleted file mode 100644 index 07458c747..000000000 --- a/x/tokenfactory/types/tx.pb.go +++ /dev/null @@ -1,2238 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: quicksilver/tokenfactory/v1beta1/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/x/bank/types" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/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 defines the message structure for the CreateDenom gRPC service -// method. It allows an account to create a new denom. It requires a sender -// address and a sub denomination. The (sender_address, sub_denomination) tuple -// must be unique and cannot be re-used. -// -// The resulting denom created is defined as -// . The resulting denom's admin is -// originally set to be the creator, but this can be changed later. The token -// denom does not indicate the current admin. -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_f1d0fc0ea8bbe1bf, []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 -// It returns the full string of the newly created denom -type MsgCreateDenomResponse struct { - 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_f1d0fc0ea8bbe1bf, []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 "" -} - -// MsgMint is the sdk.Msg type for allowing an admin account to mint -// more of a token. For now, we only support minting to the sender account -type MsgMint struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount" yaml:"amount"` -} - -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_f1d0fc0ea8bbe1bf, []int{2} -} -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) GetAmount() types.Coin { - if m != nil { - return m.Amount - } - return types.Coin{} -} - -type MsgMintResponse struct { -} - -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_f1d0fc0ea8bbe1bf, []int{3} -} -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 - -// MsgBurn is the sdk.Msg type for allowing an admin account to burn -// a token. For now, we only support burning from the sender account. -type MsgBurn struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount" yaml:"amount"` -} - -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_f1d0fc0ea8bbe1bf, []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) GetAmount() types.Coin { - if m != nil { - return m.Amount - } - 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_f1d0fc0ea8bbe1bf, []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 - -// MsgChangeAdmin is the sdk.Msg type for allowing an admin account to reassign -// adminship 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_f1d0fc0ea8bbe1bf, []int{6} -} -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 defines the response structure for an executed -// MsgChangeAdmin message. -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_f1d0fc0ea8bbe1bf, []int{7} -} -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 - -// MsgSetDenomMetadata is the sdk.Msg type for allowing an admin account to set -// the denom's bank metadata -type MsgSetDenomMetadata struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Metadata types1.Metadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata" yaml:"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_f1d0fc0ea8bbe1bf, []int{8} -} -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{} -} - -// MsgSetDenomMetadataResponse defines the response structure for an executed -// MsgSetDenomMetadata message. -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_f1d0fc0ea8bbe1bf, []int{9} -} -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 - -func init() { - proto.RegisterType((*MsgCreateDenom)(nil), "quicksilver.tokenfactory.v1beta1.MsgCreateDenom") - proto.RegisterType((*MsgCreateDenomResponse)(nil), "quicksilver.tokenfactory.v1beta1.MsgCreateDenomResponse") - proto.RegisterType((*MsgMint)(nil), "quicksilver.tokenfactory.v1beta1.MsgMint") - proto.RegisterType((*MsgMintResponse)(nil), "quicksilver.tokenfactory.v1beta1.MsgMintResponse") - proto.RegisterType((*MsgBurn)(nil), "quicksilver.tokenfactory.v1beta1.MsgBurn") - proto.RegisterType((*MsgBurnResponse)(nil), "quicksilver.tokenfactory.v1beta1.MsgBurnResponse") - proto.RegisterType((*MsgChangeAdmin)(nil), "quicksilver.tokenfactory.v1beta1.MsgChangeAdmin") - proto.RegisterType((*MsgChangeAdminResponse)(nil), "quicksilver.tokenfactory.v1beta1.MsgChangeAdminResponse") - proto.RegisterType((*MsgSetDenomMetadata)(nil), "quicksilver.tokenfactory.v1beta1.MsgSetDenomMetadata") - proto.RegisterType((*MsgSetDenomMetadataResponse)(nil), "quicksilver.tokenfactory.v1beta1.MsgSetDenomMetadataResponse") -} - -func init() { - proto.RegisterFile("quicksilver/tokenfactory/v1beta1/tx.proto", fileDescriptor_f1d0fc0ea8bbe1bf) -} - -var fileDescriptor_f1d0fc0ea8bbe1bf = []byte{ - // 597 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xbf, 0x6f, 0xd3, 0x40, - 0x18, 0x8d, 0x69, 0x09, 0xe9, 0x95, 0x92, 0xd4, 0x2d, 0x25, 0x04, 0xd5, 0xae, 0x6e, 0x40, 0x74, - 0xc0, 0x26, 0x45, 0x48, 0x08, 0xc1, 0x80, 0xcb, 0xc0, 0xe2, 0xc5, 0x20, 0x06, 0x84, 0x54, 0x5d, - 0x92, 0xc3, 0xb5, 0x12, 0xdf, 0x05, 0xdf, 0xa5, 0x69, 0x18, 0x98, 0x19, 0x19, 0x10, 0x7f, 0x53, - 0xc7, 0x8a, 0x89, 0xc9, 0x42, 0xc9, 0x7f, 0x90, 0xbf, 0x00, 0xf9, 0xee, 0xfc, 0x23, 0x2d, 0x12, - 0x0e, 0x4b, 0xb7, 0xe4, 0xbe, 0xf7, 0xde, 0xf7, 0xee, 0x7d, 0xdf, 0xc9, 0x60, 0xff, 0xd3, 0x28, - 0xe8, 0xf6, 0x59, 0x30, 0x38, 0xc1, 0x91, 0xcd, 0x69, 0x1f, 0x93, 0x8f, 0xa8, 0xcb, 0x69, 0x34, - 0xb1, 0x4f, 0xda, 0x1d, 0xcc, 0x51, 0xdb, 0xe6, 0xa7, 0xd6, 0x30, 0xa2, 0x9c, 0xea, 0x7b, 0x05, - 0xa8, 0x55, 0x84, 0x5a, 0x0a, 0xda, 0x32, 0xba, 0x94, 0x85, 0x94, 0xd9, 0x1d, 0x44, 0xfa, 0x19, - 0x3f, 0xf9, 0x23, 0x15, 0x0a, 0x75, 0x86, 0xb3, 0x7a, 0x97, 0x06, 0x44, 0xd5, 0xb7, 0x7d, 0xea, - 0x53, 0xf1, 0xd3, 0x4e, 0x7e, 0xc9, 0x53, 0x38, 0x00, 0xb7, 0x5c, 0xe6, 0x1f, 0x46, 0x18, 0x71, - 0xfc, 0x0a, 0x13, 0x1a, 0xea, 0xfb, 0xa0, 0xca, 0x30, 0xe9, 0xe1, 0xa8, 0xa9, 0xed, 0x69, 0x0f, - 0xd6, 0x9c, 0xcd, 0x79, 0x6c, 0x6e, 0x4c, 0x50, 0x38, 0x78, 0x06, 0xe5, 0x39, 0xf4, 0x14, 0x40, - 0xb7, 0x41, 0x8d, 0x8d, 0x3a, 0xbd, 0x84, 0xd6, 0xbc, 0x26, 0xc0, 0x5b, 0xf3, 0xd8, 0xac, 0x2b, - 0xb0, 0xaa, 0x40, 0x2f, 0x03, 0xc1, 0x0f, 0x60, 0x67, 0xb1, 0x9b, 0x87, 0xd9, 0x90, 0x12, 0x86, - 0x75, 0x07, 0xd4, 0x09, 0x1e, 0x1f, 0x89, 0x9b, 0x1f, 0x49, 0x45, 0xd9, 0xbe, 0x35, 0x8f, 0xcd, - 0x1d, 0xa9, 0x78, 0x01, 0x00, 0xbd, 0x0d, 0x82, 0xc7, 0x6f, 0x93, 0x03, 0xa1, 0x05, 0xbf, 0x80, - 0x1b, 0x2e, 0xf3, 0xdd, 0x80, 0xf0, 0x65, 0x2e, 0xf1, 0x1a, 0x54, 0x51, 0x48, 0x47, 0x84, 0x8b, - 0x2b, 0xac, 0x1f, 0xdc, 0xb5, 0x64, 0x90, 0x56, 0x12, 0x64, 0x9a, 0xbe, 0x75, 0x48, 0x03, 0xe2, - 0xdc, 0x3e, 0x8b, 0xcd, 0x4a, 0xae, 0x24, 0x69, 0xd0, 0x53, 0x7c, 0xb8, 0x09, 0xea, 0xaa, 0x7f, - 0x7a, 0x2d, 0x65, 0xc9, 0x19, 0x45, 0xe4, 0x2a, 0x2d, 0x25, 0xfd, 0x33, 0x4b, 0x3f, 0x34, 0x39, - 0xf2, 0x63, 0x44, 0x7c, 0xfc, 0xb2, 0x17, 0x06, 0x4b, 0x59, 0xbb, 0x0f, 0xae, 0x17, 0xe7, 0xdd, - 0x98, 0xc7, 0xe6, 0x4d, 0x89, 0x54, 0x33, 0x91, 0x65, 0xbd, 0x0d, 0xd6, 0x92, 0x71, 0xa1, 0x44, - 0xbf, 0xb9, 0x22, 0xb0, 0xdb, 0xf3, 0xd8, 0x6c, 0xe4, 0x93, 0x14, 0x25, 0xe8, 0xd5, 0x08, 0x1e, - 0x0b, 0x17, 0xb0, 0x29, 0x97, 0x23, 0xf7, 0x95, 0x59, 0xfe, 0xae, 0x81, 0x2d, 0x97, 0xf9, 0x6f, - 0x30, 0x17, 0x83, 0x76, 0x31, 0x47, 0x3d, 0xc4, 0xd1, 0x32, 0xbe, 0x3d, 0x50, 0x0b, 0x15, 0x4d, - 0x85, 0xba, 0x9b, 0x87, 0x4a, 0xfa, 0x59, 0xa8, 0xa9, 0xb6, 0x73, 0x47, 0x05, 0xab, 0xb6, 0x39, - 0x25, 0x43, 0x2f, 0xd3, 0x81, 0xbb, 0xe0, 0xde, 0x5f, 0x5c, 0xa5, 0xae, 0x0f, 0x7e, 0xae, 0x82, - 0x15, 0x97, 0xf9, 0xfa, 0x04, 0xac, 0x17, 0xdf, 0xd7, 0x23, 0xeb, 0x5f, 0x4f, 0xdd, 0x5a, 0x7c, - 0x23, 0xad, 0xa7, 0xcb, 0x32, 0xb2, 0x57, 0xd5, 0x03, 0xab, 0xf2, 0x39, 0x94, 0x52, 0x48, 0xa0, - 0xad, 0x76, 0x69, 0x68, 0xb1, 0x8b, 0xdc, 0xf0, 0x52, 0xd4, 0x04, 0x5a, 0xb2, 0x4b, 0x71, 0x6f, - 0x45, 0x8c, 0x85, 0x9d, 0x2d, 0x19, 0x63, 0xce, 0x28, 0x1b, 0xe3, 0xe5, 0xfd, 0xd3, 0xbf, 0x6a, - 0xa0, 0x71, 0x69, 0xf9, 0x9e, 0x94, 0x92, 0xbb, 0x48, 0x6b, 0xbd, 0xf8, 0x2f, 0x5a, 0x6a, 0xc5, - 0x79, 0x77, 0x36, 0x35, 0xb4, 0xf3, 0xa9, 0xa1, 0xfd, 0x9e, 0x1a, 0xda, 0xb7, 0x99, 0x51, 0x39, - 0x9f, 0x19, 0x95, 0x5f, 0x33, 0xa3, 0xf2, 0xfe, 0xb9, 0x1f, 0xf0, 0xe3, 0x51, 0xc7, 0xea, 0xd2, - 0xd0, 0x2e, 0xb4, 0x78, 0xf8, 0x99, 0x12, 0x5c, 0x3c, 0xb0, 0x4f, 0x17, 0x3f, 0x45, 0x7c, 0x32, - 0xc4, 0xac, 0x53, 0x15, 0x9f, 0x83, 0xc7, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x28, 0x54, 0xa7, - 0x65, 0xb3, 0x06, 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(ctx context.Context, in *MsgCreateDenom, opts ...grpc.CallOption) (*MsgCreateDenomResponse, error) - Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) - Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) - ChangeAdmin(ctx context.Context, in *MsgChangeAdmin, opts ...grpc.CallOption) (*MsgChangeAdminResponse, error) - SetDenomMetadata(ctx context.Context, in *MsgSetDenomMetadata, opts ...grpc.CallOption) (*MsgSetDenomMetadataResponse, 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, "/quicksilver.tokenfactory.v1beta1.Msg/CreateDenom", 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, "/quicksilver.tokenfactory.v1beta1.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, "/quicksilver.tokenfactory.v1beta1.Msg/Burn", 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, "/quicksilver.tokenfactory.v1beta1.Msg/ChangeAdmin", 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, "/quicksilver.tokenfactory.v1beta1.Msg/SetDenomMetadata", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - CreateDenom(context.Context, *MsgCreateDenom) (*MsgCreateDenomResponse, error) - Mint(context.Context, *MsgMint) (*MsgMintResponse, error) - Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) - ChangeAdmin(context.Context, *MsgChangeAdmin) (*MsgChangeAdminResponse, error) - SetDenomMetadata(context.Context, *MsgSetDenomMetadata) (*MsgSetDenomMetadataResponse, 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) 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) ChangeAdmin(ctx context.Context, req *MsgChangeAdmin) (*MsgChangeAdminResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChangeAdmin not implemented") -} -func (*UnimplementedMsgServer) SetDenomMetadata(ctx context.Context, req *MsgSetDenomMetadata) (*MsgSetDenomMetadataResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetDenomMetadata 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: "/quicksilver.tokenfactory.v1beta1.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_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: "/quicksilver.tokenfactory.v1beta1.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: "/quicksilver.tokenfactory.v1beta1.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_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: "/quicksilver.tokenfactory.v1beta1.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_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: "/quicksilver.tokenfactory.v1beta1.Msg/SetDenomMetadata", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetDenomMetadata(ctx, req.(*MsgSetDenomMetadata)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "quicksilver.tokenfactory.v1beta1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateDenom", - Handler: _Msg_CreateDenom_Handler, - }, - { - MethodName: "Mint", - Handler: _Msg_Mint_Handler, - }, - { - MethodName: "Burn", - Handler: _Msg_Burn_Handler, - }, - { - MethodName: "ChangeAdmin", - Handler: _Msg_ChangeAdmin_Handler, - }, - { - MethodName: "SetDenomMetadata", - Handler: _Msg_SetDenomMetadata_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "quicksilver/tokenfactory/v1beta1/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 *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 - { - size, err := m.Amount.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 - 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.Amount.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 *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 *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 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 *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.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgMintResponse) 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.Amount.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 (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 *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 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 *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 Amount", 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.Amount.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 *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 { - 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 Amount", 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.Amount.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 (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 *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 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") -)