diff --git a/app/app.go b/app/app.go index c24a91c97..5ae20e82c 100644 --- a/app/app.go +++ b/app/app.go @@ -100,6 +100,9 @@ import ( "github.com/neutron-org/neutron/x/contractmanager" contractmanagermodulekeeper "github.com/neutron-org/neutron/x/contractmanager/keeper" contractmanagermoduletypes "github.com/neutron-org/neutron/x/contractmanager/types" + "github.com/neutron-org/neutron/x/feeburner" + feeburnerkeeper "github.com/neutron-org/neutron/x/feeburner/keeper" + feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types" "github.com/neutron-org/neutron/x/feerefunder" feekeeper "github.com/neutron-org/neutron/x/feerefunder/keeper" "github.com/neutron-org/neutron/x/interchainqueries" @@ -177,6 +180,7 @@ var ( interchainqueries.AppModuleBasic{}, interchaintxs.AppModuleBasic{}, feerefunder.AppModuleBasic{}, + feeburner.AppModuleBasic{}, contractmanager.AppModuleBasic{}, adminmodulemodule.NewAppModuleBasic( govclient.NewProposalHandler( @@ -202,7 +206,8 @@ var ( wasm.ModuleName: {authtypes.Burner}, interchainqueriesmoduletypes.ModuleName: nil, feetypes.ModuleName: nil, - ccvconsumertypes.ConsumerRedistributeName: nil, + feeburnertypes.ModuleName: nil, + ccvconsumertypes.ConsumerRedistributeName: {authtypes.Burner}, ccvconsumertypes.ConsumerToSendToProviderName: nil, } ) @@ -258,6 +263,7 @@ type App struct { TransferKeeper wrapkeeper.KeeperTransferWrapper FeeGrantKeeper feegrantkeeper.Keeper FeeKeeper *feekeeper.Keeper + FeeBurnerKeeper *feeburnerkeeper.Keeper ConsumerKeeper ccvconsumerkeeper.Keeper // make scoped keepers public for test purposes @@ -310,7 +316,7 @@ func New( evidencetypes.StoreKey, ibctransfertypes.StoreKey, icacontrollertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, interchainqueriesmoduletypes.StoreKey, contractmanagermoduletypes.StoreKey, interchaintxstypes.StoreKey, wasm.StoreKey, feetypes.StoreKey, - adminmodulemoduletypes.StoreKey, ccvconsumertypes.StoreKey, + feeburnertypes.StoreKey, adminmodulemoduletypes.StoreKey, ccvconsumertypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, feetypes.MemStoreKey) @@ -398,6 +404,15 @@ func New( app.FeeKeeper = feekeeper.NewKeeper(appCodec, keys[feetypes.StoreKey], memKeys[feetypes.MemStoreKey], app.GetSubspace(feetypes.ModuleName), app.IBCKeeper.ChannelKeeper, app.BankKeeper) feeModule := feerefunder.NewAppModule(appCodec, *app.FeeKeeper, app.AccountKeeper, app.BankKeeper) + app.FeeBurnerKeeper = feeburnerkeeper.NewKeeper( + appCodec, + keys[feeburnertypes.StoreKey], + keys[feeburnertypes.MemStoreKey], + app.GetSubspace(feeburnertypes.ModuleName), + app.BankKeeper, + ) + feeBurnerModule := feeburner.NewAppModule(appCodec, *app.FeeBurnerKeeper, app.AccountKeeper, app.BankKeeper) + // Create Transfer Keepers app.TransferKeeper = wrapkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), @@ -485,7 +500,7 @@ func New( app.FeeKeeper, ) - wasmOpts = append(wasmbinding.RegisterCustomPlugins(&app.InterchainTxsKeeper, &app.InterchainQueriesKeeper, app.TransferKeeper, &app.AdminmoduleKeeper), wasmOpts...) + wasmOpts = append(wasmbinding.RegisterCustomPlugins(&app.InterchainTxsKeeper, &app.InterchainQueriesKeeper, app.TransferKeeper, &app.AdminmoduleKeeper, app.FeeBurnerKeeper), wasmOpts...) app.WasmKeeper = wasm.NewKeeper( appCodec, @@ -558,6 +573,7 @@ func New( interchainQueriesModule, interchainTxsModule, feeModule, + feeBurnerModule, contractManagerModule, adminModule, ) @@ -587,6 +603,7 @@ func New( contractmanagermoduletypes.ModuleName, wasm.ModuleName, feetypes.ModuleName, + feeburnertypes.ModuleName, adminmodulemoduletypes.ModuleName, ) @@ -611,6 +628,7 @@ func New( contractmanagermoduletypes.ModuleName, wasm.ModuleName, feetypes.ModuleName, + feeburnertypes.ModuleName, adminmodulemoduletypes.ModuleName, ) @@ -640,6 +658,7 @@ func New( contractmanagermoduletypes.ModuleName, wasm.ModuleName, feetypes.ModuleName, + feeburnertypes.ModuleName, adminmodulemoduletypes.ModuleName, ) @@ -880,6 +899,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(interchaintxstypes.ModuleName) paramsKeeper.Subspace(wasm.ModuleName) paramsKeeper.Subspace(feetypes.ModuleName) + paramsKeeper.Subspace(feeburnertypes.ModuleName) return paramsKeeper } diff --git a/app/proposals_whitelist_test.go b/app/proposals_whitelist_test.go index 22e19df7c..f1645f3a9 100644 --- a/app/proposals_whitelist_test.go +++ b/app/proposals_whitelist_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - simapp "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/simapp" ibctesting "github.com/cosmos/ibc-go/v3/testing" icssimapp "github.com/cosmos/interchain-security/testutil/simapp" "github.com/stretchr/testify/require" @@ -15,6 +15,8 @@ import ( ) func TestConsumerWhitelistingKeys(t *testing.T) { + _ = app.GetDefaultConfig() + chain := ibctesting.NewTestChain(t, icssimapp.NewBasicCoordinator(t), SetupTestingAppConsumer, "test") paramKeeper := chain.App.(*app.App).ParamsKeeper for paramKey := range app.WhitelistedParams { diff --git a/contracts/neutron_treasury.wasm b/contracts/neutron_treasury.wasm new file mode 100644 index 000000000..cfa1e4671 Binary files /dev/null and b/contracts/neutron_treasury.wasm differ diff --git a/go.mod b/go.mod index 5ae5b1d3f..12e540d0f 100644 --- a/go.mod +++ b/go.mod @@ -23,8 +23,8 @@ require ( github.com/stretchr/testify v1.8.1 github.com/tendermint/tendermint v0.34.20 github.com/tendermint/tm-db v0.6.7 - google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 - google.golang.org/grpc v1.50.1 + google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 + google.golang.org/grpc v1.51.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -57,11 +57,13 @@ require ( github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/gateway v1.1.0 // indirect + github.com/golang/glog v1.0.0 // indirect github.com/golang/snappy v0.0.3 // indirect github.com/google/btree v1.0.0 // indirect github.com/google/gofuzz v1.2.0 // indirect @@ -70,7 +72,7 @@ require ( github.com/gorilla/websocket v1.5.0 // indirect github.com/gravity-devs/liquidity v1.4.5 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect @@ -120,10 +122,10 @@ require ( github.com/zondax/hid v0.9.0 // indirect go.etcd.io/bbolt v1.3.6 // indirect golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect - golang.org/x/net v0.2.0 // indirect - golang.org/x/sys v0.2.0 // indirect - golang.org/x/term v0.2.0 // indirect - golang.org/x/text v0.4.0 // indirect + golang.org/x/net v0.3.0 // indirect + golang.org/x/sys v0.3.0 // indirect + golang.org/x/term v0.3.0 // indirect + golang.org/x/text v0.5.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/ini.v1 v1.66.6 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index ec16da649..29d9c441f 100644 --- a/go.sum +++ b/go.sum @@ -423,6 +423,7 @@ github.com/fullstorydev/grpcurl v1.6.0/go.mod h1:ZQ+ayqbKMJNhzLmbpCiurTVlaK2M/3n github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E= github.com/fzipp/gocyclo v0.5.1/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -500,6 +501,8 @@ github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2V github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -674,6 +677,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFb github.com/grpc-ecosystem/grpc-gateway/v2 v2.0.1/go.mod h1:oVMjMN64nzEcepv1kdZKgx1qNYt4Ro0Gqefiq2JWdis= github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 h1:t7uX3JBHdVwAi3G7sSSdbsk8NfgA+LnUS88V/2EKaA0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0/go.mod h1:4OGVnY4qf2+gw+ssiHbW+pq4mo2yko94YxxMmXZ7jCA= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -1646,6 +1651,8 @@ golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.3.0 h1:VWL6FNY2bEEmsGVKabSlHu5Irp34xmMRoqb/9lF9lxk= +golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1807,6 +1814,8 @@ golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1814,6 +1823,8 @@ golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI= +golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1825,6 +1836,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2100,6 +2113,8 @@ google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 h1:jCw9YRd2s40X9Vxi4zKsPRvSPlHWNqadVkpbMsCPzPQ= google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= +google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70= +google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= diff --git a/network/init.sh b/network/init.sh index 79382dc62..c3234cdc5 100755 --- a/network/init.sh +++ b/network/init.sh @@ -11,6 +11,7 @@ PRE_PROPOSAL_CONTRACT=./contracts/cwd_pre_propose_single.wasm PROPOSAL_CONTRACT=./contracts/cwd_proposal_single.wasm VOTING_REGISTRY_CONTRACT=./contracts/neutron_voting_registry.wasm VAULT_CONTRACT=./contracts/neutron_vault.wasm +TREASURY_CONTRACT=./contracts/neutron_treasury.wasm VAL_MNEMONIC_1="clock post desk civil pottery foster expand merit dash seminar song memory figure uniform spice circle try happy obvious trash crime hybrid hood cushion" VAL_MNEMONIC_2="angry twist harsh drastic left brass behave host shove marriage fall update business leg direct reward object ugly security warm tuna model broccoli choice" DEMO_MNEMONIC_1="banner spread envelope side kite person disagree path silver will brother under couch edit food venture squirrel civil budget number acquire point work mass" @@ -83,6 +84,7 @@ $NEUTROND_BINARY add-wasm-message store ${DAO_CONTRACT} --output json --run-as $NEUTROND_BINARY add-wasm-message store ${PROPOSAL_CONTRACT} --output json --run-as ${ADMIN_ADDRESS} --home $CHAIN_DIR/$CHAINID_1 $NEUTROND_BINARY add-wasm-message store ${VOTING_REGISTRY_CONTRACT} --output json --run-as ${ADMIN_ADDRESS} --home $CHAIN_DIR/$CHAINID_1 $NEUTROND_BINARY add-wasm-message store ${PRE_PROPOSAL_CONTRACT} --output json --run-as ${ADMIN_ADDRESS} --home $CHAIN_DIR/$CHAINID_1 +$NEUTROND_BINARY add-wasm-message store ${TREASURY_CONTRACT} --output json --run-as ${ADMIN_ADDRESS} --home $CHAIN_DIR/$CHAINID_1 # Instantiate the contract INIT='{ @@ -106,10 +108,20 @@ DAO_INIT='{ "msg": "ewogICAgICAibWFuYWdlciI6IG51bGwsCiAgICAgICJvd25lciI6IG51bGwsCiAgICAgICJ2b3RpbmdfdmF1bHQiOiAibmV1dHJvbjE0aGoydGF2cThmcGVzZHd4eGN1NDRydHkzaGg5MHZodWpydmNtc3RsNHpyM3R4bWZ2dzlzNWMyZXBxIgogICAgfQ==" } }' +# TODO: properly initialize treasury +TREASURY_INIT="$(printf '{ + "owner": "%s", + "denom": "stake", + "distribution_rate": "0.1", + "min_period": 10, + "distribution_contract": "%s", + "reserve_contract": "%s" +}' "$ADMIN_ADDRESS" "$ADMIN_ADDRESS" "$ADMIN_ADDRESS")" echo "Instantiate contracts" -$NEUTROND_BINARY add-wasm-message instantiate-contract 1 "$INIT" --run-as ${ADMIN_ADDRESS} --admin ${ADMIN_ADDRESS} --label "DAO_Neutron_voting_vault" --home $CHAIN_DIR/$CHAINID_1 -$NEUTROND_BINARY add-wasm-message instantiate-contract 2 "$DAO_INIT" --run-as ${ADMIN_ADDRESS} --admin ${ADMIN_ADDRESS} --label "DAO" --home $CHAIN_DIR/$CHAINID_1 +$NEUTROND_BINARY add-wasm-message instantiate-contract 1 "$INIT" --run-as ${ADMIN_ADDRESS} --admin ${ADMIN_ADDRESS} --label "DAO_Neutron_voting_vault" --home $CHAIN_DIR/$CHAINID_1 +$NEUTROND_BINARY add-wasm-message instantiate-contract 2 "$DAO_INIT" --run-as ${ADMIN_ADDRESS} --admin ${ADMIN_ADDRESS} --label "DAO" --home $CHAIN_DIR/$CHAINID_1 +$NEUTROND_BINARY add-wasm-message instantiate-contract 6 "$TREASURY_INIT" --run-as ${ADMIN_ADDRESS} --admin ${ADMIN_ADDRESS} --label "Treasury" --home $CHAIN_DIR/$CHAINID_1 echo "Add consumer section..." @@ -129,7 +141,7 @@ sed -i -e 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAINID_1/config/app.to sed -i -e 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml sed -i -e 's#"tcp://0.0.0.0:1317"#"tcp://0.0.0.0:'"$RESTPORT_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/app.toml sed -i -e 's#":8080"#":'"$ROSETTA_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/app.toml -sed -i -e 's/minimum-gas-prices = ""/minimum-gas-prices = "0.0025stake"/g' $CHAIN_DIR/$CHAINID_1/config/app.toml +sed -i -e 's/minimum-gas-prices = ""/minimum-gas-prices = "0.0025stake,0.0025ibc\/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878"/g' $CHAIN_DIR/$CHAINID_1/config/app.toml sed -i -e 's/enabled = false/enabled = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml sed -i -e 's/prometheus-retention-time = 0/prometheus-retention-time = 1000/g' $CHAIN_DIR/$CHAINID_1/config/app.toml diff --git a/proto/feeburner/genesis.proto b/proto/feeburner/genesis.proto new file mode 100644 index 000000000..4ebb36623 --- /dev/null +++ b/proto/feeburner/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package neutron.feeburner; + +import "gogoproto/gogo.proto"; +import "feeburner/params.proto"; +import "feeburner/total_burned_neutrons_amount.proto"; +// this line is used by starport scaffolding # genesis/proto/import + +option go_package = "github.com/neutron-org/neutron/x/feeburner/types"; + +// GenesisState defines the feeburner module's genesis state. +message GenesisState { + Params params = 1 [ (gogoproto.nullable) = false ]; + TotalBurnedNeutronsAmount total_burned_neutrons_amount = 2 [ (gogoproto.nullable) = false ]; + // this line is used by starport scaffolding # genesis/proto/state +} diff --git a/proto/feeburner/params.proto b/proto/feeburner/params.proto new file mode 100644 index 000000000..3afba60ae --- /dev/null +++ b/proto/feeburner/params.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package neutron.feeburner; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/neutron-org/neutron/x/feeburner/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + // Defines Neutron denom, which will be burned during fee processing, any other denom will be sent to Treasury + string neutron_denom = 1; + // Defines Treasury address + string treasury_address = 2; +} diff --git a/proto/feeburner/query.proto b/proto/feeburner/query.proto new file mode 100644 index 000000000..1d48550d9 --- /dev/null +++ b/proto/feeburner/query.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; +package neutron.feeburner; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "feeburner/params.proto"; +import "feeburner/total_burned_neutrons_amount.proto"; +// this line is used by starport scaffolding # 1 + +option go_package = "github.com/neutron-org/neutron/x/feeburner/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/neutron/feeburner/params"; + } + + // TotalBurnedNeutronsAmount queries total amount of burned neutron fees. + rpc TotalBurnedNeutronsAmount(QueryTotalBurnedNeutronsAmountRequest) returns (QueryTotalBurnedNeutronsAmountResponse) { + option (google.api.http).get = "/neutron/feeburner/total_burned_neutrons_amount"; + } + // this line is used by starport scaffolding # 2 +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryTotalBurnedNeutronsAmountRequest is request type for the +// Query/QueryTotalBurnedNeutronsAmount method. +message QueryTotalBurnedNeutronsAmountRequest {} + +// QueryTotalBurnedNeutronsAmountResponse is response type for the +// Query/QueryTotalBurnedNeutronsAmount method. +message QueryTotalBurnedNeutronsAmountResponse { + TotalBurnedNeutronsAmount total_burned_neutrons_amount = 1 [ (gogoproto.nullable) = false ]; +} + +// this line is used by starport scaffolding # 3 diff --git a/proto/feeburner/total_burned_neutrons_amount.proto b/proto/feeburner/total_burned_neutrons_amount.proto new file mode 100644 index 000000000..17c8ac18b --- /dev/null +++ b/proto/feeburner/total_burned_neutrons_amount.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package neutron.feeburner; + +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/neutron-org/neutron/x/feeburner/types"; + +// TotalBurnedNeutronsAmount defines total amount of burned neutron fees +message TotalBurnedNeutronsAmount { + repeated cosmos.base.v1beta1.Coin coins = 1 [ + (gogoproto.moretags) = "yaml:\"coins\"", + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} diff --git a/tests/e2e/interchain_security_test.go b/tests/e2e/interchain_security_test.go index b383ad878..9a0e5639d 100644 --- a/tests/e2e/interchain_security_test.go +++ b/tests/e2e/interchain_security_test.go @@ -18,8 +18,18 @@ import ( appConsumer "github.com/neutron-org/neutron/app" ) +type OverloadedSuite struct { + *e2e.CCVTestSuite +} + +func (_ *OverloadedSuite) TestRewardsDistribution() { + // this empty function disables TestCCVTestSuite/TestRewardsDistribution test +} + // Executes the standard group of ccv tests against a consumer and provider app.go implementation. func TestCCVTestSuite(t *testing.T) { + _ = app.GetDefaultConfig() + ccvSuite := e2e.NewCCVTestSuite( func(t *testing.T) ( *ibctesting.Coordinator, @@ -34,7 +44,7 @@ func TestCCVTestSuite(t *testing.T) { return coord, prov, cons, prov.App.(*appProvider.App), cons.App.(*appConsumer.App) }, ) - suite.Run(t, ccvSuite) + suite.Run(t, &OverloadedSuite{ccvSuite}) } // NewCoordinator initializes Coordinator with interchain security dummy provider and neutron consumer chain diff --git a/testutil/feeburner/keeper/feeburner.go b/testutil/feeburner/keeper/feeburner.go new file mode 100644 index 000000000..be7fc4827 --- /dev/null +++ b/testutil/feeburner/keeper/feeburner.go @@ -0,0 +1,53 @@ +package keeper + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/neutron-org/neutron/x/feeburner/keeper" + "github.com/neutron-org/neutron/x/feeburner/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmdb "github.com/tendermint/tm-db" +) + +func FeeburnerKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramsSubspace := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "FeeburnerParams", + ) + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + nil, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/testutil/feeburner/nullify/nullify.go b/testutil/feeburner/nullify/nullify.go new file mode 100644 index 000000000..3b968c09c --- /dev/null +++ b/testutil/feeburner/nullify/nullify.go @@ -0,0 +1,57 @@ +// Package nullify provides methods to init nil values structs for test assertion. +package nullify + +import ( + "reflect" + "unsafe" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + coinType = reflect.TypeOf(sdk.Coin{}) + coinsType = reflect.TypeOf(sdk.Coins{}) +) + +// Fill analyze all struct fields and slices with +// reflection and initialize the nil and empty slices, +// structs, and pointers. +func Fill(x interface{}) interface{} { + v := reflect.Indirect(reflect.ValueOf(x)) + switch v.Kind() { + case reflect.Slice: + for i := 0; i < v.Len(); i++ { + obj := v.Index(i) + objPt := reflect.NewAt(obj.Type(), unsafe.Pointer(obj.UnsafeAddr())).Interface() + objPt = Fill(objPt) + obj.Set(reflect.ValueOf(objPt)) + } + case reflect.Struct: + for i := 0; i < v.NumField(); i++ { + f := reflect.Indirect(v.Field(i)) + if !f.CanSet() { + continue + } + switch f.Kind() { + case reflect.Slice: + f.Set(reflect.MakeSlice(f.Type(), 0, 0)) + case reflect.Struct: + switch f.Type() { + case coinType: + coin := reflect.New(coinType).Interface() + s := reflect.ValueOf(coin).Elem() + f.Set(s) + case coinsType: + coins := reflect.New(coinsType).Interface() + s := reflect.ValueOf(coins).Elem() + f.Set(s) + default: + objPt := reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Interface() + s := Fill(objPt) + f.Set(reflect.ValueOf(s)) + } + } + } + } + return reflect.Indirect(v).Interface() +} diff --git a/testutil/feeburner/sample/sample.go b/testutil/feeburner/sample/sample.go new file mode 100644 index 000000000..98f2153ed --- /dev/null +++ b/testutil/feeburner/sample/sample.go @@ -0,0 +1,13 @@ +package sample + +import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// AccAddress returns a sample account address +func AccAddress() string { + pk := ed25519.GenPrivKey().PubKey() + addr := pk.Address() + return sdk.AccAddress(addr).String() +} diff --git a/wasmbinding/bindings/query.go b/wasmbinding/bindings/query.go index acbb134b5..a2a9d6d1d 100644 --- a/wasmbinding/bindings/query.go +++ b/wasmbinding/bindings/query.go @@ -11,14 +11,16 @@ import ( // NeutronQuery contains neutron custom queries. type NeutronQuery struct { - /// Registered Interchain Query Result for specified QueryID + // Registered Interchain Query Result for specified QueryID InterchainQueryResult *QueryRegisteredQueryResultRequest `json:"interchain_query_result,omitempty"` - /// Interchain account address for specified ConnectionID and OwnerAddress + // Interchain account address for specified ConnectionID and OwnerAddress InterchainAccountAddress *QueryInterchainAccountAddressRequest `json:"interchain_account_address,omitempty"` - /// RegisteredInterchainQueries + // RegisteredInterchainQueries RegisteredInterchainQueries *QueryRegisteredQueriesRequest `json:"registered_interchain_queries,omitempty"` - /// RegisteredInterchainQuery + // RegisteredInterchainQuery RegisteredInterchainQuery *QueryRegisteredQueryRequest `json:"registered_interchain_query,omitempty"` + // TotalBurnedNeutronsAmount + TotalBurnedNeutronsAmount *QueryTotalBurnedNeutronsAmountRequest `json:"total_burned_neutrons_amount,omitempty"` } /* Requests */ @@ -81,6 +83,12 @@ type RegisteredQuery struct { SubmitTimeout uint64 `json:"submit_timeout"` } +type QueryTotalBurnedNeutronsAmountRequest struct{} + +type QueryTotalBurnedNeutronsAmountResponse struct { + Coins sdktypes.Coins `json:"coins"` +} + func (rq RegisteredQuery) MarshalJSON() ([]byte, error) { type AliasRQ RegisteredQuery diff --git a/wasmbinding/custom_querier.go b/wasmbinding/custom_querier.go index b32915872..fa4af5c7e 100644 --- a/wasmbinding/custom_querier.go +++ b/wasmbinding/custom_querier.go @@ -69,6 +69,18 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag return nil, sdkerrors.Wrapf(err, "failed to marshal interchain account query response: %v", err) } + return bz, nil + case contractQuery.TotalBurnedNeutronsAmount != nil: + totalBurnedNeutrons, err := qp.GetTotalBurnedNeutronsAmount(ctx, contractQuery.TotalBurnedNeutronsAmount) + if err != nil { + return nil, sdkerrors.Wrapf(err, "failed to get total burned neutrons amount: %v", err) + } + + bz, err := json.Marshal(totalBurnedNeutrons) + if err != nil { + return nil, sdkerrors.Wrapf(err, "failed to marshal total burned neutrons amount response: %v", err) + } + return bz, nil default: return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown neutron query type"} diff --git a/wasmbinding/queries.go b/wasmbinding/queries.go index 2f72ebf2d..64dbbe4b2 100644 --- a/wasmbinding/queries.go +++ b/wasmbinding/queries.go @@ -84,6 +84,11 @@ func (qp *QueryPlugin) GetRegisteredInterchainQuery(ctx sdk.Context, req *bindin return &bindings.QueryRegisteredQueryResponse{RegisteredQuery: &query}, nil } +func (qp *QueryPlugin) GetTotalBurnedNeutronsAmount(ctx sdk.Context, _ *bindings.QueryTotalBurnedNeutronsAmountRequest) (*bindings.QueryTotalBurnedNeutronsAmountResponse, error) { + grpcResp := qp.feeBurnerKeeper.GetTotalBurnedNeutronsAmount(ctx) + return &bindings.QueryTotalBurnedNeutronsAmountResponse{Coins: grpcResp.Coins}, nil +} + func mapGRPCRegisteredQueryToWasmBindings(grpcQuery types.RegisteredQuery) bindings.RegisteredQuery { return bindings.RegisteredQuery{ ID: grpcQuery.GetId(), diff --git a/wasmbinding/query_plugin.go b/wasmbinding/query_plugin.go index 2b5f105e6..1ec924c81 100644 --- a/wasmbinding/query_plugin.go +++ b/wasmbinding/query_plugin.go @@ -1,6 +1,7 @@ package wasmbinding import ( + feeburnerkeeper "github.com/neutron-org/neutron/x/feeburner/keeper" icqkeeper "github.com/neutron-org/neutron/x/interchainqueries/keeper" icacontrollerkeeper "github.com/neutron-org/neutron/x/interchaintxs/keeper" ) @@ -8,9 +9,10 @@ import ( type QueryPlugin struct { icaControllerKeeper *icacontrollerkeeper.Keeper icqKeeper *icqkeeper.Keeper + feeBurnerKeeper *feeburnerkeeper.Keeper } // NewQueryPlugin returns a reference to a new QueryPlugin. -func NewQueryPlugin(icaControllerKeeper *icacontrollerkeeper.Keeper, icqKeeper *icqkeeper.Keeper) *QueryPlugin { - return &QueryPlugin{icaControllerKeeper: icaControllerKeeper, icqKeeper: icqKeeper} +func NewQueryPlugin(icaControllerKeeper *icacontrollerkeeper.Keeper, icqKeeper *icqkeeper.Keeper, feeBurnerKeeper *feeburnerkeeper.Keeper) *QueryPlugin { + return &QueryPlugin{icaControllerKeeper: icaControllerKeeper, icqKeeper: icqKeeper, feeBurnerKeeper: feeBurnerKeeper} } diff --git a/wasmbinding/wasm.go b/wasmbinding/wasm.go index 00a77d79c..75c146c28 100644 --- a/wasmbinding/wasm.go +++ b/wasmbinding/wasm.go @@ -3,6 +3,7 @@ package wasmbinding import ( "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + feeburnerkeeper "github.com/neutron-org/neutron/x/feeburner/keeper" adminmodulemodulekeeper "github.com/cosmos/admin-module/x/adminmodule/keeper" @@ -12,8 +13,14 @@ import ( ) // RegisterCustomPlugins returns wasmkeeper.Option that we can use to connect handlers for implemented custom queries and messages to the App -func RegisterCustomPlugins(ictxKeeper *interchaintransactionsmodulekeeper.Keeper, icqKeeper *interchainqueriesmodulekeeper.Keeper, transfer transfer.KeeperTransferWrapper, admKeeper *adminmodulemodulekeeper.Keeper) []wasmkeeper.Option { - wasmQueryPlugin := NewQueryPlugin(ictxKeeper, icqKeeper) +func RegisterCustomPlugins( + ictxKeeper *interchaintransactionsmodulekeeper.Keeper, + icqKeeper *interchainqueriesmodulekeeper.Keeper, + transfer transfer.KeeperTransferWrapper, + admKeeper *adminmodulemodulekeeper.Keeper, + feeBurnerKeeper *feeburnerkeeper.Keeper, +) []wasmkeeper.Option { + wasmQueryPlugin := NewQueryPlugin(ictxKeeper, icqKeeper, feeBurnerKeeper) queryPluginOpt := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{ Custom: CustomQuerier(wasmQueryPlugin), diff --git a/x/contractmanager/client/cli/query_failure_test.go b/x/contractmanager/client/cli/query_failure_test.go index 216bee767..1cbed3b64 100644 --- a/x/contractmanager/client/cli/query_failure_test.go +++ b/x/contractmanager/client/cli/query_failure_test.go @@ -6,6 +6,8 @@ import ( "strconv" "testing" + "github.com/neutron-org/neutron/app" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" @@ -47,6 +49,8 @@ func networkWithFailureObjects(t *testing.T, n int) (*network.Network, []types.F } func TestAddressFailures(t *testing.T) { + _ = app.GetDefaultConfig() + net, objs := networkWithFailureObjects(t, 2) ctx := net.Validators[0].ClientCtx diff --git a/x/feeburner/client/cli/query.go b/x/feeburner/client/cli/query.go new file mode 100644 index 000000000..5a41cdadd --- /dev/null +++ b/x/feeburner/client/cli/query.go @@ -0,0 +1,32 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/neutron-org/neutron/x/feeburner/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group feeburner queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdQueryTotalBurnedNeutronsAmount()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/feeburner/client/cli/query_params.go b/x/feeburner/client/cli/query_params.go new file mode 100644 index 000000000..297e59bbb --- /dev/null +++ b/x/feeburner/client/cli/query_params.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/neutron-org/neutron/x/feeburner/types" + "github.com/spf13/cobra" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/feeburner/client/cli/query_total_burned_neutrons_amount.go b/x/feeburner/client/cli/query_total_burned_neutrons_amount.go new file mode 100644 index 000000000..cd602ffc2 --- /dev/null +++ b/x/feeburner/client/cli/query_total_burned_neutrons_amount.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/neutron-org/neutron/x/feeburner/types" + "github.com/spf13/cobra" +) + +func CmdQueryTotalBurnedNeutronsAmount() *cobra.Command { + cmd := &cobra.Command{ + Use: "total-burned-neutrons-amount", + Short: "shows total amount of burned neutrons", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.TotalBurnedNeutronsAmount(context.Background(), &types.QueryTotalBurnedNeutronsAmountRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/feeburner/genesis.go b/x/feeburner/genesis.go new file mode 100644 index 000000000..20662d5a8 --- /dev/null +++ b/x/feeburner/genesis.go @@ -0,0 +1,23 @@ +package feeburner + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/neutron-org/neutron/x/feeburner/keeper" + "github.com/neutron-org/neutron/x/feeburner/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/feeburner/genesis_test.go b/x/feeburner/genesis_test.go new file mode 100644 index 000000000..e97b16db9 --- /dev/null +++ b/x/feeburner/genesis_test.go @@ -0,0 +1,33 @@ +package feeburner_test + +import ( + "testing" + + "github.com/neutron-org/neutron/app" + + "github.com/neutron-org/neutron/testutil/feeburner/keeper" + "github.com/neutron-org/neutron/testutil/feeburner/nullify" + "github.com/neutron-org/neutron/x/feeburner" + "github.com/neutron-org/neutron/x/feeburner/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + _ = app.GetDefaultConfig() + + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keeper.FeeburnerKeeper(t) + feeburner.InitGenesis(ctx, *k, genesisState) + got := feeburner.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/feeburner/keeper/grpc_query.go b/x/feeburner/keeper/grpc_query.go new file mode 100644 index 000000000..c32e4e0d5 --- /dev/null +++ b/x/feeburner/keeper/grpc_query.go @@ -0,0 +1,18 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/neutron-org/neutron/x/feeburner/types" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) TotalBurnedNeutronsAmount(goCtx context.Context, request *types.QueryTotalBurnedNeutronsAmountRequest) (*types.QueryTotalBurnedNeutronsAmountResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + totalBurnedNeutronsAmount := k.GetTotalBurnedNeutronsAmount(ctx) + + return &types.QueryTotalBurnedNeutronsAmountResponse{TotalBurnedNeutronsAmount: totalBurnedNeutronsAmount}, nil +} diff --git a/x/feeburner/keeper/grpc_query_params.go b/x/feeburner/keeper/grpc_query_params.go new file mode 100644 index 000000000..4989281c2 --- /dev/null +++ b/x/feeburner/keeper/grpc_query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/neutron-org/neutron/x/feeburner/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/feeburner/keeper/grpc_query_params_test.go b/x/feeburner/keeper/grpc_query_params_test.go new file mode 100644 index 000000000..80d4e7e1a --- /dev/null +++ b/x/feeburner/keeper/grpc_query_params_test.go @@ -0,0 +1,25 @@ +package keeper_test + +import ( + "testing" + + "github.com/neutron-org/neutron/app" + + sdk "github.com/cosmos/cosmos-sdk/types" + testkeeper "github.com/neutron-org/neutron/testutil/feeburner/keeper" + "github.com/neutron-org/neutron/x/feeburner/types" + "github.com/stretchr/testify/require" +) + +func TestParamsQuery(t *testing.T) { + _ = app.GetDefaultConfig() + + keeper, ctx := testkeeper.FeeburnerKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/feeburner/keeper/keeper.go b/x/feeburner/keeper/keeper.go new file mode 100644 index 000000000..e15bc2058 --- /dev/null +++ b/x/feeburner/keeper/keeper.go @@ -0,0 +1,71 @@ +package keeper + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/neutron-org/neutron/x/feeburner/types" + "github.com/tendermint/tendermint/libs/log" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + + bankKeeper types.BankKeeper + } +) + +var KeyBurnedFees = []byte("BurnedFees") + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + + bankKeeper types.BankKeeper, +) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + bankKeeper: bankKeeper, + } +} + +func (k Keeper) RecordBurnedFees(ctx sdk.Context, amount sdk.Coin) { + store := ctx.KVStore(k.storeKey) + + totalBurnedNeutronsAmount := k.GetTotalBurnedNeutronsAmount(ctx) + totalBurnedNeutronsAmount.Coins = totalBurnedNeutronsAmount.Coins.Add(amount) + store.Set(KeyBurnedFees, k.cdc.MustMarshal(&totalBurnedNeutronsAmount)) +} + +func (k Keeper) GetTotalBurnedNeutronsAmount(ctx sdk.Context) types.TotalBurnedNeutronsAmount { + store := ctx.KVStore(k.storeKey) + + var totalBurnedNeutronsAmount types.TotalBurnedNeutronsAmount + bzTotalBurnedNeutronsAmount := store.Get(KeyBurnedFees) + if bzTotalBurnedNeutronsAmount != nil { + k.cdc.MustUnmarshal(bzTotalBurnedNeutronsAmount, &totalBurnedNeutronsAmount) + } + + return totalBurnedNeutronsAmount +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/feeburner/keeper/params.go b/x/feeburner/keeper/params.go new file mode 100644 index 000000000..886dd528f --- /dev/null +++ b/x/feeburner/keeper/params.go @@ -0,0 +1,18 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/neutron-org/neutron/x/feeburner/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramstore.GetParamSet(ctx, ¶ms) + + return params +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} diff --git a/x/feeburner/keeper/params_test.go b/x/feeburner/keeper/params_test.go new file mode 100644 index 000000000..7ef93e9e9 --- /dev/null +++ b/x/feeburner/keeper/params_test.go @@ -0,0 +1,22 @@ +package keeper_test + +import ( + "testing" + + "github.com/neutron-org/neutron/app" + + testkeeper "github.com/neutron-org/neutron/testutil/feeburner/keeper" + "github.com/neutron-org/neutron/x/feeburner/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + _ = app.GetDefaultConfig() + + k, ctx := testkeeper.FeeburnerKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/feeburner/module.go b/x/feeburner/module.go new file mode 100644 index 000000000..810c5c33f --- /dev/null +++ b/x/feeburner/module.go @@ -0,0 +1,205 @@ +package feeburner + +import ( + "context" + "encoding/json" + "fmt" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" + "github.com/gorilla/mux" + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/neutron-org/neutron/x/feeburner/client/cli" + "github.com/neutron-org/neutron/x/feeburner/keeper" + "github.com/neutron-org/neutron/x/feeburner/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func (a AppModuleBasic) RegisterRESTRoutes(c client.Context, router *mux.Router) { +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// Deprecated: use RegisterServices +func (am AppModule) Route() sdk.Route { return sdk.Route{} } + +// Deprecated: use RegisterServices +func (AppModule) QuerierRoute() string { return types.RouterKey } + +// Deprecated: use RegisterServices +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + moduleAddr := am.accountKeeper.GetModuleAddress(consumertypes.ConsumerRedistributeName) + if moduleAddr == nil { + panic("ConsumerRedistributeName must have module address") + } + + params := am.keeper.GetParams(ctx) + balances := am.bankKeeper.GetAllBalances(ctx, moduleAddr) + fundsForTreasury := make(sdk.Coins, 0, len(balances)) + + for _, balance := range balances { + if !balance.IsZero() { + if balance.Denom == params.NeutronDenom { + err := am.bankKeeper.BurnCoins(ctx, consumertypes.ConsumerRedistributeName, sdk.Coins{balance}) + if err != nil { + panic(sdkerrors.Wrapf(err, "failed to burn NTRN tokens during fee processing")) + } + + am.keeper.RecordBurnedFees(ctx, balance) + } else { + fundsForTreasury = append(fundsForTreasury, balance) + } + } + } + + if len(fundsForTreasury) > 0 { + err := am.bankKeeper.SendCoins( + ctx, + moduleAddr, sdk.MustAccAddressFromBech32(params.TreasuryAddress), + fundsForTreasury, + ) + if err != nil { + ctx.Logger().Error( + "feeburner: EndBlock: failed to send tokens to Treasury", + "tokens", fundsForTreasury, + "error", err, + ) + } + } + + return []abci.ValidatorUpdate{} +} diff --git a/x/feeburner/module_simulation.go b/x/feeburner/module_simulation.go new file mode 100644 index 000000000..87c9dc63e --- /dev/null +++ b/x/feeburner/module_simulation.go @@ -0,0 +1,63 @@ +package feeburner + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/neutron-org/neutron/testutil/feeburner/sample" + feeburnersimulation "github.com/neutron-org/neutron/x/feeburner/simulation" + "github.com/neutron-org/neutron/x/feeburner/types" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = feeburnersimulation.FindAccount + _ = simappparams.StakePerAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace +) + +const ( +// this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + feeburnerGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&feeburnerGenesis) +} + +// ProposalContents doesn't return any content functions for governance proposals +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized param changes for the simulator +func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { + return []simtypes.ParamChange{} +} + +// RegisterStoreDecoder registers a decoder +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} diff --git a/x/feeburner/simulation/helpers.go b/x/feeburner/simulation/helpers.go new file mode 100644 index 000000000..92c437c0d --- /dev/null +++ b/x/feeburner/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/feeburner/types/codec.go b/x/feeburner/types/codec.go new file mode 100644 index 000000000..0baf57d01 --- /dev/null +++ b/x/feeburner/types/codec.go @@ -0,0 +1,20 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + // this line is used by starport scaffolding # 1 +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/feeburner/types/errors.go b/x/feeburner/types/errors.go new file mode 100644 index 000000000..526904dc5 --- /dev/null +++ b/x/feeburner/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/feeburner module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") +) diff --git a/x/feeburner/types/expected_keepers.go b/x/feeburner/types/expected_keepers.go new file mode 100644 index 000000000..8720228f1 --- /dev/null +++ b/x/feeburner/types/expected_keepers.go @@ -0,0 +1,19 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetModuleAddress(moduleName string) sdk.AccAddress + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + // Methods imported from bank should be defined here +} diff --git a/x/feeburner/types/genesis.go b/x/feeburner/types/genesis.go new file mode 100644 index 000000000..0af9b4416 --- /dev/null +++ b/x/feeburner/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/feeburner/types/genesis.pb.go b/x/feeburner/types/genesis.pb.go new file mode 100644 index 000000000..d01d89c0e --- /dev/null +++ b/x/feeburner/types/genesis.pb.go @@ -0,0 +1,377 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: feeburner/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the feeburner module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + TotalBurnedNeutronsAmount TotalBurnedNeutronsAmount `protobuf:"bytes,2,opt,name=total_burned_neutrons_amount,json=totalBurnedNeutronsAmount,proto3" json:"total_burned_neutrons_amount"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_6bcf9b99915c37ac, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetTotalBurnedNeutronsAmount() TotalBurnedNeutronsAmount { + if m != nil { + return m.TotalBurnedNeutronsAmount + } + return TotalBurnedNeutronsAmount{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "neutron.feeburner.GenesisState") +} + +func init() { proto.RegisterFile("feeburner/genesis.proto", fileDescriptor_6bcf9b99915c37ac) } + +var fileDescriptor_6bcf9b99915c37ac = []byte{ + // 249 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0x4b, 0x4d, 0x4d, + 0x2a, 0x2d, 0xca, 0x4b, 0x2d, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xcc, 0x4b, 0x2d, 0x2d, 0x29, 0xca, 0xcf, 0xd3, 0x83, 0x2b, 0x90, + 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xea, 0x83, 0x58, 0x10, 0x85, 0x52, 0x62, 0x08, 0x13, + 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0x06, 0x48, 0xe9, 0x20, 0xc4, 0x4b, 0xf2, 0x4b, 0x12, 0x73, + 0xe2, 0xc1, 0x9c, 0x94, 0x78, 0xa8, 0xb9, 0xc5, 0xf1, 0x89, 0xb9, 0xf9, 0xa5, 0x79, 0x25, 0x10, + 0xd5, 0x4a, 0x7b, 0x18, 0xb9, 0x78, 0xdc, 0x21, 0x0e, 0x08, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0x32, + 0xe7, 0x62, 0x83, 0x18, 0x27, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa9, 0x87, 0xe1, 0x20, + 0xbd, 0x00, 0xb0, 0x02, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0xca, 0x85, 0x8a, 0xb9, + 0x64, 0xf0, 0xd9, 0x27, 0xc1, 0x04, 0x36, 0x4e, 0x07, 0x8b, 0x71, 0x21, 0x20, 0x6d, 0x4e, 0x60, + 0x5d, 0x7e, 0x50, 0x4d, 0x8e, 0x60, 0x3d, 0x50, 0x1b, 0x24, 0x4b, 0x70, 0x2a, 0xf0, 0x3a, 0xf1, + 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, + 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x83, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, + 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0x95, 0xba, 0xf9, 0x45, 0xe9, 0x30, 0xb6, 0x7e, 0x85, 0x3e, + 0x52, 0x38, 0x55, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x43, 0xc4, 0x18, 0x10, 0x00, 0x00, 0xff, + 0xff, 0x5c, 0xd8, 0x06, 0x42, 0x9b, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.TotalBurnedNeutronsAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.TotalBurnedNeutronsAmount.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBurnedNeutronsAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalBurnedNeutronsAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feeburner/types/genesis_test.go b/x/feeburner/types/genesis_test.go new file mode 100644 index 000000000..86d267d06 --- /dev/null +++ b/x/feeburner/types/genesis_test.go @@ -0,0 +1,62 @@ +package types_test + +import ( + "testing" + + "github.com/neutron-org/neutron/app" + + "github.com/stretchr/testify/require" + + keepertest "github.com/neutron-org/neutron/testutil/feeburner/keeper" + "github.com/neutron-org/neutron/testutil/feeburner/nullify" + "github.com/neutron-org/neutron/x/feeburner" + "github.com/neutron-org/neutron/x/feeburner/types" +) + +func TestGenesis(t *testing.T) { + _ = app.GetDefaultConfig() + + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + } + + k, ctx := keepertest.FeeburnerKeeper(t) + feeburner.InitGenesis(ctx, *k, genesisState) + got := feeburner.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) +} + +func TestGenesisState_Validate(t *testing.T) { + for _, tc := range []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "empty neutron denom", + genState: &types.GenesisState{ + Params: types.Params{ + NeutronDenom: "", + }, + }, + valid: false, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/feeburner/types/keys.go b/x/feeburner/types/keys.go new file mode 100644 index 000000000..26284b44c --- /dev/null +++ b/x/feeburner/types/keys.go @@ -0,0 +1,19 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "feeburner" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_feeburner" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/feeburner/types/params.go b/x/feeburner/types/params.go new file mode 100644 index 000000000..9dcf2e6f8 --- /dev/null +++ b/x/feeburner/types/params.go @@ -0,0 +1,111 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +var ( + KeyNeutronDenom = []byte("NeutronDenom") + DefaultNeutronDenom = "stake" + KeyTreasuryAddress = []byte("TreasuryAddress") + DefaultTreasuryAddress = "neutron1pvrwmjuusn9wh34j7y520g8gumuy9xtl3gvprlljfdpwju3x7ucsj3fj40" +) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable( + paramtypes.NewParamSetPair( + KeyNeutronDenom, + DefaultNeutronDenom, + validateNeutronDenom, + ), + paramtypes.NewParamSetPair( + KeyTreasuryAddress, + DefaultTreasuryAddress, + validateTreasuryAddress, + ), + ) +} + +// NewParams creates a new Params instance +func NewParams(neutronDenom, treasuryAddress string) Params { + return Params{ + NeutronDenom: neutronDenom, + TreasuryAddress: treasuryAddress, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams(DefaultNeutronDenom, DefaultTreasuryAddress) +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair( + KeyNeutronDenom, + &p.NeutronDenom, + validateNeutronDenom, + ), + paramtypes.NewParamSetPair( + KeyTreasuryAddress, + &p.TreasuryAddress, + validateTreasuryAddress, + ), + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + err := validateNeutronDenom(p.NeutronDenom) + if err != nil { + return err + } + + err = validateTreasuryAddress(p.TreasuryAddress) + if err != nil { + return err + } + + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +func validateNeutronDenom(i interface{}) error { + v, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == "" { + return fmt.Errorf("NeutronDenom must not be empty") + } + + return nil +} + +func validateTreasuryAddress(i interface{}) error { + v, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + _, err := sdk.AccAddressFromBech32(v) + if err != nil { + return fmt.Errorf("invalid treasury address: %w", err) + } + + return nil +} diff --git a/x/feeburner/types/params.pb.go b/x/feeburner/types/params.pb.go new file mode 100644 index 000000000..c6767c740 --- /dev/null +++ b/x/feeburner/types/params.pb.go @@ -0,0 +1,371 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: feeburner/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + // Defines Neutron denom + NeutronDenom string `protobuf:"bytes,1,opt,name=neutron_denom,json=neutronDenom,proto3" json:"neutron_denom,omitempty"` + // Defines Treasury address + TreasuryAddress string `protobuf:"bytes,2,opt,name=treasury_address,json=treasuryAddress,proto3" json:"treasury_address,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_ccaaf97f3dcc64c0, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetNeutronDenom() string { + if m != nil { + return m.NeutronDenom + } + return "" +} + +func (m *Params) GetTreasuryAddress() string { + if m != nil { + return m.TreasuryAddress + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "neutron.feeburner.Params") +} + +func init() { proto.RegisterFile("feeburner/params.proto", fileDescriptor_ccaaf97f3dcc64c0) } + +var fileDescriptor_ccaaf97f3dcc64c0 = []byte{ + // 204 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4b, 0x4b, 0x4d, 0x4d, + 0x2a, 0x2d, 0xca, 0x4b, 0x2d, 0xd2, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0x12, 0xcc, 0x4b, 0x2d, 0x2d, 0x29, 0xca, 0xcf, 0xd3, 0x83, 0xcb, 0x4b, 0x89, + 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x65, 0xf5, 0x41, 0x2c, 0x88, 0x42, 0xa5, 0x38, 0x2e, 0xb6, 0x00, + 0xb0, 0x46, 0x21, 0x65, 0x2e, 0x5e, 0xa8, 0xa6, 0xf8, 0x94, 0xd4, 0xbc, 0xfc, 0x5c, 0x09, 0x46, + 0x05, 0x46, 0x0d, 0xce, 0x20, 0x1e, 0xa8, 0xa0, 0x0b, 0x48, 0x4c, 0x48, 0x93, 0x4b, 0xa0, 0xa4, + 0x28, 0x35, 0xb1, 0xb8, 0xb4, 0xa8, 0x32, 0x3e, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x58, 0x82, + 0x09, 0xac, 0x8e, 0x1f, 0x26, 0xee, 0x08, 0x11, 0xb6, 0x62, 0x99, 0xb1, 0x40, 0x9e, 0xc1, 0xc9, + 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, + 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, 0x33, 0x4b, 0x32, + 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xa1, 0x76, 0xe8, 0xe6, 0x17, 0xa5, 0xc3, 0xd8, 0xfa, + 0x15, 0xfa, 0x08, 0xbf, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x9d, 0x6c, 0x0c, 0x08, + 0x00, 0x00, 0xff, 0xff, 0x31, 0x53, 0x8f, 0xcb, 0xf5, 0x00, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TreasuryAddress) > 0 { + i -= len(m.TreasuryAddress) + copy(dAtA[i:], m.TreasuryAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.TreasuryAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.NeutronDenom) > 0 { + i -= len(m.NeutronDenom) + copy(dAtA[i:], m.NeutronDenom) + i = encodeVarintParams(dAtA, i, uint64(len(m.NeutronDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.NeutronDenom) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.TreasuryAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NeutronDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NeutronDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TreasuryAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TreasuryAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feeburner/types/query.pb.go b/x/feeburner/types/query.pb.go new file mode 100644 index 000000000..c52404616 --- /dev/null +++ b/x/feeburner/types/query.pb.go @@ -0,0 +1,879 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: feeburner/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c8567953574c9090, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c8567953574c9090, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryTotalBurnedNeutronsAmountRequest is request type for the +// Query/QueryTotalBurnedNeutronsAmount method. +type QueryTotalBurnedNeutronsAmountRequest struct { +} + +func (m *QueryTotalBurnedNeutronsAmountRequest) Reset() { *m = QueryTotalBurnedNeutronsAmountRequest{} } +func (m *QueryTotalBurnedNeutronsAmountRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTotalBurnedNeutronsAmountRequest) ProtoMessage() {} +func (*QueryTotalBurnedNeutronsAmountRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c8567953574c9090, []int{2} +} +func (m *QueryTotalBurnedNeutronsAmountRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalBurnedNeutronsAmountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalBurnedNeutronsAmountRequest.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 *QueryTotalBurnedNeutronsAmountRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalBurnedNeutronsAmountRequest.Merge(m, src) +} +func (m *QueryTotalBurnedNeutronsAmountRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalBurnedNeutronsAmountRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalBurnedNeutronsAmountRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalBurnedNeutronsAmountRequest proto.InternalMessageInfo + +// QueryTotalBurnedNeutronsAmountResponse is response type for the +// Query/QueryTotalBurnedNeutronsAmount method. +type QueryTotalBurnedNeutronsAmountResponse struct { + TotalBurnedNeutronsAmount TotalBurnedNeutronsAmount `protobuf:"bytes,1,opt,name=total_burned_neutrons_amount,json=totalBurnedNeutronsAmount,proto3" json:"total_burned_neutrons_amount"` +} + +func (m *QueryTotalBurnedNeutronsAmountResponse) Reset() { + *m = QueryTotalBurnedNeutronsAmountResponse{} +} +func (m *QueryTotalBurnedNeutronsAmountResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTotalBurnedNeutronsAmountResponse) ProtoMessage() {} +func (*QueryTotalBurnedNeutronsAmountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c8567953574c9090, []int{3} +} +func (m *QueryTotalBurnedNeutronsAmountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalBurnedNeutronsAmountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalBurnedNeutronsAmountResponse.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 *QueryTotalBurnedNeutronsAmountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalBurnedNeutronsAmountResponse.Merge(m, src) +} +func (m *QueryTotalBurnedNeutronsAmountResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalBurnedNeutronsAmountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalBurnedNeutronsAmountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalBurnedNeutronsAmountResponse proto.InternalMessageInfo + +func (m *QueryTotalBurnedNeutronsAmountResponse) GetTotalBurnedNeutronsAmount() TotalBurnedNeutronsAmount { + if m != nil { + return m.TotalBurnedNeutronsAmount + } + return TotalBurnedNeutronsAmount{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "neutron.feeburner.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "neutron.feeburner.QueryParamsResponse") + proto.RegisterType((*QueryTotalBurnedNeutronsAmountRequest)(nil), "neutron.feeburner.QueryTotalBurnedNeutronsAmountRequest") + proto.RegisterType((*QueryTotalBurnedNeutronsAmountResponse)(nil), "neutron.feeburner.QueryTotalBurnedNeutronsAmountResponse") +} + +func init() { proto.RegisterFile("feeburner/query.proto", fileDescriptor_c8567953574c9090) } + +var fileDescriptor_c8567953574c9090 = []byte{ + // 407 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x41, 0x6f, 0xda, 0x30, + 0x1c, 0xc5, 0x13, 0xb4, 0x71, 0xf0, 0x4e, 0xf3, 0xd8, 0xb4, 0x64, 0x28, 0xdb, 0x22, 0xc1, 0xa6, + 0x89, 0xc5, 0x83, 0x1d, 0xd8, 0x8e, 0xe3, 0xb8, 0x03, 0xda, 0x50, 0x4f, 0xbd, 0x20, 0x87, 0xba, + 0x69, 0x24, 0xe2, 0x7f, 0x88, 0x9d, 0xaa, 0xf4, 0xd8, 0x4f, 0x50, 0xa9, 0xe7, 0x7e, 0x1f, 0x7a, + 0x2a, 0x52, 0x2f, 0x3d, 0x55, 0x15, 0xf4, 0x83, 0x54, 0x38, 0x06, 0xda, 0x42, 0x40, 0xea, 0x2d, + 0xf1, 0xff, 0xf9, 0xbd, 0xdf, 0xb3, 0x8d, 0xde, 0xee, 0x33, 0xe6, 0xa7, 0x09, 0x67, 0x09, 0x19, + 0xa4, 0x2c, 0x19, 0x7a, 0x71, 0x02, 0x12, 0xf0, 0x6b, 0xce, 0x52, 0x99, 0x00, 0xf7, 0x16, 0x63, + 0xbb, 0x14, 0x40, 0x00, 0x6a, 0x4a, 0x66, 0x5f, 0x99, 0xd0, 0x2e, 0x07, 0x00, 0x41, 0x9f, 0x11, + 0x1a, 0x87, 0x84, 0x72, 0x0e, 0x92, 0xca, 0x10, 0xb8, 0xd0, 0xd3, 0x6f, 0x3d, 0x10, 0x11, 0x08, + 0xe2, 0x53, 0xc1, 0x32, 0x7f, 0x72, 0x58, 0xf7, 0x99, 0xa4, 0x75, 0x12, 0xd3, 0x20, 0xe4, 0x4a, + 0xac, 0xb5, 0xef, 0x96, 0x24, 0x31, 0x4d, 0x68, 0x34, 0xf7, 0xa8, 0x2d, 0xd7, 0x25, 0x48, 0xda, + 0xef, 0xaa, 0x9f, 0xbd, 0xae, 0x26, 0x14, 0x5d, 0x1a, 0x41, 0xca, 0x65, 0xa6, 0x76, 0x4b, 0x08, + 0xff, 0x9f, 0xe5, 0xfc, 0x53, 0x16, 0x1d, 0x36, 0x48, 0x99, 0x90, 0x6e, 0x1b, 0xbd, 0x79, 0xb4, + 0x2a, 0x62, 0xe0, 0x82, 0xe1, 0x26, 0x2a, 0x66, 0x51, 0xef, 0xcd, 0x4f, 0xe6, 0xd7, 0x57, 0x0d, + 0xcb, 0x5b, 0xa9, 0xed, 0x65, 0x5b, 0x5a, 0x2f, 0x46, 0x37, 0x1f, 0x8d, 0x8e, 0x96, 0xbb, 0x5f, + 0x50, 0x45, 0xf9, 0xed, 0xcc, 0x80, 0x5a, 0x8a, 0xa7, 0xad, 0x71, 0xfe, 0x28, 0x9a, 0x79, 0xf0, + 0xb9, 0x89, 0xaa, 0xdb, 0x94, 0x1a, 0x46, 0xa0, 0xf2, 0xa6, 0x7e, 0x1a, 0xb1, 0xb6, 0x06, 0x31, + 0xd7, 0x5b, 0x53, 0x5b, 0x32, 0x4f, 0xd0, 0xb8, 0x2c, 0xa0, 0x97, 0x8a, 0x0f, 0x1f, 0xa3, 0x62, + 0x56, 0x15, 0x57, 0xd6, 0x44, 0xac, 0x9e, 0xa9, 0x5d, 0xdd, 0x26, 0xcb, 0x7a, 0xb9, 0x9f, 0x4f, + 0xae, 0xee, 0xce, 0x0a, 0x1f, 0xb0, 0x45, 0xb4, 0x9e, 0x3c, 0xbd, 0x68, 0x7c, 0x61, 0x22, 0x2b, + 0xb7, 0x04, 0xfe, 0x95, 0x17, 0xb4, 0xed, 0xf4, 0xed, 0xdf, 0xcf, 0xd8, 0xa9, 0xa9, 0x9b, 0x8a, + 0xba, 0x8e, 0xc9, 0x1a, 0xea, 0x4d, 0xd7, 0xd4, 0xfa, 0x3b, 0x9a, 0x38, 0xe6, 0x78, 0xe2, 0x98, + 0xb7, 0x13, 0xc7, 0x3c, 0x9d, 0x3a, 0xc6, 0x78, 0xea, 0x18, 0xd7, 0x53, 0xc7, 0xd8, 0xfd, 0x11, + 0x84, 0xf2, 0x20, 0xf5, 0xbd, 0x1e, 0x44, 0x73, 0xd3, 0xef, 0x90, 0x04, 0x8b, 0x80, 0xa3, 0x87, + 0x11, 0xc3, 0x98, 0x09, 0xbf, 0xa8, 0xde, 0xf4, 0xcf, 0xfb, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3e, + 0x4a, 0x4d, 0x46, 0xa5, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // TotalBurnedNeutronsAmount queries total amount of burned neutron fees. + TotalBurnedNeutronsAmount(ctx context.Context, in *QueryTotalBurnedNeutronsAmountRequest, opts ...grpc.CallOption) (*QueryTotalBurnedNeutronsAmountResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/neutron.feeburner.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) TotalBurnedNeutronsAmount(ctx context.Context, in *QueryTotalBurnedNeutronsAmountRequest, opts ...grpc.CallOption) (*QueryTotalBurnedNeutronsAmountResponse, error) { + out := new(QueryTotalBurnedNeutronsAmountResponse) + err := c.cc.Invoke(ctx, "/neutron.feeburner.Query/TotalBurnedNeutronsAmount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // TotalBurnedNeutronsAmount queries total amount of burned neutron fees. + TotalBurnedNeutronsAmount(context.Context, *QueryTotalBurnedNeutronsAmountRequest) (*QueryTotalBurnedNeutronsAmountResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) TotalBurnedNeutronsAmount(ctx context.Context, req *QueryTotalBurnedNeutronsAmountRequest) (*QueryTotalBurnedNeutronsAmountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TotalBurnedNeutronsAmount not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutron.feeburner.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_TotalBurnedNeutronsAmount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTotalBurnedNeutronsAmountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TotalBurnedNeutronsAmount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutron.feeburner.Query/TotalBurnedNeutronsAmount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TotalBurnedNeutronsAmount(ctx, req.(*QueryTotalBurnedNeutronsAmountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "neutron.feeburner.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "TotalBurnedNeutronsAmount", + Handler: _Query_TotalBurnedNeutronsAmount_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "feeburner/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryTotalBurnedNeutronsAmountRequest) 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 *QueryTotalBurnedNeutronsAmountRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalBurnedNeutronsAmountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryTotalBurnedNeutronsAmountResponse) 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 *QueryTotalBurnedNeutronsAmountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalBurnedNeutronsAmountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.TotalBurnedNeutronsAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryTotalBurnedNeutronsAmountRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryTotalBurnedNeutronsAmountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TotalBurnedNeutronsAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTotalBurnedNeutronsAmountRequest) 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: QueryTotalBurnedNeutronsAmountRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalBurnedNeutronsAmountRequest: 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 *QueryTotalBurnedNeutronsAmountResponse) 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: QueryTotalBurnedNeutronsAmountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalBurnedNeutronsAmountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBurnedNeutronsAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalBurnedNeutronsAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feeburner/types/query.pb.gw.go b/x/feeburner/types/query.pb.gw.go new file mode 100644 index 000000000..5ae660741 --- /dev/null +++ b/x/feeburner/types/query.pb.gw.go @@ -0,0 +1,218 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: feeburner/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_TotalBurnedNeutronsAmount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalBurnedNeutronsAmountRequest + var metadata runtime.ServerMetadata + + msg, err := client.TotalBurnedNeutronsAmount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TotalBurnedNeutronsAmount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalBurnedNeutronsAmountRequest + var metadata runtime.ServerMetadata + + msg, err := server.TotalBurnedNeutronsAmount(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TotalBurnedNeutronsAmount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TotalBurnedNeutronsAmount_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalBurnedNeutronsAmount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TotalBurnedNeutronsAmount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TotalBurnedNeutronsAmount_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalBurnedNeutronsAmount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"neutron", "feeburner", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TotalBurnedNeutronsAmount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"neutron", "feeburner", "total_burned_neutrons_amount"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_TotalBurnedNeutronsAmount_0 = runtime.ForwardResponseMessage +) diff --git a/x/feeburner/types/total_burned_neutrons_amount.pb.go b/x/feeburner/types/total_burned_neutrons_amount.pb.go new file mode 100644 index 000000000..b0dd1f0c4 --- /dev/null +++ b/x/feeburner/types/total_burned_neutrons_amount.pb.go @@ -0,0 +1,338 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: feeburner/total_burned_neutrons_amount.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// TotalBurnedNeutronsAmount defines total amount of burned neutron fees +type TotalBurnedNeutronsAmount struct { + Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins" yaml:"coins"` +} + +func (m *TotalBurnedNeutronsAmount) Reset() { *m = TotalBurnedNeutronsAmount{} } +func (m *TotalBurnedNeutronsAmount) String() string { return proto.CompactTextString(m) } +func (*TotalBurnedNeutronsAmount) ProtoMessage() {} +func (*TotalBurnedNeutronsAmount) Descriptor() ([]byte, []int) { + return fileDescriptor_3a29e81c9c2bc4df, []int{0} +} +func (m *TotalBurnedNeutronsAmount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TotalBurnedNeutronsAmount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TotalBurnedNeutronsAmount.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 *TotalBurnedNeutronsAmount) XXX_Merge(src proto.Message) { + xxx_messageInfo_TotalBurnedNeutronsAmount.Merge(m, src) +} +func (m *TotalBurnedNeutronsAmount) XXX_Size() int { + return m.Size() +} +func (m *TotalBurnedNeutronsAmount) XXX_DiscardUnknown() { + xxx_messageInfo_TotalBurnedNeutronsAmount.DiscardUnknown(m) +} + +var xxx_messageInfo_TotalBurnedNeutronsAmount proto.InternalMessageInfo + +func (m *TotalBurnedNeutronsAmount) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Coins + } + return nil +} + +func init() { + proto.RegisterType((*TotalBurnedNeutronsAmount)(nil), "neutron.feeburner.TotalBurnedNeutronsAmount") +} + +func init() { + proto.RegisterFile("feeburner/total_burned_neutrons_amount.proto", fileDescriptor_3a29e81c9c2bc4df) +} + +var fileDescriptor_3a29e81c9c2bc4df = []byte{ + // 269 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x49, 0x4b, 0x4d, 0x4d, + 0x2a, 0x2d, 0xca, 0x4b, 0x2d, 0xd2, 0x2f, 0xc9, 0x2f, 0x49, 0xcc, 0x89, 0x07, 0x73, 0x52, 0xe2, + 0xf3, 0x52, 0x4b, 0x4b, 0x8a, 0xf2, 0xf3, 0x8a, 0xe3, 0x13, 0x73, 0xf3, 0x4b, 0xf3, 0x4a, 0xf4, + 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0xa1, 0xc2, 0x7a, 0x70, 0x5d, 0x52, 0x72, 0xc9, 0xf9, + 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0x49, 0x89, 0xc5, 0xa9, 0xfa, 0x65, 0x86, 0x49, 0xa9, 0x25, 0x89, + 0x86, 0xfa, 0xc9, 0xf9, 0x99, 0x79, 0x10, 0x2d, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xa6, + 0x3e, 0x88, 0x05, 0x11, 0x55, 0xea, 0x63, 0xe4, 0x92, 0x0c, 0x01, 0xd9, 0xe7, 0x04, 0xb6, 0xce, + 0x0f, 0x6a, 0x9b, 0x23, 0xd8, 0x32, 0xa1, 0x42, 0x2e, 0x56, 0x90, 0x09, 0xc5, 0x12, 0x8c, 0x0a, + 0xcc, 0x1a, 0xdc, 0x46, 0x92, 0x7a, 0x10, 0x3b, 0xf4, 0x40, 0x76, 0xe8, 0x41, 0xed, 0xd0, 0x73, + 0xce, 0xcf, 0xcc, 0x73, 0x72, 0x38, 0x71, 0x4f, 0x9e, 0xe1, 0xd3, 0x3d, 0x79, 0x9e, 0xca, 0xc4, + 0xdc, 0x1c, 0x2b, 0x25, 0xb0, 0x2e, 0xa5, 0x55, 0xf7, 0xe5, 0x35, 0xd2, 0x33, 0x4b, 0x32, 0x4a, + 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xa1, 0x0e, 0x84, 0x50, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x25, + 0x95, 0x05, 0xa9, 0xc5, 0x60, 0x03, 0x8a, 0x83, 0x20, 0x36, 0x39, 0x79, 0x9d, 0x78, 0x24, 0xc7, + 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, + 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x01, 0x92, 0x51, 0x50, 0xef, 0xeb, 0xe6, 0x17, 0xa5, + 0xc3, 0xd8, 0xfa, 0x15, 0xfa, 0x48, 0x41, 0x08, 0x32, 0x38, 0x89, 0x0d, 0xec, 0x47, 0x63, 0x40, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x9b, 0x3d, 0x37, 0xe2, 0x5c, 0x01, 0x00, 0x00, +} + +func (m *TotalBurnedNeutronsAmount) 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 *TotalBurnedNeutronsAmount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TotalBurnedNeutronsAmount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Coins) > 0 { + for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTotalBurnedNeutronsAmount(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintTotalBurnedNeutronsAmount(dAtA []byte, offset int, v uint64) int { + offset -= sovTotalBurnedNeutronsAmount(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *TotalBurnedNeutronsAmount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Coins) > 0 { + for _, e := range m.Coins { + l = e.Size() + n += 1 + l + sovTotalBurnedNeutronsAmount(uint64(l)) + } + } + return n +} + +func sovTotalBurnedNeutronsAmount(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTotalBurnedNeutronsAmount(x uint64) (n int) { + return sovTotalBurnedNeutronsAmount(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *TotalBurnedNeutronsAmount) 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 ErrIntOverflowTotalBurnedNeutronsAmount + } + 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: TotalBurnedNeutronsAmount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TotalBurnedNeutronsAmount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTotalBurnedNeutronsAmount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTotalBurnedNeutronsAmount + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTotalBurnedNeutronsAmount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Coins = append(m.Coins, types.Coin{}) + if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTotalBurnedNeutronsAmount(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTotalBurnedNeutronsAmount + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTotalBurnedNeutronsAmount(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTotalBurnedNeutronsAmount + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTotalBurnedNeutronsAmount + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTotalBurnedNeutronsAmount + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTotalBurnedNeutronsAmount + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTotalBurnedNeutronsAmount + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTotalBurnedNeutronsAmount + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTotalBurnedNeutronsAmount = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTotalBurnedNeutronsAmount = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTotalBurnedNeutronsAmount = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feeburner/types/types.go b/x/feeburner/types/types.go new file mode 100644 index 000000000..ab1254f4c --- /dev/null +++ b/x/feeburner/types/types.go @@ -0,0 +1 @@ +package types diff --git a/x/feerefunder/client/cli/query_test.go b/x/feerefunder/client/cli/query_test.go index 2acc9eddd..56309eeb7 100644 --- a/x/feerefunder/client/cli/query_test.go +++ b/x/feerefunder/client/cli/query_test.go @@ -1,6 +1,7 @@ package cli_test import ( + "github.com/neutron-org/neutron/app" "testing" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" @@ -33,6 +34,8 @@ func feeRefunderNetwork(t *testing.T, feeInfo types.Fee) *network.Network { } func TestQueryFeeInfo(t *testing.T) { + _ = app.GetDefaultConfig() + feeInfo := types.Fee{ RecvFee: sdk.NewCoins(), AckFee: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1001))),