From e0104a82388e96f608221b871402e3c32eb876e1 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Thu, 15 Jun 2023 21:28:52 -0500 Subject: [PATCH 1/2] Adds all stargate queries --- app/keepers/keepers.go | 158 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 144 insertions(+), 14 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 8a120e383..83688a8f0 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -9,7 +9,9 @@ import ( "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + globalfeetypes "github.com/CosmosContracts/juno/v16/x/globalfee/types" "github.com/CosmosContracts/juno/v16/x/ibchooks" ibchookskeeper "github.com/CosmosContracts/juno/v16/x/ibchooks/keeper" ibchookstypes "github.com/CosmosContracts/juno/v16/x/ibchooks/types" @@ -22,7 +24,9 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtype "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -30,11 +34,13 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" + evedencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" "github.com/cosmos/cosmos-sdk/x/feegrant" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" @@ -468,31 +474,42 @@ func NewAppKeepers( wasmOpts = append(wasmOpts, tfOpts...) // Stargate Queries + // (Define custom modules here, then the next function takes care of the standard SDK types) accepted := wasmkeeper.AcceptedStargateQueries{ + // wasm + "/cosmwasm.wasm.v1/Query/ContractInfo": &wasmtypes.QueryContractInfoResponse{}, + "/cosmwasm.wasm.v1/Query/ContractHistory": &wasmtypes.QueryContractHistoryResponse{}, + "/cosmwasm.wasm.v1/Query/ContractsByCode": &wasmtypes.QueryContractsByCodeResponse{}, + "/cosmwasm.wasm.v1/Query/AllContractState": &wasmtypes.QueryAllContractStateResponse{}, + "/cosmwasm.wasm.v1/Query/RawContractState": &wasmtypes.QueryRawContractStateResponse{}, + "/cosmwasm.wasm.v1/Query/SmartContractState": &wasmtypes.QuerySmartContractStateResponse{}, + "/cosmwasm.wasm.v1/Query/Code": &wasmtypes.QueryCodeResponse{}, + "/cosmwasm.wasm.v1/Query/Codes": &wasmtypes.QueryCodesResponse{}, + "/cosmwasm.wasm.v1/Query/PinnedCodes": &wasmtypes.QueryPinnedCodesResponse{}, + "/cosmwasm.wasm.v1/Query/Params": &wasmtypes.QueryParamsResponse{}, + "/cosmwasm.wasm.v1/Query/ContractsByCreator": &wasmtypes.QueryContractsByCreatorResponse{}, + // ibc "/ibc.core.client.v1.Query/ClientState": &ibcclienttypes.QueryClientStateResponse{}, "/ibc.core.client.v1.Query/ConsensusState": &ibcclienttypes.QueryConsensusStateResponse{}, "/ibc.core.connection.v1.Query/Connection": &ibcconnectiontypes.QueryConnectionResponse{}, - // governance - "/cosmos.gov.v1beta1.Query/Vote": &govv1.QueryVoteResponse{}, - - // distribution - "/cosmos.distribution.v1beta1.Query/DelegationRewards": &distrtypes.QueryDelegationRewardsResponse{}, - - // staking - "/cosmos.staking.v1beta1.Query/Delegation": &stakingtypes.QueryDelegationResponse{}, - "/cosmos.staking.v1beta1.Query/Redelegations": &stakingtypes.QueryRedelegationsResponse{}, - "/cosmos.staking.v1beta1.Query/UnbondingDelegation": &stakingtypes.QueryUnbondingDelegationResponse{}, - "/cosmos.staking.v1beta1.Query/Validator": &stakingtypes.QueryValidatorResponse{}, - "/cosmos.staking.v1beta1.Query/Params": &stakingtypes.QueryParamsResponse{}, - "/cosmos.staking.v1beta1.Query/Pool": &stakingtypes.QueryPoolResponse{}, - // token factory "/osmosis.tokenfactory.v1beta1.Query/Params": &tokenfactorytypes.QueryParamsResponse{}, "/osmosis.tokenfactory.v1beta1.Query/DenomAuthorityMetadata": &tokenfactorytypes.QueryDenomAuthorityMetadataResponse{}, "/osmosis.tokenfactory.v1beta1.Query/DenomsFromCreator": &tokenfactorytypes.QueryDenomsFromCreatorResponse{}, + + // feeshare + "/juno.feeshare.v1.Query/FeeShares": &feesharetypes.QueryFeeSharesResponse{}, + "/juno.feeshare.v1.Query/FeeShare": &feesharetypes.QueryFeeShareResponse{}, + "/juno.feeshare.v1.Query/Params": &feesharetypes.QueryParamsResponse{}, + "/juno.feeshare.v1.Query/DeployerFeeShares": &feesharetypes.QueryDeployerFeeSharesResponse{}, + "/juno.feeshare.v1.Query/WithdrawerFeeShares": &feesharetypes.QueryWithdrawerFeeSharesResponse{}, + + // globalfee + "/gaia.globalfee.v1beta1.Query/MinimumGasPrices": &globalfeetypes.QueryMinimumGasPricesResponse{}, } + accepted = addCosmosSDKStdStargateQueries(accepted) querierOpts := wasmkeeper.WithQueryPlugins( &wasmkeeper.QueryPlugins{ @@ -594,6 +611,119 @@ func NewAppKeepers( return appKeepers } +func addCosmosSDKStdStargateQueries(asq wasmkeeper.AcceptedStargateQueries) wasmkeeper.AcceptedStargateQueries { + std := map[string]codec.ProtoMarshaler{ + // auth + "/cosmos.auth.v1beta1.Query/Account": &authtype.QueryAccountResponse{}, + "/cosmos.auth.v1beta1.Query/AccountAddressByID": &authtype.QueryAccountAddressByIDResponse{}, + "/cosmos.auth.v1beta1.Query/Params": &authtype.QueryParamsResponse{}, + "/cosmos.auth.v1beta1.Query/ModuleAccounts": &authtype.QueryModuleAccountsResponse{}, + "/cosmos.auth.v1beta1.Query/ModuleAccountByName": &authtype.QueryModuleAccountByNameResponse{}, + "/cosmos.auth.v1beta1.Query/Bech32Prefix": &authtype.Bech32PrefixResponse{}, + "/cosmos.auth.v1beta1.Query/AddressBytesToString": &authtype.AddressBytesToStringResponse{}, + "/cosmos.auth.v1beta1.Query/AddressStringToBytes": &authtype.AddressStringToBytesResponse{}, + "/cosmos.auth.v1beta1.Query/AccountInfo": &authtype.QueryAccountInfoResponse{}, + + // authz + "/cosmos.authz.v1beta1.Query/Grants": &authz.QueryGrantsResponse{}, + "/cosmos.authz.v1beta1.Query/GranterGrants": &authz.QueryGranterGrantsResponse{}, + + // bank + "/cosmos.bank.v1beta1.Query/Balance": &banktypes.QueryBalanceResponse{}, + "/cosmos.bank.v1beta1.Query/AllBalances": &banktypes.QueryAllBalancesResponse{}, + "/cosmos.bank.v1beta1.Query/SpendableBalances": &banktypes.QuerySpendableBalancesResponse{}, + "/cosmos.bank.v1beta1.Query/SpendableBalanceByDenom": &banktypes.QuerySpendableBalanceByDenomResponse{}, + "/cosmos.bank.v1beta1.Query/TotalSupply": &banktypes.QueryTotalSupplyResponse{}, + "/cosmos.bank.v1beta1.Query/SupplyOf": &banktypes.QuerySupplyOfResponse{}, + "/cosmos.bank.v1beta1.Query/Params": &banktypes.QueryParamsResponse{}, + "/cosmos.bank.v1beta1.Query/DenomMetadata": &banktypes.QueryDenomMetadataResponse{}, + "/cosmos.bank.v1beta1.Query/DenomsMetadata": &banktypes.QueryDenomsMetadataResponse{}, + "/cosmos.bank.v1beta1.Query/DenomOwners": &banktypes.QueryDenomOwnersResponse{}, + "/cosmos.bank.v1beta1.Query/SendEnabled": &banktypes.QuerySendEnabledResponse{}, + + // consensus + "/cosmos.consensus.v1beta1.Query/Params": &consensustypes.QueryParamsResponse{}, + + // distribution + "/cosmos.distribution.v1beta1.Query/ParamsRequest": &distrtypes.QueryParamsRequest{}, + "/cosmos.distribution.v1beta1.Query/ValidatorDistributionInfo": &distrtypes.QueryValidatorDistributionInfoResponse{}, + "/cosmos.distribution.v1beta1.Query/ValidatorOutstandingRewards": &distrtypes.QueryValidatorOutstandingRewardsResponse{}, + "/cosmos.distribution.v1beta1.Query/ValidatorCommission": &distrtypes.QueryValidatorCommissionResponse{}, + "/cosmos.distribution.v1beta1.Query/ValidatorSlashes": &distrtypes.QueryValidatorSlashesResponse{}, + "/cosmos.distribution.v1beta1.Query/DelegationRewards": &distrtypes.QueryDelegationRewardsResponse{}, + "/cosmos.distribution.v1beta1.Query/DelegationTotalRewards": &distrtypes.QueryDelegationTotalRewardsResponse{}, + "/cosmos.distribution.v1beta1.Query/DelegatorValidators": &distrtypes.QueryDelegatorValidatorsResponse{}, + "/cosmos.distribution.v1beta1.Query/DelegatorWithdrawAddress": &distrtypes.QueryDelegatorWithdrawAddressResponse{}, + "/cosmos.distribution.v1beta1.Query/CommunityPool": &distrtypes.QueryCommunityPoolResponse{}, + + // evidence + "/cosmos.evidence.v1beta1.Query/Evidence": &evedencetypes.QueryEvidenceResponse{}, + "/cosmos.evidence.v1beta1.Query/AllEvidence": &evedencetypes.QueryAllEvidenceResponse{}, + + // feegrant + "/cosmos.feegrant.v1beta1.Query/Allowance": &feegrant.QueryAllowanceResponse{}, + "/cosmos.feegrant.v1beta1.Query/Allowances": &feegrant.QueryAllowancesResponse{}, + "/cosmos.feegrant.v1beta1.Query/AllowancesByGranter": &feegrant.QueryAllowancesByGranterResponse{}, + + // governance + "/cosmos.gov.v1beta1.Query/Proposal": &govv1.QueryProposalResponse{}, + "/cosmos.gov.v1beta1.Query/Proposals": &govv1.QueryProposalsResponse{}, + "/cosmos.gov.v1beta1.Query/Vote": &govv1.QueryVoteResponse{}, + "/cosmos.gov.v1beta1.Query/Votes": &govv1.QueryVotesResponse{}, + "/cosmos.gov.v1beta1.Query/Params": &govv1.QueryParamsResponse{}, + "/cosmos.gov.v1beta1.Query/Deposit": &govv1.QueryDepositResponse{}, + "/cosmos.gov.v1beta1.Query/TallyResult": &govv1.QueryTallyResultResponse{}, + + // mint + "/juno.mint.Query/Params": &minttypes.QueryParamsResponse{}, + "/juno.mint.Query/Inflation": &minttypes.QueryInflationResponse{}, + "/juno.mint.Query/AnnualProvisions": &minttypes.QueryAnnualProvisionsResponse{}, + + // nft + "/cosmos.nft.v1beta1.Query/Balance": &nft.QueryBalanceResponse{}, + "/cosmos.nft.v1beta1.Query/Owner": &nft.QueryOwnerResponse{}, + "/cosmos.nft.v1beta1.Query/Supply": &nft.QuerySupplyResponse{}, + "/cosmos.nft.v1beta1.Query/NFTs": &nft.QueryNFTsResponse{}, + "/cosmos.nft.v1beta1.Query/NFT": &nft.QueryNFTResponse{}, + "/cosmos.nft.v1beta1.Query/Class": &nft.QueryClassResponse{}, + "/cosmos.nft.v1beta1.Query/Classes": &nft.QueryClassesResponse{}, + + // slashing + "/cosmos.slashing.v1beta1.Query/Params": &slashingtypes.QueryParamsResponse{}, + "/cosmos.slashing.v1beta1.Query/SigningInfo": &slashingtypes.QuerySigningInfoResponse{}, + "/cosmos.slashing.v1beta1.Query/SigningInfos": &slashingtypes.QuerySigningInfosResponse{}, + + // staking + "/cosmos.staking.v1beta1.Query/Validators": &stakingtypes.QueryValidatorsResponse{}, + "/cosmos.staking.v1beta1.Query/Validator": &stakingtypes.QueryValidatorResponse{}, + "/cosmos.staking.v1beta1.Query/ValidatorDelegations": &stakingtypes.QueryValidatorDelegationsResponse{}, + "/cosmos.staking.v1beta1.Query/ValidatorUnbondingDelegations": &stakingtypes.QueryValidatorUnbondingDelegationsResponse{}, + "/cosmos.staking.v1beta1.Query/Delegation": &stakingtypes.QueryDelegationResponse{}, + "/cosmos.staking.v1beta1.Query/UnbondingDelegation": &stakingtypes.QueryUnbondingDelegationResponse{}, + "/cosmos.staking.v1beta1.Query/DelegatorDelegations": &stakingtypes.QueryDelegatorDelegationsResponse{}, + "/cosmos.staking.v1beta1.Query/DelegatorUnbondingDelegations": &stakingtypes.QueryDelegatorUnbondingDelegationsResponse{}, + "/cosmos.staking.v1beta1.Query/Redelegations": &stakingtypes.QueryRedelegationsResponse{}, + "/cosmos.staking.v1beta1.Query/DelegatorValidators": &stakingtypes.QueryDelegatorValidatorsResponse{}, + "/cosmos.staking.v1beta1.Query/DelegatorValidator": &stakingtypes.QueryDelegatorValidatorResponse{}, + "/cosmos.staking.v1beta1.Query/HistoricalInfo": &stakingtypes.QueryHistoricalInfoResponse{}, + "/cosmos.staking.v1beta1.Query/Params": &stakingtypes.QueryParamsResponse{}, + "/cosmos.staking.v1beta1.Query/Pool": &stakingtypes.QueryPoolResponse{}, + + // upgrade + "/cosmos.upgrade.v1beta1.Query/CurrentPlan": &upgradetypes.QueryCurrentPlanResponse{}, + "/cosmos.upgrade.v1beta1.Query/AppliedPlan": &upgradetypes.QueryAppliedPlanResponse{}, + "/cosmos.upgrade.v1beta1.Query/UpgradedConsensusState": &upgradetypes.QueryUpgradedConsensusStateResponse{}, + "/cosmos.upgrade.v1beta1.Query/QueryModuleVersionsResponse": &upgradetypes.QueryModuleVersionsResponse{}, + "/cosmos.upgrade.v1beta1.Query/QueryAuthorityResponse": &upgradetypes.QueryAuthorityResponse{}, + } + + updated := asq + for k, v := range std { + updated[k] = v + } + return updated +} + // initParamsKeeper init params keeper and its subspaces func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) From a10dd40fbf15ad065381c245a22d021bbb760878 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Fri, 16 Jun 2023 13:51:32 -0500 Subject: [PATCH 2/2] lint --- app/keepers/keepers.go | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 83688a8f0..bfa560c4f 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -24,7 +24,6 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authtype "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/authz" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" @@ -34,13 +33,11 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - evedencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" "github.com/cosmos/cosmos-sdk/x/feegrant" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" @@ -614,15 +611,15 @@ func NewAppKeepers( func addCosmosSDKStdStargateQueries(asq wasmkeeper.AcceptedStargateQueries) wasmkeeper.AcceptedStargateQueries { std := map[string]codec.ProtoMarshaler{ // auth - "/cosmos.auth.v1beta1.Query/Account": &authtype.QueryAccountResponse{}, - "/cosmos.auth.v1beta1.Query/AccountAddressByID": &authtype.QueryAccountAddressByIDResponse{}, - "/cosmos.auth.v1beta1.Query/Params": &authtype.QueryParamsResponse{}, - "/cosmos.auth.v1beta1.Query/ModuleAccounts": &authtype.QueryModuleAccountsResponse{}, - "/cosmos.auth.v1beta1.Query/ModuleAccountByName": &authtype.QueryModuleAccountByNameResponse{}, - "/cosmos.auth.v1beta1.Query/Bech32Prefix": &authtype.Bech32PrefixResponse{}, - "/cosmos.auth.v1beta1.Query/AddressBytesToString": &authtype.AddressBytesToStringResponse{}, - "/cosmos.auth.v1beta1.Query/AddressStringToBytes": &authtype.AddressStringToBytesResponse{}, - "/cosmos.auth.v1beta1.Query/AccountInfo": &authtype.QueryAccountInfoResponse{}, + "/cosmos.auth.v1beta1.Query/Account": &authtypes.QueryAccountResponse{}, + "/cosmos.auth.v1beta1.Query/AccountAddressByID": &authtypes.QueryAccountAddressByIDResponse{}, + "/cosmos.auth.v1beta1.Query/Params": &authtypes.QueryParamsResponse{}, + "/cosmos.auth.v1beta1.Query/ModuleAccounts": &authtypes.QueryModuleAccountsResponse{}, + "/cosmos.auth.v1beta1.Query/ModuleAccountByName": &authtypes.QueryModuleAccountByNameResponse{}, + "/cosmos.auth.v1beta1.Query/Bech32Prefix": &authtypes.Bech32PrefixResponse{}, + "/cosmos.auth.v1beta1.Query/AddressBytesToString": &authtypes.AddressBytesToStringResponse{}, + "/cosmos.auth.v1beta1.Query/AddressStringToBytes": &authtypes.AddressStringToBytesResponse{}, + "/cosmos.auth.v1beta1.Query/AccountInfo": &authtypes.QueryAccountInfoResponse{}, // authz "/cosmos.authz.v1beta1.Query/Grants": &authz.QueryGrantsResponse{}, @@ -642,7 +639,7 @@ func addCosmosSDKStdStargateQueries(asq wasmkeeper.AcceptedStargateQueries) wasm "/cosmos.bank.v1beta1.Query/SendEnabled": &banktypes.QuerySendEnabledResponse{}, // consensus - "/cosmos.consensus.v1beta1.Query/Params": &consensustypes.QueryParamsResponse{}, + "/cosmos.consensus.v1beta1.Query/Params": &consensusparamtypes.QueryParamsResponse{}, // distribution "/cosmos.distribution.v1beta1.Query/ParamsRequest": &distrtypes.QueryParamsRequest{}, @@ -657,8 +654,8 @@ func addCosmosSDKStdStargateQueries(asq wasmkeeper.AcceptedStargateQueries) wasm "/cosmos.distribution.v1beta1.Query/CommunityPool": &distrtypes.QueryCommunityPoolResponse{}, // evidence - "/cosmos.evidence.v1beta1.Query/Evidence": &evedencetypes.QueryEvidenceResponse{}, - "/cosmos.evidence.v1beta1.Query/AllEvidence": &evedencetypes.QueryAllEvidenceResponse{}, + "/cosmos.evidence.v1beta1.Query/Evidence": &evidencetypes.QueryEvidenceResponse{}, + "/cosmos.evidence.v1beta1.Query/AllEvidence": &evidencetypes.QueryAllEvidenceResponse{}, // feegrant "/cosmos.feegrant.v1beta1.Query/Allowance": &feegrant.QueryAllowanceResponse{}, @@ -712,7 +709,6 @@ func addCosmosSDKStdStargateQueries(asq wasmkeeper.AcceptedStargateQueries) wasm // upgrade "/cosmos.upgrade.v1beta1.Query/CurrentPlan": &upgradetypes.QueryCurrentPlanResponse{}, "/cosmos.upgrade.v1beta1.Query/AppliedPlan": &upgradetypes.QueryAppliedPlanResponse{}, - "/cosmos.upgrade.v1beta1.Query/UpgradedConsensusState": &upgradetypes.QueryUpgradedConsensusStateResponse{}, "/cosmos.upgrade.v1beta1.Query/QueryModuleVersionsResponse": &upgradetypes.QueryModuleVersionsResponse{}, "/cosmos.upgrade.v1beta1.Query/QueryAuthorityResponse": &upgradetypes.QueryAuthorityResponse{}, }