diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 8b2d70ad..ce85ea48 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -78,6 +78,7 @@ jobs: - "DungeonTransferBlock" - "XionSendPlatformFee" - "MintModuleNoInflationNoFees" + - "MintModuleInflationNoFees" - "MintModuleInflationHighFees" - "MintModuleInflationLowFees" - "JWTAbstractAccount" @@ -91,7 +92,7 @@ jobs: - "TreasuryContract" - "TreasuryMulti" - "SingleAbstractAccountMigration" - # - "Simulate" + - "Simulate" steps: - name: checkout diff --git a/Makefile b/Makefile index 9fbf01ee..c9581a83 100644 --- a/Makefile +++ b/Makefile @@ -256,6 +256,9 @@ test-integration-dungeon-transfer-block: compile_integration_tests test-integration-mint-module-no-inflation-no-fees: compile_integration_tests @XION_TEST_IMAGE=$(XION_TEST_IMAGE) ./integration_tests/integration_tests.test -test.failfast -test.v -test.run TestMintModuleNoInflationNoFees +test-integration-mint-module-inflation-no-fees: compile_integration_tests + @XION_TEST_IMAGE=$(XION_TEST_IMAGE) ./integration_tests/integration_tests.test -test.failfast -test.v -test.run TestMintModuleInflationNoFees + test-integration-mint-module-inflation-high-fees: compile_integration_tests @XION_TEST_IMAGE=$(XION_TEST_IMAGE) ./integration_tests/integration_tests.test -test.failfast -test.v -test.run TestMintModuleInflationHighFees diff --git a/app/app.go b/app/app.go index 1e8a7a59..ac763832 100644 --- a/app/app.go +++ b/app/app.go @@ -322,6 +322,8 @@ func NewWasmApp( wasmOpts []wasmkeeper.Option, baseAppOptions ...func(*baseapp.BaseApp), ) *WasmApp { + overrideWasmVariables() + interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ ProtoFiles: proto.HybridResolver, SigningOptions: signing.Options{ @@ -1381,3 +1383,11 @@ func (app *WasmApp) AutoCliOpts() autocli.AppOptions { ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), } } + +// overrideWasmVariables overrides the wasm variables to: +// - allow for larger wasm files +func overrideWasmVariables() { + // Override Wasm size limitation from WASMD. + wasmtypes.MaxWasmSize = 2 * 1024 * 1024 + wasmtypes.MaxProposalWasmSize = wasmtypes.MaxWasmSize +} diff --git a/app/upgrades.go b/app/upgrades.go index 6ff8bab1..291fe5e8 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -4,8 +4,6 @@ import ( "context" "fmt" - ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" - storetypes "cosmossdk.io/store/types" upgradetypes "cosmossdk.io/x/upgrade/types" @@ -13,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" ) -const UpgradeName = "v13" +const UpgradeName = "v14" func (app *WasmApp) RegisterUpgradeHandlers() { app.WrapSetUpgradeHandler(UpgradeName) @@ -25,11 +23,7 @@ func (app *WasmApp) RegisterUpgradeHandlers() { if upgradeInfo.Name == UpgradeName { if !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{ - ibcwasmtypes.ModuleName, - }, - } + storeUpgrades := storetypes.StoreUpgrades{} app.Logger().Info("setting upgrade store loaders") app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) diff --git a/client/docs/static/openapi.json b/client/docs/static/openapi.json index db1433bc..c198a8e5 100644 --- a/client/docs/static/openapi.json +++ b/client/docs/static/openapi.json @@ -51010,6 +51010,15 @@ }, "description": "QueryParamsResponse is the response type for the Query/Params RPC method." }, + "xion.v1.QueryPlatformPercentageResponse": { + "type": "object", + "properties": { + "platform_percentage": { + "type": "string", + "format": "uint64" + } + } + }, "xion.v1.QueryWebAuthNVerifyAuthenticateResponse": { "type": "object" }, diff --git a/client/docs/static/swagger.json b/client/docs/static/swagger.json index 512f338a..9817feaf 100644 --- a/client/docs/static/swagger.json +++ b/client/docs/static/swagger.json @@ -48372,6 +48372,15 @@ }, "description": "QueryParamsResponse is the response type for the Query/Params RPC method." }, + "xion.v1.QueryPlatformPercentageResponse": { + "type": "object", + "properties": { + "platform_percentage": { + "type": "string", + "format": "uint64" + } + } + }, "xion.v1.QueryWebAuthNVerifyAuthenticateResponse": { "type": "object" }, diff --git a/go.mod b/go.mod index 203d8aac..0ddc0a53 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,28 @@ module github.com/burnt-labs/xion go 1.22.7 +replace ( + + cosmossdk.io/core => cosmossdk.io/core v0.11.1 + github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 + + // dgrijalva/jwt-go is deprecated and doesn't receive security updates. + // See: https://github.com/cosmos/cosmos-sdk/issues/13134 + github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 + // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. + // See: https://github.com/cosmos/cosmos-sdk/issues/10409 + github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1 + + github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 + github.com/larry0x/abstract-account => github.com/burnt-labs/abstract-account v0.0.0-20241017182826-e40d245c944a + github.com/strangelove-ventures/tokenfactory => github.com/strangelove-ventures/tokenfactory v0.50.3-wasmvm2 + + // pin version! 126854af5e6d has issues with the store so that queries fail + github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 + + github.com/vektra/mockery/v2 => github.com/vektra/mockery/v2 v2.14.0 +) + require ( cosmossdk.io/api v0.7.5 cosmossdk.io/client/v2 v2.0.0-beta.4 @@ -244,27 +266,3 @@ require ( nhooyr.io/websocket v1.8.10 // indirect pgregory.net/rapid v1.1.0 // indirect ) - -replace ( - github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 - - // dgrijalva/jwt-go is deprecated and doesn't receive security updates. - // See: https://github.com/cosmos/cosmos-sdk/issues/13134 - github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 - // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. - // See: https://github.com/cosmos/cosmos-sdk/issues/10409 - github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1 - - github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 - - // pin version! 126854af5e6d has issues with the store so that queries fail - github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - - github.com/vektra/mockery/v2 => github.com/vektra/mockery/v2 v2.14.0 -) - -replace ( - cosmossdk.io/core => cosmossdk.io/core v0.11.1 - github.com/larry0x/abstract-account => github.com/burnt-labs/abstract-account v0.0.0-20240911164801-9a0dcb4a06b1 - github.com/strangelove-ventures/tokenfactory => github.com/strangelove-ventures/tokenfactory v0.50.3-wasmvm2 -) diff --git a/go.sum b/go.sum index 0bf97dc3..bce550b0 100644 --- a/go.sum +++ b/go.sum @@ -290,8 +290,8 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOF github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= -github.com/burnt-labs/abstract-account v0.0.0-20240911164801-9a0dcb4a06b1 h1:zhebc72UZSCqCkebfXbgxe9RmxY2FmD1f4nYMsdtXZg= -github.com/burnt-labs/abstract-account v0.0.0-20240911164801-9a0dcb4a06b1/go.mod h1:0q/LBlPChRsvsub88tL4wgvx7RuWGrjcAXFiZf4uSjo= +github.com/burnt-labs/abstract-account v0.0.0-20241017182826-e40d245c944a h1:bvO9Hr25/dVRdF8aGEMfc7TuTvlOtAF1b3x1876wLm0= +github.com/burnt-labs/abstract-account v0.0.0-20241017182826-e40d245c944a/go.mod h1:0q/LBlPChRsvsub88tL4wgvx7RuWGrjcAXFiZf4uSjo= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= diff --git a/integration_tests/abstract_account_test.go b/integration_tests/abstract_account_test.go index 96452b70..c6a2a6ac 100644 --- a/integration_tests/abstract_account_test.go +++ b/integration_tests/abstract_account_test.go @@ -495,6 +495,9 @@ func TestXionAbstractAccount(t *testing.T) { ) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 1, xion) + require.NoError(t, err) + // Confirm the updated balance balance, err := xion.GetBalance(ctx, recipientKeyAddress, xion.Config().Denom) require.NoError(t, err) diff --git a/integration_tests/go.mod b/integration_tests/go.mod index 0ffc7731..19bf9de1 100644 --- a/integration_tests/go.mod +++ b/integration_tests/go.mod @@ -2,6 +2,18 @@ module integration_tests go 1.22.7 +replace ( + cosmossdk.io/core => cosmossdk.io/core v0.11.1 + github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d + github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0 + github.com/burnt-labs/xion => ../ + github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 + github.com/larry0x/abstract-account => github.com/burnt-labs/abstract-account v0.0.0-20241017182826-e40d245c944a + github.com/strangelove-ventures/tokenfactory => github.com/strangelove-ventures/tokenfactory v0.50.3-wasmvm2 + github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7 + github.com/vektra/mockery/v2 => github.com/vektra/mockery/v2 v2.14.0 +) + require ( cosmossdk.io/api v0.7.5 cosmossdk.io/math v1.3.0 @@ -297,15 +309,3 @@ require ( rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) - -replace ( - cosmossdk.io/core => cosmossdk.io/core v0.11.1 - github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d - github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0 - github.com/burnt-labs/xion => ../ - github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 - github.com/larry0x/abstract-account => github.com/burnt-labs/abstract-account v0.0.0-20240911164801-9a0dcb4a06b1 - github.com/strangelove-ventures/tokenfactory => github.com/strangelove-ventures/tokenfactory v0.50.3-wasmvm2 - github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7 - github.com/vektra/mockery/v2 => github.com/vektra/mockery/v2 v2.14.0 -) diff --git a/integration_tests/go.sum b/integration_tests/go.sum index 2654286a..16d66f90 100644 --- a/integration_tests/go.sum +++ b/integration_tests/go.sum @@ -308,8 +308,8 @@ github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pY github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= -github.com/burnt-labs/abstract-account v0.0.0-20240911164801-9a0dcb4a06b1 h1:zhebc72UZSCqCkebfXbgxe9RmxY2FmD1f4nYMsdtXZg= -github.com/burnt-labs/abstract-account v0.0.0-20240911164801-9a0dcb4a06b1/go.mod h1:0q/LBlPChRsvsub88tL4wgvx7RuWGrjcAXFiZf4uSjo= +github.com/burnt-labs/abstract-account v0.0.0-20241017182826-e40d245c944a h1:bvO9Hr25/dVRdF8aGEMfc7TuTvlOtAF1b3x1876wLm0= +github.com/burnt-labs/abstract-account v0.0.0-20241017182826-e40d245c944a/go.mod h1:0q/LBlPChRsvsub88tL4wgvx7RuWGrjcAXFiZf4uSjo= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= diff --git a/integration_tests/minimum_fee_test.go b/integration_tests/minimum_fee_test.go index f1a91c80..da92ab84 100644 --- a/integration_tests/minimum_fee_test.go +++ b/integration_tests/minimum_fee_test.go @@ -2,8 +2,16 @@ package integration_tests import ( "context" + "encoding/json" "fmt" + "strconv" "testing" + "time" + + xiontypes "github.com/burnt-labs/xion/x/xion/types" + "github.com/cosmos/cosmos-sdk/codec" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "cosmossdk.io/math" @@ -97,6 +105,61 @@ func testMinimumFee(t *testing.T, td *TestData, assert assertionFn) { require.NoError(t, err) require.Equal(t, fundAmount, xionUserBalInitial) + cdc := codec.NewProtoCodec(xion.Config().EncodingConfig.InterfaceRegistry) + config := types.GetConfig() + config.SetBech32PrefixForAccount("xion", "xionpub") + + setPlatformMinimumsMsg := xiontypes.MsgSetPlatformMinimum{ + Authority: authtypes.NewModuleAddress("gov").String(), + Minimums: types.Coins{types.Coin{Amount: math.NewInt(10), Denom: "uxion"}}, + } + + msg, err := cdc.MarshalInterfaceJSON(&setPlatformMinimumsMsg) + require.NoError(t, err) + + prop := cosmos.TxProposalv1{ + Messages: []json.RawMessage{msg}, + Metadata: "", + Deposit: "100uxion", + Title: "Set platform percentage to 5%", + Summary: "Ups the platform fee to 5% for the integration test", + } + paramChangeTx, err := xion.SubmitProposal(ctx, xionUser.KeyName(), prop) + require.NoError(t, err) + t.Logf("Platform percentage change proposal submitted with ID %s in transaction %s", paramChangeTx.ProposalID, paramChangeTx.TxHash) + + proposalID, err := strconv.Atoi(paramChangeTx.ProposalID) + require.NoError(t, err) + + require.Eventuallyf(t, func() bool { + proposalInfo, err := xion.GovQueryProposal(ctx, uint64(proposalID)) + if err != nil { + require.NoError(t, err) + } else { + if proposalInfo.Status == govv1beta1.StatusVotingPeriod { + return true + } + t.Logf("Waiting for proposal to enter voting status VOTING, current status: %s", proposalInfo.Status) + } + return false + }, time.Second*11, time.Second, "failed to reach status VOTING after 11s") + + err = xion.VoteOnProposalAllValidators(ctx, uint64(proposalID), cosmos.ProposalVoteYes) + require.NoError(t, err) + + require.Eventuallyf(t, func() bool { + proposalInfo, err := xion.GovQueryProposal(ctx, uint64(proposalID)) + if err != nil { + require.NoError(t, err) + } else { + if proposalInfo.Status == govv1beta1.StatusPassed { + return true + } + t.Logf("Waiting for proposal to enter voting status PASSED, current status: %s", proposalInfo.Status) + } + return false + }, time.Second*11, time.Second, "failed to reach status PASSED after 11s") + // step 1: send a xion message with default (0%) platform fee recipientKeyName := "recipient-key" err = xion.CreateKey(ctx, recipientKeyName) diff --git a/integration_tests/mint_test.go b/integration_tests/mint_test.go index 5fba5d90..e52d8338 100644 --- a/integration_tests/mint_test.go +++ b/integration_tests/mint_test.go @@ -32,15 +32,20 @@ func TestMintModuleNoInflationNoFees(t *testing.T) { t.Skip("skipping in short mode") } - td := BuildXionChain(t, "0.0uxion", ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals}, [][]string{{votingPeriod, maxDepositPeriod}})) + td := BuildXionChain(t, "0.0uxion", ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals, ModifyGenesisInflation}, [][]string{{votingPeriod, maxDepositPeriod}, {minInflation, maxInflation, inflationRateChange}})) xion, ctx := td.xionChain, td.ctx // Wait for some blocks and check if that supply stays the same chainHeight, _ := xion.Height(ctx) testutil.WaitForBlocks(ctx, int(chainHeight)+10, xion) + assertion := func(t *testing.T, provision math.LegacyDec, feesAccrued int64, tokenChange int64) { + require.Equal(t, math.NewInt(0), math.NewInt(tokenChange)) + t.Logf("No minted or Burned tokens. Token change: %d", tokenChange) + } + // Run test harness - VerifyMintModuleTestRandomBlocks(t, xion, ctx) + VerifyMintModuleTestRandomBlocks(t, xion, ctx, assertion) } // In this test case, the mint module inflation is left to the default value in @@ -59,9 +64,16 @@ func TestMintModuleInflationNoFees(t *testing.T) { chainHeight, _ := xion.Height(ctx) testutil.WaitForBlocks(ctx, int(chainHeight)+10, xion) + assertion := func(t *testing.T, provision math.LegacyDec, feesAccrued int64, tokenChange int64) { + require.Truef(t, provision.TruncateInt().GT(math.NewInt(feesAccrued)), "provision should be greater if tokens where minted, provision: %s, fees accrued:%s", provision.TruncateInt(), feesAccrued) + // We have minted tokens because the fees accrued is less than the block provision + mintedTokens := provision.TruncateInt().Sub(math.NewInt(feesAccrued)) + t.Logf("Minted tokens: %d and Token change: %d", mintedTokens.Int64(), int64(tokenChange)) + require.Equal(t, mintedTokens, math.NewInt(int64(tokenChange))) + } // Run test harness - VerifyMintModuleTestRandomBlocks(t, xion, ctx) + VerifyMintModuleTestRandomBlocks(t, xion, ctx, assertion) } // TxCommand is a helper to retrieve a full command for broadcasting a tx @@ -158,7 +170,7 @@ func TestMintModuleInflationHighFees(t *testing.T) { t.Parallel() - td := BuildXionChain(t, "0.0uxion", ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals}, [][]string{{votingPeriod, maxDepositPeriod}})) + td := BuildXionChain(t, "0.00uxion", ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals}, [][]string{{votingPeriod, maxDepositPeriod}})) xion, ctx := td.xionChain, td.ctx txHashes := MintModuleTest{ @@ -173,8 +185,17 @@ func TestMintModuleInflationHighFees(t *testing.T) { testutil.WaitForBlocks(ctx, 25, xion) require.NotEmpty(t, txHashes.TxHashes) + + assertion := func(t *testing.T, provision math.LegacyDec, feesAccrued int64, tokenChange int64) { + // We have burned tokens because the fees accrued is greater than the block provision so the fees + // accrued are used to pay validators and the remaining is burned + require.True(t, provision.TruncateInt().LT(math.NewInt(feesAccrued)), "provision should be lower, in order to burn tokens") + burnedTokens := math.NewInt(feesAccrued).Sub(provision.TruncateInt()) + t.Logf("Burned tokens: %d and Token change: %d", burnedTokens.Int64(), tokenChange) + require.Equal(t, burnedTokens, math.NewInt(tokenChange).Abs()) + } // Run test harness - VerifyMintModuleTest(t, xion, ctx, txHashes.TxHashes) + VerifyMintModuleTest(t, xion, ctx, txHashes.TxHashes, assertion) } // Here we test the mint module by sending a bunch of transactions with extra low fees @@ -187,7 +208,7 @@ func TestMintModuleInflationLowFees(t *testing.T) { t.Parallel() - td := BuildXionChain(t, "0.0uxion", ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals}, [][]string{{votingPeriod, maxDepositPeriod}})) + td := BuildXionChain(t, "0.00uxion", ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals}, [][]string{{votingPeriod, maxDepositPeriod}})) xion, ctx := td.xionChain, td.ctx txHashes := MintModuleTest{ @@ -205,6 +226,14 @@ func TestMintModuleInflationLowFees(t *testing.T) { testutil.WaitForBlocks(ctx, 25, xion) require.NotEmpty(t, txHashes.TxHashes) + + assertion := func(t *testing.T, provision math.LegacyDec, feesAccrued int64, tokenChange int64) { + require.Truef(t, provision.TruncateInt().GT(math.NewInt(feesAccrued)), "provision should be greater if tokens where minted") + // We have minted tokens because the fees accrued is less than the block provision + mintedTokens := provision.TruncateInt().Sub(math.NewInt(feesAccrued)) + t.Logf("Minted tokens: %d and Token change: %d", mintedTokens.Int64(), int64(tokenChange)) + require.Equal(t, mintedTokens, math.NewInt(int64(tokenChange))) + } // Run test harness - VerifyMintModuleTest(t, xion, ctx, txHashes.TxHashes) + VerifyMintModuleTest(t, xion, ctx, txHashes.TxHashes, assertion) } diff --git a/integration_tests/send_test.go b/integration_tests/send_test.go index 36147042..62c7b4bd 100644 --- a/integration_tests/send_test.go +++ b/integration_tests/send_test.go @@ -54,6 +54,68 @@ func TestXionSendPlatformFee(t *testing.T) { require.NoError(t, err) cdc := codec.NewProtoCodec(xion.Config().EncodingConfig.InterfaceRegistry) + config := types.GetConfig() + config.SetBech32PrefixForAccount("xion", "xionpub") + + setPlatformMinimumsMsg := xiontypes.MsgSetPlatformMinimum{ + Authority: authtypes.NewModuleAddress("gov").String(), + Minimums: types.Coins{types.Coin{Amount: math.NewInt(10), Denom: "uxion"}}, + } + + msg, err := cdc.MarshalInterfaceJSON(&setPlatformMinimumsMsg) + require.NoError(t, err) + + _, err = xion.GetNode().ExecTx(ctx, + xionUser.KeyName(), + "xion", "send", xionUser.KeyName(), + "--chain-id", xion.Config().ChainID, + recipientKeyAddress, fmt.Sprintf("%d%s", 100, xion.Config().Denom), + ) + // platform minimums unset, so this should fail + require.Error(t, err) + + prop := cosmos.TxProposalv1{ + Messages: []json.RawMessage{msg}, + Metadata: "", + Deposit: "100uxion", + Title: "Set platform percentage to 5%", + Summary: "Ups the platform fee to 5% for the integration test", + } + paramChangeTx, err := xion.SubmitProposal(ctx, xionUser.KeyName(), prop) + require.NoError(t, err) + t.Logf("Platform percentage change proposal submitted with ID %s in transaction %s", paramChangeTx.ProposalID, paramChangeTx.TxHash) + + proposalID, err := strconv.Atoi(paramChangeTx.ProposalID) + require.NoError(t, err) + + require.Eventuallyf(t, func() bool { + proposalInfo, err := xion.GovQueryProposal(ctx, uint64(proposalID)) + if err != nil { + require.NoError(t, err) + } else { + if proposalInfo.Status == govv1beta1.StatusVotingPeriod { + return true + } + t.Logf("Waiting for proposal to enter voting status VOTING, current status: %s", proposalInfo.Status) + } + return false + }, time.Second*11, time.Second, "failed to reach status VOTING after 11s") + + err = xion.VoteOnProposalAllValidators(ctx, uint64(proposalID), cosmos.ProposalVoteYes) + require.NoError(t, err) + + require.Eventuallyf(t, func() bool { + proposalInfo, err := xion.GovQueryProposal(ctx, uint64(proposalID)) + if err != nil { + require.NoError(t, err) + } else { + if proposalInfo.Status == govv1beta1.StatusPassed { + return true + } + t.Logf("Waiting for proposal to enter voting status PASSED, current status: %s", proposalInfo.Status) + } + return false + }, time.Second*11, time.Second, "failed to reach status PASSED after 11s") _, err = xion.GetNode().ExecTx(ctx, xionUser.KeyName(), @@ -74,29 +136,26 @@ func TestXionSendPlatformFee(t *testing.T) { "balance never correctly changed") // step 2: update the platform percentage to 5% - config := types.GetConfig() - config.SetBech32PrefixForAccount("xion", "xionpub") setPlatformPercentageMsg := xiontypes.MsgSetPlatformPercentage{ Authority: authtypes.NewModuleAddress("gov").String(), PlatformPercentage: 500, } - - msg, err := cdc.MarshalInterfaceJSON(&setPlatformPercentageMsg) + msg, err = cdc.MarshalInterfaceJSON(&setPlatformPercentageMsg) require.NoError(t, err) - prop := cosmos.TxProposalv1{ + prop = cosmos.TxProposalv1{ Messages: []json.RawMessage{msg}, Metadata: "", Deposit: "100uxion", Title: "Set platform percentage to 5%", Summary: "Ups the platform fee to 5% for the integration test", } - paramChangeTx, err := xion.SubmitProposal(ctx, xionUser.KeyName(), prop) + paramChangeTx, err = xion.SubmitProposal(ctx, xionUser.KeyName(), prop) require.NoError(t, err) t.Logf("Platform percentage change proposal submitted with ID %s in transaction %s", paramChangeTx.ProposalID, paramChangeTx.TxHash) - proposalID, err := strconv.Atoi(paramChangeTx.ProposalID) + proposalID, err = strconv.Atoi(paramChangeTx.ProposalID) require.NoError(t, err) require.Eventuallyf(t, func() bool { diff --git a/integration_tests/simulate_test.go b/integration_tests/simulate_test.go index 1bb952c1..9a7ad187 100644 --- a/integration_tests/simulate_test.go +++ b/integration_tests/simulate_test.go @@ -1,6 +1,7 @@ package integration_tests import ( + "context" "crypto/sha256" "encoding/base64" "encoding/hex" @@ -8,7 +9,6 @@ import ( "fmt" "os" "path" - "strings" "testing" "time" @@ -16,6 +16,8 @@ import ( txsigning "cosmossdk.io/x/tx/signing" "google.golang.org/protobuf/types/known/anypb" + txtypes "github.com/cosmos/cosmos-sdk/types/tx" + signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -348,27 +350,11 @@ func TestSimulate(t *testing.T) { err = txBuilder.SetSignatures(sig) require.NoError(t, err) - jsonTx, err := xion.Config().EncodingConfig.TxConfig.TxJSONEncoder()(txBuilder.GetTx()) - require.NoError(t, err) - t.Logf("json tx: %s", jsonTx) - - sendFile, err := os.CreateTemp("", "*-msg-bank-send.json") - require.NoError(t, err) - defer os.Remove(sendFile.Name()) - - _, err = sendFile.Write(jsonTx) - require.NoError(t, err) - - err = UploadFileToContainer(t, ctx, xion.GetNode(), sendFile) - require.NoError(t, err) - - // call `xiond tx simulate ..` - sendFilePath := strings.Split(sendFile.Name(), "/") - _, err = ExecTx(t, ctx, xion.GetNode(), - xionUser.KeyName(), - "simulate", - path.Join(xion.GetNode().HomeDir(), sendFilePath[len(sendFilePath)-1]), - "--chain-id", xion.Config().ChainID, - ) + txBytes, err := xion.Config().EncodingConfig.TxConfig.TxEncoder()(txBuilder.GetTx()) + txSvcClient := txtypes.NewServiceClient(xion.GetNode().GrpcConn) + simRes, err := txSvcClient.Simulate(context.Background(), &txtypes.SimulateRequest{ + TxBytes: txBytes, + }) require.NoError(t, err) + t.Logf("sim res: %s", simRes) } diff --git a/integration_tests/utils.go b/integration_tests/utils.go index 5d3f8d2a..66536acf 100644 --- a/integration_tests/utils.go +++ b/integration_tests/utils.go @@ -81,6 +81,8 @@ const ( votingPeriod = "10s" maxDepositPeriod = "10s" packetforward = "0.0" + minInflation = "0.0" + maxInflation = "0.0" ) var defaultMinGasPrices = sdk.DecCoins{sdk.NewDecCoin("uxion", math.ZeroInt())} @@ -582,7 +584,7 @@ func GetBlockAnnualProvision(t *testing.T, xion *cosmos.CosmosChain, ctx context * Otherwise, we had equal fees and provisions. We do not mint or burn any tokens * If these checks passes then the mint module functions as expected */ -func MintModuleTestHarness(t *testing.T, xion *cosmos.CosmosChain, ctx context.Context, blockHeight int) { +func MintModuleTestHarness(t *testing.T, xion *cosmos.CosmosChain, ctx context.Context, blockHeight int, assertion func(*testing.T, math.LegacyDec, int64, int64)) { // Get bank supply at previous height previousXionBankSupply, err := strconv.ParseInt(getTotalCoinSupplyInBank(t, xion, ctx, xion.Config().Denom, uint64(blockHeight-1)), 10, 64) t.Logf("Previous Xion bank supply: %d", previousXionBankSupply) @@ -613,27 +615,30 @@ func MintModuleTestHarness(t *testing.T, xion *cosmos.CosmosChain, ctx context.C // Get the block provision. This is the minted tokens for the block for validators and delegator blockProvision := GetBlockAnnualProvision(t, xion, ctx, xion.Config().Denom, uint64(blockHeight)) - if blockProvision.TruncateInt().GT(math.NewInt(feesAccrued)) { - // We have minted tokens because the fees accrued is less than the block provision - mintedTokens := blockProvision.TruncateInt().Sub(math.NewInt(feesAccrued)) - t.Logf("Minted tokens: %d and Token change: %d", mintedTokens.Int64(), int64(tokenChange)) - require.Equal(t, mintedTokens, math.NewInt(int64(tokenChange))) - } else if blockProvision.TruncateInt().LT(math.NewInt(feesAccrued)) { - // We have burned tokens because the fees accrued is greater than the block provision so the fees - // accrued are used to pay validators and the remaining is burned - burnedTokens := math.NewInt(feesAccrued).Sub(blockProvision.TruncateInt()) - t.Logf("Burned tokens: %d and Token change: %d", burnedTokens.Int64(), tokenChange) - require.Equal(t, burnedTokens, math.NewInt(tokenChange).Abs()) - } else { - // We have not minted or burned tokens but just used all fees accrued to pay validators - require.Equal(t, math.NewInt(0), math.NewInt(tokenChange)) - t.Logf("No minted or Burned tokens. Token change: %d", tokenChange) - } + assertion(t, blockProvision, feesAccrued, tokenChange) + /* + if blockProvision.TruncateInt().GT(math.NewInt(feesAccrued)) { + // We have minted tokens because the fees accrued is less than the block provision + mintedTokens := blockProvision.TruncateInt().Sub(math.NewInt(feesAccrued)) + t.Logf("Minted tokens: %d and Token change: %d", mintedTokens.Int64(), int64(tokenChange)) + require.Equal(t, mintedTokens, math.NewInt(int64(tokenChange))) + } else if blockProvision.TruncateInt().LT(math.NewInt(feesAccrued)) { + // We have burned tokens because the fees accrued is greater than the block provision so the fees + // accrued are used to pay validators and the remaining is burned + burnedTokens := math.NewInt(feesAccrued).Sub(blockProvision.TruncateInt()) + t.Logf("Burned tokens: %d and Token change: %d", burnedTokens.Int64(), tokenChange) + require.Equal(t, burnedTokens, math.NewInt(tokenChange).Abs()) + } else { + // We have not minted or burned tokens but just used all fees accrued to pay validators + require.Equal(t, math.NewInt(0), math.NewInt(tokenChange)) + t.Logf("No minted or Burned tokens. Token change: %d", tokenChange) + } + */ } // Run Mint module test harness over some random block height // Chain must have at least 12 blocks -func VerifyMintModuleTestRandomBlocks(t *testing.T, xion *cosmos.CosmosChain, ctx context.Context) { +func VerifyMintModuleTestRandomBlocks(t *testing.T, xion *cosmos.CosmosChain, ctx context.Context, assertion func(*testing.T, math.LegacyDec, int64, int64)) { currentBlockHeight, err := xion.Height(ctx) require.NoError(t, err) require.GreaterOrEqual(t, currentBlockHeight, int64(12)) @@ -642,17 +647,17 @@ func VerifyMintModuleTestRandomBlocks(t *testing.T, xion *cosmos.CosmosChain, ct for i := randomHeight; i < randomHeight+10; i++ { t.Logf("Current random height: %d", i) - MintModuleTestHarness(t, xion, ctx, i) + MintModuleTestHarness(t, xion, ctx, i, assertion) } } // Run Mint module test over some txHash -func VerifyMintModuleTest(t *testing.T, xion *cosmos.CosmosChain, ctx context.Context, txHashes []string) { +func VerifyMintModuleTest(t *testing.T, xion *cosmos.CosmosChain, ctx context.Context, txHashes []string, assertion func(*testing.T, math.LegacyDec, int64, int64)) { for i, txHash := range txHashes { txResp, err := authTx.QueryTx(xion.GetNode().CliContext(), txHash) require.NoError(t, err) t.Logf("Bank send msg %d BH: %d", i, txResp.Height) - MintModuleTestHarness(t, xion, ctx, int(txResp.Height)+1) // check my block and the next one + MintModuleTestHarness(t, xion, ctx, int(txResp.Height)+1, assertion) // check my block and the next one } } diff --git a/proto/xion/v1/genesis.proto b/proto/xion/v1/genesis.proto index 73dc03c6..23805469 100644 --- a/proto/xion/v1/genesis.proto +++ b/proto/xion/v1/genesis.proto @@ -1,8 +1,17 @@ syntax = "proto3"; package xion.v1; +import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/burnt-labs/xion/x/xion/types"; -message GenesisState { uint32 platform_percentage = 1; } +message GenesisState { + uint32 platform_percentage = 1; + repeated cosmos.base.v1beta1.Coin platform_minimums = 2 [ + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "platform_minimums,omitempty", + (gogoproto.moretags) = "yaml:\"platform_minimums\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} diff --git a/proto/xion/v1/query.proto b/proto/xion/v1/query.proto index bd396333..80292d66 100644 --- a/proto/xion/v1/query.proto +++ b/proto/xion/v1/query.proto @@ -6,6 +6,7 @@ option go_package = "github.com/burnt-labs/xion/x/xion/types"; service Query { rpc WebAuthNVerifyRegister(QueryWebAuthNVerifyRegisterRequest) returns (QueryWebAuthNVerifyRegisterResponse) {} rpc WebAuthNVerifyAuthenticate(QueryWebAuthNVerifyAuthenticateRequest) returns (QueryWebAuthNVerifyAuthenticateResponse) {} + rpc PlatformPercentage(QueryPlatformPercentageRequest) returns (QueryPlatformPercentageResponse) {} } message QueryWebAuthNVerifyRegisterRequest { @@ -27,4 +28,10 @@ message QueryWebAuthNVerifyAuthenticateRequest { bytes data = 5; } -message QueryWebAuthNVerifyAuthenticateResponse {} \ No newline at end of file +message QueryWebAuthNVerifyAuthenticateResponse {} + +message QueryPlatformPercentageRequest {} + +message QueryPlatformPercentageResponse { + uint64 platform_percentage = 1; +} \ No newline at end of file diff --git a/proto/xion/v1/tx.proto b/proto/xion/v1/tx.proto index f5a0b3ac..70353242 100644 --- a/proto/xion/v1/tx.proto +++ b/proto/xion/v1/tx.proto @@ -25,6 +25,11 @@ service Msg { // percentage fee rpc SetPlatformPercentage(MsgSetPlatformPercentage) returns (MsgSetPlatformPercentageResponse); + + // SetPlatformMinimum defines the method for updating the platform + // percentage fee + rpc SetPlatformMinimum(MsgSetPlatformMinimum) + returns (MsgSetPlatformMinimumResponse); } // MsgSend represents a message to send coins from one account to another. @@ -76,3 +81,18 @@ message MsgSetPlatformPercentage { } message MsgSetPlatformPercentageResponse {} + +message MsgSetPlatformMinimum { + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "xion/MsgSetPlatformMinimum"; + + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + repeated cosmos.base.v1beta1.Coin minimums = 3 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +message MsgSetPlatformMinimumResponse {} diff --git a/x/jwk/types/query.pb.go b/x/jwk/types/query.pb.go index f5a5d643..8625a2ca 100644 --- a/x/jwk/types/query.pb.go +++ b/x/jwk/types/query.pb.go @@ -558,52 +558,52 @@ func init() { func init() { proto.RegisterFile("xion/jwk/v1/query.proto", fileDescriptor_6aa237fef6ed9f02) } var fileDescriptor_6aa237fef6ed9f02 = []byte{ - // 708 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xc1, 0x4f, 0xd4, 0x4e, - 0x18, 0xdd, 0x02, 0x4b, 0x60, 0x16, 0x12, 0x32, 0xec, 0x2f, 0xec, 0xaf, 0xc1, 0x05, 0x27, 0x0a, - 0x8a, 0xa1, 0xe3, 0x62, 0xd4, 0xa3, 0x82, 0x89, 0x18, 0x4f, 0x50, 0x8d, 0x46, 0x3d, 0x90, 0xe9, - 0xee, 0xa4, 0x94, 0xed, 0x76, 0xca, 0xce, 0xb4, 0xb0, 0x21, 0x5c, 0xbc, 0x78, 0x54, 0xe3, 0xd5, - 0x3f, 0x88, 0x23, 0x89, 0x17, 0x4f, 0xc6, 0x80, 0x7f, 0x88, 0xe9, 0xcc, 0x74, 0x69, 0xd9, 0xae, - 0x70, 0xd9, 0x4c, 0x67, 0xde, 0xf7, 0xde, 0xeb, 0xf7, 0xcd, 0xdb, 0x82, 0xb9, 0x43, 0x8f, 0x05, - 0x78, 0xef, 0xa0, 0x8d, 0xe3, 0x06, 0xde, 0x8f, 0x68, 0xb7, 0x67, 0x85, 0x5d, 0x26, 0x18, 0xac, - 0x24, 0x07, 0xd6, 0xde, 0x41, 0xdb, 0x8a, 0x1b, 0x66, 0xd5, 0x65, 0x2e, 0x93, 0xfb, 0x38, 0x59, - 0x29, 0x88, 0x39, 0xef, 0x32, 0xe6, 0xfa, 0x14, 0x93, 0xd0, 0xc3, 0x24, 0x08, 0x98, 0x20, 0xc2, - 0x63, 0x01, 0xd7, 0xa7, 0x2b, 0x4d, 0xc6, 0x3b, 0x8c, 0x63, 0x87, 0x70, 0xaa, 0x98, 0x71, 0xdc, - 0x70, 0xa8, 0x20, 0x0d, 0x1c, 0x12, 0xd7, 0x0b, 0x24, 0x58, 0x63, 0x6b, 0x59, 0x17, 0x21, 0xe9, - 0x92, 0x4e, 0xca, 0x62, 0x66, 0x4f, 0x48, 0xd4, 0xf2, 0x68, 0xd0, 0xa4, 0xea, 0x0c, 0x55, 0x01, - 0xdc, 0x4e, 0x78, 0xb7, 0x64, 0x81, 0x4d, 0xf7, 0x23, 0xca, 0x05, 0x7a, 0x01, 0x66, 0x73, 0xbb, - 0x3c, 0x64, 0x01, 0xa7, 0xb0, 0x01, 0xc6, 0x15, 0x71, 0xcd, 0x58, 0x34, 0xee, 0x54, 0xd6, 0x66, - 0xad, 0xcc, 0x0b, 0x5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x96, 0x90, - 0x29, 0xd5, 0xab, 0x10, 0x0e, 0xaa, 0xc3, 0xaf, 0x06, 0xa8, 0x64, 0xae, 0x53, 0x91, 0xf0, 0x60, - 0x00, 0x8a, 0x84, 0x0b, 0xee, 0x24, 0x7a, 0x28, 0x85, 0x31, 0x5c, 0xbd, 0x10, 0x8e, 0x35, 0x6c, - 0x67, 0xef, 0x40, 0xa8, 0x57, 0xc7, 0x47, 0x3c, 0x72, 0x92, 0x5f, 0x9d, 0x8e, 0xe3, 0x8d, 0xa7, - 0x27, 0x67, 0x75, 0xe3, 0xf4, 0xac, 0x6e, 0xfc, 0x3e, 0xab, 0x1b, 0x5f, 0xce, 0xeb, 0xa5, 0xd3, - 0xf3, 0x7a, 0xe9, 0xe7, 0x79, 0xbd, 0xf4, 0x7e, 0xc9, 0xf5, 0xc4, 0x6e, 0xe4, 0x58, 0x4d, 0xd6, - 0xc1, 0x4e, 0xd4, 0x0d, 0xc4, 0xaa, 0x4f, 0x1c, 0xae, 0xd8, 0x0f, 0x25, 0xbf, 0xe8, 0x85, 0x94, - 0x3b, 0xe3, 0xf2, 0x6b, 0xf1, 0xe0, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3e, 0x7a, 0x9f, 0xe0, - 0xeb, 0x06, 0x00, 0x00, + // 706 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x95, 0xc1, 0x4f, 0xd4, 0x4a, + 0x1c, 0xc7, 0xb7, 0xc0, 0x12, 0x98, 0x85, 0x84, 0x0c, 0xfb, 0xc2, 0xbe, 0x86, 0xb7, 0xf0, 0x26, + 0xef, 0x81, 0x62, 0xe8, 0xb8, 0x18, 0xf5, 0xa8, 0x60, 0x22, 0xc6, 0x13, 0x54, 0xa3, 0x51, 0x0f, + 0x64, 0xba, 0x3b, 0x29, 0x65, 0xbb, 0x9d, 0xb2, 0x33, 0x2d, 0x6c, 0x08,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, 0xd4, 0x56, 0xdf, 0x8b, 0x89, 0x50, 0xaf, 0x9e, 0x54, + 0x77, 0xe9, 0x20, 0xf5, 0xeb, 0xd2, 0x01, 0xac, 0x83, 0x6a, 0x4c, 0xfc, 0x88, 0x6a, 0x47, 0xf5, + 0x03, 0xbd, 0xd3, 0x17, 0x96, 0x43, 0xd2, 0x17, 0xf6, 0x08, 0x4c, 0x87, 0x19, 0x4f, 0xae, 0x6f, + 0xed, 0xef, 0x7c, 0xcf, 0x67, 0x14, 0x76, 0x5e, 0xbf, 0xf6, 0xa1, 0x0a, 0xaa, 0xd2, 0x1d, 0x52, + 0x30, 0xae, 0x86, 0x03, 0x2e, 0xe4, 0xaa, 0x8b, 0x93, 0x67, 0x2e, 0x0e, 0x17, 0x28, 0x2e, 0xd4, + 0x78, 0xff, 0xed, 0xd7, 0x97, 0x11, 0x08, 0x67, 0xf0, 0xc5, 0x58, 0xab, 0x59, 0x83, 0x1f, 0x0d, + 0x30, 0x9d, 0xeb, 0x7e, 0x78, 0xbb, 0xe8, 0x36, 0x64, 0x10, 0xcd, 0x95, 0x9b, 0x48, 0x35, 0xc2, + 0xb2, 0x44, 0xf8, 0x17, 0x2e, 0x5c, 0x22, 0xa4, 0xed, 0xb2, 0x23, 0xe7, 0x0d, 0x1f, 0x25, 0x83, + 0x7c, 0x0c, 0x07, 0x60, 0x22, 0x75, 0x80, 0xff, 0xfd, 0x31, 0x20, 0xc5, 0xf8, 0xff, 0x1a, 0x95, + 0x26, 0x58, 0x94, 0x04, 0x26, 0x6c, 0x14, 0x09, 0xf0, 0x11, 0x89, 0x3a, 0xc7, 0x30, 0x06, 0xb5, + 0xb4, 0x6a, 0xdd, 0xf7, 0xcb, 0xd2, 0x8b, 0x93, 0x58, 0x96, 0x5e, 0x32, 0x4b, 0xc8, 0x94, 0xe9, + 0x75, 0x08, 0x8b, 0xe9, 0xf0, 0xb3, 0x01, 0x6a, 0x99, 0x76, 0x2a, 0x0b, 0x2e, 0x0e, 0x40, 0x59, + 0x70, 0x49, 0x4f, 0xa2, 0xfb, 0x32, 0x18, 0xc3, 0xd5, 0xcb, 0xe0, 0x58, 0xcb, 0x76, 0xf6, 0x0e, + 0x84, 0xfa, 0x74, 0x7c, 0xc4, 0x23, 0x27, 0xf9, 0xab, 0xa7, 0xe3, 0x78, 0xe3, 0xf1, 0xc9, 0x59, + 0xd3, 0x38, 0x3d, 0x6b, 0x1a, 0x3f, 0xcf, 0x9a, 0xc6, 0xa7, 0xf3, 0x66, 0xe5, 0xf4, 0xbc, 0x59, + 0xf9, 0x7e, 0xde, 0xac, 0xbc, 0x5d, 0x72, 0x3d, 0xb1, 0x1b, 0x39, 0x56, 0x9b, 0xf5, 0xb0, 0x13, + 0xf5, 0x03, 0xb1, 0xea, 0x13, 0x87, 0x2b, 0xf7, 0x43, 0xe9, 0x2f, 0x06, 0x21, 0xe5, 0xce, 0xb8, + 0xfc, 0x6f, 0x71, 0xef, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x19, 0x5a, 0xe3, 0xba, 0xeb, 0x06, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/mint/abci.go b/x/mint/abci.go index bfa85aec..522fbb00 100644 --- a/x/mint/abci.go +++ b/x/mint/abci.go @@ -13,12 +13,18 @@ import ( ) // BeginBlocker mints new tokens for the previous block. -func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ic types.InflationCalculationFn) { +func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ic types.InflationCalculationFn) error { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) // fetch stored minter & params - minter := k.GetMinter(ctx) - params := k.GetParams(ctx) + minter, err := k.GetMinter(ctx) + if err != nil { + return err + } + params, err := k.GetParams(ctx) + if err != nil { + return err + } // fetch collected fees collectedFeeCoin := k.CountCollectedFees(ctx, params.MintDenom) @@ -26,16 +32,18 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ic types.InflationCalculatio // recalculate inflation rate bondedRatio, err := k.BondedRatio(ctx) if err != nil { - panic(err) + return err } minter.Inflation = ic(ctx, minter, params, bondedRatio) bondedTokenSupply, err := k.BondedTokenSupply(ctx) if err != nil { - panic(err) + return err } minter.AnnualProvisions = minter.NextAnnualProvisions(params, bondedTokenSupply) - k.SetMinter(ctx, minter) + if err := k.SetMinter(ctx, minter); err != nil { + return err + } // mint coins, update supply neededCoin := minter.BlockProvision(params) @@ -50,13 +58,13 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ic types.InflationCalculatio err := k.MintCoins(ctx, mintedCoins) if err != nil { - panic(err) + return err } // send the minted coins to the fee collector account err = k.AddCollectedFees(ctx, mintedCoins) if err != nil { - panic(err) + return err } if mintedCoin.Amount.IsInt64() { @@ -70,7 +78,7 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ic types.InflationCalculatio burnedCoins := sdk.NewCoins(burnedCoin) err := k.BurnFees(ctx, burnedCoins) if err != nil { - panic(err) + return err } } @@ -83,9 +91,5 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ic types.InflationCalculatio MintedAmount: mintedCoin.Amount.Uint64(), BurnedAmount: burnedCoin.Amount.Uint64(), } - if err := ctx.EventManager().EmitTypedEvent(&mintEvent); err != nil { - k.Logger(ctx).Error("error emitting event", - "error", err, - "event", mintEvent) - } + return ctx.EventManager().EmitTypedEvent(&mintEvent) } diff --git a/x/mint/abci_test.go b/x/mint/abci_test.go index 84d76a5e..0bb019e0 100644 --- a/x/mint/abci_test.go +++ b/x/mint/abci_test.go @@ -116,7 +116,8 @@ func TestBeginBlocker(t *testing.T) { Populate mock */ - keeper.SetMinter(ctx, types.InitialMinter(tc.parameters.bondedRatio)) + err := keeper.SetMinter(ctx, types.InitialMinter(tc.parameters.bondedRatio)) + assert.NoError(t, err) stakingKeeper.EXPECT().TotalBondedTokens(ctx).Return(tc.parameters.bonded, nil) stakingKeeper.EXPECT().BondedRatio(ctx).Return(tc.parameters.bondedRatio, nil) @@ -132,7 +133,8 @@ func TestBeginBlocker(t *testing.T) { bankKeeper.EXPECT().BurnCoins(ctx, authtypes.FeeCollectorName, sdk.NewCoins(tc.parameters.collectedFees.Sub(c))).Return(nil) } - BeginBlocker(ctx, *keeper, types.DefaultInflationCalculationFn) + err = BeginBlocker(ctx, *keeper, types.DefaultInflationCalculationFn) + assert.NoError(t, err) events := ctx.EventManager().Events() assert.Equalf(t, 1, len(events), "A single event must be emitted. However %d events were emitted", len(events)) diff --git a/x/mint/keeper/genesis.go b/x/mint/keeper/genesis.go index 7bc7ff24..71937cb9 100644 --- a/x/mint/keeper/genesis.go +++ b/x/mint/keeper/genesis.go @@ -8,7 +8,9 @@ import ( // InitGenesis new mint genesis func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) { - k.SetMinter(ctx, data.Minter) + if err := k.SetMinter(ctx, data.Minter); err != nil { + panic(err) + } if err := k.SetParams(ctx, data.Params); err != nil { panic(err) @@ -19,7 +21,13 @@ func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types // ExportGenesis returns a GenesisState for a given context and keeper. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - minter := k.GetMinter(ctx) - params := k.GetParams(ctx) + minter, err := k.GetMinter(ctx) + if err != nil { + panic(err) + } + params, err := k.GetParams(ctx) + if err != nil { + panic(err) + } return types.NewGenesisState(minter, params) } diff --git a/x/mint/keeper/genesis_test.go b/x/mint/keeper/genesis_test.go index 010d643e..2387ca4f 100644 --- a/x/mint/keeper/genesis_test.go +++ b/x/mint/keeper/genesis_test.go @@ -49,8 +49,6 @@ func (s *GenesisTestSuite) SetupTest() { s.sdkCtx = testCtx.Ctx s.key = key - store := runtime.NewKVStoreService(s.key) - stakingKeeper := minttestutil.NewMockStakingKeeper(ctrl) accountKeeper := minttestutil.NewMockAccountKeeper(ctrl) bankKeeper := minttestutil.NewMockBankKeeper(ctrl) @@ -58,7 +56,7 @@ func (s *GenesisTestSuite) SetupTest() { accountKeeper.EXPECT().GetModuleAddress(minterAcc.Name).Return(minterAcc.GetAddress()) accountKeeper.EXPECT().GetModuleAccount(s.sdkCtx, minterAcc.Name).Return(minterAcc) - s.keeper = keeper.NewKeeper(s.cdc, store, stakingKeeper, accountKeeper, bankKeeper, "", "") + s.keeper = keeper.NewKeeper(s.cdc, runtime.NewKVStoreService(key), stakingKeeper, accountKeeper, bankKeeper, "", "") } func (s *GenesisTestSuite) TestImportExportGenesis() { @@ -75,13 +73,18 @@ func (s *GenesisTestSuite) TestImportExportGenesis() { s.keeper.InitGenesis(s.sdkCtx, s.accountKeeper, genesisState) - minter := s.keeper.GetMinter(s.sdkCtx) + minter, err := s.keeper.GetMinter(s.sdkCtx) + s.Require().NoError(err) s.Require().Equal(genesisState.Minter, minter) + s.Require().NoError(err) + + // invalidCtx := testutil.DefaultContextWithDB(s.T(), s.key, storetypes.NewTransientStoreKey("transient_test")) + // _, err = s.keeper.GetMinter(invalidCtx.Ctx) + // s.Require().ErrorIs(err, collections.ErrNotFound) - invalidCtx := testutil.DefaultContextWithDB(s.T(), s.key, storetypes.NewTransientStoreKey("transient_test")) - s.Require().Panics(func() { s.keeper.GetMinter(invalidCtx.Ctx) }, "stored minter should not have been nil") - params := s.keeper.GetParams(s.sdkCtx) + params, err := s.keeper.GetParams(s.sdkCtx) s.Require().Equal(genesisState.Params, params) + s.Require().NoError(err) genesisState2 := s.keeper.ExportGenesis(s.sdkCtx) s.Require().Equal(genesisState, genesisState2) diff --git a/x/mint/keeper/grpc_query.go b/x/mint/keeper/grpc_query.go index d93578ce..3caf302f 100644 --- a/x/mint/keeper/grpc_query.go +++ b/x/mint/keeper/grpc_query.go @@ -13,7 +13,10 @@ var _ types.QueryServer = Keeper{} // Params returns params of the mint module. func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { ctx := sdk.UnwrapSDKContext(c) - params := k.GetParams(ctx) + params, err := k.GetParams(ctx) + if err != nil { + return nil, err + } return &types.QueryParamsResponse{Params: params}, nil } @@ -21,7 +24,10 @@ func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.Q // Inflation returns minter.Inflation of the mint module. func (k Keeper) Inflation(c context.Context, _ *types.QueryInflationRequest) (*types.QueryInflationResponse, error) { ctx := sdk.UnwrapSDKContext(c) - minter := k.GetMinter(ctx) + minter, err := k.GetMinter(ctx) + if err != nil { + return nil, err + } return &types.QueryInflationResponse{Inflation: minter.Inflation}, nil } @@ -29,7 +35,10 @@ func (k Keeper) Inflation(c context.Context, _ *types.QueryInflationRequest) (*t // AnnualProvisions returns minter.AnnualProvisions of the mint module. func (k Keeper) AnnualProvisions(c context.Context, _ *types.QueryAnnualProvisionsRequest) (*types.QueryAnnualProvisionsResponse, error) { ctx := sdk.UnwrapSDKContext(c) - minter := k.GetMinter(ctx) + minter, err := k.GetMinter(ctx) + if err != nil { + return nil, err + } return &types.QueryAnnualProvisionsResponse{AnnualProvisions: minter.AnnualProvisions}, nil } diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go index d7b4511a..70a115ac 100644 --- a/x/mint/keeper/grpc_query_test.go +++ b/x/mint/keeper/grpc_query_test.go @@ -58,7 +58,8 @@ func (suite *MintTestSuite) SetupTest() { err := suite.mintKeeper.SetParams(suite.ctx, types.DefaultParams()) suite.Require().NoError(err) - suite.mintKeeper.SetMinter(suite.ctx, types.DefaultInitialMinter()) + err = suite.mintKeeper.SetMinter(suite.ctx, types.DefaultInitialMinter()) + suite.Require().NoError(err) queryHelper := baseapp.NewQueryServerTestHelper(testCtx.Ctx, encCfg.InterfaceRegistry) types.RegisterQueryServer(queryHelper, suite.mintKeeper) @@ -69,15 +70,19 @@ func (suite *MintTestSuite) SetupTest() { func (suite *MintTestSuite) TestGRPCParams() { params, err := suite.queryClient.Params(gocontext.Background(), &types.QueryParamsRequest{}) suite.Require().NoError(err) - suite.Require().Equal(params.Params, suite.mintKeeper.GetParams(suite.ctx)) + keeperParams, err := suite.mintKeeper.GetParams(suite.ctx) + suite.Require().NoError(err) + suite.Require().Equal(params.Params, keeperParams) inflation, err := suite.queryClient.Inflation(gocontext.Background(), &types.QueryInflationRequest{}) suite.Require().NoError(err) - suite.Require().Equal(inflation.Inflation, suite.mintKeeper.GetMinter(suite.ctx).Inflation) + keeperMinter, err := suite.mintKeeper.GetMinter(suite.ctx) + suite.Require().NoError(err) + suite.Require().Equal(inflation.Inflation, keeperMinter.Inflation) annualProvisions, err := suite.queryClient.AnnualProvisions(gocontext.Background(), &types.QueryAnnualProvisionsRequest{}) suite.Require().NoError(err) - suite.Require().Equal(annualProvisions.AnnualProvisions, suite.mintKeeper.GetMinter(suite.ctx).AnnualProvisions) + suite.Require().Equal(annualProvisions.AnnualProvisions, keeperMinter.AnnualProvisions) } func TestMintTestSuite(t *testing.T) { diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index a3a8a13d..45271f3f 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -64,14 +64,14 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // GetMinter returns the minter. -func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) { +func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter, err error) { store := k.storeService.OpenKVStore(ctx) bz, err := store.Get(types.MinterKey) if err != nil { - panic("failed to get minter") + return types.Minter{}, err } if bz == nil { - panic("stored minter should not have been nil") + return types.Minter{}, err } k.cdc.MustUnmarshal(bz, &minter) @@ -79,13 +79,11 @@ func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) { } // SetMinter sets the minter. -func (k Keeper) SetMinter(ctx sdk.Context, minter types.Minter) { +func (k Keeper) SetMinter(ctx sdk.Context, minter types.Minter) (err error) { store := k.storeService.OpenKVStore(ctx) bz := k.cdc.MustMarshal(&minter) - err := store.Set(types.MinterKey, bz) - if err != nil { - panic("failed to set minter") - } + err = store.Set(types.MinterKey, bz) + return err } // SetParams sets the x/mint module parameters. @@ -105,18 +103,18 @@ func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { } // GetParams returns the current x/mint module parameters. -func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { +func (k Keeper) GetParams(ctx sdk.Context) (p types.Params, err error) { store := k.storeService.OpenKVStore(ctx) bz, err := store.Get(types.ParamsKey) if err != nil { - panic("failed to get params") + return types.Params{}, err } if bz == nil { - return p + return p, nil } k.cdc.MustUnmarshal(bz, &p) - return p + return p, nil } // StakingTokenSupply implements an alias call to the underlying staking keeper's diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go index 0eaccc7f..781a061d 100644 --- a/x/mint/keeper/keeper_test.go +++ b/x/mint/keeper/keeper_test.go @@ -68,7 +68,8 @@ func (s *IntegrationTestSuite) SetupTest() { err := s.mintKeeper.SetParams(s.ctx, types.DefaultParams()) s.Require().NoError(err) - s.mintKeeper.SetMinter(s.ctx, types.DefaultInitialMinter()) + err = s.mintKeeper.SetMinter(s.ctx, types.DefaultInitialMinter()) + s.Require().NoError(err) s.msgServer = keeper.NewMsgServerImpl(s.mintKeeper) } @@ -107,8 +108,9 @@ func (s *IntegrationTestSuite) TestParams() { for _, tc := range testCases { s.Run(tc.name, func() { - expected := s.mintKeeper.GetParams(s.ctx) - err := s.mintKeeper.SetParams(s.ctx, tc.input) + expected, err := s.mintKeeper.GetParams(s.ctx) + s.Require().NoError(err) + err = s.mintKeeper.SetParams(s.ctx, tc.input) if tc.expectErr { s.Require().Error(err) } else { @@ -116,7 +118,8 @@ func (s *IntegrationTestSuite) TestParams() { s.Require().NoError(err) } - p := s.mintKeeper.GetParams(s.ctx) + p, err := s.mintKeeper.GetParams(s.ctx) + s.Require().NoError(err) s.Require().Equal(expected, p) }) } diff --git a/x/mint/module.go b/x/mint/module.go index 5b25fdb1..b00f66ce 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -8,8 +8,6 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - abci "github.com/cometbft/cometbft/abci/types" - modulev1 "cosmossdk.io/api/cosmos/mint/module/v1" "cosmossdk.io/core/appmodule" store2 "cosmossdk.io/core/store" @@ -37,6 +35,11 @@ const ConsensusVersion = 1 var ( _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModuleBasic defines the basic application module used by the mint module. @@ -154,12 +157,11 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // InitGenesis performs genesis initialization for the mint module. It returns // no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) am.keeper.InitGenesis(ctx, am.authKeeper, &genesisState) - return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the mint @@ -172,13 +174,13 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } -// BeginBlock returns the begin blocker for the mint module. -/*func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { - BeginBlocker(ctx, am.keeper, am.inflationCalculator) +// BeginBlock returns the BeginBlocker for the mint module. +func (am AppModule) BeginBlock(ctx context.Context) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + return BeginBlocker(sdkCtx, am.keeper, am.inflationCalculator) } - -*/ // AppModuleSimulation functions +// AppModuleSimulation functions func (am AppModule) RegisterStoreDecoder(registry simtypes.StoreDecoderRegistry) { registry[types.StoreKey] = simulation.NewDecodeStore(am.cdc) } diff --git a/x/xion/client/cli/query.go b/x/xion/client/cli/query.go index 06734238..0fefc5e4 100644 --- a/x/xion/client/cli/query.go +++ b/x/xion/client/cli/query.go @@ -23,6 +23,7 @@ func GetQueryCmd() *cobra.Command { cmd.AddCommand(CmdWebAuthNVerifyRegister()) cmd.AddCommand(CmdWebAuthNVerifyAuthenticate()) + cmd.AddCommand(CmdPlatformFee()) // this line is used by starport scaffolding # 1 diff --git a/x/xion/client/cli/query_platform_fee.go b/x/xion/client/cli/query_platform_fee.go new file mode 100644 index 00000000..062d312c --- /dev/null +++ b/x/xion/client/cli/query_platform_fee.go @@ -0,0 +1,38 @@ +package cli + +import ( + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + + "github.com/burnt-labs/xion/x/xion/types" +) + +func CmdPlatformFee() *cobra.Command { + cmd := &cobra.Command{ + Use: "platform-fee", + Short: "Get Platform Fee", + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryPlatformPercentageRequest{} + + res, err := queryClient.PlatformPercentage(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/xion/keeper/genesis.go b/x/xion/keeper/genesis.go index d3b61658..c7c5c6a8 100644 --- a/x/xion/keeper/genesis.go +++ b/x/xion/keeper/genesis.go @@ -11,12 +11,21 @@ import ( // InitGenesis initializes the bank module's state from a given genesis state. func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { k.OverwritePlatformPercentage(ctx, genState.PlatformPercentage) + err := k.OverwritePlatformMinimum(ctx, genState.PlatformMinimums) + if err != nil { + panic(err) + } } // ExportGenesis returns the bank module's genesis state. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { bz := ctx.KVStore(k.storeKey).Get(types.PlatformPercentageKey) platformPercentage := binary.BigEndian.Uint32(bz) - rv := types.NewGenesisState(platformPercentage) + + platformMinimums, err := k.GetPlatformMinimums(ctx) + if err != nil { + panic(err) + } + rv := types.NewGenesisState(platformPercentage, platformMinimums) return rv } diff --git a/x/xion/keeper/keeper.go b/x/xion/keeper/keeper.go index 46b92fce..5d023b10 100644 --- a/x/xion/keeper/keeper.go +++ b/x/xion/keeper/keeper.go @@ -1,6 +1,9 @@ package keeper import ( + "context" + "encoding/json" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "cosmossdk.io/log" @@ -68,9 +71,36 @@ func (k Keeper) OverwritePlatformPercentage(ctx sdktypes.Context, percentage uin ctx.KVStore(k.storeKey).Set(types.PlatformPercentageKey, sdktypes.Uint64ToBigEndian(uint64(percentage))) } +// Platform Minimum +func (k Keeper) GetPlatformMinimums(ctx sdktypes.Context) (coins sdktypes.Coins, err error) { + bz := ctx.KVStore(k.storeKey).Get(types.PlatformMinimumKey) + + if len(bz) != 0 { + err = json.Unmarshal(bz, &coins) + } + + return coins, err +} + +func (k Keeper) OverwritePlatformMinimum(ctx sdktypes.Context, coins sdktypes.Coins) error { + bz, err := json.Marshal(coins) + if err != nil { + return err + } + ctx.KVStore(k.storeKey).Set(types.PlatformMinimumKey, bz) + return nil +} + // Authority // GetAuthority returns the x/xion module's authority. func (k Keeper) GetAuthority() string { return k.authority } + +// PlatformPercentage implements types.QueryServer. +func (k Keeper) PlatformPercentage(ctx context.Context, _ *types.QueryPlatformPercentageRequest) (*types.QueryPlatformPercentageResponse, error) { + sdkCtx := sdktypes.UnwrapSDKContext(ctx) + percentage := k.GetPlatformPercentage(sdkCtx).Uint64() + return &types.QueryPlatformPercentageResponse{PlatformPercentage: percentage}, nil +} diff --git a/x/xion/keeper/msg_server.go b/x/xion/keeper/msg_server.go index b9387394..9d493b9c 100644 --- a/x/xion/keeper/msg_server.go +++ b/x/xion/keeper/msg_server.go @@ -52,7 +52,15 @@ func (k msgServer) Send(goCtx context.Context, msg *types.MsgSend) (*types.MsgSe } percentage := k.GetPlatformPercentage(ctx) + minimums, err := k.GetPlatformMinimums(ctx) + if err != nil { + return nil, err + } throughCoins := msg.Amount + if !msg.Amount.IsAnyGT(minimums) { + // minimum has not been met. no coin in msg.Amount exceeds a minimum that has been set + return nil, errorsmod.Wrapf(types.ErrMinimumNotMet, "received %v, needed at least %v", msg.Amount, minimums) + } if !percentage.IsZero() { platformCoins := msg.Amount.MulInt(percentage).QuoInt(math.NewInt(10000)) @@ -94,9 +102,18 @@ func (k msgServer) MultiSend(goCtx context.Context, msg *types.MsgMultiSend) (*t } percentage := k.GetPlatformPercentage(ctx) + minimums, err := k.GetPlatformMinimums(ctx) + if err != nil { + return nil, err + } var outputs []banktypes.Output totalPlatformCoins := sdk.NewCoins() + if !msg.Inputs[0].Coins.IsAnyGT(minimums) { + // minimum has not been met. no coin in msg.Amount exceeds a minimum that has been set + return nil, errorsmod.Wrapf(types.ErrMinimumNotMet, "received %v, needed at least %v", msg.Inputs[0].Coins, minimums) + } + for _, out := range msg.Outputs { accAddr := sdk.MustAccAddressFromBech32(out.Address) @@ -125,7 +142,7 @@ func (k msgServer) MultiSend(goCtx context.Context, msg *types.MsgMultiSend) (*t outputs = append(outputs, banktypes.NewOutput(feeCollectorAcc, totalPlatformCoins)) } - err := k.bankKeeper.InputOutputCoins(ctx, msg.Inputs[0], outputs) + err = k.bankKeeper.InputOutputCoins(ctx, msg.Inputs[0], outputs) if err != nil { return nil, err } @@ -143,3 +160,14 @@ func (k msgServer) SetPlatformPercentage(goCtx context.Context, msg *types.MsgSe return &types.MsgSetPlatformPercentageResponse{}, nil } + +func (k msgServer) SetPlatformMinimum(goCtx context.Context, msg *types.MsgSetPlatformMinimum) (*types.MsgSetPlatformMinimumResponse, error) { + if k.GetAuthority() != msg.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), msg.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + err := k.OverwritePlatformMinimum(ctx, msg.Minimums) + + return &types.MsgSetPlatformMinimumResponse{}, err +} diff --git a/x/xion/types/errors.go b/x/xion/types/errors.go index 57b36186..859323c0 100644 --- a/x/xion/types/errors.go +++ b/x/xion/types/errors.go @@ -11,4 +11,5 @@ var ( ErrNoAllowedContracts = errorsmod.Register(DefaultCodespace, 2, "no contract addresses specified") ErrNoValidAllowances = errorsmod.Register(DefaultCodespace, 3, "none of the allowances accepted the msg") ErrInconsistentExpiry = errorsmod.Register(DefaultCodespace, 4, "multi allowances must all expire together") + ErrMinimumNotMet = errorsmod.Register(DefaultCodespace, 5, "minimum send amount not met") ) diff --git a/x/xion/types/genesis.go b/x/xion/types/genesis.go index 205801ee..16155aea 100644 --- a/x/xion/types/genesis.go +++ b/x/xion/types/genesis.go @@ -5,6 +5,7 @@ import ( "errors" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types" ) // Validate performs basic validation of supply genesis data returning an @@ -18,16 +19,17 @@ func (gs GenesisState) Validate() error { } // NewGenesisState creates a new genesis state. -func NewGenesisState(platformPercentage uint32) *GenesisState { +func NewGenesisState(platformPercentage uint32, platformMinimums types.Coins) *GenesisState { rv := &GenesisState{ PlatformPercentage: platformPercentage, + PlatformMinimums: platformMinimums, } return rv } // DefaultGenesisState returns a default bank module genesis state. func DefaultGenesisState() *GenesisState { - return NewGenesisState(0) + return NewGenesisState(0, types.Coins{}) } // GetGenesisStateFromAppState returns x/bank GenesisState given raw application diff --git a/x/xion/types/genesis.pb.go b/x/xion/types/genesis.pb.go index 3346616f..4bfc95be 100644 --- a/x/xion/types/genesis.pb.go +++ b/x/xion/types/genesis.pb.go @@ -5,6 +5,8 @@ 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/cosmos/gogoproto/proto" io "io" @@ -24,7 +26,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { - PlatformPercentage uint32 `protobuf:"varint,1,opt,name=platform_percentage,json=platformPercentage,proto3" json:"platform_percentage,omitempty"` + PlatformPercentage uint32 `protobuf:"varint,1,opt,name=platform_percentage,json=platformPercentage,proto3" json:"platform_percentage,omitempty"` + PlatformMinimums github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=platform_minimums,json=platformMinimums,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"platform_minimums,omitempty" yaml:"platform_minimums"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -67,6 +70,13 @@ func (m *GenesisState) GetPlatformPercentage() uint32 { return 0 } +func (m *GenesisState) GetPlatformMinimums() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.PlatformMinimums + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "xion.v1.GenesisState") } @@ -74,19 +84,27 @@ func init() { func init() { proto.RegisterFile("xion/v1/genesis.proto", fileDescriptor_9a0f59b6b1baf029) } var fileDescriptor_9a0f59b6b1baf029 = []byte{ - // 181 bytes of a gzipped FileDescriptorProto + // 312 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xad, 0xc8, 0xcc, 0xcf, 0xd3, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x62, 0x07, 0x09, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xc5, - 0xf4, 0x41, 0x2c, 0x88, 0xb4, 0x92, 0x3d, 0x17, 0x8f, 0x3b, 0x44, 0x7d, 0x70, 0x49, 0x62, 0x49, - 0xaa, 0x90, 0x3e, 0x97, 0x70, 0x41, 0x4e, 0x62, 0x49, 0x5a, 0x7e, 0x51, 0x6e, 0x7c, 0x41, 0x6a, - 0x51, 0x72, 0x6a, 0x5e, 0x49, 0x62, 0x7a, 0xaa, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x6f, 0x90, 0x10, - 0x4c, 0x2a, 0x00, 0x2e, 0xe3, 0xe4, 0x78, 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, 0xea, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x49, 0xa5, 0x45, - 0x79, 0x25, 0xba, 0x39, 0x89, 0x49, 0xc5, 0xfa, 0x60, 0x67, 0x56, 0x40, 0xa8, 0x92, 0xca, 0x82, - 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x53, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x35, 0xe8, - 0xba, 0xc2, 0x00, 0x00, 0x00, + 0xc9, 0x17, 0x62, 0x07, 0x09, 0xeb, 0x95, 0x19, 0x4a, 0xc9, 0x25, 0xe7, 0x17, 0xe7, 0xe6, 0x17, + 0xeb, 0x27, 0x25, 0x16, 0xa7, 0xea, 0x97, 0x19, 0x26, 0xa5, 0x96, 0x24, 0x1a, 0xea, 0x27, 0xe7, + 0x67, 0xe6, 0x41, 0x14, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x99, 0xfa, 0x20, 0x16, 0x44, + 0x54, 0xe9, 0x2b, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0xc0, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x7d, + 0x2e, 0xe1, 0x82, 0x9c, 0xc4, 0x92, 0xb4, 0xfc, 0xa2, 0x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a, 0x08, 0x05, 0x36, 0x3a, 0x89, 0x0d, 0x1c, 0x82, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xa0, 0xd2, 0xf5, 0xdb, 0x99, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -109,6 +127,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.PlatformMinimums) > 0 { + for iNdEx := len(m.PlatformMinimums) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PlatformMinimums[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } if m.PlatformPercentage != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.PlatformPercentage)) i-- @@ -137,6 +169,12 @@ func (m *GenesisState) Size() (n int) { if m.PlatformPercentage != 0 { n += 1 + sovGenesis(uint64(m.PlatformPercentage)) } + if len(m.PlatformMinimums) > 0 { + for _, e := range m.PlatformMinimums { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -194,6 +232,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { break } } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PlatformMinimums", 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.PlatformMinimums = append(m.PlatformMinimums, types.Coin{}) + if err := m.PlatformMinimums[len(m.PlatformMinimums)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/xion/types/keys.go b/x/xion/types/keys.go index 7d27d8db..15b7d299 100644 --- a/x/xion/types/keys.go +++ b/x/xion/types/keys.go @@ -1,6 +1,9 @@ package types -var PlatformPercentageKey = []byte{0x00} +var ( + PlatformPercentageKey = []byte{0x00} + PlatformMinimumKey = []byte{0x01} +) const ( // ModuleName is the module name constant used in many places diff --git a/x/xion/types/query.pb.go b/x/xion/types/query.pb.go index 8d9c3584..51e091ac 100644 --- a/x/xion/types/query.pb.go +++ b/x/xion/types/query.pb.go @@ -255,39 +255,125 @@ func (m *QueryWebAuthNVerifyAuthenticateResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryWebAuthNVerifyAuthenticateResponse proto.InternalMessageInfo +type QueryPlatformPercentageRequest struct { +} + +func (m *QueryPlatformPercentageRequest) Reset() { *m = QueryPlatformPercentageRequest{} } +func (m *QueryPlatformPercentageRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPlatformPercentageRequest) ProtoMessage() {} +func (*QueryPlatformPercentageRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2d6eabf4b8b83bc3, []int{4} +} +func (m *QueryPlatformPercentageRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPlatformPercentageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPlatformPercentageRequest.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 *QueryPlatformPercentageRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPlatformPercentageRequest.Merge(m, src) +} +func (m *QueryPlatformPercentageRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPlatformPercentageRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPlatformPercentageRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPlatformPercentageRequest proto.InternalMessageInfo + +type QueryPlatformPercentageResponse struct { + PlatformPercentage uint64 `protobuf:"varint,1,opt,name=platform_percentage,json=platformPercentage,proto3" json:"platform_percentage,omitempty"` +} + +func (m *QueryPlatformPercentageResponse) Reset() { *m = QueryPlatformPercentageResponse{} } +func (m *QueryPlatformPercentageResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPlatformPercentageResponse) ProtoMessage() {} +func (*QueryPlatformPercentageResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2d6eabf4b8b83bc3, []int{5} +} +func (m *QueryPlatformPercentageResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPlatformPercentageResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPlatformPercentageResponse.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 *QueryPlatformPercentageResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPlatformPercentageResponse.Merge(m, src) +} +func (m *QueryPlatformPercentageResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPlatformPercentageResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPlatformPercentageResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPlatformPercentageResponse proto.InternalMessageInfo + +func (m *QueryPlatformPercentageResponse) GetPlatformPercentage() uint64 { + if m != nil { + return m.PlatformPercentage + } + return 0 +} + func init() { proto.RegisterType((*QueryWebAuthNVerifyRegisterRequest)(nil), "xion.v1.QueryWebAuthNVerifyRegisterRequest") proto.RegisterType((*QueryWebAuthNVerifyRegisterResponse)(nil), "xion.v1.QueryWebAuthNVerifyRegisterResponse") proto.RegisterType((*QueryWebAuthNVerifyAuthenticateRequest)(nil), "xion.v1.QueryWebAuthNVerifyAuthenticateRequest") proto.RegisterType((*QueryWebAuthNVerifyAuthenticateResponse)(nil), "xion.v1.QueryWebAuthNVerifyAuthenticateResponse") + proto.RegisterType((*QueryPlatformPercentageRequest)(nil), "xion.v1.QueryPlatformPercentageRequest") + proto.RegisterType((*QueryPlatformPercentageResponse)(nil), "xion.v1.QueryPlatformPercentageResponse") } func init() { proto.RegisterFile("xion/v1/query.proto", fileDescriptor_2d6eabf4b8b83bc3) } var fileDescriptor_2d6eabf4b8b83bc3 = []byte{ - // 340 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xae, 0xc8, 0xcc, 0xcf, - 0xd3, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, - 0x62, 0x07, 0x09, 0xea, 0x95, 0x19, 0x2a, 0x55, 0x71, 0x29, 0x05, 0x82, 0xc4, 0xc3, 0x53, 0x93, - 0x1c, 0x4b, 0x4b, 0x32, 0xfc, 0xc2, 0x52, 0x8b, 0x32, 0xd3, 0x2a, 0x83, 0x52, 0xd3, 0x33, 0x8b, - 0x4b, 0x52, 0x8b, 0x82, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x84, 0x84, 0xb8, 0x58, 0x12, 0x53, - 0x52, 0x8a, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xc0, 0x6c, 0x21, 0x19, 0x2e, 0xce, 0xe4, - 0x8c, 0xc4, 0x9c, 0x9c, 0xd4, 0xbc, 0xf4, 0x54, 0x09, 0x26, 0xb0, 0x04, 0x42, 0x40, 0x88, 0x8f, - 0x8b, 0xa9, 0xa8, 0x40, 0x82, 0x19, 0x2c, 0xcc, 0x54, 0x54, 0x00, 0x32, 0x21, 0x25, 0xb1, 0x24, - 0x51, 0x82, 0x45, 0x81, 0x51, 0x83, 0x27, 0x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x05, 0xa9, - 0xc5, 0x49, 0x6c, 0xe0, 0x64, 0x6e, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xcd, 0xd9, 0x5e, 0xff, - 0xfd, 0x02, 0x00, 0x00, + // 404 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xcd, 0xca, 0xd3, 0x40, + 0x14, 0xcd, 0xc4, 0x7c, 0xca, 0x77, 0xf9, 0x70, 0x31, 0x1f, 0x48, 0x08, 0x32, 0x96, 0x08, 0xb6, + 0xa2, 0x26, 0x56, 0x9f, 0xa0, 0x82, 0x5b, 0xa9, 0x59, 0x28, 0xb8, 0x91, 0x49, 0x72, 0x9b, 0x06, + 0xd2, 0x64, 0x3a, 0x99, 0x94, 0xd6, 0x9d, 0x6f, 0xe0, 0x13, 0xf8, 0x3c, 0x2e, 0xbb, 0x74, 0x29, + 0xed, 0xda, 0x77, 0x90, 0x4c, 0xd3, 0xda, 0xda, 0xdf, 0x85, 0xab, 0x5c, 0xce, 0x3d, 0x39, 0x73, + 0xce, 0xbd, 0x33, 0x70, 0x3b, 0x4d, 0x8b, 0xdc, 0x9f, 0x74, 0xfd, 0x71, 0x85, 0x72, 0xe6, 0x09, + 0x59, 0xa8, 0x82, 0xde, 0xab, 0x41, 0x6f, 0xd2, 0x75, 0xbf, 0x80, 0xfb, 0xbe, 0xc6, 0x3f, 0x62, + 0xd8, 0xab, 0xd4, 0xf0, 0xdd, 0x07, 0x94, 0xe9, 0x60, 0x16, 0x60, 0x92, 0x96, 0x0a, 0x65, 0x80, + 0xe3, 0x0a, 0x4b, 0x45, 0x29, 0x58, 0x3c, 0x8e, 0xa5, 0x4d, 0x5a, 0xa4, 0x73, 0x1d, 0xe8, 0x9a, + 0x3e, 0x84, 0xeb, 0x68, 0xc8, 0xb3, 0x0c, 0xf3, 0x04, 0x6d, 0x53, 0x37, 0xfe, 0x02, 0xf4, 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x2c, 0x18, 0x99, 0x2f, 0x18, 0xf9, 0xb5, 0x60, 0xe4, 0xdb, 0x92, 0x19, 0xf3, + 0x25, 0x33, 0x7e, 0x2e, 0x99, 0xf1, 0xa9, 0x9d, 0xa4, 0x6a, 0x58, 0x85, 0x5e, 0x54, 0x8c, 0xfc, + 0xb0, 0x92, 0xb9, 0x7a, 0x91, 0xf1, 0xb0, 0xf4, 0xf5, 0x13, 0x9e, 0xae, 0x3e, 0x6a, 0x26, 0xb0, + 0x0c, 0xef, 0xea, 0x77, 0xfc, 0xfa, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x48, 0xf8, 0xb9, 0x62, + 0xde, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -304,6 +390,7 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { WebAuthNVerifyRegister(ctx context.Context, in *QueryWebAuthNVerifyRegisterRequest, opts ...grpc.CallOption) (*QueryWebAuthNVerifyRegisterResponse, error) WebAuthNVerifyAuthenticate(ctx context.Context, in *QueryWebAuthNVerifyAuthenticateRequest, opts ...grpc.CallOption) (*QueryWebAuthNVerifyAuthenticateResponse, error) + PlatformPercentage(ctx context.Context, in *QueryPlatformPercentageRequest, opts ...grpc.CallOption) (*QueryPlatformPercentageResponse, error) } type queryClient struct { @@ -332,10 +419,20 @@ func (c *queryClient) WebAuthNVerifyAuthenticate(ctx context.Context, in *QueryW return out, nil } +func (c *queryClient) PlatformPercentage(ctx context.Context, in *QueryPlatformPercentageRequest, opts ...grpc.CallOption) (*QueryPlatformPercentageResponse, error) { + out := new(QueryPlatformPercentageResponse) + err := c.cc.Invoke(ctx, "/xion.v1.Query/PlatformPercentage", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { WebAuthNVerifyRegister(context.Context, *QueryWebAuthNVerifyRegisterRequest) (*QueryWebAuthNVerifyRegisterResponse, error) WebAuthNVerifyAuthenticate(context.Context, *QueryWebAuthNVerifyAuthenticateRequest) (*QueryWebAuthNVerifyAuthenticateResponse, error) + PlatformPercentage(context.Context, *QueryPlatformPercentageRequest) (*QueryPlatformPercentageResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -348,6 +445,9 @@ func (*UnimplementedQueryServer) WebAuthNVerifyRegister(ctx context.Context, req func (*UnimplementedQueryServer) WebAuthNVerifyAuthenticate(ctx context.Context, req *QueryWebAuthNVerifyAuthenticateRequest) (*QueryWebAuthNVerifyAuthenticateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method WebAuthNVerifyAuthenticate not implemented") } +func (*UnimplementedQueryServer) PlatformPercentage(ctx context.Context, req *QueryPlatformPercentageRequest) (*QueryPlatformPercentageResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PlatformPercentage not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -389,6 +489,24 @@ func _Query_WebAuthNVerifyAuthenticate_Handler(srv interface{}, ctx context.Cont return interceptor(ctx, in, info, handler) } +func _Query_PlatformPercentage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPlatformPercentageRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PlatformPercentage(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/xion.v1.Query/PlatformPercentage", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PlatformPercentage(ctx, req.(*QueryPlatformPercentageRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "xion.v1.Query", HandlerType: (*QueryServer)(nil), @@ -401,6 +519,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "WebAuthNVerifyAuthenticate", Handler: _Query_WebAuthNVerifyAuthenticate_Handler, }, + { + MethodName: "PlatformPercentage", + Handler: _Query_PlatformPercentage_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "xion/v1/query.proto", @@ -568,6 +690,57 @@ func (m *QueryWebAuthNVerifyAuthenticateResponse) MarshalToSizedBuffer(dAtA []by return len(dAtA) - i, nil } +func (m *QueryPlatformPercentageRequest) 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 *QueryPlatformPercentageRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPlatformPercentageRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryPlatformPercentageResponse) 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 *QueryPlatformPercentageResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPlatformPercentageResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PlatformPercentage != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PlatformPercentage)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -655,6 +828,27 @@ func (m *QueryWebAuthNVerifyAuthenticateResponse) Size() (n int) { return n } +func (m *QueryPlatformPercentageRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryPlatformPercentageResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PlatformPercentage != 0 { + n += 1 + sovQuery(uint64(m.PlatformPercentage)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1189,6 +1383,125 @@ func (m *QueryWebAuthNVerifyAuthenticateResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPlatformPercentageRequest) 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: QueryPlatformPercentageRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPlatformPercentageRequest: 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 *QueryPlatformPercentageResponse) 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: QueryPlatformPercentageResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPlatformPercentageResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PlatformPercentage", wireType) + } + m.PlatformPercentage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PlatformPercentage |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/xion/types/tx.pb.go b/x/xion/types/tx.pb.go index 8275d518..95c96f64 100644 --- a/x/xion/types/tx.pb.go +++ b/x/xion/types/tx.pb.go @@ -292,6 +292,94 @@ func (m *MsgSetPlatformPercentageResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetPlatformPercentageResponse proto.InternalMessageInfo +type MsgSetPlatformMinimum struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Minimums github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=minimums,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"minimums"` +} + +func (m *MsgSetPlatformMinimum) Reset() { *m = MsgSetPlatformMinimum{} } +func (m *MsgSetPlatformMinimum) String() string { return proto.CompactTextString(m) } +func (*MsgSetPlatformMinimum) ProtoMessage() {} +func (*MsgSetPlatformMinimum) Descriptor() ([]byte, []int) { + return fileDescriptor_5076275aa290c9b8, []int{6} +} +func (m *MsgSetPlatformMinimum) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetPlatformMinimum) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetPlatformMinimum.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 *MsgSetPlatformMinimum) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetPlatformMinimum.Merge(m, src) +} +func (m *MsgSetPlatformMinimum) XXX_Size() int { + return m.Size() +} +func (m *MsgSetPlatformMinimum) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetPlatformMinimum.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetPlatformMinimum proto.InternalMessageInfo + +func (m *MsgSetPlatformMinimum) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgSetPlatformMinimum) GetMinimums() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Minimums + } + return nil +} + +type MsgSetPlatformMinimumResponse struct { +} + +func (m *MsgSetPlatformMinimumResponse) Reset() { *m = MsgSetPlatformMinimumResponse{} } +func (m *MsgSetPlatformMinimumResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetPlatformMinimumResponse) ProtoMessage() {} +func (*MsgSetPlatformMinimumResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5076275aa290c9b8, []int{7} +} +func (m *MsgSetPlatformMinimumResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetPlatformMinimumResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetPlatformMinimumResponse.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 *MsgSetPlatformMinimumResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetPlatformMinimumResponse.Merge(m, src) +} +func (m *MsgSetPlatformMinimumResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetPlatformMinimumResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetPlatformMinimumResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetPlatformMinimumResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSend)(nil), "xion.v1.MsgSend") proto.RegisterType((*MsgSendResponse)(nil), "xion.v1.MsgSendResponse") @@ -299,50 +387,56 @@ func init() { proto.RegisterType((*MsgMultiSendResponse)(nil), "xion.v1.MsgMultiSendResponse") proto.RegisterType((*MsgSetPlatformPercentage)(nil), "xion.v1.MsgSetPlatformPercentage") proto.RegisterType((*MsgSetPlatformPercentageResponse)(nil), "xion.v1.MsgSetPlatformPercentageResponse") + proto.RegisterType((*MsgSetPlatformMinimum)(nil), "xion.v1.MsgSetPlatformMinimum") + proto.RegisterType((*MsgSetPlatformMinimumResponse)(nil), "xion.v1.MsgSetPlatformMinimumResponse") } func init() { proto.RegisterFile("xion/v1/tx.proto", fileDescriptor_5076275aa290c9b8) } var fileDescriptor_5076275aa290c9b8 = []byte{ - // 601 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x41, 0x8f, 0xd2, 0x40, - 0x14, 0x6e, 0x41, 0x21, 0xcc, 0xae, 0x71, 0xa9, 0xac, 0xb2, 0x35, 0x5b, 0xb0, 0x89, 0x11, 0x49, - 0x68, 0x05, 0xa3, 0x26, 0x18, 0x13, 0xc1, 0x93, 0x07, 0xe2, 0x86, 0xbd, 0x79, 0x21, 0x2d, 0xcc, - 0x96, 0x06, 0x3a, 0xd3, 0x74, 0xa6, 0x84, 0xbd, 0x19, 0x4f, 0xc6, 0x93, 0x17, 0xef, 0x7b, 0x34, - 0x9e, 0xf6, 0xa0, 0xfe, 0x86, 0x3d, 0x6e, 0x3c, 0x79, 0x52, 0x03, 0x87, 0x35, 0xfe, 0x0a, 0x33, - 0xd3, 0x69, 0x61, 0x5d, 0x36, 0x5c, 0xe8, 0xcc, 0x7b, 0xef, 0xfb, 0xe6, 0xfb, 0xde, 0x9b, 0x01, - 0x6c, 0x4d, 0x5d, 0x8c, 0xcc, 0x49, 0xdd, 0xa4, 0x53, 0xc3, 0x0f, 0x30, 0xc5, 0x4a, 0x96, 0x45, - 0x8c, 0x49, 0x5d, 0x2d, 0x38, 0xd8, 0xc1, 0x3c, 0x66, 0xb2, 0x55, 0x94, 0x56, 0x6f, 0xf5, 0x31, - 0xf1, 0x30, 0x31, 0x3d, 0xe2, 0x30, 0x98, 0x47, 0x1c, 0x91, 0xc8, 0x5b, 0x9e, 0x8b, 0xb0, 0xc9, - 0x7f, 0x45, 0x68, 0x27, 0xaa, 0xed, 0x45, 0x24, 0xd1, 0x46, 0xa4, 0x34, 0x41, 0x63, 0x5b, 0x04, - 0x9a, 0x93, 0xba, 0x0d, 0xa9, 0x55, 0x37, 0xfb, 0xd8, 0x45, 0x17, 0xf2, 0x68, 0x94, 0xe4, 0xd9, - 0x26, 0xca, 0xeb, 0x1f, 0x53, 0x20, 0xdb, 0x21, 0xce, 0x3e, 0x44, 0x03, 0xe5, 0x29, 0xd8, 0x3c, - 0x08, 0xb0, 0xd7, 0xb3, 0x06, 0x83, 0x00, 0x12, 0x52, 0x94, 0xcb, 0x72, 0x25, 0xd7, 0x2e, 0x7e, - 0xff, 0x52, 0x2b, 0x88, 0x33, 0x5b, 0x51, 0x66, 0x9f, 0x06, 0x2e, 0x72, 0xba, 0x1b, 0xac, 0x5a, - 0x84, 0x94, 0x27, 0x00, 0x50, 0x9c, 0x40, 0x53, 0x6b, 0xa0, 0x39, 0x8a, 0x63, 0xe0, 0x10, 0x64, - 0x2c, 0x0f, 0x87, 0x88, 0x16, 0xd3, 0xe5, 0x74, 0x65, 0xa3, 0xb1, 0x63, 0x08, 0x04, 0xb3, 0x64, - 0x08, 0xc9, 0xc6, 0x0b, 0xec, 0xa2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, 0xc1, 0xd6, - 0xf3, 0x13, 0x3a, 0x7e, 0x21, 0xae, 0x75, 0x15, 0xff, 0xc2, 0x41, 0xcd, 0x07, 0xcc, 0xc0, 0x82, - 0x80, 0x79, 0xd8, 0x5d, 0x8c, 0x62, 0x85, 0x34, 0x5d, 0x07, 0xe5, 0xcb, 0x72, 0xb1, 0xb7, 0xc6, - 0x5f, 0x19, 0xa4, 0x3b, 0xc4, 0x51, 0x1a, 0xe0, 0x0a, 0x9f, 0xd5, 0x96, 0x21, 0x9e, 0xa3, 0x21, - 0xc6, 0xaa, 0x16, 0xff, 0x8f, 0xc4, 0x58, 0xa5, 0x05, 0x72, 0x8b, 0x21, 0x6f, 0x2f, 0x97, 0x25, - 0x61, 0x75, 0x77, 0x65, 0x38, 0xa1, 0x80, 0x60, 0x7b, 0x75, 0x5b, 0xef, 0x9c, 0x3f, 0x75, 0x45, - 0x89, 0x7a, 0x7f, 0x6d, 0x49, 0x7c, 0x8c, 0x7a, 0xf5, 0x0d, 0xbb, 0x10, 0xed, 0xd6, 0xc9, 0x4c, - 0x93, 0x4f, 0x67, 0x9a, 0xfc, 0x7b, 0xa6, 0xc9, 0x1f, 0xe6, 0x9a, 0x74, 0x3a, 0xd7, 0xa4, 0x1f, - 0x73, 0x4d, 0x7a, 0x7d, 0x6f, 0xe9, 0xa5, 0xd8, 0x61, 0x80, 0x68, 0x6d, 0x6c, 0xd9, 0xc4, 0xe4, - 0xfd, 0x9d, 0x46, 0x1f, 0xfe, 0x5c, 0xec, 0x0c, 0xff, 0x3b, 0x78, 0xf8, 0x2f, 0x00, 0x00, 0xff, - 0xff, 0x33, 0x6e, 0xe5, 0xa1, 0xc8, 0x04, 0x00, 0x00, + // 660 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xb6, 0x53, 0x68, 0xc9, 0xb5, 0x88, 0xd6, 0xb4, 0x90, 0x1a, 0xc5, 0x09, 0x96, 0x80, 0x10, + 0x29, 0x36, 0x09, 0x02, 0xa4, 0x20, 0x24, 0x12, 0x26, 0x86, 0x88, 0x2a, 0xdd, 0x10, 0x52, 0x64, + 0x27, 0xae, 0x63, 0x25, 0xbe, 0xb3, 0x7c, 0xe7, 0x28, 0xdd, 0x10, 0x13, 0x62, 0x62, 0x61, 0xef, + 0x88, 0x98, 0x3a, 0x00, 0xbf, 0x21, 0x63, 0xc5, 0xc4, 0x04, 0x28, 0x19, 0xca, 0xc0, 0x8f, 0x40, + 0x77, 0x3e, 0x3b, 0x09, 0x71, 0x89, 0x84, 0xc4, 0x62, 0xfb, 0xde, 0xf7, 0xbe, 0xef, 0xde, 0xf7, + 0xde, 0x93, 0xc1, 0xe6, 0xd0, 0x41, 0x50, 0x1f, 0x94, 0x75, 0x32, 0xd4, 0x3c, 0x1f, 0x11, 0x24, + 0xad, 0xd1, 0x88, 0x36, 0x28, 0xcb, 0xdb, 0x36, 0xb2, 0x11, 0x8b, 0xe9, 0xf4, 0x2b, 0x84, 0xe5, + 0xab, 0x6d, 0x84, 0x5d, 0x84, 0x75, 0x17, 0xdb, 0x94, 0xe6, 0x62, 0x9b, 0x03, 0x5b, 0x86, 0xeb, + 0x40, 0xa4, 0xb3, 0x27, 0x0f, 0xed, 0x86, 0xb9, 0xad, 0x50, 0x24, 0x3c, 0x70, 0x48, 0xe1, 0x32, + 0xa6, 0x81, 0x2d, 0x7d, 0x50, 0x36, 0x2d, 0x62, 0x94, 0xf5, 0x36, 0x72, 0xe0, 0x02, 0x0e, 0x7b, + 0x31, 0x4e, 0x0f, 0x21, 0xae, 0xbe, 0x4b, 0x81, 0xb5, 0x06, 0xb6, 0xf7, 0x2d, 0xd8, 0x91, 0x1e, + 0x82, 0x8d, 0x03, 0x1f, 0xb9, 0x2d, 0xa3, 0xd3, 0xf1, 0x2d, 0x8c, 0x33, 0x62, 0x5e, 0x2c, 0xa4, + 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x35, 0x21, 0x45, 0xbe, 0xbd, + 0x34, 0x25, 0xbe, 0xe6, 0x05, 0x90, 0x12, 0x26, 0xae, 0x9c, 0x21, 0xc0, 0x71, 0xf9, 0xe6, 0xdf, + 0xf1, 0x48, 0x5d, 0x3e, 0xff, 0x92, 0x0e, 0xa9, 0x5e, 0x1b, 0x8d, 0x15, 0xf1, 0x64, 0xac, 0x88, + 0x3f, 0xc6, 0x8a, 0xf8, 0x76, 0xa2, 0x08, 0x27, 0x13, 0x45, 0xf8, 0x3a, 0x51, 0x84, 0xe7, 0xb7, + 0x66, 0xa6, 0x6d, 0x06, 0x3e, 0x24, 0xa5, 0xbe, 0x61, 0x62, 0x9d, 0xcd, 0x6d, 0x18, 0xbe, 0xd8, + 0xc8, 0xcd, 0x55, 0xf6, 0xf3, 0xbd, 0xfb, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x4a, 0x24, 0x83, + 0x36, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -366,6 +460,9 @@ type MsgClient interface { // SetPlatformPercentage defines the method for updating the platform // percentage fee SetPlatformPercentage(ctx context.Context, in *MsgSetPlatformPercentage, opts ...grpc.CallOption) (*MsgSetPlatformPercentageResponse, error) + // SetPlatformMinimum defines the method for updating the platform + // percentage fee + SetPlatformMinimum(ctx context.Context, in *MsgSetPlatformMinimum, opts ...grpc.CallOption) (*MsgSetPlatformMinimumResponse, error) } type msgClient struct { @@ -403,6 +500,15 @@ func (c *msgClient) SetPlatformPercentage(ctx context.Context, in *MsgSetPlatfor return out, nil } +func (c *msgClient) SetPlatformMinimum(ctx context.Context, in *MsgSetPlatformMinimum, opts ...grpc.CallOption) (*MsgSetPlatformMinimumResponse, error) { + out := new(MsgSetPlatformMinimumResponse) + err := c.cc.Invoke(ctx, "/xion.v1.Msg/SetPlatformMinimum", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // Send defines a method for sending coins from one account to another @@ -414,6 +520,9 @@ type MsgServer interface { // SetPlatformPercentage defines the method for updating the platform // percentage fee SetPlatformPercentage(context.Context, *MsgSetPlatformPercentage) (*MsgSetPlatformPercentageResponse, error) + // SetPlatformMinimum defines the method for updating the platform + // percentage fee + SetPlatformMinimum(context.Context, *MsgSetPlatformMinimum) (*MsgSetPlatformMinimumResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -429,6 +538,9 @@ func (*UnimplementedMsgServer) MultiSend(ctx context.Context, req *MsgMultiSend) func (*UnimplementedMsgServer) SetPlatformPercentage(ctx context.Context, req *MsgSetPlatformPercentage) (*MsgSetPlatformPercentageResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetPlatformPercentage not implemented") } +func (*UnimplementedMsgServer) SetPlatformMinimum(ctx context.Context, req *MsgSetPlatformMinimum) (*MsgSetPlatformMinimumResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetPlatformMinimum not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -488,6 +600,24 @@ func _Msg_SetPlatformPercentage_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _Msg_SetPlatformMinimum_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetPlatformMinimum) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetPlatformMinimum(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/xion.v1.Msg/SetPlatformMinimum", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetPlatformMinimum(ctx, req.(*MsgSetPlatformMinimum)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "xion.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -504,6 +634,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "SetPlatformPercentage", Handler: _Msg_SetPlatformPercentage_Handler, }, + { + MethodName: "SetPlatformMinimum", + Handler: _Msg_SetPlatformMinimum_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "xion/v1/tx.proto", @@ -715,6 +849,73 @@ func (m *MsgSetPlatformPercentageResponse) MarshalToSizedBuffer(dAtA []byte) (in return len(dAtA) - i, nil } +func (m *MsgSetPlatformMinimum) 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 *MsgSetPlatformMinimum) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetPlatformMinimum) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Minimums) > 0 { + for iNdEx := len(m.Minimums) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Minimums[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetPlatformMinimumResponse) 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 *MsgSetPlatformMinimumResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetPlatformMinimumResponse) 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 @@ -813,6 +1014,34 @@ func (m *MsgSetPlatformPercentageResponse) Size() (n int) { return n } +func (m *MsgSetPlatformMinimum) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Minimums) > 0 { + for _, e := range m.Minimums { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgSetPlatformMinimumResponse) 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 } @@ -1336,6 +1565,172 @@ func (m *MsgSetPlatformPercentageResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgSetPlatformMinimum) 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: MsgSetPlatformMinimum: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetPlatformMinimum: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minimums", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Minimums = append(m.Minimums, types.Coin{}) + if err := m.Minimums[len(m.Minimums)-1].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 *MsgSetPlatformMinimumResponse) 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: MsgSetPlatformMinimumResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetPlatformMinimumResponse: 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