diff --git a/app/ante/check_reissuance_decorator.go b/app/ante/check_reissuance_decorator.go index c1361d9..bcf4e04 100644 --- a/app/ante/check_reissuance_decorator.go +++ b/app/ante/check_reissuance_decorator.go @@ -4,7 +4,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/planetmint/planetmint-go/config" - "github.com/planetmint/planetmint-go/x/dao" + "github.com/planetmint/planetmint-go/x/dao/keeper" daotypes "github.com/planetmint/planetmint-go/x/dao/types" ) @@ -22,7 +22,7 @@ func (cmad CheckReissuanceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu if ok { logger.Debug("REISSUE: receive Proposal") conf := config.GetConfig() - isValid := dao.IsValidReissuanceCommand(MsgProposal.GetTx(), conf.ReissuanceAsset, MsgProposal.GetBlockHeight()) + isValid := keeper.IsValidReissuanceCommand(MsgProposal.GetTx(), conf.ReissuanceAsset, MsgProposal.GetBlockHeight()) if !isValid { logger.Debug("REISSUE: Invalid Proposal") return ctx, errorsmod.Wrapf(daotypes.ErrReissuanceProposal, "error during CheckTx or ReCheckTx") diff --git a/config/config.go b/config/config.go index 2d28e7c..cc5b5ae 100644 --- a/config/config.go +++ b/config/config.go @@ -24,6 +24,11 @@ rpc-password = "{{ .PlmntConfig.RPCPassword }}" issuance-service-dir = "{{ .PlmntConfig.IssuanceServiceDir }}" reissuance-asset = "{{ .PlmntConfig.ReissuanceAsset }}" validator-address = "{{ .PlmntConfig.ValidatorAddress }}" +distribution-address-inv = "{{ .PlmntConfig.DistributionAddrInv }}" +distribution-address-dao = "{{ .PlmntConfig.DistributionAddrDAO }}" +distribution-address-pop = "{{ .PlmntConfig.DistributionAddrPoP }}" +distribution-epochs = {{ .PlmntConfig.DistributionEpochs }} + ` // Config defines Planetmint's top level configuration @@ -41,6 +46,10 @@ type Config struct { IssuanceServiceDir string `mapstructure:"issuance-service-dir" json:"issuance-service-dir"` ReissuanceAsset string `mapstructure:"reissuance-asset" json:"reissuance-asset"` ValidatorAddress string `mapstructure:"validator-address" json:"validator-address"` + DistributionAddrInv string `mapstructure:"distribution-address-inv" json:"distribution-address-inv"` + DistributionAddrDAO string `mapstructure:"distribution-address-dao" json:"distribution-address-dao"` + DistributionAddrPoP string `mapstructure:"distribution-address-pop" json:"distribution-address-pop"` + DistributionEpochs int `mapstructure:"distribution-epochs" json:"distribution-epochs"` } // cosmos-sdk wide global singleton @@ -61,10 +70,14 @@ func DefaultConfig() *Config { RPCHost: "localhost", RPCPort: 18884, RPCUser: "user", - RPCPassword: "passwor", + RPCPassword: "password", IssuanceServiceDir: "/opt/issuer_service", - ReissuanceAsset: "asset-id-or-name", + ReissuanceAsset: "7add40beb27df701e02ee85089c5bc0021bc813823fedb5f1dcb5debda7f3da9", ValidatorAddress: "plmnt1w5dww335zhh98pzv783hqre355ck3u4w4hjxcx", + DistributionAddrInv: "vjTyRN2G42Yq3T5TJBecHj1dF1xdhKF89hKV4HJN3uXxUbaVGVR76hAfVRQqQCovWaEpar7G5qBBprFG", + DistributionAddrDAO: "vjU8eMzU3JbUWZEpVANt2ePJuPWSPixgjiSj2jDMvkVVQQi2DDnZuBRVX4Ygt5YGBf5zvTWCr1ntdqYH", + DistributionAddrPoP: "vjTvXCFSReRsZ7grdsAreRR12KuKpDw8idueQJK9Yh1BYS7ggAqgvCxCgwh13KGK6M52y37HUmvr4GdD", + DistributionEpochs: 17280, // CometBFT epochs of 5s equate 1 day (12*60*24) } } diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 573f4ec..a140450 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -46702,7 +46702,7 @@ paths: type: string rawtx: type: string - txId: + txID: type: string blockHeight: type: string @@ -46750,7 +46750,7 @@ paths: type: string rawtx: type: string - txId: + txID: type: string blockHeight: type: string @@ -75967,6 +75967,35 @@ definitions: description: params holds all the parameters of this module. type: object description: QueryParamsResponse is response type for the Query/Params RPC method. + planetmintgo.dao.DistributionOrder: + type: object + properties: + daoAddr: + type: string + daoAmount: + type: string + daoTxID: + type: string + investorAddr: + type: string + investorAmount: + type: string + investorTxID: + type: string + popAddr: + type: string + popAmount: + type: string + popTxID: + type: string + firstPop: + type: string + format: int64 + lastPop: + type: string + format: int64 + proposer: + type: string planetmintgo.dao.MintRequest: type: object properties: @@ -75992,6 +76021,10 @@ definitions: format: uint64 liquidTxHash: type: string + planetmintgo.dao.MsgDistributionRequestResponse: + type: object + planetmintgo.dao.MsgDistributionResultResponse: + type: object planetmintgo.dao.MsgMintTokenResponse: type: object planetmintgo.dao.MsgReissueRDDLProposalResponse: @@ -76029,7 +76062,7 @@ definitions: type: string rawtx: type: string - txId: + txID: type: string blockHeight: type: string @@ -76044,7 +76077,7 @@ definitions: type: string rawtx: type: string - txId: + txID: type: string blockHeight: type: string @@ -76110,7 +76143,7 @@ definitions: type: string rawtx: type: string - txId: + txID: type: string blockHeight: type: string diff --git a/go.mod b/go.mod index 8213cb8..2b4d221 100644 --- a/go.mod +++ b/go.mod @@ -27,6 +27,7 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 google.golang.org/grpc v1.56.3 gopkg.in/yaml.v2 v2.4.0 + gotest.tools v2.2.0+incompatible sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index 72e3b69..857e5ee 100644 --- a/go.sum +++ b/go.sum @@ -1644,6 +1644,7 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= +gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/proto/planetmintgo/dao/distribution_order.proto b/proto/planetmintgo/dao/distribution_order.proto new file mode 100644 index 0000000..f70cde3 --- /dev/null +++ b/proto/planetmintgo/dao/distribution_order.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; +package planetmintgo.dao; + +option go_package = "github.com/planetmint/planetmint-go/x/dao/types"; + +message DistributionOrder { + + + string daoAddr = 1; + string daoAmount = 2; + string daoTxID = 3; + string investorAddr = 4; + string investorAmount = 5; + string investorTxID = 6; + string popAddr = 7; + string popAmount = 8; + string popTxID = 9; + int64 firstPop = 10; + int64 lastPop = 11; + string proposer = 12; +} diff --git a/proto/planetmintgo/dao/reissuance.proto b/proto/planetmintgo/dao/reissuance.proto index eae3c41..5f9fd87 100644 --- a/proto/planetmintgo/dao/reissuance.proto +++ b/proto/planetmintgo/dao/reissuance.proto @@ -7,6 +7,6 @@ message Reissuance { string proposer = 1; string rawtx = 2; - string txId = 3; + string txID = 3; int64 blockHeight = 4; } diff --git a/proto/planetmintgo/dao/tx.proto b/proto/planetmintgo/dao/tx.proto index cbc1395..22bdd07 100644 --- a/proto/planetmintgo/dao/tx.proto +++ b/proto/planetmintgo/dao/tx.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package planetmintgo.dao; import "planetmintgo/dao/mint_request.proto"; +import "planetmintgo/dao/distribution_order.proto"; import "planetmintgo/dao/params.proto"; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -13,9 +14,11 @@ option go_package = "github.com/planetmint/planetmint-go/x/dao/types"; // Msg defines the Msg service. service Msg { - rpc ReissueRDDLProposal (MsgReissueRDDLProposal) returns (MsgReissueRDDLProposalResponse); - rpc MintToken (MsgMintToken ) returns (MsgMintTokenResponse ); - rpc ReissueRDDLResult (MsgReissueRDDLResult ) returns (MsgReissueRDDLResultResponse ); + rpc ReissueRDDLProposal (MsgReissueRDDLProposal ) returns (MsgReissueRDDLProposalResponse ); + rpc MintToken (MsgMintToken ) returns (MsgMintTokenResponse ); + rpc ReissueRDDLResult (MsgReissueRDDLResult ) returns (MsgReissueRDDLResultResponse ); + rpc DistributionResult (MsgDistributionResult ) returns (MsgDistributionResultResponse ); + rpc DistributionRequest (MsgDistributionRequest) returns (MsgDistributionRequestResponse); rpc UpdateParams (MsgUpdateParams ) returns (MsgUpdateParamsResponse ); } message MsgReissueRDDLProposal { @@ -37,11 +40,27 @@ message MsgMintTokenResponse {} message MsgReissueRDDLResult { string creator = 1; string proposer = 2; - string txId = 3; + string txID = 3; int64 blockHeight = 4; } message MsgReissueRDDLResultResponse {} +message MsgDistributionResult { + string creator = 1; + int64 lastPop = 2; + string daoTxID = 3; + string investorTxID = 4; + string popTxID = 5; +} + +message MsgDistributionResultResponse {} + +message MsgDistributionRequest { + string creator = 1; + DistributionOrder distribution = 2; +} + +message MsgDistributionRequestResponse {} message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; diff --git a/tests/e2e/dao/suite.go b/tests/e2e/dao/suite.go index 551f8a1..8b347b9 100644 --- a/tests/e2e/dao/suite.go +++ b/tests/e2e/dao/suite.go @@ -5,26 +5,24 @@ import ( "encoding/json" "fmt" "os" - - "github.com/planetmint/planetmint-go/config" - "github.com/planetmint/planetmint-go/testutil/network" - "github.com/planetmint/planetmint-go/testutil/sample" + "strconv" "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" - sdk "github.com/cosmos/cosmos-sdk/types" - - clitestutil "github.com/planetmint/planetmint-go/testutil/cli" - - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bank "github.com/cosmos/cosmos-sdk/x/bank/client/cli" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/planetmint/planetmint-go/config" + clitestutil "github.com/planetmint/planetmint-go/testutil/cli" + "github.com/planetmint/planetmint-go/testutil/network" + "github.com/planetmint/planetmint-go/testutil/sample" + daocli "github.com/planetmint/planetmint-go/x/dao/client/cli" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - daocli "github.com/planetmint/planetmint-go/x/dao/client/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" daotypes "github.com/planetmint/planetmint-go/x/dao/types" ) @@ -92,8 +90,6 @@ func (s *E2ETestSuite) SetupSuite() { bankGenState.Balances = append(bankGenState.Balances, accountBalances...) s.cfg.GenesisState[banktypes.ModuleName] = s.cfg.Codec.MustMarshalJSON(&bankGenState) - s.cfg.MinGasPrices = fmt.Sprintf("0.000006%s", conf.FeeDenom) - // Setup MintAddress parameter in genesis state // use sample.Mnemonic to make mint address deterministic for test s.cfg.Mnemonics = []string{sample.Mnemonic} @@ -107,6 +103,7 @@ func (s *E2ETestSuite) SetupSuite() { daoGenState.Params.MintAddress = valAddr.String() s.cfg.GenesisState[daotypes.ModuleName] = s.cfg.Codec.MustMarshalJSON(&daoGenState) + s.cfg.MinGasPrices = fmt.Sprintf("0.000006%s", conf.FeeDenom) s.network = network.New(s.T(), s.cfg) } @@ -259,3 +256,18 @@ func (s *E2ETestSuite) createValAccount(cfg network.Config) (address sdk.AccAddr return addr, nil } + +func (s *E2ETestSuite) TestReissuance() { + conf := config.GetConfig() + val := s.network.Validators[0] + + var err error + for i := 0; i < conf.PoPEpochs+10; i++ { + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + } + var height int64 + height, _ = s.network.LatestHeight() + intValue := strconv.FormatInt(height, 10) + _, _ = clitestutil.ExecTestCLICmd(val.ClientCtx, daocli.CmdGetReissuance(), []string{intValue}) +} diff --git a/testutil/network/network.go b/testutil/network/network.go index 46b72b2..45f6834 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -18,6 +18,7 @@ import ( "github.com/stretchr/testify/require" "github.com/planetmint/planetmint-go/app" + "github.com/planetmint/planetmint-go/config" ) type ( @@ -37,7 +38,16 @@ func New(t *testing.T, configs ...Config) *Network { } else { cfg = configs[0] } - net, err := network.New(t, t.TempDir(), cfg) + validatorTmpDir := t.TempDir() + + //set the proper root dir for the test environment so that the abci.go logic works + appConfig := config.GetConfig() + appConfig.SetRoot(validatorTmpDir + "/node0/simd") + + net, err := network.New(t, validatorTmpDir, cfg) + + appConfig.ValidatorAddress = net.Validators[0].Address.String() + require.NoError(t, err) _, err = net.WaitForHeight(1) require.NoError(t, err) diff --git a/util/elementsd_connector.go b/util/elementsd_connector.go index 0c2f482..78ece0b 100644 --- a/util/elementsd_connector.go +++ b/util/elementsd_connector.go @@ -31,7 +31,34 @@ func ReissueAsset(reissueTx string) (txid string, err error) { errstr := stderr.String() if err != nil || len(errstr) > 0 { - err = errors.New("reissuance of RDDL failed") + err = errors.New("reissuance of RDDL failed: " + errstr) + } else { + var txobj ReissueResult + err = json.Unmarshal(stdout.Bytes(), &txobj) + if err == nil { + txid = txobj.Txid + } + } + return txid, err +} + +func DistributeAsset(address string, amount string) (txid string, err error) { + conf := config.GetConfig() + cmd := exec.Command("/usr/local/bin/elements-cli", "-rpcpassword="+conf.RPCPassword, + "-rpcuser="+conf.RPCUser, "-rpcport="+strconv.Itoa(conf.RPCPort), "-rpcconnect="+conf.RPCHost, + "sendtoaddress", address, amount, "", "", "false", "true", "null", "\"unset\"", "false", + "\""+conf.ReissuanceAsset+"\"") + + var stdout, stderr bytes.Buffer + cmd.Stdout = &stdout + cmd.Stderr = &stderr + + err = cmd.Run() + errstr := stderr.String() + + if err != nil || len(errstr) > 0 { + errormessage := "distribution of RDDL failed for " + address + err = errors.New(errormessage) } else { var txobj ReissueResult err = json.Unmarshal(stdout.Bytes(), &txobj) diff --git a/util/issue_commands.go b/util/issue_commands.go index f4c41fa..16f8d5b 100644 --- a/util/issue_commands.go +++ b/util/issue_commands.go @@ -1,13 +1,12 @@ package util import ( - "bytes" - "errors" "os/exec" "strconv" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/planetmint/planetmint-go/config" + "github.com/planetmint/planetmint-go/x/dao/types" ) func InitRDDLReissuanceProcess(ctx sdk.Context, proposerAddress string, txUnsigned string, blockHeight int64) error { @@ -20,19 +19,8 @@ func InitRDDLReissuanceProcess(ctx sdk.Context, proposerAddress string, txUnsign "--from", sendingValidatorAddress, "-y", proposerAddress, txUnsigned, strconv.FormatInt(blockHeight, 10)) - var stdout, stderr bytes.Buffer - cmd.Stdout = &stdout - cmd.Stderr = &stderr - - // Start the command in a non-blocking way - err := cmd.Start() - errstr := stderr.String() - if err != nil || len(errstr) > 0 { - if err == nil { - err = errors.New(errstr) - } - } - return err + logger.Debug("REISSUE: create Proposal") + return cmd.Start() } func SendRDDLReissuanceResult(ctx sdk.Context, proposerAddress string, txID string, blockHeight int64) error { @@ -43,17 +31,28 @@ func SendRDDLReissuanceResult(ctx sdk.Context, proposerAddress string, txID stri cmd := exec.Command("planetmint-god", "tx", "dao", "reissue-rddl-result", "--from", sendingValidatorAddress, "-y", proposerAddress, txID, strconv.FormatInt(blockHeight, 10)) - - var stdout, stderr bytes.Buffer - cmd.Stdout = &stdout - cmd.Stderr = &stderr - // Start the command in a non-blocking way - err := cmd.Start() - errstr := stderr.String() - if err != nil || len(errstr) > 0 { - if err == nil { - err = errors.New(errstr) - } - } - return err + logger.Debug("REISSUE: create Result") + return cmd.Start() +} + +func SendRDDLDistributionRequest(ctx sdk.Context, distribution types.DistributionOrder) error { + logger := ctx.Logger() + // Construct the command + sendingValidatorAddress := config.GetConfig().ValidatorAddress + cmd := exec.Command("planetmint-god", "tx", "dao", "distribution-request", + "--from", sendingValidatorAddress, "-y", "'"+distribution.String()+"'") + logger.Debug("REISSUE: create Result") + return cmd.Start() +} + +func SendRDDLDistributionResult(ctx sdk.Context, lastPoP string, daoTxid string, invTxid string, popTxid string) error { + logger := ctx.Logger() + // Construct the command + sendingValidatorAddress := config.GetConfig().ValidatorAddress + logger.Debug("REISSUE: create Result") + cmd := exec.Command("planetmint-god", "tx", "dao", "distribution-result", + "--from", sendingValidatorAddress, "-y", + lastPoP, daoTxid, invTxid, popTxid) + logger.Debug("REISSUE: create Result") + return cmd.Start() } diff --git a/util/rddl_token.go b/util/rddl_token.go new file mode 100644 index 0000000..6ffb523 --- /dev/null +++ b/util/rddl_token.go @@ -0,0 +1,26 @@ +package util + +import "strconv" + +var factor = 100000000.0 + +func RDDLToken2Uint(amount float64) uint64 { + return uint64(amount * factor) +} + +func RDDLToken2Float(amount uint64) float64 { + return float64(amount) / factor +} + +func RDDLTokenStringToFloat(amount string) (amountFloat float64, err error) { + amountFloat, err = strconv.ParseFloat(amount, 64) + return amountFloat, err +} + +func RDDLTokenStringToUint(amount string) (amountUint uint64, err error) { + amountFloat, err := RDDLTokenStringToFloat(amount) + if err == nil { + amountUint = RDDLToken2Uint(amountFloat) + } + return amountUint, err +} diff --git a/util/rddl_token_test.go b/util/rddl_token_test.go new file mode 100644 index 0000000..d4caded --- /dev/null +++ b/util/rddl_token_test.go @@ -0,0 +1,33 @@ +package util + +import ( + "testing" + + "gotest.tools/assert" +) + +func Test2FloatConvertion(t *testing.T) { + var expectedValue uint64 = 99869000000 + value := RDDLToken2Uint(998.69) + assert.Equal(t, expectedValue, value) +} + +func Test2UintConvertion(t *testing.T) { + expectedValue := 998.69 + value := RDDLToken2Float(99869000000) + assert.Equal(t, expectedValue, value) +} + +func TestStringToFloat(t *testing.T) { + expectedValue := 998.69 + value, err := RDDLTokenStringToFloat("998.69") + assert.Equal(t, expectedValue, value) + assert.Equal(t, nil, err) +} + +func TestStringToUint(t *testing.T) { + var expectedValue uint64 = 99869000000 + value, err := RDDLTokenStringToUint("998.69") + assert.Equal(t, expectedValue, value) + assert.Equal(t, nil, err) +} diff --git a/x/dao/abci.go b/x/dao/abci.go index 002c850..0238f52 100644 --- a/x/dao/abci.go +++ b/x/dao/abci.go @@ -11,24 +11,38 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, _ keeper.Keeper) { +func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) { logger := ctx.Logger() proposerAddress := req.Header.GetProposerAddress() // Check if node is block proposer - - if isPoPHeight(req.Header.GetHeight()) && util.IsValidatorBlockProposer(ctx, proposerAddress) { + // take the following actions only once, that's why we filter for the Block Proposer + if util.IsValidatorBlockProposer(ctx, proposerAddress) { blockHeight := req.Header.GetHeight() - // TODO: implement PoP trigger - logger.Info("TODO: implement PoP trigger") - hexProposerAddress := hex.EncodeToString(proposerAddress) - conf := config.GetConfig() - txUnsigned := GetReissuanceCommand(conf.ReissuanceAsset, blockHeight) - err := util.InitRDDLReissuanceProcess(ctx, hexProposerAddress, txUnsigned, blockHeight) - if err != nil { - logger.Error("error while initializing RDDL issuance", err) + if isPoPHeight(blockHeight) { + logger.Debug("TODO: implement PoP trigger") + hexProposerAddress := hex.EncodeToString(proposerAddress) + conf := config.GetConfig() + txUnsigned := keeper.GetReissuanceCommand(conf.ReissuanceAsset, blockHeight) + err := util.InitRDDLReissuanceProcess(ctx, hexProposerAddress, txUnsigned, blockHeight) + if err != nil { + logger.Error("error while initializing RDDL issuance", err) + } + } + if isDistributionHeight(blockHeight) { + // initialize the distribution message + distribution, err := k.GetDistributionForReissuedTokens(ctx, blockHeight) + if err != nil { + logger.Error("error while computing the RDDL distribution ", err) + } + err = util.SendRDDLDistributionRequest(ctx, distribution) + if err != nil { + logger.Error("sending the distribution request failed") + } + } } + } func isPoPHeight(height int64) bool { @@ -36,6 +50,11 @@ func isPoPHeight(height int64) bool { return height%int64(cfg.PoPEpochs) == 0 } +func isDistributionHeight(height int64) bool { + cfg := config.GetConfig() + return height%int64(cfg.DistributionEpochs) == 0 +} + func EndBlocker(ctx sdk.Context, _ abci.RequestEndBlock, k keeper.Keeper) { k.DistributeCollectedFees(ctx) } diff --git a/x/dao/client/cli/tx.go b/x/dao/client/cli/tx.go index 430841b..b89eeaa 100644 --- a/x/dao/client/cli/tx.go +++ b/x/dao/client/cli/tx.go @@ -28,6 +28,8 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdReissueRDDLProposal()) cmd.AddCommand(CmdMintToken()) cmd.AddCommand(CmdReissueRDDLResult()) + cmd.AddCommand(CmdDistributionResult()) + cmd.AddCommand(CmdDistributionRequest()) cmd.AddCommand(CmdUpdateParams()) // this line is used by starport scaffolding # 1 diff --git a/x/dao/client/cli/tx_distribution_request.go b/x/dao/client/cli/tx_distribution_request.go new file mode 100644 index 0000000..c043b66 --- /dev/null +++ b/x/dao/client/cli/tx_distribution_request.go @@ -0,0 +1,47 @@ +package cli + +import ( + "strconv" + + "encoding/json" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/planetmint/planetmint-go/x/dao/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdDistributionRequest() *cobra.Command { + cmd := &cobra.Command{ + Use: "distribution-request [distribution]", + Short: "Broadcast message distribution-request", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argDistribution := new(types.DistributionOrder) + err = json.Unmarshal([]byte(args[0]), argDistribution) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgDistributionRequest( + clientCtx.GetFromAddress().String(), + argDistribution, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dao/client/cli/tx_distribution_result.go b/x/dao/client/cli/tx_distribution_result.go new file mode 100644 index 0000000..5314b8d --- /dev/null +++ b/x/dao/client/cli/tx_distribution_result.go @@ -0,0 +1,52 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/planetmint/planetmint-go/x/dao/types" + "github.com/spf13/cast" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdDistributionResult() *cobra.Command { + cmd := &cobra.Command{ + Use: "distribution-result [last-pop] [dao-txid] [investor-txid] [pop-txid]", + Short: "Broadcast message DistributionResult", + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argLastPop, err := cast.ToInt64E(args[0]) + if err != nil { + return err + } + argDaoTxid := args[1] + argInvestorTxid := args[2] + argPopTxid := args[3] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgDistributionResult( + clientCtx.GetFromAddress().String(), + argLastPop, + argDaoTxid, + argInvestorTxid, + argPopTxid, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dao/keeper/distribution.go b/x/dao/keeper/distribution.go new file mode 100644 index 0000000..181ffb1 --- /dev/null +++ b/x/dao/keeper/distribution.go @@ -0,0 +1,120 @@ +package keeper + +import ( + "math/big" + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/config" + "github.com/planetmint/planetmint-go/util" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func (k Keeper) StoreDistributionOrder(ctx sdk.Context, distributionOrder types.DistributionOrder) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DistributionKey)) + appendValue := k.cdc.MustMarshal(&distributionOrder) + store.Set(getLastPopBytes(distributionOrder.LastPop), appendValue) +} + +func (k Keeper) LookupDistributionOrder(ctx sdk.Context, lastPopHeight int64) (val types.DistributionOrder, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DistributionKey)) + distributionOrder := store.Get(getLastPopBytes(lastPopHeight)) + if distributionOrder == nil { + return val, false + } + k.cdc.MustUnmarshal(distributionOrder, &val) + return val, true +} + +func (k Keeper) GetLastDistributionOrder(ctx sdk.Context) (val types.DistributionOrder, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DistributionKey)) + + iterator := store.ReverseIterator(nil, nil) + defer iterator.Close() + found = iterator.Valid() + if found { + distributionOrder := iterator.Value() + k.cdc.MustUnmarshal(distributionOrder, &val) + } + return val, found +} + +// TODO to be integrated at a later stage +// func (k Keeper) getDistributionRequestPage(ctx sdk.Context, key []byte, offset uint64, page_size uint64, all bool, reverse bool) (distribution_orders []types.DistributionOrder) { +// store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DistributionKey)) + +// iterator := store.Iterator(nil, nil) +// defer iterator.Close() +// if reverse { +// iterator = store.ReverseIterator(nil, nil) +// defer iterator.Close() +// } +// for ; iterator.Valid(); iterator.Next() { +// distribution_order := iterator.Value() +// var distribution_order_org types.DistributionOrder +// k.cdc.MustUnmarshal(distribution_order, &distribution_order_org) +// distribution_orders = append(distribution_orders, distribution_order_org) +// } +// return distribution_orders +// } + +func getLastPopBytes(height int64) []byte { + // Adding 1 because 0 will be interpreted as nil, which is an invalid key + return big.NewInt(height + 1).Bytes() +} + +func ComputeDistribution(lastReissuance int64, BlockHeight int64, amount uint64) (distribution types.DistributionOrder) { + conf := config.GetConfig() + distribution.FirstPop = lastReissuance + distribution.LastPop = BlockHeight + + distribution.DaoAddr = conf.DistributionAddrDAO + distribution.InvestorAddr = conf.DistributionAddrInv + distribution.PopAddr = conf.DistributionAddrPoP + + distribution.DaoAmount = strconv.FormatUint(uint64(float64(amount)*types.PercentageDao), 10) + distribution.InvestorAmount = strconv.FormatUint(uint64(float64(amount)*types.PercentageInvestor), 10) + distribution.PopAmount = strconv.FormatUint(uint64(float64(amount)*types.PercentagePop), 10) + + return distribution +} + +func getUint64FromTxString(ctx sdk.Context, tx string) (amount uint64, err error) { + subStrings := strings.Split(tx, " ") + if len(subStrings) < 3 { + ctx.Logger().Error("Reissue tx string is shorter than expected. " + tx) + } else { + value := subStrings[2] + amount, err = util.RDDLTokenStringToUint(value) + if err != nil { + ctx.Logger().Error("Reissue tx string value is invalid " + subStrings[2]) + } + } + return amount, err +} + +func (k Keeper) GetDistributionForReissuedTokens(ctx sdk.Context, blockHeight int64) (distribution types.DistributionOrder, err error) { + var lastPoP int64 + lastDistributionOrder, found := k.GetLastDistributionOrder(ctx) + if found { + lastPoP = lastDistributionOrder.LastPop + } + + reissuances := k.getReissuancesRange(ctx, lastPoP) + var overallAmount uint64 + for index, obj := range reissuances { + if (index == 0 && lastPoP == 0 && obj.BlockHeight == 0) || //corner case (beginning of he chain) + (int64(lastPoP) < int64(obj.BlockHeight) && int64(obj.BlockHeight) <= blockHeight) { + amount, err := getUint64FromTxString(ctx, obj.Rawtx) + if err == nil { + overallAmount = overallAmount + amount + } + } else { + ctx.Logger().Info("%u %u %u", lastPoP, obj.BlockHeight, blockHeight) + } + } + distribution = ComputeDistribution(lastPoP, blockHeight, overallAmount) + return distribution, err +} diff --git a/x/dao/keeper/distribution_test.go b/x/dao/keeper/distribution_test.go new file mode 100644 index 0000000..ecc2c79 --- /dev/null +++ b/x/dao/keeper/distribution_test.go @@ -0,0 +1,82 @@ +package keeper_test + +import ( + "fmt" + "strconv" + "testing" + + keepertest "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/stretchr/testify/assert" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/dao/keeper" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func createNDistributionOrder(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.DistributionOrder { + items := make([]types.DistributionOrder, n) + for i := range items { + amount := 10000 + items[i].FirstPop = int64(i)*1000 + 1 + items[i].LastPop = int64(i+1) * 1000 + items[i].DaoAddr = fmt.Sprintf("DAO%v", i) + items[i].DaoAmount = fmt.Sprintf("%v", float64(amount)*types.PercentageDao) + items[i].InvestorAddr = fmt.Sprintf("INVESTOR%v", i) + items[i].InvestorAmount = fmt.Sprintf("%v", int64(float64(amount)*types.PercentageInvestor)) + items[i].PopAddr = fmt.Sprintf("POP%v", i) + items[i].PopAmount = fmt.Sprintf("%v", float64(amount)*types.PercentagePop) + keeper.StoreDistributionOrder(ctx, items[i]) + } + return items +} + +func TestDistributionOrder(t *testing.T) { + keeper, ctx := keepertest.DaoKeeper(t) + items := createNDistributionOrder(keeper, ctx, 10) + for _, item := range items { + challenge, found := keeper.LookupDistributionOrder(ctx, item.LastPop) + assert.True(t, found) + assert.Equal(t, item, challenge) + } + + lastDistribution, found := keeper.GetLastDistributionOrder(ctx) + assert.True(t, found) + assert.Equal(t, items[9], lastDistribution) +} + +func TestTokenDistribution(t *testing.T) { + k, ctx := keepertest.DaoKeeper(t) + var reissuanceValue uint64 = 99869000000 + reissuances := 1000 + var Amount1stBatch uint64 = 781 + var Amount2ndBatch uint64 = 219 + _ = createNReissuances(k, ctx, reissuances) + distribution, err := k.GetDistributionForReissuedTokens(ctx, 780) + assert.Nil(t, err) + amount1, err1 := strconv.ParseUint(distribution.DaoAmount, 10, 64) + amount2, err2 := strconv.ParseUint(distribution.InvestorAmount, 10, 64) + amount3, err3 := strconv.ParseUint(distribution.PopAmount, 10, 64) + assert.Nil(t, err1) + assert.Nil(t, err2) + assert.Nil(t, err3) + sum := amount1 + amount2 + amount3 + expSum := reissuanceValue * Amount1stBatch // add the [0] of the + assert.Equal(t, expSum, sum) + + var lastDistribution types.DistributionOrder + lastDistribution.LastPop = 780 + k.StoreDistributionOrder(ctx, lastDistribution) + lastDistribution, err0 := k.GetDistributionForReissuedTokens(ctx, 999) + assert.Nil(t, err0) + amount1, err1 = strconv.ParseUint(lastDistribution.DaoAmount, 10, 64) + amount2, err2 = strconv.ParseUint(lastDistribution.InvestorAmount, 10, 64) + amount3, err3 = strconv.ParseUint(lastDistribution.PopAmount, 10, 64) + assert.Nil(t, err1) + assert.Nil(t, err2) + assert.Nil(t, err3) + sum = amount1 + amount2 + amount3 + expSum = reissuanceValue * Amount2ndBatch // add the [0] of the + assert.Equal(t, expSum, sum) + assert.Equal(t, uint64(reissuances), Amount1stBatch+Amount2ndBatch) + +} diff --git a/x/dao/keeper/msg_server_distribution_request.go b/x/dao/keeper/msg_server_distribution_request.go new file mode 100644 index 0000000..2d41739 --- /dev/null +++ b/x/dao/keeper/msg_server_distribution_request.go @@ -0,0 +1,43 @@ +package keeper + +import ( + "context" + "strconv" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/util" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func (k msgServer) DistributionRequest(goCtx context.Context, msg *types.MsgDistributionRequest) (*types.MsgDistributionRequestResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + validatorIdentity, validResult := util.GetValidatorCometBFTIdentity(ctx) + if validResult && msg.Distribution.GetProposer() == validatorIdentity { + // issue three distributions: + investorTx, err := util.DistributeAsset(msg.Distribution.InvestorAddr, msg.Distribution.InvestorAmount) + if err != nil { + ctx.Logger().Error("Distribution Request: could not distribute asset to Investors: ", err.Error()) + } + popTx, err := util.DistributeAsset(msg.Distribution.PopAddr, msg.Distribution.PopAmount) + if err != nil { + ctx.Logger().Error("Distribution Request: could not distribute asset to PoP: ", err.Error()) + } + daoTx, err := util.DistributeAsset(msg.Distribution.DaoAddr, msg.Distribution.DaoAmount) + if err != nil { + ctx.Logger().Error("Distribution Request: could not distribute asset to DAO: ", err.Error()) + } + + msg.Distribution.InvestorTxID = investorTx + msg.Distribution.PopTxID = popTx + msg.Distribution.DaoTxID = daoTx + lastPopString := strconv.FormatInt(msg.Distribution.LastPop, 10) + err = util.SendRDDLDistributionResult(ctx, lastPopString, daoTx, investorTx, popTx) + if err != nil { + ctx.Logger().Error("Distribution Request: could not send distribution result ", err.Error()) + } + } + k.StoreDistributionOrder(ctx, *msg.GetDistribution()) + + return &types.MsgDistributionRequestResponse{}, nil +} diff --git a/x/dao/keeper/msg_server_distribution_result.go b/x/dao/keeper/msg_server_distribution_result.go new file mode 100644 index 0000000..4740c3b --- /dev/null +++ b/x/dao/keeper/msg_server_distribution_result.go @@ -0,0 +1,26 @@ +package keeper + +import ( + "context" + "strconv" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func (k msgServer) DistributionResult(goCtx context.Context, msg *types.MsgDistributionResult) (*types.MsgDistributionResultResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + distribution, found := k.LookupDistributionOrder(ctx, msg.GetLastPop()) + if found { + distribution.DaoTxID = msg.DaoTxID + distribution.PopTxID = msg.PopTxID + distribution.InvestorTxID = msg.InvestorTxID + k.StoreDistributionOrder(ctx, distribution) + } else { + return nil, errorsmod.Wrapf(types.ErrDistributionNotFound, " for provided block height %s", strconv.FormatInt(msg.GetLastPop(), 10)) + } + + return &types.MsgDistributionResultResponse{}, nil +} diff --git a/x/dao/keeper/msg_server_reissue_rddl_proposal.go b/x/dao/keeper/msg_server_reissue_rddl_proposal.go index 2e6aaf0..1f60e1d 100644 --- a/x/dao/keeper/msg_server_reissue_rddl_proposal.go +++ b/x/dao/keeper/msg_server_reissue_rddl_proposal.go @@ -23,9 +23,8 @@ func (k msgServer) ReissueRDDLProposal(goCtx context.Context, msg *types.MsgReis _ = util.SendRDDLReissuanceResult(ctx, msg.GetProposer(), txID, msg.GetBlockHeight()) //TODO verify and resolve error } else { - logger.Debug("REISSUE: Asset reissuance failure") + logger.Error("REISSUE: Asset reissuance failure: " + err.Error()) } - //TODO: reissuance need to be initiated otherwise } var reissuance types.Reissuance @@ -33,6 +32,5 @@ func (k msgServer) ReissueRDDLProposal(goCtx context.Context, msg *types.MsgReis reissuance.Proposer = msg.GetProposer() reissuance.Rawtx = msg.GetTx() k.StoreReissuance(ctx, reissuance) - return &types.MsgReissueRDDLProposalResponse{}, nil } diff --git a/x/dao/keeper/msg_server_reissue_rddl_result.go b/x/dao/keeper/msg_server_reissue_rddl_result.go index 3b51c65..4068523 100644 --- a/x/dao/keeper/msg_server_reissue_rddl_result.go +++ b/x/dao/keeper/msg_server_reissue_rddl_result.go @@ -22,10 +22,10 @@ func (k msgServer) ReissueRDDLResult(goCtx context.Context, msg *types.MsgReissu if reissuance.GetProposer() != msg.GetProposer() { return nil, errorsmod.Wrapf(types.ErrInvalidProposer, " for provided block height %s", strconv.FormatInt(msg.GetBlockHeight(), 10)) } - if reissuance.GetTxId() != "" { + if reissuance.GetTxID() != "" { return nil, errorsmod.Wrapf(types.ErrTXAlreadySet, " for provided block height %s", strconv.FormatInt(msg.GetBlockHeight(), 10)) } - reissuance.TxId = msg.GetTxId() + reissuance.TxID = msg.GetTxID() k.StoreReissuance(ctx, reissuance) return &types.MsgReissueRDDLResultResponse{}, nil diff --git a/x/dao/keeper/reissuance.go b/x/dao/keeper/reissuance.go index a50d44f..e5d045b 100644 --- a/x/dao/keeper/reissuance.go +++ b/x/dao/keeper/reissuance.go @@ -8,6 +8,15 @@ import ( "github.com/planetmint/planetmint-go/x/dao/types" ) +func GetReissuanceCommand(assetID string, _ int64) string { + return "reissueasset " + assetID + " 998.69000000" +} + +func IsValidReissuanceCommand(reissuanceStr string, assetID string, _ int64) bool { + expected := "reissueasset " + assetID + " 998.69000000" + return reissuanceStr == expected +} + func (k Keeper) StoreReissuance(ctx sdk.Context, reissuance types.Reissuance) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReissuanceBlockHeightKey)) appendValue := k.cdc.MustMarshal(&reissuance) @@ -24,6 +33,21 @@ func (k Keeper) LookupReissuance(ctx sdk.Context, height int64) (val types.Reiss return val, true } +func (k Keeper) getReissuancesRange(ctx sdk.Context, from int64) (reissuances []types.Reissuance) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReissuanceBlockHeightKey)) + + iterator := store.Iterator(getReissuanceBytes(from), nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + reissuance := iterator.Value() + var reissuanceOrg types.Reissuance + k.cdc.MustUnmarshal(reissuance, &reissuanceOrg) + reissuances = append(reissuances, reissuanceOrg) + } + return reissuances +} + func (k Keeper) getReissuancesPage(ctx sdk.Context, _ []byte, _ uint64, _ uint64, _ bool, reverse bool) (reissuances []types.Reissuance) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReissuanceBlockHeightKey)) diff --git a/x/dao/keeper/reissuance_test.go b/x/dao/keeper/reissuance_test.go index b946d9c..0ea6cdb 100644 --- a/x/dao/keeper/reissuance_test.go +++ b/x/dao/keeper/reissuance_test.go @@ -12,14 +12,14 @@ import ( "github.com/planetmint/planetmint-go/x/dao/types" ) -func createNReissuances(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Reissuance { +func createNReissuances(k *keeper.Keeper, ctx sdk.Context, n int) []types.Reissuance { items := make([]types.Reissuance, n) for i := range items { items[i].BlockHeight = int64(i) items[i].Proposer = fmt.Sprintf("proposer_%v", i) - items[i].Rawtx = fmt.Sprintf("rawtransaction_%v", i) - items[i].TxId = "" - keeper.StoreReissuance(ctx, items[i]) + items[i].Rawtx = keeper.GetReissuanceCommand("asset_id", int64(i)) + items[i].TxID = "" + k.StoreReissuance(ctx, items[i]) } return items } diff --git a/x/dao/module_simulation.go b/x/dao/module_simulation.go index 0a777d2..934eece 100644 --- a/x/dao/module_simulation.go +++ b/x/dao/module_simulation.go @@ -32,10 +32,6 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgReissueRDDLResult int = 100 - opWeightMsgUpdateParams = "op_weight_msg_update_params" - // TODO: Determine the simulation weight value - defaultWeightMsgUpdateParams int = 100 - // this line is used by starport scaffolding # simapp/module/const ) @@ -86,17 +82,6 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp daosimulation.SimulateMsgReissueRDDLResult(am.accountKeeper, am.bankKeeper, am.keeper), )) - var weightMsgUpdateParams int - simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateParams, &weightMsgUpdateParams, nil, - func(_ *rand.Rand) { - weightMsgUpdateParams = defaultWeightMsgUpdateParams - }, - ) - operations = append(operations, simulation.NewWeightedOperation( - weightMsgUpdateParams, - daosimulation.SimulateMsgUpdateParams(am.accountKeeper, am.bankKeeper, am.keeper), - )) - // this line is used by starport scaffolding # simapp/module/operation return operations @@ -121,14 +106,6 @@ func (am AppModule) ProposalMsgs(_ module.SimulationState) []simtypes.WeightedPr return nil }, ), - simulation.NewWeightedProposalMsg( - opWeightMsgUpdateParams, - defaultWeightMsgUpdateParams, - func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { - daosimulation.SimulateMsgUpdateParams(am.accountKeeper, am.bankKeeper, am.keeper) - return nil - }, - ), // this line is used by starport scaffolding # simapp/module/OpMsg } } diff --git a/x/dao/simulation/distribution_request.go b/x/dao/simulation/distribution_request.go new file mode 100644 index 0000000..a775696 --- /dev/null +++ b/x/dao/simulation/distribution_request.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/planetmint/planetmint-go/x/dao/keeper" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func SimulateMsgDistributionRequest( + _ types.AccountKeeper, + _ types.BankKeeper, + _ keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgDistributionRequest{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the DistributionRequest simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "DistributionRequest simulation not implemented"), nil, nil + } +} diff --git a/x/dao/simulation/distribution_result.go b/x/dao/simulation/distribution_result.go new file mode 100644 index 0000000..362d35e --- /dev/null +++ b/x/dao/simulation/distribution_result.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/planetmint/planetmint-go/x/dao/keeper" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func SimulateMsgDistributionResult( + _ types.AccountKeeper, + _ types.BankKeeper, + _ keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgDistributionResult{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the DistributionResult simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "DistributionResult simulation not implemented"), nil, nil + } +} diff --git a/x/dao/types/codec.go b/x/dao/types/codec.go index 02640af..cbd6cf0 100644 --- a/x/dao/types/codec.go +++ b/x/dao/types/codec.go @@ -11,6 +11,8 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgReissueRDDLProposal{}, "dao/ReissueRDDLProposal", nil) cdc.RegisterConcrete(&MsgMintToken{}, "dao/MintToken", nil) cdc.RegisterConcrete(&MsgReissueRDDLResult{}, "dao/ReissueRDDLResult", nil) + cdc.RegisterConcrete(&MsgDistributionResult{}, "dao/DistributionResult", nil) + cdc.RegisterConcrete(&MsgDistributionRequest{}, "dao/DistributionRequest", nil) cdc.RegisterConcrete(&MsgUpdateParams{}, "dao/UpdateParams", nil) // this line is used by starport scaffolding # 2 } @@ -24,6 +26,8 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgReissueRDDLResult{}, ) registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgDistributionResult{}, + &MsgDistributionRequest{}, &MsgUpdateParams{}, ) // this line is used by starport scaffolding # 3 diff --git a/x/dao/types/constants.go b/x/dao/types/constants.go new file mode 100644 index 0000000..cdf1aa9 --- /dev/null +++ b/x/dao/types/constants.go @@ -0,0 +1,5 @@ +package types + +const PercentageDao float64 = 0.61 +const PercentageInvestor float64 = 0.31 +const PercentagePop float64 = 0.08 diff --git a/x/dao/types/distribution_order.pb.go b/x/dao/types/distribution_order.pb.go new file mode 100644 index 0000000..d672ae4 --- /dev/null +++ b/x/dao/types/distribution_order.pb.go @@ -0,0 +1,855 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: planetmintgo/dao/distribution_order.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type DistributionOrder struct { + DaoAddr string `protobuf:"bytes,1,opt,name=daoAddr,proto3" json:"daoAddr,omitempty"` + DaoAmount string `protobuf:"bytes,2,opt,name=daoAmount,proto3" json:"daoAmount,omitempty"` + DaoTxID string `protobuf:"bytes,3,opt,name=daoTxID,proto3" json:"daoTxID,omitempty"` + InvestorAddr string `protobuf:"bytes,4,opt,name=investorAddr,proto3" json:"investorAddr,omitempty"` + InvestorAmount string `protobuf:"bytes,5,opt,name=investorAmount,proto3" json:"investorAmount,omitempty"` + InvestorTxID string `protobuf:"bytes,6,opt,name=investorTxID,proto3" json:"investorTxID,omitempty"` + PopAddr string `protobuf:"bytes,7,opt,name=popAddr,proto3" json:"popAddr,omitempty"` + PopAmount string `protobuf:"bytes,8,opt,name=popAmount,proto3" json:"popAmount,omitempty"` + PopTxID string `protobuf:"bytes,9,opt,name=popTxID,proto3" json:"popTxID,omitempty"` + FirstPop int64 `protobuf:"varint,10,opt,name=firstPop,proto3" json:"firstPop,omitempty"` + LastPop int64 `protobuf:"varint,11,opt,name=lastPop,proto3" json:"lastPop,omitempty"` + Proposer string `protobuf:"bytes,12,opt,name=proposer,proto3" json:"proposer,omitempty"` +} + +func (m *DistributionOrder) Reset() { *m = DistributionOrder{} } +func (m *DistributionOrder) String() string { return proto.CompactTextString(m) } +func (*DistributionOrder) ProtoMessage() {} +func (*DistributionOrder) Descriptor() ([]byte, []int) { + return fileDescriptor_2bd326325e0d716d, []int{0} +} +func (m *DistributionOrder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DistributionOrder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DistributionOrder.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 *DistributionOrder) XXX_Merge(src proto.Message) { + xxx_messageInfo_DistributionOrder.Merge(m, src) +} +func (m *DistributionOrder) XXX_Size() int { + return m.Size() +} +func (m *DistributionOrder) XXX_DiscardUnknown() { + xxx_messageInfo_DistributionOrder.DiscardUnknown(m) +} + +var xxx_messageInfo_DistributionOrder proto.InternalMessageInfo + +func (m *DistributionOrder) GetDaoAddr() string { + if m != nil { + return m.DaoAddr + } + return "" +} + +func (m *DistributionOrder) GetDaoAmount() string { + if m != nil { + return m.DaoAmount + } + return "" +} + +func (m *DistributionOrder) GetDaoTxID() string { + if m != nil { + return m.DaoTxID + } + return "" +} + +func (m *DistributionOrder) GetInvestorAddr() string { + if m != nil { + return m.InvestorAddr + } + return "" +} + +func (m *DistributionOrder) GetInvestorAmount() string { + if m != nil { + return m.InvestorAmount + } + return "" +} + +func (m *DistributionOrder) GetInvestorTxID() string { + if m != nil { + return m.InvestorTxID + } + return "" +} + +func (m *DistributionOrder) GetPopAddr() string { + if m != nil { + return m.PopAddr + } + return "" +} + +func (m *DistributionOrder) GetPopAmount() string { + if m != nil { + return m.PopAmount + } + return "" +} + +func (m *DistributionOrder) GetPopTxID() string { + if m != nil { + return m.PopTxID + } + return "" +} + +func (m *DistributionOrder) GetFirstPop() int64 { + if m != nil { + return m.FirstPop + } + return 0 +} + +func (m *DistributionOrder) GetLastPop() int64 { + if m != nil { + return m.LastPop + } + return 0 +} + +func (m *DistributionOrder) GetProposer() string { + if m != nil { + return m.Proposer + } + return "" +} + +func init() { + proto.RegisterType((*DistributionOrder)(nil), "planetmintgo.dao.DistributionOrder") +} + +func init() { + proto.RegisterFile("planetmintgo/dao/distribution_order.proto", fileDescriptor_2bd326325e0d716d) +} + +var fileDescriptor_2bd326325e0d716d = []byte{ + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x51, 0xbf, 0x4e, 0xf3, 0x30, + 0x10, 0xaf, 0xdb, 0xef, 0x6b, 0x1b, 0x53, 0x21, 0xc8, 0x64, 0x21, 0x64, 0x55, 0x1d, 0x50, 0x19, + 0x48, 0x06, 0x9e, 0x00, 0xd4, 0xa5, 0x13, 0xa8, 0x62, 0x62, 0x41, 0x09, 0x0e, 0xc1, 0x52, 0x93, + 0xb3, 0x1c, 0x07, 0x95, 0xb7, 0xe0, 0xb1, 0x18, 0x3b, 0x32, 0xa2, 0xe4, 0x29, 0xd8, 0x90, 0x2f, + 0xa9, 0x9b, 0xb2, 0xdd, 0xef, 0x7e, 0xff, 0x6c, 0x1d, 0xbd, 0x54, 0xeb, 0x28, 0x4f, 0x4c, 0x26, + 0x73, 0x93, 0x42, 0x28, 0x22, 0x08, 0x85, 0x2c, 0x8c, 0x96, 0x71, 0x69, 0x24, 0xe4, 0x4f, 0xa0, + 0x45, 0xa2, 0x03, 0xa5, 0xc1, 0x80, 0x7f, 0xd2, 0x95, 0x06, 0x22, 0x82, 0xd9, 0x4f, 0x9f, 0x9e, + 0x2e, 0x3a, 0xf2, 0x3b, 0xab, 0xf6, 0x19, 0x1d, 0x89, 0x08, 0x6e, 0x84, 0xd0, 0x8c, 0x4c, 0xc9, + 0xdc, 0x5b, 0xed, 0xa0, 0x7f, 0x4e, 0x3d, 0x3b, 0x66, 0x50, 0xe6, 0x86, 0xf5, 0x91, 0xdb, 0x2f, + 0x5a, 0xdf, 0xc3, 0x66, 0xb9, 0x60, 0x03, 0xe7, 0xb3, 0xd0, 0x9f, 0xd1, 0x89, 0xcc, 0xdf, 0x92, + 0xc2, 0x80, 0xc6, 0xd8, 0x7f, 0x48, 0x1f, 0xec, 0xfc, 0x0b, 0x7a, 0xec, 0x70, 0x53, 0xf0, 0x1f, + 0x55, 0x7f, 0xb6, 0xdd, 0x2c, 0xac, 0x1a, 0x1e, 0x66, 0x61, 0x1f, 0xa3, 0x23, 0x05, 0x0a, 0xab, + 0x46, 0xcd, 0x4b, 0x5a, 0x68, 0x7f, 0x60, 0xc7, 0xa6, 0x60, 0xdc, 0xfc, 0xc0, 0x2d, 0x5a, 0x1f, + 0xc6, 0x7a, 0xce, 0x87, 0x89, 0x67, 0x74, 0xfc, 0x22, 0x75, 0x61, 0xee, 0x41, 0x31, 0x3a, 0x25, + 0xf3, 0xc1, 0xca, 0x61, 0xeb, 0x5a, 0x47, 0x0d, 0x75, 0x84, 0xd4, 0x0e, 0x5a, 0x97, 0xd2, 0xa0, + 0xa0, 0x48, 0x34, 0x9b, 0x60, 0xa0, 0xc3, 0xb7, 0xcb, 0xcf, 0x8a, 0x93, 0x6d, 0xc5, 0xc9, 0x77, + 0xc5, 0xc9, 0x47, 0xcd, 0x7b, 0xdb, 0x9a, 0xf7, 0xbe, 0x6a, 0xde, 0x7b, 0x0c, 0x53, 0x69, 0x5e, + 0xcb, 0x38, 0x78, 0x86, 0x2c, 0xdc, 0x9f, 0xac, 0x33, 0x5e, 0xa5, 0x10, 0x6e, 0xf0, 0xd6, 0xe6, + 0x5d, 0x25, 0x45, 0x3c, 0xc4, 0xfb, 0x5e, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x44, 0x71, 0x90, + 0x55, 0x0c, 0x02, 0x00, 0x00, +} + +func (m *DistributionOrder) 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 *DistributionOrder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DistributionOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Proposer) > 0 { + i -= len(m.Proposer) + copy(dAtA[i:], m.Proposer) + i = encodeVarintDistributionOrder(dAtA, i, uint64(len(m.Proposer))) + i-- + dAtA[i] = 0x62 + } + if m.LastPop != 0 { + i = encodeVarintDistributionOrder(dAtA, i, uint64(m.LastPop)) + i-- + dAtA[i] = 0x58 + } + if m.FirstPop != 0 { + i = encodeVarintDistributionOrder(dAtA, i, uint64(m.FirstPop)) + i-- + dAtA[i] = 0x50 + } + if len(m.PopTxID) > 0 { + i -= len(m.PopTxID) + copy(dAtA[i:], m.PopTxID) + i = encodeVarintDistributionOrder(dAtA, i, uint64(len(m.PopTxID))) + i-- + dAtA[i] = 0x4a + } + if len(m.PopAmount) > 0 { + i -= len(m.PopAmount) + copy(dAtA[i:], m.PopAmount) + i = encodeVarintDistributionOrder(dAtA, i, uint64(len(m.PopAmount))) + i-- + dAtA[i] = 0x42 + } + if len(m.PopAddr) > 0 { + i -= len(m.PopAddr) + copy(dAtA[i:], m.PopAddr) + i = encodeVarintDistributionOrder(dAtA, i, uint64(len(m.PopAddr))) + i-- + dAtA[i] = 0x3a + } + if len(m.InvestorTxID) > 0 { + i -= len(m.InvestorTxID) + copy(dAtA[i:], m.InvestorTxID) + i = encodeVarintDistributionOrder(dAtA, i, uint64(len(m.InvestorTxID))) + i-- + dAtA[i] = 0x32 + } + if len(m.InvestorAmount) > 0 { + i -= len(m.InvestorAmount) + copy(dAtA[i:], m.InvestorAmount) + i = encodeVarintDistributionOrder(dAtA, i, uint64(len(m.InvestorAmount))) + i-- + dAtA[i] = 0x2a + } + if len(m.InvestorAddr) > 0 { + i -= len(m.InvestorAddr) + copy(dAtA[i:], m.InvestorAddr) + i = encodeVarintDistributionOrder(dAtA, i, uint64(len(m.InvestorAddr))) + i-- + dAtA[i] = 0x22 + } + if len(m.DaoTxID) > 0 { + i -= len(m.DaoTxID) + copy(dAtA[i:], m.DaoTxID) + i = encodeVarintDistributionOrder(dAtA, i, uint64(len(m.DaoTxID))) + i-- + dAtA[i] = 0x1a + } + if len(m.DaoAmount) > 0 { + i -= len(m.DaoAmount) + copy(dAtA[i:], m.DaoAmount) + i = encodeVarintDistributionOrder(dAtA, i, uint64(len(m.DaoAmount))) + i-- + dAtA[i] = 0x12 + } + if len(m.DaoAddr) > 0 { + i -= len(m.DaoAddr) + copy(dAtA[i:], m.DaoAddr) + i = encodeVarintDistributionOrder(dAtA, i, uint64(len(m.DaoAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintDistributionOrder(dAtA []byte, offset int, v uint64) int { + offset -= sovDistributionOrder(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DistributionOrder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DaoAddr) + if l > 0 { + n += 1 + l + sovDistributionOrder(uint64(l)) + } + l = len(m.DaoAmount) + if l > 0 { + n += 1 + l + sovDistributionOrder(uint64(l)) + } + l = len(m.DaoTxID) + if l > 0 { + n += 1 + l + sovDistributionOrder(uint64(l)) + } + l = len(m.InvestorAddr) + if l > 0 { + n += 1 + l + sovDistributionOrder(uint64(l)) + } + l = len(m.InvestorAmount) + if l > 0 { + n += 1 + l + sovDistributionOrder(uint64(l)) + } + l = len(m.InvestorTxID) + if l > 0 { + n += 1 + l + sovDistributionOrder(uint64(l)) + } + l = len(m.PopAddr) + if l > 0 { + n += 1 + l + sovDistributionOrder(uint64(l)) + } + l = len(m.PopAmount) + if l > 0 { + n += 1 + l + sovDistributionOrder(uint64(l)) + } + l = len(m.PopTxID) + if l > 0 { + n += 1 + l + sovDistributionOrder(uint64(l)) + } + if m.FirstPop != 0 { + n += 1 + sovDistributionOrder(uint64(m.FirstPop)) + } + if m.LastPop != 0 { + n += 1 + sovDistributionOrder(uint64(m.LastPop)) + } + l = len(m.Proposer) + if l > 0 { + n += 1 + l + sovDistributionOrder(uint64(l)) + } + return n +} + +func sovDistributionOrder(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDistributionOrder(x uint64) (n int) { + return sovDistributionOrder(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DistributionOrder) 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 ErrIntOverflowDistributionOrder + } + 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: DistributionOrder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DistributionOrder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DaoAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + 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 ErrInvalidLengthDistributionOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistributionOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DaoAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DaoAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + 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 ErrInvalidLengthDistributionOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistributionOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DaoAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DaoTxID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + 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 ErrInvalidLengthDistributionOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistributionOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DaoTxID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InvestorAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + 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 ErrInvalidLengthDistributionOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistributionOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InvestorAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InvestorAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + 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 ErrInvalidLengthDistributionOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistributionOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InvestorAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InvestorTxID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + 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 ErrInvalidLengthDistributionOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistributionOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InvestorTxID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PopAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + 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 ErrInvalidLengthDistributionOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistributionOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PopAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PopAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + 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 ErrInvalidLengthDistributionOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistributionOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PopAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PopTxID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + 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 ErrInvalidLengthDistributionOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistributionOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PopTxID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FirstPop", wireType) + } + m.FirstPop = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FirstPop |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastPop", wireType) + } + m.LastPop = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastPop |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proposer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionOrder + } + 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 ErrInvalidLengthDistributionOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistributionOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proposer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDistributionOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistributionOrder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDistributionOrder(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, ErrIntOverflowDistributionOrder + } + 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, ErrIntOverflowDistributionOrder + } + 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, ErrIntOverflowDistributionOrder + } + 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, ErrInvalidLengthDistributionOrder + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDistributionOrder + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDistributionOrder + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDistributionOrder = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDistributionOrder = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDistributionOrder = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dao/types/errors.go b/x/dao/types/errors.go index e5c85d2..5eac42a 100644 --- a/x/dao/types/errors.go +++ b/x/dao/types/errors.go @@ -8,15 +8,16 @@ import ( // x/dao module sentinel errors var ( - ErrInvalidMintAddress = errorsmod.Register(ModuleName, 2, "invalid mint address") - ErrMintFailed = errorsmod.Register(ModuleName, 3, "minting failed") - ErrTransferFailed = errorsmod.Register(ModuleName, 4, "transfer failed") - ErrInvalidAddress = errorsmod.Register(ModuleName, 5, "invalid address") - ErrAlreadyMinted = errorsmod.Register(ModuleName, 6, "already minted") - ErrWrongBlockHeight = errorsmod.Register(ModuleName, 7, "wrong block height") - ErrReissuanceNotFound = errorsmod.Register(ModuleName, 8, "reissuance not found") - ErrInvalidProposer = errorsmod.Register(ModuleName, 9, "invalid proposer") - ErrTXAlreadySet = errorsmod.Register(ModuleName, 10, "tx already set") - ErrReissuanceProposal = errorsmod.Register(ModuleName, 11, "invalid reissuance proposal") - ErrReissuanceFailed = errorsmod.Register(ModuleName, 12, "reissuance of RDDL failed") + ErrInvalidMintAddress = errorsmod.Register(ModuleName, 2, "invalid mint address") + ErrMintFailed = errorsmod.Register(ModuleName, 3, "minting failed") + ErrTransferFailed = errorsmod.Register(ModuleName, 4, "transfer failed") + ErrInvalidAddress = errorsmod.Register(ModuleName, 5, "invalid address") + ErrAlreadyMinted = errorsmod.Register(ModuleName, 6, "already minted") + ErrWrongBlockHeight = errorsmod.Register(ModuleName, 7, "wrong block height") + ErrReissuanceNotFound = errorsmod.Register(ModuleName, 8, "reissuance not found") + ErrInvalidProposer = errorsmod.Register(ModuleName, 9, "invalid proposer") + ErrTXAlreadySet = errorsmod.Register(ModuleName, 10, "tx already set") + ErrReissuanceProposal = errorsmod.Register(ModuleName, 11, "invalid reissuance proposal") + ErrReissuanceFailed = errorsmod.Register(ModuleName, 12, "reissuance of RDDL failed") + ErrDistributionNotFound = errorsmod.Register(ModuleName, 13, "distribution not found") ) diff --git a/x/dao/types/keys.go b/x/dao/types/keys.go index a2328d0..9c2e4c0 100644 --- a/x/dao/types/keys.go +++ b/x/dao/types/keys.go @@ -21,6 +21,10 @@ const ( ReissuanceBlockHeightKey = "Dao/ReissuanceBlockHeight" + DistributionKey = "Dao/Distribution" + + PoPDistributionKey = "Dao/PoPDistribution" + ParamsKey = "Dao/Params" ) diff --git a/x/dao/types/message_distribution_request.go b/x/dao/types/message_distribution_request.go new file mode 100644 index 0000000..037befc --- /dev/null +++ b/x/dao/types/message_distribution_request.go @@ -0,0 +1,47 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgDistributionRequest = "distribution_request" + +var _ sdk.Msg = &MsgDistributionRequest{} + +func NewMsgDistributionRequest(creator string, distribution *DistributionOrder) *MsgDistributionRequest { + return &MsgDistributionRequest{ + Creator: creator, + Distribution: distribution, + } +} + +func (msg *MsgDistributionRequest) Route() string { + return RouterKey +} + +func (msg *MsgDistributionRequest) Type() string { + return TypeMsgDistributionRequest +} + +func (msg *MsgDistributionRequest) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgDistributionRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgDistributionRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/dao/types/message_distribution_result.go b/x/dao/types/message_distribution_result.go new file mode 100644 index 0000000..16848d1 --- /dev/null +++ b/x/dao/types/message_distribution_result.go @@ -0,0 +1,50 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgDistributionResult = "distribution_result" + +var _ sdk.Msg = &MsgDistributionResult{} + +func NewMsgDistributionResult(creator string, lastPop int64, daoTxID string, investorTxID string, popTxID string) *MsgDistributionResult { + return &MsgDistributionResult{ + Creator: creator, + LastPop: lastPop, + DaoTxID: daoTxID, + InvestorTxID: investorTxID, + PopTxID: popTxID, + } +} + +func (msg *MsgDistributionResult) Route() string { + return RouterKey +} + +func (msg *MsgDistributionResult) Type() string { + return TypeMsgDistributionResult +} + +func (msg *MsgDistributionResult) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgDistributionResult) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgDistributionResult) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/dao/types/message_reissue_rddl_proposal_test.go b/x/dao/types/message_reissue_rddl_proposal_test.go deleted file mode 100644 index 2a39bae..0000000 --- a/x/dao/types/message_reissue_rddl_proposal_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package types - -import ( - "testing" - - "github.com/cometbft/cometbft/crypto/ed25519" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" -) - -func AccAddress() string { - pk := ed25519.GenPrivKey().PubKey() - addr := pk.Address() - return sdk.AccAddress(addr).String() -} - -func TestMsgReissueRDDLProposal_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgReissueRDDLProposal - err error - }{ - { - name: "invalid address", - msg: MsgReissueRDDLProposal{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", - msg: MsgReissueRDDLProposal{ - Creator: AccAddress(), - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} diff --git a/x/dao/types/message_reissue_rddl_result.go b/x/dao/types/message_reissue_rddl_result.go index 6f18608..e1a92f8 100644 --- a/x/dao/types/message_reissue_rddl_result.go +++ b/x/dao/types/message_reissue_rddl_result.go @@ -14,7 +14,7 @@ func NewMsgReissueRDDLResult(creator string, proposer string, txID string, block return &MsgReissueRDDLResult{ Creator: creator, Proposer: proposer, - TxId: txID, + TxID: txID, BlockHeight: blockHeight, } } diff --git a/x/dao/types/message_reissue_rddl_result_test.go b/x/dao/types/message_reissue_rddl_result_test.go deleted file mode 100644 index 2ad24f6..0000000 --- a/x/dao/types/message_reissue_rddl_result_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package types - -import ( - "testing" - - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" -) - -func TestMsgReissueRDDLResult_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgReissueRDDLResult - err error - }{ - { - name: "invalid address", - msg: MsgReissueRDDLResult{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", - msg: MsgReissueRDDLResult{ - Creator: AccAddress(), - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} diff --git a/x/dao/types/reissuance.pb.go b/x/dao/types/reissuance.pb.go index 0ee80bb..51e005f 100644 --- a/x/dao/types/reissuance.pb.go +++ b/x/dao/types/reissuance.pb.go @@ -25,7 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Reissuance struct { Proposer string `protobuf:"bytes,1,opt,name=proposer,proto3" json:"proposer,omitempty"` Rawtx string `protobuf:"bytes,2,opt,name=rawtx,proto3" json:"rawtx,omitempty"` - TxId string `protobuf:"bytes,3,opt,name=txId,proto3" json:"txId,omitempty"` + TxID string `protobuf:"bytes,3,opt,name=txID,proto3" json:"txID,omitempty"` BlockHeight int64 `protobuf:"varint,4,opt,name=blockHeight,proto3" json:"blockHeight,omitempty"` } @@ -76,9 +76,9 @@ func (m *Reissuance) GetRawtx() string { return "" } -func (m *Reissuance) GetTxId() string { +func (m *Reissuance) GetTxID() string { if m != nil { - return m.TxId + return m.TxID } return "" } @@ -104,13 +104,13 @@ var fileDescriptor_35cf062bd4436e27 = []byte{ 0x56, 0xa2, 0x97, 0x92, 0x98, 0xaf, 0x54, 0xc2, 0xc5, 0x15, 0x04, 0x57, 0x25, 0x24, 0xc5, 0xc5, 0x51, 0x50, 0x94, 0x5f, 0x90, 0x5f, 0x9c, 0x5a, 0x24, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe7, 0x0b, 0x89, 0x70, 0xb1, 0x16, 0x25, 0x96, 0x97, 0x54, 0x48, 0x30, 0x81, 0x25, 0x20, 0x1c, - 0x21, 0x21, 0x2e, 0x96, 0x92, 0x0a, 0xcf, 0x14, 0x09, 0x66, 0xb0, 0x20, 0x98, 0x2d, 0xa4, 0xc0, + 0x21, 0x21, 0x2e, 0x96, 0x92, 0x0a, 0x4f, 0x17, 0x09, 0x66, 0xb0, 0x20, 0x98, 0x2d, 0xa4, 0xc0, 0xc5, 0x9d, 0x94, 0x93, 0x9f, 0x9c, 0xed, 0x91, 0x9a, 0x99, 0x9e, 0x51, 0x22, 0xc1, 0xa2, 0xc0, 0xa8, 0xc1, 0x1c, 0x84, 0x2c, 0xe4, 0xe4, 0x79, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xfa, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x08, 0xc7, 0x22, 0x31, 0x75, 0xd3, 0xf3, 0xf5, 0x2b, 0xc0, 0xbe, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, - 0x03, 0xfb, 0xcc, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xb7, 0xaf, 0x8f, 0xce, 0xfe, 0x00, 0x00, + 0x03, 0xfb, 0xcc, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x56, 0x20, 0xa3, 0x6c, 0xfe, 0x00, 0x00, 0x00, } @@ -139,10 +139,10 @@ func (m *Reissuance) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if len(m.TxId) > 0 { - i -= len(m.TxId) - copy(dAtA[i:], m.TxId) - i = encodeVarintReissuance(dAtA, i, uint64(len(m.TxId))) + if len(m.TxID) > 0 { + i -= len(m.TxID) + copy(dAtA[i:], m.TxID) + i = encodeVarintReissuance(dAtA, i, uint64(len(m.TxID))) i-- dAtA[i] = 0x1a } @@ -188,7 +188,7 @@ func (m *Reissuance) Size() (n int) { if l > 0 { n += 1 + l + sovReissuance(uint64(l)) } - l = len(m.TxId) + l = len(m.TxID) if l > 0 { n += 1 + l + sovReissuance(uint64(l)) } @@ -299,7 +299,7 @@ func (m *Reissuance) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TxId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TxID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -327,7 +327,7 @@ func (m *Reissuance) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TxId = string(dAtA[iNdEx:postIndex]) + m.TxID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 0 { diff --git a/x/dao/types/tx.pb.go b/x/dao/types/tx.pb.go index 74f323a..8eee923 100644 --- a/x/dao/types/tx.pb.go +++ b/x/dao/types/tx.pb.go @@ -226,7 +226,7 @@ var xxx_messageInfo_MsgMintTokenResponse proto.InternalMessageInfo type MsgReissueRDDLResult struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` Proposer string `protobuf:"bytes,2,opt,name=proposer,proto3" json:"proposer,omitempty"` - TxId string `protobuf:"bytes,3,opt,name=txId,proto3" json:"txId,omitempty"` + TxID string `protobuf:"bytes,3,opt,name=txID,proto3" json:"txID,omitempty"` BlockHeight int64 `protobuf:"varint,4,opt,name=blockHeight,proto3" json:"blockHeight,omitempty"` } @@ -277,9 +277,9 @@ func (m *MsgReissueRDDLResult) GetProposer() string { return "" } -func (m *MsgReissueRDDLResult) GetTxId() string { +func (m *MsgReissueRDDLResult) GetTxID() string { if m != nil { - return m.TxId + return m.TxID } return "" } @@ -327,6 +327,206 @@ func (m *MsgReissueRDDLResultResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgReissueRDDLResultResponse proto.InternalMessageInfo +type MsgDistributionResult struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + LastPop int64 `protobuf:"varint,2,opt,name=lastPop,proto3" json:"lastPop,omitempty"` + DaoTxID string `protobuf:"bytes,3,opt,name=daoTxID,proto3" json:"daoTxID,omitempty"` + InvestorTxID string `protobuf:"bytes,4,opt,name=investorTxID,proto3" json:"investorTxID,omitempty"` + PopTxID string `protobuf:"bytes,5,opt,name=popTxID,proto3" json:"popTxID,omitempty"` +} + +func (m *MsgDistributionResult) Reset() { *m = MsgDistributionResult{} } +func (m *MsgDistributionResult) String() string { return proto.CompactTextString(m) } +func (*MsgDistributionResult) ProtoMessage() {} +func (*MsgDistributionResult) Descriptor() ([]byte, []int) { + return fileDescriptor_7117c47dbc1828c7, []int{6} +} +func (m *MsgDistributionResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDistributionResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDistributionResult.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 *MsgDistributionResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDistributionResult.Merge(m, src) +} +func (m *MsgDistributionResult) XXX_Size() int { + return m.Size() +} +func (m *MsgDistributionResult) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDistributionResult.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDistributionResult proto.InternalMessageInfo + +func (m *MsgDistributionResult) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgDistributionResult) GetLastPop() int64 { + if m != nil { + return m.LastPop + } + return 0 +} + +func (m *MsgDistributionResult) GetDaoTxID() string { + if m != nil { + return m.DaoTxID + } + return "" +} + +func (m *MsgDistributionResult) GetInvestorTxID() string { + if m != nil { + return m.InvestorTxID + } + return "" +} + +func (m *MsgDistributionResult) GetPopTxID() string { + if m != nil { + return m.PopTxID + } + return "" +} + +type MsgDistributionResultResponse struct { +} + +func (m *MsgDistributionResultResponse) Reset() { *m = MsgDistributionResultResponse{} } +func (m *MsgDistributionResultResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDistributionResultResponse) ProtoMessage() {} +func (*MsgDistributionResultResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7117c47dbc1828c7, []int{7} +} +func (m *MsgDistributionResultResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDistributionResultResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDistributionResultResponse.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 *MsgDistributionResultResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDistributionResultResponse.Merge(m, src) +} +func (m *MsgDistributionResultResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDistributionResultResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDistributionResultResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDistributionResultResponse proto.InternalMessageInfo + +type MsgDistributionRequest struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Distribution *DistributionOrder `protobuf:"bytes,2,opt,name=distribution,proto3" json:"distribution,omitempty"` +} + +func (m *MsgDistributionRequest) Reset() { *m = MsgDistributionRequest{} } +func (m *MsgDistributionRequest) String() string { return proto.CompactTextString(m) } +func (*MsgDistributionRequest) ProtoMessage() {} +func (*MsgDistributionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_7117c47dbc1828c7, []int{8} +} +func (m *MsgDistributionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDistributionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDistributionRequest.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 *MsgDistributionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDistributionRequest.Merge(m, src) +} +func (m *MsgDistributionRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgDistributionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDistributionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDistributionRequest proto.InternalMessageInfo + +func (m *MsgDistributionRequest) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgDistributionRequest) GetDistribution() *DistributionOrder { + if m != nil { + return m.Distribution + } + return nil +} + +type MsgDistributionRequestResponse struct { +} + +func (m *MsgDistributionRequestResponse) Reset() { *m = MsgDistributionRequestResponse{} } +func (m *MsgDistributionRequestResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDistributionRequestResponse) ProtoMessage() {} +func (*MsgDistributionRequestResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7117c47dbc1828c7, []int{9} +} +func (m *MsgDistributionRequestResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDistributionRequestResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDistributionRequestResponse.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 *MsgDistributionRequestResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDistributionRequestResponse.Merge(m, src) +} +func (m *MsgDistributionRequestResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDistributionRequestResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDistributionRequestResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDistributionRequestResponse proto.InternalMessageInfo + type MsgUpdateParams struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` @@ -340,7 +540,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_7117c47dbc1828c7, []int{6} + return fileDescriptor_7117c47dbc1828c7, []int{10} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -390,7 +590,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7117c47dbc1828c7, []int{7} + return fileDescriptor_7117c47dbc1828c7, []int{11} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -426,6 +626,10 @@ func init() { proto.RegisterType((*MsgMintTokenResponse)(nil), "planetmintgo.dao.MsgMintTokenResponse") proto.RegisterType((*MsgReissueRDDLResult)(nil), "planetmintgo.dao.MsgReissueRDDLResult") proto.RegisterType((*MsgReissueRDDLResultResponse)(nil), "planetmintgo.dao.MsgReissueRDDLResultResponse") + proto.RegisterType((*MsgDistributionResult)(nil), "planetmintgo.dao.MsgDistributionResult") + proto.RegisterType((*MsgDistributionResultResponse)(nil), "planetmintgo.dao.MsgDistributionResultResponse") + proto.RegisterType((*MsgDistributionRequest)(nil), "planetmintgo.dao.MsgDistributionRequest") + proto.RegisterType((*MsgDistributionRequestResponse)(nil), "planetmintgo.dao.MsgDistributionRequestResponse") proto.RegisterType((*MsgUpdateParams)(nil), "planetmintgo.dao.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "planetmintgo.dao.MsgUpdateParamsResponse") } @@ -433,43 +637,52 @@ func init() { func init() { proto.RegisterFile("planetmintgo/dao/tx.proto", fileDescriptor_7117c47dbc1828c7) } var fileDescriptor_7117c47dbc1828c7 = []byte{ - // 564 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xce, 0x26, 0xa5, 0x9a, 0x97, 0x52, 0xed, 0x1a, 0xda, 0xcd, 0x62, 0xd7, 0x18, 0xa1, 0xc4, - 0x42, 0x77, 0xb5, 0x82, 0x07, 0x3d, 0x88, 0xa1, 0x07, 0x0b, 0x2e, 0x94, 0xad, 0x5e, 0x44, 0x28, - 0x93, 0xec, 0x30, 0x59, 0x92, 0xdd, 0xd9, 0xce, 0x4c, 0x24, 0xbd, 0x49, 0x7f, 0x81, 0x27, 0xf1, - 0x27, 0x78, 0xec, 0xc1, 0x1f, 0xd1, 0x63, 0xf1, 0xe4, 0x49, 0x24, 0x39, 0xf4, 0x6f, 0x48, 0x66, - 0x36, 0x9b, 0xb5, 0x59, 0xda, 0xe0, 0x25, 0x79, 0xef, 0x7d, 0xdf, 0x7b, 0xef, 0xe3, 0xcd, 0xc7, - 0x42, 0x2d, 0xee, 0xa3, 0x08, 0x8b, 0x30, 0x88, 0x04, 0xa1, 0x8e, 0x8f, 0xa8, 0x23, 0x86, 0x76, - 0xcc, 0xa8, 0xa0, 0xfa, 0xdd, 0x2c, 0x64, 0xfb, 0x88, 0x9a, 0x8f, 0xe6, 0xc8, 0x93, 0xf0, 0x88, - 0xe1, 0xe3, 0x01, 0xe6, 0x42, 0xb5, 0x99, 0x9b, 0x73, 0xa4, 0x18, 0x31, 0x14, 0xf2, 0x04, 0x5e, - 0x43, 0x61, 0x10, 0x51, 0x47, 0xfe, 0x26, 0xa5, 0x2a, 0xa1, 0x84, 0xca, 0xd0, 0x99, 0x44, 0x49, - 0xb5, 0xd6, 0xa1, 0x3c, 0xa4, 0xfc, 0x48, 0x01, 0x2a, 0x49, 0xa0, 0x0d, 0x95, 0x39, 0x21, 0x27, - 0xce, 0xa7, 0xa7, 0x93, 0x3f, 0x05, 0x34, 0x3e, 0x6b, 0xb0, 0xee, 0x72, 0xe2, 0xe1, 0x80, 0xf3, - 0x01, 0xf6, 0xf6, 0xf6, 0xde, 0x1e, 0x30, 0x1a, 0x53, 0x8e, 0xfa, 0xba, 0x01, 0xb7, 0x3a, 0x0c, - 0x23, 0x41, 0x99, 0xa1, 0xd5, 0xb5, 0x66, 0xd9, 0x9b, 0xa6, 0xba, 0x09, 0xb7, 0x63, 0xc9, 0xc2, - 0xcc, 0x28, 0x4a, 0x28, 0xcd, 0xf5, 0x55, 0x28, 0x8a, 0xa1, 0x51, 0x92, 0xd5, 0xa2, 0x18, 0xea, - 0x75, 0xa8, 0xb4, 0xfb, 0xb4, 0xd3, 0x7b, 0x83, 0x03, 0xd2, 0x15, 0xc6, 0x52, 0x5d, 0x6b, 0x96, - 0xbc, 0x6c, 0xa9, 0x51, 0x07, 0x2b, 0x5f, 0x81, 0x87, 0x79, 0x4c, 0x23, 0x8e, 0x1b, 0x01, 0xac, - 0xb8, 0x9c, 0xb8, 0x41, 0x24, 0xde, 0xd1, 0x1e, 0x8e, 0xae, 0x51, 0xf6, 0x0a, 0x2a, 0x93, 0x33, - 0x7a, 0xea, 0xbe, 0x52, 0x5c, 0x65, 0x77, 0xd3, 0xbe, 0xfa, 0x2e, 0xb6, 0x3b, 0x23, 0x79, 0xd9, - 0x8e, 0xc6, 0x3a, 0x54, 0xb3, 0xab, 0x52, 0x09, 0xa7, 0x9a, 0x04, 0x32, 0x2a, 0x3d, 0xcc, 0x07, - 0x7d, 0xf1, 0x9f, 0x57, 0xd2, 0x61, 0x49, 0x0c, 0xf7, 0xfd, 0xe4, 0x4e, 0x32, 0x5e, 0xe0, 0x52, - 0x16, 0xdc, 0xcf, 0xd3, 0x90, 0x8a, 0xfc, 0xaa, 0xc1, 0x1d, 0x97, 0x93, 0xf7, 0xb1, 0x8f, 0x04, - 0x3e, 0x90, 0x1e, 0xd2, 0x9f, 0x43, 0x19, 0x0d, 0x44, 0x97, 0xb2, 0x40, 0x9c, 0x28, 0x85, 0x2d, - 0xe3, 0xe7, 0x8f, 0x9d, 0x6a, 0x62, 0x8f, 0xd7, 0xbe, 0xcf, 0x30, 0xe7, 0x87, 0x82, 0x05, 0x11, - 0xf1, 0x66, 0x54, 0xfd, 0x25, 0x2c, 0x2b, 0x17, 0x26, 0x47, 0x34, 0xe6, 0x8f, 0xa8, 0x36, 0xb4, - 0xca, 0xe7, 0xbf, 0x1f, 0x14, 0xbe, 0x5f, 0x9e, 0x6d, 0x6b, 0x5e, 0xd2, 0xf2, 0x62, 0xf5, 0xf4, - 0xf2, 0x6c, 0x7b, 0x36, 0xac, 0x51, 0x83, 0x8d, 0x2b, 0xba, 0xa6, 0x9a, 0x77, 0xbf, 0x95, 0xa0, - 0xe4, 0x72, 0xa2, 0x1f, 0xc3, 0xbd, 0x3c, 0x13, 0x36, 0x73, 0xde, 0x2e, 0xd7, 0x2c, 0xe6, 0x93, - 0x45, 0x99, 0xd3, 0xd5, 0xfa, 0x21, 0x94, 0x67, 0x9e, 0xb2, 0x72, 0xdb, 0x53, 0xdc, 0xdc, 0xba, - 0x1e, 0x4f, 0x87, 0xf6, 0x60, 0x6d, 0xde, 0x24, 0x5b, 0x37, 0x69, 0x53, 0x3c, 0xd3, 0x5e, 0x8c, - 0x97, 0x2e, 0xfb, 0x08, 0x2b, 0xff, 0x3c, 0xf6, 0xc3, 0xdc, 0xfe, 0x2c, 0xc5, 0x7c, 0x7c, 0x23, - 0x65, 0x3a, 0xbd, 0xb5, 0x7f, 0x3e, 0xb2, 0xb4, 0x8b, 0x91, 0xa5, 0xfd, 0x19, 0x59, 0xda, 0x97, - 0xb1, 0x55, 0xb8, 0x18, 0x5b, 0x85, 0x5f, 0x63, 0xab, 0xf0, 0xc1, 0x21, 0x81, 0xe8, 0x0e, 0xda, - 0x76, 0x87, 0x86, 0xce, 0x6c, 0x5c, 0x26, 0xdc, 0x21, 0xd4, 0x19, 0xaa, 0x8f, 0xe3, 0x49, 0x8c, - 0x79, 0x7b, 0x59, 0x7e, 0x6d, 0x9e, 0xfd, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x46, 0xf6, 0xb0, 0xe5, - 0x3d, 0x05, 0x00, 0x00, + // 717 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x41, 0x4f, 0x13, 0x41, + 0x14, 0xee, 0xd2, 0x0a, 0xf6, 0xd1, 0xa0, 0x2c, 0x08, 0xcb, 0x46, 0x96, 0x5a, 0x12, 0x2c, 0x24, + 0x74, 0x15, 0x13, 0x0f, 0x7a, 0x30, 0x92, 0x26, 0x4a, 0xe2, 0x46, 0xb2, 0xe0, 0xc5, 0x98, 0x90, + 0x6d, 0x77, 0x32, 0x4c, 0x68, 0x77, 0x96, 0x99, 0x29, 0x29, 0xf1, 0x62, 0xf8, 0x05, 0x9e, 0xfc, + 0x03, 0x5e, 0x3c, 0x72, 0xf0, 0x47, 0x70, 0x24, 0x9e, 0x3c, 0x19, 0x03, 0x07, 0x7e, 0x84, 0x17, + 0xb3, 0xb3, 0xdb, 0xed, 0x96, 0x5d, 0x4b, 0xe3, 0x05, 0xe6, 0xcd, 0xf7, 0xbd, 0xf7, 0xbe, 0xce, + 0x7b, 0x5f, 0x16, 0x16, 0xfc, 0x96, 0xe3, 0x21, 0xd1, 0x26, 0x9e, 0xc0, 0xd4, 0x74, 0x1d, 0x6a, + 0x8a, 0x6e, 0xcd, 0x67, 0x54, 0x50, 0xf5, 0x6e, 0x12, 0xaa, 0xb9, 0x0e, 0xd5, 0x97, 0x53, 0xe4, + 0xe0, 0xb8, 0xc7, 0xd0, 0x61, 0x07, 0x71, 0x11, 0xa6, 0xe9, 0xab, 0x29, 0x92, 0x4b, 0xb8, 0x60, + 0xa4, 0xd1, 0x11, 0x84, 0x7a, 0x7b, 0x94, 0xb9, 0x88, 0x45, 0xd4, 0xc5, 0x14, 0xd5, 0x77, 0x98, + 0xd3, 0xe6, 0x11, 0x3c, 0xed, 0xb4, 0x89, 0x47, 0x4d, 0xf9, 0x37, 0xba, 0x9a, 0xc5, 0x14, 0x53, + 0x79, 0x34, 0x83, 0x53, 0x74, 0xbb, 0xd0, 0xa4, 0xbc, 0x4d, 0xf9, 0x5e, 0x08, 0x84, 0x41, 0x04, + 0xcd, 0x87, 0x91, 0xd9, 0xe6, 0xd8, 0x3c, 0x7a, 0x1c, 0xfc, 0x0b, 0x81, 0xca, 0x27, 0x05, 0xe6, + 0x2c, 0x8e, 0x6d, 0x44, 0x38, 0xef, 0x20, 0xbb, 0x5e, 0x7f, 0xb3, 0xcd, 0xa8, 0x4f, 0xb9, 0xd3, + 0x52, 0x35, 0x98, 0x68, 0x32, 0xe4, 0x08, 0xca, 0x34, 0xa5, 0xac, 0x54, 0x8b, 0x76, 0x2f, 0x54, + 0x75, 0xb8, 0xed, 0x4b, 0x16, 0x62, 0xda, 0x98, 0x84, 0xe2, 0x58, 0x9d, 0x82, 0x31, 0xd1, 0xd5, + 0xf2, 0xf2, 0x76, 0x4c, 0x74, 0xd5, 0x32, 0x4c, 0x36, 0x5a, 0xb4, 0x79, 0xf0, 0x1a, 0x11, 0xbc, + 0x2f, 0xb4, 0x42, 0x59, 0xa9, 0xe6, 0xed, 0xe4, 0x55, 0xa5, 0x0c, 0x46, 0xb6, 0x02, 0x1b, 0x71, + 0x9f, 0x7a, 0x1c, 0x55, 0x08, 0x94, 0x2c, 0x8e, 0x2d, 0xe2, 0x89, 0x5d, 0x7a, 0x80, 0xbc, 0x21, + 0xca, 0x5e, 0xc0, 0x64, 0xf0, 0x8c, 0x76, 0x38, 0x0a, 0x29, 0x6e, 0x72, 0x63, 0xb1, 0x76, 0x7d, + 0x84, 0x35, 0xab, 0x4f, 0xb2, 0x93, 0x19, 0x95, 0x39, 0x98, 0x4d, 0xb6, 0x8a, 0x25, 0x9c, 0x28, + 0x12, 0x48, 0xa8, 0xb4, 0x11, 0xef, 0xb4, 0xc4, 0x7f, 0xbe, 0x92, 0x0a, 0x05, 0xd1, 0xdd, 0xaa, + 0x47, 0xef, 0x24, 0xcf, 0x23, 0xbc, 0x94, 0x01, 0xf7, 0xb3, 0x34, 0xc4, 0x22, 0xbf, 0x2a, 0x70, + 0xcf, 0xe2, 0xb8, 0x9e, 0x58, 0xb4, 0x1b, 0x55, 0x6a, 0x30, 0xd1, 0x72, 0xb8, 0xd8, 0xa6, 0xbe, + 0x14, 0x99, 0xb7, 0x7b, 0x61, 0x80, 0xb8, 0x0e, 0xdd, 0xed, 0xcb, 0xec, 0x85, 0x6a, 0x05, 0x4a, + 0xc4, 0x3b, 0x42, 0x5c, 0x50, 0x26, 0xe1, 0x82, 0x84, 0x07, 0xee, 0x82, 0x6c, 0x9f, 0xfa, 0x12, + 0xbe, 0x15, 0x66, 0x47, 0x61, 0x65, 0x09, 0x16, 0x33, 0x45, 0xc6, 0x3f, 0xe3, 0xa3, 0x5c, 0xc9, + 0x41, 0x82, 0x9c, 0xce, 0x90, 0x9f, 0xf1, 0x0a, 0x4a, 0x49, 0x7f, 0x45, 0x93, 0x5f, 0x4e, 0x4f, + 0x3e, 0x59, 0xf6, 0x6d, 0x60, 0x42, 0x7b, 0x20, 0x31, 0xda, 0xc6, 0x8c, 0xe6, 0xb1, 0xbc, 0x2f, + 0x0a, 0xdc, 0xb1, 0x38, 0x7e, 0xe7, 0xbb, 0x8e, 0x40, 0xdb, 0xd2, 0xa9, 0xea, 0x53, 0x28, 0x3a, + 0x1d, 0xb1, 0x4f, 0x19, 0x11, 0xc7, 0xa1, 0xb4, 0x4d, 0xed, 0xc7, 0xf7, 0xf5, 0xd9, 0xc8, 0x84, + 0x2f, 0x5d, 0x97, 0x21, 0xce, 0x77, 0x04, 0x23, 0x1e, 0xb6, 0xfb, 0x54, 0xf5, 0x39, 0x8c, 0x87, + 0x5e, 0x8f, 0x04, 0x6b, 0x69, 0xc1, 0x61, 0x87, 0xcd, 0xe2, 0xd9, 0xaf, 0xa5, 0xdc, 0xb7, 0xab, + 0xd3, 0x35, 0xc5, 0x8e, 0x52, 0x9e, 0x4d, 0x9d, 0x5c, 0x9d, 0xae, 0xf5, 0x8b, 0x55, 0x16, 0x60, + 0xfe, 0x9a, 0xae, 0x9e, 0xe6, 0x8d, 0x3f, 0x05, 0xc8, 0x5b, 0x1c, 0xab, 0x87, 0x30, 0x93, 0x65, + 0xf5, 0x6a, 0x86, 0x43, 0x32, 0x2d, 0xa9, 0x3f, 0x1a, 0x95, 0xd9, 0x6b, 0xad, 0xee, 0x40, 0xb1, + 0xef, 0x5c, 0x23, 0x33, 0x3d, 0xc6, 0xf5, 0x95, 0xe1, 0x78, 0x5c, 0xf4, 0x00, 0xa6, 0xd3, 0x56, + 0x5c, 0xb9, 0x49, 0x5b, 0xc8, 0xd3, 0x6b, 0xa3, 0xf1, 0xe2, 0x66, 0x1e, 0xa8, 0x19, 0x96, 0x7a, + 0x98, 0x59, 0x25, 0x4d, 0xd4, 0xcd, 0x11, 0x89, 0x71, 0xbf, 0x43, 0x98, 0xc9, 0x5a, 0xfe, 0xea, + 0x08, 0x75, 0x24, 0xf3, 0x1f, 0x43, 0x1a, 0xb2, 0xd3, 0xea, 0x07, 0x28, 0x0d, 0xec, 0xf3, 0x83, + 0xcc, 0x0a, 0x49, 0x8a, 0xbe, 0x7a, 0x23, 0xa5, 0x57, 0x7d, 0x73, 0xeb, 0xec, 0xc2, 0x50, 0xce, + 0x2f, 0x0c, 0xe5, 0xf7, 0x85, 0xa1, 0x7c, 0xbe, 0x34, 0x72, 0xe7, 0x97, 0x46, 0xee, 0xe7, 0xa5, + 0x91, 0x7b, 0x6f, 0x62, 0x22, 0xf6, 0x3b, 0x8d, 0x5a, 0x93, 0xb6, 0xcd, 0x7e, 0xb9, 0xc4, 0x71, + 0x1d, 0x53, 0xb3, 0x1b, 0x7e, 0x90, 0x8f, 0x7d, 0xc4, 0x1b, 0xe3, 0xf2, 0xb3, 0xf5, 0xe4, 0x6f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xa5, 0xda, 0x1e, 0xc8, 0xb1, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -487,6 +700,8 @@ type MsgClient interface { ReissueRDDLProposal(ctx context.Context, in *MsgReissueRDDLProposal, opts ...grpc.CallOption) (*MsgReissueRDDLProposalResponse, error) MintToken(ctx context.Context, in *MsgMintToken, opts ...grpc.CallOption) (*MsgMintTokenResponse, error) ReissueRDDLResult(ctx context.Context, in *MsgReissueRDDLResult, opts ...grpc.CallOption) (*MsgReissueRDDLResultResponse, error) + DistributionResult(ctx context.Context, in *MsgDistributionResult, opts ...grpc.CallOption) (*MsgDistributionResultResponse, error) + DistributionRequest(ctx context.Context, in *MsgDistributionRequest, opts ...grpc.CallOption) (*MsgDistributionRequestResponse, error) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } @@ -525,6 +740,24 @@ func (c *msgClient) ReissueRDDLResult(ctx context.Context, in *MsgReissueRDDLRes return out, nil } +func (c *msgClient) DistributionResult(ctx context.Context, in *MsgDistributionResult, opts ...grpc.CallOption) (*MsgDistributionResultResponse, error) { + out := new(MsgDistributionResultResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.dao.Msg/DistributionResult", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DistributionRequest(ctx context.Context, in *MsgDistributionRequest, opts ...grpc.CallOption) (*MsgDistributionRequestResponse, error) { + out := new(MsgDistributionRequestResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.dao.Msg/DistributionRequest", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { out := new(MsgUpdateParamsResponse) err := c.cc.Invoke(ctx, "/planetmintgo.dao.Msg/UpdateParams", in, out, opts...) @@ -539,6 +772,8 @@ type MsgServer interface { ReissueRDDLProposal(context.Context, *MsgReissueRDDLProposal) (*MsgReissueRDDLProposalResponse, error) MintToken(context.Context, *MsgMintToken) (*MsgMintTokenResponse, error) ReissueRDDLResult(context.Context, *MsgReissueRDDLResult) (*MsgReissueRDDLResultResponse, error) + DistributionResult(context.Context, *MsgDistributionResult) (*MsgDistributionResultResponse, error) + DistributionRequest(context.Context, *MsgDistributionRequest) (*MsgDistributionRequestResponse, error) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } @@ -555,6 +790,12 @@ func (*UnimplementedMsgServer) MintToken(ctx context.Context, req *MsgMintToken) func (*UnimplementedMsgServer) ReissueRDDLResult(ctx context.Context, req *MsgReissueRDDLResult) (*MsgReissueRDDLResultResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ReissueRDDLResult not implemented") } +func (*UnimplementedMsgServer) DistributionResult(ctx context.Context, req *MsgDistributionResult) (*MsgDistributionResultResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DistributionResult not implemented") +} +func (*UnimplementedMsgServer) DistributionRequest(ctx context.Context, req *MsgDistributionRequest) (*MsgDistributionRequestResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DistributionRequest not implemented") +} func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } @@ -617,6 +858,42 @@ func _Msg_ReissueRDDLResult_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Msg_DistributionResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDistributionResult) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DistributionResult(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/planetmintgo.dao.Msg/DistributionResult", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DistributionResult(ctx, req.(*MsgDistributionResult)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DistributionRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDistributionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DistributionRequest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/planetmintgo.dao.Msg/DistributionRequest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DistributionRequest(ctx, req.(*MsgDistributionRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgUpdateParams) if err := dec(in); err != nil { @@ -651,6 +928,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ReissueRDDLResult", Handler: _Msg_ReissueRDDLResult_Handler, }, + { + MethodName: "DistributionResult", + Handler: _Msg_DistributionResult_Handler, + }, + { + MethodName: "DistributionRequest", + Handler: _Msg_DistributionRequest_Handler, + }, { MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, @@ -822,10 +1107,10 @@ func (m *MsgReissueRDDLResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if len(m.TxId) > 0 { - i -= len(m.TxId) - copy(dAtA[i:], m.TxId) - i = encodeVarintTx(dAtA, i, uint64(len(m.TxId))) + if len(m.TxID) > 0 { + i -= len(m.TxID) + copy(dAtA[i:], m.TxID) + i = encodeVarintTx(dAtA, i, uint64(len(m.TxID))) i-- dAtA[i] = 0x1a } @@ -869,6 +1154,150 @@ func (m *MsgReissueRDDLResultResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *MsgDistributionResult) 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 *MsgDistributionResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDistributionResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PopTxID) > 0 { + i -= len(m.PopTxID) + copy(dAtA[i:], m.PopTxID) + i = encodeVarintTx(dAtA, i, uint64(len(m.PopTxID))) + i-- + dAtA[i] = 0x2a + } + if len(m.InvestorTxID) > 0 { + i -= len(m.InvestorTxID) + copy(dAtA[i:], m.InvestorTxID) + i = encodeVarintTx(dAtA, i, uint64(len(m.InvestorTxID))) + i-- + dAtA[i] = 0x22 + } + if len(m.DaoTxID) > 0 { + i -= len(m.DaoTxID) + copy(dAtA[i:], m.DaoTxID) + i = encodeVarintTx(dAtA, i, uint64(len(m.DaoTxID))) + i-- + dAtA[i] = 0x1a + } + if m.LastPop != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.LastPop)) + i-- + dAtA[i] = 0x10 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDistributionResultResponse) 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 *MsgDistributionResultResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDistributionResultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDistributionRequest) 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 *MsgDistributionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDistributionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Distribution != nil { + { + size, err := m.Distribution.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDistributionRequestResponse) 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 *MsgDistributionRequestResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDistributionRequestResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1016,7 +1445,7 @@ func (m *MsgReissueRDDLResult) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.TxId) + l = len(m.TxID) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1035,6 +1464,69 @@ func (m *MsgReissueRDDLResultResponse) Size() (n int) { return n } +func (m *MsgDistributionResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.LastPop != 0 { + n += 1 + sovTx(uint64(m.LastPop)) + } + l = len(m.DaoTxID) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.InvestorTxID) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PopTxID) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgDistributionResultResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDistributionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Distribution != nil { + l = m.Distribution.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgDistributionRequestResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgUpdateParams) Size() (n int) { if m == nil { return 0 @@ -1543,7 +2035,7 @@ func (m *MsgReissueRDDLResult) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TxId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TxID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1571,7 +2063,7 @@ func (m *MsgReissueRDDLResult) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TxId = string(dAtA[iNdEx:postIndex]) + m.TxID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 0 { @@ -1663,6 +2155,421 @@ func (m *MsgReissueRDDLResultResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgDistributionResult) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDistributionResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDistributionResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastPop", wireType) + } + m.LastPop = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastPop |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DaoTxID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DaoTxID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InvestorTxID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InvestorTxID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PopTxID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PopTxID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDistributionResultResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDistributionResultResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDistributionResultResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDistributionRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDistributionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDistributionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Distribution", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Distribution == nil { + m.Distribution = &DistributionOrder{} + } + if err := m.Distribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDistributionRequestResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDistributionRequestResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDistributionRequestResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/dao/util.go b/x/dao/util.go deleted file mode 100644 index 14a82d2..0000000 --- a/x/dao/util.go +++ /dev/null @@ -1,10 +0,0 @@ -package dao - -func GetReissuanceCommand(assetID string, _ int64) string { - return "reissueasset " + assetID + " 99869000000" -} - -func IsValidReissuanceCommand(reissuanceStr string, assetID string, _ int64) bool { - expected := "reissueasset " + assetID + " 99869000000" - return reissuanceStr == expected -}