From d0f76dcb80fe4a2a995381da23a1ecec72b03c9d Mon Sep 17 00:00:00 2001 From: Hansol Lee <38912532+hansol-medi@users.noreply.github.com> Date: Mon, 25 Apr 2022 11:03:06 +0900 Subject: [PATCH] feat: implementation of `MsgBuyDataAccessNFT` Tx (#306) * remove contract related tx and query add code id and contract address to genesis params * change README * fix test * fix lint and add validation of params * feat: add query params * fix * fix * feat: add MsgBuyDataAccessNFT Tx * add genesis of white list * add test of BuyDataAccessNFT Tx * merge * review applied * change name * add TODO: pagination * apply changed design * refactor errors * rename tx * fix --- proto/panacea/datapool/v2/genesis.proto | 10 +- proto/panacea/datapool/v2/tx.proto | 12 +- types/testsuite/suite.go | 10 +- x/datapool/client/cli/tx.go | 2 + x/datapool/client/cli/txPool.go | 48 ++++- x/datapool/genesis.go | 13 +- x/datapool/genesis_test.go | 25 +-- x/datapool/handler.go | 3 + x/datapool/keeper/msg_server_pool.go | 16 +- x/datapool/keeper/pool.go | 96 +++++++--- x/datapool/keeper/pool_test.go | 112 ++++++++++- x/datapool/types/codec.go | 4 +- x/datapool/types/contract_msg.go | 31 ++-- x/datapool/types/errors.go | 7 + x/datapool/types/genesis.go | 4 +- x/datapool/types/genesis.pb.go | 74 ++++---- x/datapool/types/keys.go | 3 - x/datapool/types/message_pool.go | 19 +- x/datapool/types/pool.go | 11 +- x/datapool/types/tx.pb.go | 235 ++++++++++++------------ 20 files changed, 476 insertions(+), 259 deletions(-) diff --git a/proto/panacea/datapool/v2/genesis.proto b/proto/panacea/datapool/v2/genesis.proto index 77bd94f3..3d6f98e6 100644 --- a/proto/panacea/datapool/v2/genesis.proto +++ b/proto/panacea/datapool/v2/genesis.proto @@ -9,12 +9,10 @@ import "panacea/datapool/v2/pool.proto"; // GenesisState defines the datapool module's genesis state. message GenesisState { - repeated panacea.datapool.v2.DataValidator data_validators = 1; - uint64 next_pool_number = 2; - repeated Pool pools = 3; - Params params = 4 [ - (gogoproto.nullable) = false - ]; + repeated DataValidator data_validators = 1 [(gogoproto.nullable) = false]; + uint64 next_pool_number = 2; + repeated Pool pools = 3 [(gogoproto.nullable) = false]; + Params params = 4 [(gogoproto.nullable) = false]; } // Params define parameters of datapool module diff --git a/proto/panacea/datapool/v2/tx.proto b/proto/panacea/datapool/v2/tx.proto index 27da6748..cc603c17 100644 --- a/proto/panacea/datapool/v2/tx.proto +++ b/proto/panacea/datapool/v2/tx.proto @@ -24,8 +24,8 @@ service Msg { // SellData defines a method for selling data rpc SellData(MsgSellData) returns (MsgSellDataResponse); - // BuyDataAccessNFT defines a method for buying data access NFT - rpc BuyDataAccessNFT(MsgBuyDataAccessNFT) returns (MsgBuyDataAccessNFTResponse); + // BuyDataPass defines a method for buying data access NFT + rpc BuyDataPass(MsgBuyDataPass) returns (MsgBuyDataPassResponse); // RedeemDataAccessNFT defines a method for redeeming data access NFT to get data rpc RedeemDataAccessNFT(MsgRedeemDataAccessNFT) returns (MsgRedeemDataAccessNFTResponse); @@ -75,16 +75,16 @@ message MsgSellDataResponse { cosmos.base.v1beta1.Coin accum_pool_share_token = 1; // denom: DP-{pood-id} } -// MsgBuyDataAccessNFT defines the Msg/BuyDataAccessNFT request type. -message MsgBuyDataAccessNFT { +// MsgBuyDataPass defines the Msg/BuyDataPass request type. +message MsgBuyDataPass { uint64 pool_id = 1; uint64 round = 2; cosmos.base.v1beta1.Coin payment = 3; string buyer = 4; // 'panacea1' address of buyer } -// MsgBuyDataAccessNFTResponse defines the Msg/BuyDataAccessNFT response type. -message MsgBuyDataAccessNFTResponse { +// MsgBuyDataPassResponse defines the Msg/BuyDataAccessNFT response type. +message MsgBuyDataPassResponse { uint64 pool_id = 1; uint64 round = 2; uint64 nft_id = 3; diff --git a/types/testsuite/suite.go b/types/testsuite/suite.go index 091474a9..6900f7d3 100644 --- a/types/testsuite/suite.go +++ b/types/testsuite/suite.go @@ -28,7 +28,6 @@ import ( paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/medibloc/panacea-core/v2/types/assets" aolkeeper "github.com/medibloc/panacea-core/v2/x/aol/keeper" aoltypes "github.com/medibloc/panacea-core/v2/x/aol/types" burnkeeper "github.com/medibloc/panacea-core/v2/x/burn/keeper" @@ -243,13 +242,8 @@ func (suite *TestSuite) SetupTest() { ) suite.DataPoolMsgServer = datapoolkeeper.NewMsgServerImpl(suite.DataPoolKeeper) - dataPoolGenState := datapooltypes.GenesisState{ - DataValidators: []*datapooltypes.DataValidator{}, - NextPoolNumber: 1, - Pools: []*datapooltypes.Pool{}, - Params: datapooltypes.Params{DataPoolDeposit: sdk.NewCoin(assets.MicroMedDenom, sdk.NewInt(1000000))}, - } - datapool.InitGenesis(suite.Ctx, suite.DataPoolKeeper, dataPoolGenState) + dataPoolGenState := datapooltypes.DefaultGenesis() + datapool.InitGenesis(suite.Ctx, suite.DataPoolKeeper, *dataPoolGenState) } func (suite *TestSuite) BeforeTest(suiteName, testName string) { diff --git a/x/datapool/client/cli/tx.go b/x/datapool/client/cli/tx.go index a9003dfa..e76f6c37 100644 --- a/x/datapool/client/cli/tx.go +++ b/x/datapool/client/cli/tx.go @@ -24,5 +24,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdUpdateDataValidator()) cmd.AddCommand(CmdCreatePool()) cmd.AddCommand(CmdSellData()) + cmd.AddCommand(CmdBuyDataAccessNFT()) + return cmd } diff --git a/x/datapool/client/cli/txPool.go b/x/datapool/client/cli/txPool.go index b5316177..d8f41b41 100644 --- a/x/datapool/client/cli/txPool.go +++ b/x/datapool/client/cli/txPool.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "strconv" "time" "github.com/cosmos/cosmos-sdk/client" @@ -176,4 +177,49 @@ func readCertificateFromFile(file string) (*types.DataValidationCertificate, err } return &cert, nil -} \ No newline at end of file +} +func CmdBuyDataAccessNFT() *cobra.Command { + cmd := &cobra.Command{ + Use: "buy-data-access-nft [pool ID] [round] [payment]", + Short: "buy data access NFT", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + buyer := clientCtx.GetFromAddress() + + poolID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + round, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + payment, err := sdk.ParseCoinNormalized(args[2]) + if err != nil { + return err + } + + msg := &types.MsgBuyDataPass{ + PoolId: poolID, + Round: round, + Payment: &payment, + Buyer: buyer.String(), + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/datapool/genesis.go b/x/datapool/genesis.go index d4f0f6b9..7e2fab24 100644 --- a/x/datapool/genesis.go +++ b/x/datapool/genesis.go @@ -13,15 +13,16 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetPoolNumber(ctx, genState.NextPoolNumber) for _, dataValidator := range genState.DataValidators { - err := k.SetDataValidator(ctx, *dataValidator) + err := k.SetDataValidator(ctx, dataValidator) if err != nil { panic(err) } } for _, pool := range genState.Pools { - k.SetPool(ctx, pool) + k.SetPool(ctx, &pool) } + // this line is used by starport scaffolding # genesis/module/init // this line is used by starport scaffolding # ibc/genesis/init @@ -38,18 +39,14 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { panic(err) } - for _, val := range dataValidators { - genesis.DataValidators = append(genesis.DataValidators, &val) - } + genesis.DataValidators = append(genesis.DataValidators, dataValidators...) pools, err := k.GetAllPools(ctx) if err != nil { panic(err) } - for _, pool := range pools { - genesis.Pools = append(genesis.Pools, &pool) - } + genesis.Pools = append(genesis.Pools, pools...) genesis.Params = k.GetParams(ctx) diff --git a/x/datapool/genesis_test.go b/x/datapool/genesis_test.go index e25a5279..781c96f2 100644 --- a/x/datapool/genesis_test.go +++ b/x/datapool/genesis_test.go @@ -20,6 +20,7 @@ var ( curator = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) NFTPrice = sdk.NewCoin(assets.MicroMedDenom, sdk.NewInt(10000000)) downloadPeriod = time.Duration(time.Second * 100000000) + poolID = uint64(1) ) type genesisTestSuite struct { @@ -31,7 +32,7 @@ func TestGenesisTestSuite(t *testing.T) { } func (suite genesisTestSuite) TestDataPoolInitGenesis() { - var dataValidators []*types.DataValidator + var dataValidators []types.DataValidator dataValidator := makeSampleDataValidator() @@ -39,7 +40,7 @@ func (suite genesisTestSuite) TestDataPoolInitGenesis() { pool := makeSamplePool() - pools := []*types.Pool{pool} + pools := []types.Pool{pool} params := types.DefaultParams() @@ -55,7 +56,7 @@ func (suite genesisTestSuite) TestDataPoolInitGenesis() { // check data validator dataValidatorFromKeeper, err := suite.DataPoolKeeper.GetDataValidator(suite.Ctx, dataVal) suite.Require().NoError(err) - suite.Require().Equal(*dataValidator, dataValidatorFromKeeper) + suite.Require().Equal(dataValidator, dataValidatorFromKeeper) // check the next pool number suite.Require().Equal(uint64(2), suite.DataPoolKeeper.GetNextPoolNumber(suite.Ctx)) @@ -63,7 +64,7 @@ func (suite genesisTestSuite) TestDataPoolInitGenesis() { // check pool poolFromKeeper, err := suite.DataPoolKeeper.GetPool(suite.Ctx, uint64(1)) suite.Require().NoError(err) - suite.Require().Equal(pool, poolFromKeeper) + suite.Require().Equal(pool, *poolFromKeeper) // check params paramsFromKeeper := suite.DataPoolKeeper.GetParams(suite.Ctx) @@ -73,12 +74,12 @@ func (suite genesisTestSuite) TestDataPoolInitGenesis() { func (suite genesisTestSuite) TestDataPoolExportGenesis() { // register data validator dataValidator := makeSampleDataValidator() - err := suite.DataPoolKeeper.SetDataValidator(suite.Ctx, *dataValidator) + err := suite.DataPoolKeeper.SetDataValidator(suite.Ctx, dataValidator) suite.Require().NoError(err) // create pool pool := makeSamplePool() - suite.DataPoolKeeper.SetPool(suite.Ctx, pool) + suite.DataPoolKeeper.SetPool(suite.Ctx, &pool) suite.DataPoolKeeper.SetPoolNumber(suite.Ctx, uint64(2)) // set params @@ -91,21 +92,21 @@ func (suite genesisTestSuite) TestDataPoolExportGenesis() { suite.Require().Len(genesisState.DataValidators, 1) } -func makeSampleDataValidator() *types.DataValidator { - return &types.DataValidator{ +func makeSampleDataValidator() types.DataValidator { + return types.DataValidator{ Address: dataVal.String(), Endpoint: "https://my-validator.org", } } -func makeSamplePool() *types.Pool { - return &types.Pool{ - PoolId: 1, +func makeSamplePool() types.Pool { + return types.Pool{ + PoolId: poolID, PoolAddress: types.NewPoolAddress(uint64(1)).String(), Round: 1, PoolParams: makeSamplePoolParams(), CurNumData: 0, - NumIssuedNfts: 0, + NumIssuedNfts: 1, Status: types.PENDING, Curator: curator.String(), } diff --git a/x/datapool/handler.go b/x/datapool/handler.go index 24df8c93..8194e429 100644 --- a/x/datapool/handler.go +++ b/x/datapool/handler.go @@ -27,6 +27,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgCreatePool: res, err := msgServer.CreatePool(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgBuyDataPass: + res, err := msgServer.BuyDataPass(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) case *types.MsgSellData: res, err := msgServer.SellData(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) diff --git a/x/datapool/keeper/msg_server_pool.go b/x/datapool/keeper/msg_server_pool.go index cd1327ac..fb7abe9f 100644 --- a/x/datapool/keeper/msg_server_pool.go +++ b/x/datapool/keeper/msg_server_pool.go @@ -74,8 +74,20 @@ func (m msgServer) SellData(goCtx context.Context, msg *types.MsgSellData) (*typ }, nil } -func (m msgServer) BuyDataAccessNFT(goCtx context.Context, msg *types.MsgBuyDataAccessNFT) (*types.MsgBuyDataAccessNFTResponse, error) { - return &types.MsgBuyDataAccessNFTResponse{}, nil +func (m msgServer) BuyDataPass(goCtx context.Context, msg *types.MsgBuyDataPass) (*types.MsgBuyDataPassResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + buyer, err := sdk.AccAddressFromBech32(msg.Buyer) + if err != nil { + return nil, err + } + + err = m.Keeper.BuyDataPass(ctx, buyer, msg.PoolId, msg.Round, *msg.Payment) + if err != nil { + return nil, err + } + + return &types.MsgBuyDataPassResponse{PoolId: msg.PoolId, Round: msg.Round}, nil } func (m msgServer) RedeemDataAccessNFT(goCtx context.Context, msg *types.MsgRedeemDataAccessNFT) (*types.MsgRedeemDataAccessNFTResponse, error) { diff --git a/x/datapool/keeper/pool.go b/x/datapool/keeper/pool.go index 55621b3c..7ab04cd2 100644 --- a/x/datapool/keeper/pool.go +++ b/x/datapool/keeper/pool.go @@ -43,6 +43,7 @@ func (k Keeper) RegisterDataValidator(ctx sdk.Context, dataValidator types.DataV } func (k Keeper) GetAllDataValidators(ctx sdk.Context) ([]types.DataValidator, error) { + // TODO: add pagination store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixDataValidators) defer iterator.Close() @@ -55,7 +56,7 @@ func (k Keeper) GetAllDataValidators(ctx sdk.Context) ([]types.DataValidator, er err := k.cdc.UnmarshalBinaryLengthPrefixed(bz, &dataValidator) if err != nil { - return []types.DataValidator{}, err + return nil, err } dataValidators = append(dataValidators, dataValidator) @@ -128,7 +129,7 @@ func (k Keeper) CreatePool(ctx sdk.Context, curator sdk.AccAddress, poolParams t // pool address for deposit poolAddress, err := sdk.AccAddressFromBech32(newPoolAddr) if err != nil { - return 0, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address of pool %s", newPoolAddr) + return 0, sdkerrors.Wrapf(types.ErrCreatePool, "invalid address of pool %s", newPoolAddr) } // set new account for pool @@ -142,7 +143,7 @@ func (k Keeper) CreatePool(ctx sdk.Context, curator sdk.AccAddress, poolParams t for _, dataValidator := range poolParams.TrustedDataValidators { accAddr, _ := sdk.AccAddressFromBech32(dataValidator) if !k.isRegisteredDataValidator(ctx, accAddr) { - return 0, sdkerrors.Wrapf(types.ErrNotRegisteredDataValidator, "the data validator %s is not registered", dataValidator) + return 0, types.ErrNotRegisteredDataValidator } } @@ -151,58 +152,48 @@ func (k Keeper) CreatePool(ctx sdk.Context, curator sdk.AccAddress, poolParams t err = k.bankKeeper.SendCoins(ctx, curator, poolAddress, sdk.NewCoins(params.DataPoolDeposit)) if err != nil { - return 0, sdkerrors.Wrapf(types.ErrNotEnoughPoolDeposit, "The curator's balance is not enough to make a data pool") + return 0, sdkerrors.Wrapf(types.ErrCreatePool, err.Error()) } // mint curator NFT nftContractAddrParam := params.DataPoolNftContractAddress if nftContractAddrParam == "" { - return 0, sdkerrors.Wrapf(types.ErrNoRegisteredNFTContract, "failed to get NFT contract address") + return 0, types.ErrNoRegisteredNFTContract } nftContractAddr, err := sdk.AccAddressFromBech32(nftContractAddrParam) if err != nil { - return 0, sdkerrors.Wrapf(err, "invalid contract address") + return 0, sdkerrors.Wrapf(types.ErrCreatePool, "invalid contract address: %s", nftContractAddrParam) } - zeroFund, err := sdk.ParseCoinsNormalized("0umed") - if err != nil { - return 0, sdkerrors.Wrapf(err, "error in parsing coin") - } - - mintMsg := types.NewMsgMintNFT(newPool.GetPoolId(), curator.String()) + mintMsg := types.NewMsgMintCuratorNFT(newPool.GetPoolId(), curator.String()) mintMsgBz, err := json.Marshal(mintMsg) if err != nil { - return 0, sdkerrors.Wrapf(err, "failed to marshal mint NFT msg") + return 0, sdkerrors.Wrapf(types.ErrMintNFT, err.Error()) } moduleAddr := types.GetModuleAddress() - _, err = k.wasmKeeper.Execute(ctx, nftContractAddr, moduleAddr, mintMsgBz, zeroFund) - + _, err = k.wasmKeeper.Execute(ctx, nftContractAddr, moduleAddr, mintMsgBz, sdk.NewCoins(types.ZeroFund)) if err != nil { - return 0, sdkerrors.Wrapf(err, "failed to mint curator NFT") + return 0, sdkerrors.Wrapf(types.ErrMintNFT, err.Error()) } - poolName := "pool_" + strconv.FormatUint(newPool.GetPoolId(), 10) + poolName := "data_pool_" + strconv.FormatUint(newPool.GetPoolId(), 10) symbol := "DATA" + strconv.FormatUint(newPool.GetPoolId(), 10) instantiateMsg := types.NewInstantiateNFTMsg(poolName, symbol, newPoolAddr) instantiateMsgBz, err := json.Marshal(instantiateMsg) if err != nil { - return 0, sdkerrors.Wrapf(err, "failed to marshal instantiateMsg") + return 0, sdkerrors.Wrapf(types.ErrInstantiateContract, err.Error()) } codeID := k.GetParams(ctx).DataPoolCodeId - if err != nil { - return 0, sdkerrors.Wrapf(err, "invalid new pool address") - } - // instantiate NFT contract for minting data access NFT (set admin to module) poolNFTContractAddr, _, err := k.wasmKeeper.Instantiate(ctx, codeID, moduleAddr, poolAddress, instantiateMsgBz, "data access NFT", nil) if err != nil { - return 0, sdkerrors.Wrapf(err, "failed to instantiate contract") + return 0, sdkerrors.Wrapf(types.ErrInstantiateContract, err.Error()) } newPool.NftContractAddr = poolNFTContractAddr.String() @@ -269,6 +260,7 @@ func (k Keeper) SetPool(ctx sdk.Context, pool *types.Pool) { } func (k Keeper) GetAllPools(ctx sdk.Context) ([]types.Pool, error) { + // TODO: add pagination store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixPools) defer iterator.Close() @@ -492,3 +484,61 @@ func (k Keeper) GetDataValidationCertificate(ctx sdk.Context, poolID, round uint return cert, nil } + +func (k Keeper) BuyDataPass(ctx sdk.Context, buyer sdk.AccAddress, poolID, round uint64, payment sdk.Coin) error { + pool, err := k.GetPool(ctx, poolID) + if err != nil { + return sdkerrors.Wrapf(types.ErrBuyDataPass, err.Error()) + } + + if pool.GetNumIssuedNfts() == pool.GetPoolParams().GetMaxNftSupply() { + return types.ErrNFTAllIssued + } + + if pool.GetRound() != round { + return types.ErrRoundNotMatched + } + + if !payment.Equal(pool.GetPoolParams().GetNftPrice()) { + return types.ErrPaymentNotMatched + } + + poolAcc, err := sdk.AccAddressFromBech32(pool.GetPoolAddress()) + if err != nil { + return sdkerrors.Wrapf(types.ErrBuyDataPass, err.Error()) + } + + err = k.bankKeeper.SendCoins(ctx, buyer, poolAcc, sdk.NewCoins(payment)) + if err != nil { + return sdkerrors.Wrapf(types.ErrBuyDataPass, err.Error()) + } + + //mint data access NFT when pool is activated + contractAddr := pool.GetNftContractAddr() + + contractAcc, err := sdk.AccAddressFromBech32(contractAddr) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, err.Error()) + } + + mintMsg := types.NewMsgMintDataAccessNFT(pool.GetNumIssuedNfts()+1, buyer.String()) + mintMsgBz, err := json.Marshal(mintMsg) + if err != nil { + return sdkerrors.Wrapf(types.ErrMintNFT, err.Error()) + } + + _, err = k.wasmKeeper.Execute(ctx, contractAcc, poolAcc, mintMsgBz, sdk.NewCoins(types.ZeroFund)) + if err != nil { + return sdkerrors.Wrapf(types.ErrMintNFT, err.Error()) + } + + k.increaseNumIssuedNFT(ctx, pool) + + return nil +} + +func (k Keeper) increaseNumIssuedNFT(ctx sdk.Context, pool *types.Pool) { + pool.NumIssuedNfts += 1 + + k.SetPool(ctx, pool) +} diff --git a/x/datapool/keeper/pool_test.go b/x/datapool/keeper/pool_test.go index f00f017e..09afdded 100644 --- a/x/datapool/keeper/pool_test.go +++ b/x/datapool/keeper/pool_test.go @@ -2,12 +2,13 @@ package keeper_test import ( "fmt" - "github.com/cosmos/cosmos-sdk/codec" "io/ioutil" "strings" "testing" "time" + "github.com/cosmos/cosmos-sdk/codec" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -35,6 +36,9 @@ var ( curatorPrivKey = secp256k1.GenPrivKey() curatorPubKey = curatorPrivKey.PubKey() curatorAddr = sdk.AccAddress(curatorPubKey.Address()) + buyerPrivKey = secp256k1.GenPrivKey() + buyerPubKey = buyerPrivKey.PubKey() + buyerAddr = sdk.AccAddress(buyerPubKey.Address()) requesterPrivKey = secp256k1.GenPrivKey() requesterPubKey = requesterPrivKey.PubKey() @@ -42,6 +46,7 @@ var ( fundForDataVal = sdk.NewCoins(sdk.NewCoin(assets.MicroMedDenom, sdk.NewInt(10000000000))) fundForCurator = sdk.NewCoins(sdk.NewCoin(assets.MicroMedDenom, sdk.NewInt(10000000000))) + fundForBuyer = sdk.NewCoins(sdk.NewCoin(assets.MicroMedDenom, sdk.NewInt(10000000000))) NFTPrice = sdk.NewCoin(assets.MicroMedDenom, sdk.NewInt(10000000)) downloadPeriod = time.Duration(time.Second * 100000000) @@ -65,6 +70,21 @@ func (suite poolTestSuite) setupNFTContract() { suite.DataPoolKeeper.SetParams(suite.Ctx, params) } +func (suite poolTestSuite) setupCreatePool(maxNftSupply uint64) uint64 { + suite.setupNFTContract() + + err := suite.BankKeeper.AddCoins(suite.Ctx, curatorAddr, fundForCurator) + suite.Require().NoError(err) + + newPoolParams := makePoolParamsNoDataValidator(maxNftSupply) + + poolID, err := suite.DataPoolKeeper.CreatePool(suite.Ctx, curatorAddr, newPoolParams) + suite.Require().NoError(err) + suite.Require().Equal(poolID, uint64(1)) + + return poolID +} + func (suite *poolTestSuite) TestRegisterDataValidator() { err := suite.BankKeeper.AddCoins(suite.Ctx, dataVal1, fundForDataVal) suite.Require().NoError(err) @@ -250,7 +270,7 @@ func (suite poolTestSuite) TestNotEnoughBalanceForDeposit() { // create and instantiate NFT contract suite.setupNFTContract() - newPoolParams := makePoolParamsNoDataValidator() + newPoolParams := makePoolParamsNoDataValidator(10) _, err := suite.DataPoolKeeper.CreatePool(suite.Ctx, curatorAddr, newPoolParams) suite.Require().Error(err, types.ErrNotEnoughPoolDeposit) @@ -260,12 +280,94 @@ func (suite poolTestSuite) TestNotRegisteredNFTContract() { err := suite.BankKeeper.AddCoins(suite.Ctx, curatorAddr, fundForCurator) suite.Require().NoError(err) - newPoolParams := makePoolParamsNoDataValidator() + newPoolParams := makePoolParamsNoDataValidator(10) _, err = suite.DataPoolKeeper.CreatePool(suite.Ctx, curatorAddr, newPoolParams) suite.Require().Error(err, types.ErrNoRegisteredNFTContract) } +func (suite poolTestSuite) TestBuyDataAccessNFTPending() { + // create pool + poolID := suite.setupCreatePool(10) + + err := suite.BankKeeper.AddCoins(suite.Ctx, buyerAddr, fundForBuyer) + suite.Require().NoError(err) + + err = suite.DataPoolKeeper.BuyDataPass(suite.Ctx, buyerAddr, poolID, 1, NFTPrice) + suite.Require().NoError(err) + + pool, err := suite.DataPoolKeeper.GetPool(suite.Ctx, poolID) + suite.Require().NoError(err) + + suite.Require().Equal(pool.GetNumIssuedNfts(), uint64(1)) +} + +// TODO: TestBuyDataAccessNFTActive - check if data access NFT is mintes successfully + +func (suite poolTestSuite) TestBuyDataAccessNFTPoolNotFound() { + // create pool + suite.setupCreatePool(10) + + err := suite.BankKeeper.AddCoins(suite.Ctx, buyerAddr, fundForBuyer) + suite.Require().NoError(err) + + // buy NFT other data pool + err = suite.DataPoolKeeper.BuyDataPass(suite.Ctx, buyerAddr, 2, 1, NFTPrice) + suite.Require().Error(err, types.ErrPoolNotFound) +} + +func (suite poolTestSuite) TestBuyDataAccessNFTSoldOut() { + // create pool w/ NFT max supply of 1 + poolID := suite.setupCreatePool(1) + + err := suite.BankKeeper.AddCoins(suite.Ctx, buyerAddr, fundForBuyer) + suite.Require().NoError(err) + + // buy 1 NFT + err = suite.DataPoolKeeper.BuyDataPass(suite.Ctx, buyerAddr, poolID, 1, NFTPrice) + suite.Require().NoError(err) + + // buy 1 NFT more + err = suite.DataPoolKeeper.BuyDataPass(suite.Ctx, buyerAddr, poolID, 1, NFTPrice) + suite.Require().Error(err, types.ErrNFTAllIssued) +} + +func (suite poolTestSuite) TestBuyDataAccessNFTRoundNotMatched() { + // create pool + poolID := suite.setupCreatePool(10) + + err := suite.BankKeeper.AddCoins(suite.Ctx, buyerAddr, fundForBuyer) + suite.Require().NoError(err) + + // different round + err = suite.DataPoolKeeper.BuyDataPass(suite.Ctx, buyerAddr, poolID, 2, NFTPrice) + suite.Require().Error(err, types.ErrRoundNotMatched) +} + +func (suite poolTestSuite) TestBuyDataAccessNFTPaymentNotMatched() { + // create pool + poolID := suite.setupCreatePool(10) + + err := suite.BankKeeper.AddCoins(suite.Ctx, buyerAddr, fundForBuyer) + suite.Require().NoError(err) + + // buy NFT with different payment + err = suite.DataPoolKeeper.BuyDataPass(suite.Ctx, buyerAddr, poolID, 1, sdk.NewCoin(assets.MicroMedDenom, sdk.NewInt(5000000))) + suite.Require().Error(err, types.ErrPaymentNotMatched) +} + +func (suite poolTestSuite) TestBuyDataAccessNFTInsufficientBalance() { + // create pool + poolID := suite.setupCreatePool(10) + + // buyer with small balance + err := suite.BankKeeper.AddCoins(suite.Ctx, buyerAddr, sdk.NewCoins(sdk.NewCoin(assets.MicroMedDenom, sdk.NewInt(1000)))) + suite.Require().NoError(err) + + err = suite.DataPoolKeeper.BuyDataPass(suite.Ctx, buyerAddr, poolID, 1, NFTPrice) + suite.Require().Error(err, sdkerrors.ErrInsufficientFunds) +} + func makePoolParamsWithDataValidator() types.PoolParams { return types.PoolParams{ DataSchema: []string{"https://www.json.ld"}, @@ -278,11 +380,11 @@ func makePoolParamsWithDataValidator() types.PoolParams { } } -func makePoolParamsNoDataValidator() types.PoolParams { +func makePoolParamsNoDataValidator(maxNftSupply uint64) types.PoolParams { return types.PoolParams{ DataSchema: []string{"https://www.json.ld"}, TargetNumData: 100, - MaxNftSupply: 10, + MaxNftSupply: maxNftSupply, NftPrice: &NFTPrice, TrustedDataValidators: []string(nil), TrustedDataIssuers: []string(nil), diff --git a/x/datapool/types/codec.go b/x/datapool/types/codec.go index 96fa6a2d..b00b28db 100644 --- a/x/datapool/types/codec.go +++ b/x/datapool/types/codec.go @@ -14,7 +14,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdateDataValidator{}, "datapool/UpdateDataValidator", nil) cdc.RegisterConcrete(&MsgCreatePool{}, "datapool/CreatePool", nil) cdc.RegisterConcrete(&MsgSellData{}, "datapool/SellData", nil) - cdc.RegisterConcrete(&MsgBuyDataAccessNFT{}, "datapool/BuyDataAccessNFT", nil) + cdc.RegisterConcrete(&MsgBuyDataPass{}, "datapool/BuyDataPass", nil) cdc.RegisterConcrete(&MsgRedeemDataAccessNFT{}, "datapool/RedeemDataAccessNFT", nil) } @@ -24,7 +24,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgUpdateDataValidator{}, &MsgCreatePool{}, &MsgSellData{}, - &MsgBuyDataAccessNFT{}, + &MsgBuyDataPass{}, &MsgRedeemDataAccessNFT{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/datapool/types/contract_msg.go b/x/datapool/types/contract_msg.go index 850fb954..34ff1fe3 100644 --- a/x/datapool/types/contract_msg.go +++ b/x/datapool/types/contract_msg.go @@ -4,7 +4,6 @@ import ( "strconv" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/medibloc/panacea-core/v2/types/assets" ) type mint struct { @@ -18,15 +17,23 @@ type MsgMintNFT struct { mint `json:"mint"` } -func NewMsgMintNFT(poolID uint64, owner string) *MsgMintNFT { - tokenID := "data_pool_" + strconv.FormatUint(poolID, 10) - zeroFund := sdk.NewCoin(assets.MicroMedDenom, sdk.NewInt(0)) - +func NewMsgMintCuratorNFT(poolID uint64, owner string) *MsgMintNFT { mint := &mint{ - TokenId: tokenID, + TokenId: strconv.FormatUint(poolID, 10), Owner: owner, Name: "curator_nft", - Price: zeroFund, + Price: ZeroFund, + } + + return &MsgMintNFT{mint: *mint} +} + +func NewMsgMintDataAccessNFT(numNFT uint64, owner string) *MsgMintNFT { + mint := &mint{ + TokenId: strconv.FormatUint(numNFT, 10), + Owner: owner, + Name: "data_access_nft", + Price: ZeroFund, } return &MsgMintNFT{mint: *mint} @@ -45,13 +52,3 @@ func NewInstantiateNFTMsg(name, symbol, minterAddress string) *InstantiateNFTMsg Minter: minterAddress, } } - -type MigrateContractMsg struct { - Payout sdk.AccAddress `json:"payout"` -} - -func NewMigrateContractMsg(payout sdk.AccAddress) *MigrateContractMsg { - return &MigrateContractMsg{ - Payout: payout, - } -} diff --git a/x/datapool/types/errors.go b/x/datapool/types/errors.go index 7069c0e7..10cc2450 100644 --- a/x/datapool/types/errors.go +++ b/x/datapool/types/errors.go @@ -18,4 +18,11 @@ var ( ErrExistSameDataHash = sdkerrors.Register(ModuleName, 10, "data already exists in the pool") ErrGetDataValidationCert = sdkerrors.Register(ModuleName, 11, "failed get certificate.") ErrFailedMintShareToken = sdkerrors.Register(ModuleName, 12, "failed mint share token.") + ErrNFTAllIssued = sdkerrors.Register(ModuleName, 13, "all NFTs issued") + ErrRoundNotMatched = sdkerrors.Register(ModuleName, 14, "data pool sales round not matched") + ErrPaymentNotMatched = sdkerrors.Register(ModuleName, 15, "payment not matched") + ErrCreatePool = sdkerrors.Register(ModuleName, 16, "failed to create data pool") + ErrMintNFT = sdkerrors.Register(ModuleName, 17, "failed to mint NFT") + ErrInstantiateContract = sdkerrors.Register(ModuleName, 18, "failed to instantiate contract") + ErrBuyDataPass = sdkerrors.Register(ModuleName, 19, "failed to buy data pass") ) diff --git a/x/datapool/types/genesis.go b/x/datapool/types/genesis.go index 9da362a7..22b0b18d 100644 --- a/x/datapool/types/genesis.go +++ b/x/datapool/types/genesis.go @@ -3,9 +3,9 @@ package types // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - DataValidators: []*DataValidator{}, + DataValidators: []DataValidator{}, NextPoolNumber: uint64(1), - Pools: []*Pool{}, + Pools: []Pool{}, Params: DefaultParams(), // this line is used by starport scaffolding # ibc/genesistype/default // this line is used by starport scaffolding # genesis/types/default diff --git a/x/datapool/types/genesis.pb.go b/x/datapool/types/genesis.pb.go index 5484df10..afb96966 100644 --- a/x/datapool/types/genesis.pb.go +++ b/x/datapool/types/genesis.pb.go @@ -26,10 +26,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the datapool module's genesis state. type GenesisState struct { - DataValidators []*DataValidator `protobuf:"bytes,1,rep,name=data_validators,json=dataValidators,proto3" json:"data_validators,omitempty"` - NextPoolNumber uint64 `protobuf:"varint,2,opt,name=next_pool_number,json=nextPoolNumber,proto3" json:"next_pool_number,omitempty"` - Pools []*Pool `protobuf:"bytes,3,rep,name=pools,proto3" json:"pools,omitempty"` - Params Params `protobuf:"bytes,4,opt,name=params,proto3" json:"params"` + DataValidators []DataValidator `protobuf:"bytes,1,rep,name=data_validators,json=dataValidators,proto3" json:"data_validators"` + NextPoolNumber uint64 `protobuf:"varint,2,opt,name=next_pool_number,json=nextPoolNumber,proto3" json:"next_pool_number,omitempty"` + Pools []Pool `protobuf:"bytes,3,rep,name=pools,proto3" json:"pools"` + Params Params `protobuf:"bytes,4,opt,name=params,proto3" json:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -65,7 +65,7 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetDataValidators() []*DataValidator { +func (m *GenesisState) GetDataValidators() []DataValidator { if m != nil { return m.DataValidators } @@ -79,7 +79,7 @@ func (m *GenesisState) GetNextPoolNumber() uint64 { return 0 } -func (m *GenesisState) GetPools() []*Pool { +func (m *GenesisState) GetPools() []Pool { if m != nil { return m.Pools } @@ -162,35 +162,35 @@ func init() { func init() { proto.RegisterFile("panacea/datapool/v2/genesis.proto", fileDescriptor_c5ac074515cc3a48) } var fileDescriptor_c5ac074515cc3a48 = []byte{ - // 433 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x86, 0xb3, 0x34, 0x44, 0x62, 0x8b, 0x0a, 0x18, 0x0e, 0x6e, 0x90, 0xdc, 0xe0, 0x93, 0x39, - 0xb0, 0xab, 0x84, 0x13, 0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- 0xe0, 0x7d, 0x74, 0xef, 0x04, 0xb6, 0x8a, 0x5f, 0x3d, 0xdc, 0x8a, 0xbd, 0x6e, 0x94, 0xc9, 0x27, - 0xfe, 0x54, 0xde, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x1c, 0x73, 0x14, 0xf4, 0xba, 0x02, 0x00, - 0x00, + // 436 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xc1, 0x6b, 0xd4, 0x40, + 0x14, 0xc6, 0x77, 0xec, 0xba, 0xe0, 0x54, 0xaa, 0x46, 0x0f, 0xe9, 0x0a, 0xe9, 0x9a, 0x53, 0x3c, + 0x38, 0xc3, 0xae, 0x78, 0xd0, 0x9b, 0xbb, 0x05, 0x11, 0xa1, 0xe8, 0x0a, 0x1e, 0xbc, 0x84, 0x97, + 0x99, 0x69, 0x0c, 0x24, 0xf3, 0x42, 0x66, 0xba, 0xb4, 0xff, 0x85, 0x7f, 0x56, 0x8f, 0x3d, 0x7a, + 0x2a, 0x65, 0xf7, 0x3f, 0xf0, 0x2e, 0xc8, 0x4c, 0x12, 0x5a, 0x68, 0x6e, 0xe1, 0xbd, 0xdf, 0xf7, + 0x7d, 0x2f, 0x1f, 0x43, 0x5f, 0xd5, 0xa0, 0x41, 0x28, 0xe0, 0x12, 0x2c, 0xd4, 0x88, 0x25, 0xdf, + 0x2c, 0x78, 0xae, 0xb4, 0x32, 0x85, 0x61, 0x75, 0x83, 0x16, 0x83, 0xe7, 0x1d, 0xc2, 0x7a, 0x84, + 0x6d, 0x16, 0xd3, 0x17, 0x39, 0xe6, 0xe8, 0xf7, 0xdc, 0x7d, 0xb5, 0xe8, 0x34, 0x12, 0x68, 0x2a, + 0x34, 0x3c, 0x03, 0xa3, 0xf8, 0x66, 0x9e, 0x29, 0x0b, 0x73, 0x2e, 0xb0, 0xd0, 0xfd, 0x7e, 0x28, + 0xcd, 0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0xd2, 0xb3, 0x2b, 0x94, 0xea, 0xb3, 0x0c, 0x96, 0x34, 0xba, + 0x45, 0xf5, 0xa9, 0x4d, 0x05, 0x6a, 0xdb, 0x80, 0xb0, 0x29, 0x48, 0xd9, 0x28, 0xe3, 0x9a, 0x22, + 0xc9, 0xa3, 0xf5, 0xb4, 0xd7, 0x9d, 0x9c, 0xda, 0x55, 0x87, 0x7c, 0x6c, 0x89, 0xe5, 0x97, 0xcb, + 0x6d, 0x44, 0xae, 0xb6, 0x11, 0xb9, 0xd9, 0x46, 0xe4, 0xf7, 0x2e, 0x1a, 0x5d, 0xed, 0xa2, 0xd1, + 0x9f, 0x5d, 0x34, 0xfa, 0x39, 0xcf, 0x0b, 0xfb, 0xeb, 0x2c, 0x63, 0x02, 0x2b, 0x5e, 0x29, 0x59, + 0x64, 0x25, 0x0a, 0xde, 0x55, 0xf7, 0x46, 0x60, 0xa3, 0xf8, 0xf9, 0xed, 0xbb, 0xb1, 0x17, 0xb5, + 0x32, 0xd9, 0xc4, 0x3f, 0x9b, 0xb7, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x22, 0xc1, 0xbd, + 0xc6, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -423,7 +423,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.DataValidators = append(m.DataValidators, &DataValidator{}) + m.DataValidators = append(m.DataValidators, DataValidator{}) if err := m.DataValidators[len(m.DataValidators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -476,7 +476,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Pools = append(m.Pools, &Pool{}) + m.Pools = append(m.Pools, Pool{}) if err := m.Pools[len(m.Pools)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/datapool/types/keys.go b/x/datapool/types/keys.go index 11e2bbec..0cd41d90 100644 --- a/x/datapool/types/keys.go +++ b/x/datapool/types/keys.go @@ -31,9 +31,6 @@ var ( // KeyPrefixPools defines key to store Pools KeyPrefixPools = []byte{0x03} - // KeyNFTContractAddress defines key to contract address - KeyNFTContractAddress = []byte{0x04} - // KeyPrefixDataValidatorCerts defines key to store dataValidator certs KeyPrefixDataValidatorCerts = []byte{0x05} ) diff --git a/x/datapool/types/message_pool.go b/x/datapool/types/message_pool.go index 8aa9b092..cedb5289 100644 --- a/x/datapool/types/message_pool.go +++ b/x/datapool/types/message_pool.go @@ -213,30 +213,35 @@ func (msg *MsgSellData) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{seller} } -var _ sdk.Msg = &MsgBuyDataAccessNFT{} +var _ sdk.Msg = &MsgBuyDataPass{} -func (msg *MsgBuyDataAccessNFT) Route() string { +func (msg *MsgBuyDataPass) Route() string { return RouterKey } -func (msg *MsgBuyDataAccessNFT) Type() string { - return "BuyDataAccessNFT" +func (msg *MsgBuyDataPass) Type() string { + return "BuyDataPass" } -func (msg *MsgBuyDataAccessNFT) ValidateBasic() error { +func (msg *MsgBuyDataPass) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Buyer) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid buyer address (%s)", err) } + + if !msg.Payment.IsValid() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "invalid payment") + } + return nil } -func (msg *MsgBuyDataAccessNFT) GetSignBytes() []byte { +func (msg *MsgBuyDataPass) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgBuyDataAccessNFT) GetSigners() []sdk.AccAddress { +func (msg *MsgBuyDataPass) GetSigners() []sdk.AccAddress { buyer, err := sdk.AccAddressFromBech32(msg.Buyer) if err != nil { panic(err) diff --git a/x/datapool/types/pool.go b/x/datapool/types/pool.go index 8f233536..7db77a18 100644 --- a/x/datapool/types/pool.go +++ b/x/datapool/types/pool.go @@ -1,20 +1,25 @@ package types import ( + "github.com/medibloc/panacea-core/v2/types/assets" + "fmt" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "strconv" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) const ( - PENDING = "PENDING" - ACTIVE = "ACTIVE" + PENDING = "PENDING" + ACTIVE = "ACTIVE" ShareTokenPrefix = "DP" ) +var ZeroFund = sdk.NewCoin(assets.MicroMedDenom, sdk.NewInt(0)) + func NewPool(poolID uint64, curator sdk.AccAddress, poolParams PoolParams) *Pool { poolAddress := NewPoolAddress(poolID) diff --git a/x/datapool/types/tx.pb.go b/x/datapool/types/tx.pb.go index 4a8b36e7..7d891695 100644 --- a/x/datapool/types/tx.pb.go +++ b/x/datapool/types/tx.pb.go @@ -414,26 +414,26 @@ func (m *MsgSellDataResponse) GetAccumPoolShareToken() *types.Coin { return nil } -// MsgBuyDataAccessNFT defines the Msg/BuyDataAccessNFT request type. -type MsgBuyDataAccessNFT struct { +// MsgBuyDataPass defines the Msg/BuyDataPass request type. +type MsgBuyDataPass struct { PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` Round uint64 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` Payment *types.Coin `protobuf:"bytes,3,opt,name=payment,proto3" json:"payment,omitempty"` Buyer string `protobuf:"bytes,4,opt,name=buyer,proto3" json:"buyer,omitempty"` } -func (m *MsgBuyDataAccessNFT) Reset() { *m = MsgBuyDataAccessNFT{} } -func (m *MsgBuyDataAccessNFT) String() string { return proto.CompactTextString(m) } -func (*MsgBuyDataAccessNFT) ProtoMessage() {} -func (*MsgBuyDataAccessNFT) Descriptor() ([]byte, []int) { +func (m *MsgBuyDataPass) Reset() { *m = MsgBuyDataPass{} } +func (m *MsgBuyDataPass) String() string { return proto.CompactTextString(m) } +func (*MsgBuyDataPass) ProtoMessage() {} +func (*MsgBuyDataPass) Descriptor() ([]byte, []int) { return fileDescriptor_eb3d400cb0e531d6, []int{8} } -func (m *MsgBuyDataAccessNFT) XXX_Unmarshal(b []byte) error { +func (m *MsgBuyDataPass) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgBuyDataAccessNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgBuyDataPass) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgBuyDataAccessNFT.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgBuyDataPass.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -443,65 +443,65 @@ func (m *MsgBuyDataAccessNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *MsgBuyDataAccessNFT) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBuyDataAccessNFT.Merge(m, src) +func (m *MsgBuyDataPass) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBuyDataPass.Merge(m, src) } -func (m *MsgBuyDataAccessNFT) XXX_Size() int { +func (m *MsgBuyDataPass) XXX_Size() int { return m.Size() } -func (m *MsgBuyDataAccessNFT) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBuyDataAccessNFT.DiscardUnknown(m) +func (m *MsgBuyDataPass) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBuyDataPass.DiscardUnknown(m) } -var xxx_messageInfo_MsgBuyDataAccessNFT proto.InternalMessageInfo +var xxx_messageInfo_MsgBuyDataPass proto.InternalMessageInfo -func (m *MsgBuyDataAccessNFT) GetPoolId() uint64 { +func (m *MsgBuyDataPass) GetPoolId() uint64 { if m != nil { return m.PoolId } return 0 } -func (m *MsgBuyDataAccessNFT) GetRound() uint64 { +func (m *MsgBuyDataPass) GetRound() uint64 { if m != nil { return m.Round } return 0 } -func (m *MsgBuyDataAccessNFT) GetPayment() *types.Coin { +func (m *MsgBuyDataPass) GetPayment() *types.Coin { if m != nil { return m.Payment } return nil } -func (m *MsgBuyDataAccessNFT) GetBuyer() string { +func (m *MsgBuyDataPass) GetBuyer() string { if m != nil { return m.Buyer } return "" } -// MsgBuyDataAccessNFTResponse defines the Msg/BuyDataAccessNFT response type. -type MsgBuyDataAccessNFTResponse struct { +// MsgBuyDataPassResponse defines the Msg/BuyDataAccessNFT response type. +type MsgBuyDataPassResponse struct { PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` Round uint64 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` NftId uint64 `protobuf:"varint,3,opt,name=nft_id,json=nftId,proto3" json:"nft_id,omitempty"` } -func (m *MsgBuyDataAccessNFTResponse) Reset() { *m = MsgBuyDataAccessNFTResponse{} } -func (m *MsgBuyDataAccessNFTResponse) String() string { return proto.CompactTextString(m) } -func (*MsgBuyDataAccessNFTResponse) ProtoMessage() {} -func (*MsgBuyDataAccessNFTResponse) Descriptor() ([]byte, []int) { +func (m *MsgBuyDataPassResponse) Reset() { *m = MsgBuyDataPassResponse{} } +func (m *MsgBuyDataPassResponse) String() string { return proto.CompactTextString(m) } +func (*MsgBuyDataPassResponse) ProtoMessage() {} +func (*MsgBuyDataPassResponse) Descriptor() ([]byte, []int) { return fileDescriptor_eb3d400cb0e531d6, []int{9} } -func (m *MsgBuyDataAccessNFTResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgBuyDataPassResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgBuyDataAccessNFTResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgBuyDataPassResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgBuyDataAccessNFTResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgBuyDataPassResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -511,33 +511,33 @@ func (m *MsgBuyDataAccessNFTResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *MsgBuyDataAccessNFTResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBuyDataAccessNFTResponse.Merge(m, src) +func (m *MsgBuyDataPassResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBuyDataPassResponse.Merge(m, src) } -func (m *MsgBuyDataAccessNFTResponse) XXX_Size() int { +func (m *MsgBuyDataPassResponse) XXX_Size() int { return m.Size() } -func (m *MsgBuyDataAccessNFTResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBuyDataAccessNFTResponse.DiscardUnknown(m) +func (m *MsgBuyDataPassResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBuyDataPassResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgBuyDataAccessNFTResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgBuyDataPassResponse proto.InternalMessageInfo -func (m *MsgBuyDataAccessNFTResponse) GetPoolId() uint64 { +func (m *MsgBuyDataPassResponse) GetPoolId() uint64 { if m != nil { return m.PoolId } return 0 } -func (m *MsgBuyDataAccessNFTResponse) GetRound() uint64 { +func (m *MsgBuyDataPassResponse) GetRound() uint64 { if m != nil { return m.Round } return 0 } -func (m *MsgBuyDataAccessNFTResponse) GetNftId() uint64 { +func (m *MsgBuyDataPassResponse) GetNftId() uint64 { if m != nil { return m.NftId } @@ -667,8 +667,8 @@ func init() { proto.RegisterType((*MsgCreatePoolResponse)(nil), "panacea.datapool.v2.MsgCreatePoolResponse") proto.RegisterType((*MsgSellData)(nil), "panacea.datapool.v2.MsgSellData") proto.RegisterType((*MsgSellDataResponse)(nil), "panacea.datapool.v2.MsgSellDataResponse") - proto.RegisterType((*MsgBuyDataAccessNFT)(nil), "panacea.datapool.v2.MsgBuyDataAccessNFT") - proto.RegisterType((*MsgBuyDataAccessNFTResponse)(nil), "panacea.datapool.v2.MsgBuyDataAccessNFTResponse") + proto.RegisterType((*MsgBuyDataPass)(nil), "panacea.datapool.v2.MsgBuyDataPass") + proto.RegisterType((*MsgBuyDataPassResponse)(nil), "panacea.datapool.v2.MsgBuyDataPassResponse") proto.RegisterType((*MsgRedeemDataAccessNFT)(nil), "panacea.datapool.v2.MsgRedeemDataAccessNFT") proto.RegisterType((*MsgRedeemDataAccessNFTResponse)(nil), "panacea.datapool.v2.MsgRedeemDataAccessNFTResponse") } @@ -676,54 +676,55 @@ func init() { func init() { proto.RegisterFile("panacea/datapool/v2/tx.proto", fileDescriptor_eb3d400cb0e531d6) } var fileDescriptor_eb3d400cb0e531d6 = []byte{ - // 748 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xdd, 0x4e, 0x3b, 0x45, - 0x14, 0xa7, 0x52, 0x5a, 0x3c, 0x0d, 0x42, 0xb6, 0x80, 0x75, 0x35, 0x6b, 0xb3, 0x89, 0x86, 0x48, - 0xd8, 0x95, 0x12, 0xef, 0x15, 0x88, 0x09, 0x31, 0x25, 0x64, 0x41, 0x2e, 0xd4, 0xa4, 0x99, 0xce, - 0x9e, 0x2e, 0x13, 0xb6, 0x3b, 0x9b, 0x9d, 0x69, 0xa5, 0x26, 0x3e, 0x83, 0x3e, 0x80, 0x0f, 0xe4, - 0x25, 0x97, 0x5e, 0x1a, 0x78, 0x11, 0x33, 0xd3, 0xdd, 0xa1, 0x95, 0x5d, 0x10, 0xff, 0x77, 0x3d, - 0x3d, 0xbf, 0x8f, 0x73, 0xe6, 0x9c, 0x99, 0x85, 0x4f, 0x52, 0x92, 0x10, 0x8a, 0xc4, 0x0f, 0x89, - 0x24, 0x29, 0xe7, 0xb1, 0x3f, 0xed, 0xf9, 0xf2, 0xce, 0x4b, 0x33, 0x2e, 0xb9, 0xd5, 0xce, 0xb3, - 0x5e, 0x91, 0xf5, 0xa6, 0x3d, 0x7b, 0x3b, 0xe2, 0x11, 0xd7, 0x79, 0x5f, 0xfd, 0x9a, 0x43, 0x6d, - 0x87, 0x72, 0x31, 0xe6, 0xc2, 0x1f, 0x12, 0x81, 0xfe, 0xf4, 0x70, 0x88, 0x92, 0x1c, 0xfa, 0x94, - 0xb3, 0xa4, 0xc8, 0x47, 0x9c, 0x47, 0x31, 0xfa, 0x3a, 0x1a, 0x4e, 0x46, 0x7e, 0x38, 0xc9, 0x88, - 0x64, 0xdc, 0xe4, 0xcb, 0x0a, 0xd1, 0x96, 0x3a, 0xef, 0x32, 0xe8, 0xf4, 0x45, 0x14, 0x60, 0xc4, - 0x84, 0xc4, 0xec, 0x94, 0x48, 0x72, 0x4d, 0x62, 0x16, 0x12, 0xc9, 0x33, 0xab, 0x0f, 0x5b, 0xd3, - 0x22, 0x18, 0x84, 0x28, 0x09, 0x8b, 0x3b, 0xb5, 0x6e, 0x6d, 0xaf, 0xd5, 0x73, 0xbd, 0x92, 0x0e, - 0xbc, 0x25, 0x76, 0xb0, 0x69, 0xb8, 0xa7, 0x9a, 0xea, 0xba, 0xd0, 0xad, 0xb2, 0x0a, 0x50, 0xa4, - 0x3c, 0x11, 0xe8, 0xfe, 0x08, 0xbb, 0x7d, 0x11, 0x7d, 0x9f, 0x86, 0x44, 0xe2, 0x72, 0x31, 0x9f, - 0xc1, 0x07, 0xca, 0x6b, 0x60, 0x54, 0x75, 0x29, 0xef, 0x07, 0x1b, 0xe1, 0x12, 0xcc, 0x86, 0x75, - 0x4c, 0xc2, 0x94, 0xb3, 0x44, 0x76, 0xde, 0xd3, 0x00, 0x13, 0xbb, 0x5d, 0x70, 0xca, 0xc5, 0x8d, - 0xfd, 0x2d, 0x6c, 0xf4, 0x45, 0x74, 0x92, 0x21, 0x91, 0x78, 0xc1, 0x79, 0x6c, 0x75, 0xa0, 0x49, - 0xd5, 0x81, 0x1a, 0xbb, 0x22, 0xb4, 0xbe, 0x86, 0x96, 0xea, 0x7b, 0x90, 0x92, 0x8c, 0x8c, 0x85, - 0xf6, 0x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c2, - 0xa6, 0x1f, 0x7f, 0xf7, 0xe7, 0x83, 0x53, 0xbb, 0x7f, 0x70, 0x6a, 0x7f, 0x3f, 0x38, 0xb5, 0xdf, - 0x1f, 0x9d, 0x95, 0xfb, 0x47, 0x67, 0xe5, 0xaf, 0x47, 0x67, 0xe5, 0x87, 0xc3, 0x88, 0xc9, 0x9b, - 0xc9, 0xd0, 0xa3, 0x7c, 0xec, 0x8f, 0x31, 0x64, 0xc3, 0x98, 0x53, 0x3f, 0x77, 0x38, 0xa0, 0x3c, - 0x43, 0xff, 0xee, 0xe9, 0x83, 0x2c, 0x67, 0x29, 0x8a, 0x61, 0x43, 0x7f, 0x8f, 0x8f, 0xfe, 0x09, - 0x00, 0x00, 0xff, 0xff, 0x7c, 0xc2, 0xa5, 0x03, 0x3a, 0x08, 0x00, 0x00, + // 756 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x5f, 0x4f, 0xdb, 0x48, + 0x10, 0x27, 0x47, 0x48, 0xb8, 0x89, 0x80, 0x93, 0x03, 0x5c, 0xce, 0x3a, 0xf9, 0x22, 0x9f, 0xee, + 0x84, 0x0e, 0x61, 0x8b, 0xa0, 0x7b, 0xbf, 0x03, 0x54, 0x09, 0x55, 0x41, 0xc8, 0x50, 0x1e, 0xda, + 0xaa, 0xd1, 0xc6, 0x9e, 0x98, 0x15, 0x8e, 0xd7, 0xf2, 0x6e, 0x52, 0x52, 0xa9, 0x5f, 0xa0, 0x52, + 0xa5, 0x7e, 0xac, 0x3e, 0xf2, 0xd8, 0xc7, 0x0a, 0xbe, 0x48, 0xb5, 0x1b, 0x7b, 0x49, 0x54, 0x1b, + 0x4a, 0xd5, 0xb7, 0x4c, 0xe6, 0xf7, 0x67, 0x66, 0x67, 0x76, 0x0d, 0xbf, 0x27, 0x24, 0x26, 0x3e, + 0x12, 0x37, 0x20, 0x82, 0x24, 0x8c, 0x45, 0xee, 0xb8, 0xe3, 0x8a, 0x2b, 0x27, 0x49, 0x99, 0x60, + 0x46, 0x33, 0xcb, 0x3a, 0x79, 0xd6, 0x19, 0x77, 0xcc, 0xf5, 0x90, 0x85, 0x4c, 0xe5, 0x5d, 0xf9, + 0x6b, 0x0a, 0x35, 0x2d, 0x9f, 0xf1, 0x21, 0xe3, 0x6e, 0x9f, 0x70, 0x74, 0xc7, 0xbb, 0x7d, 0x14, + 0x64, 0xd7, 0xf5, 0x19, 0x8d, 0xf3, 0x7c, 0xc8, 0x58, 0x18, 0xa1, 0xab, 0xa2, 0xfe, 0x68, 0xe0, + 0x06, 0xa3, 0x94, 0x08, 0xca, 0x74, 0xbe, 0xa8, 0x10, 0x65, 0xa9, 0xf2, 0x36, 0x85, 0x56, 0x97, + 0x87, 0x1e, 0x86, 0x94, 0x0b, 0x4c, 0x0f, 0x89, 0x20, 0xe7, 0x24, 0xa2, 0x01, 0x11, 0x2c, 0x35, + 0xba, 0xf0, 0xcb, 0x38, 0x0f, 0x7a, 0x01, 0x0a, 0x42, 0xa3, 0x56, 0xa5, 0x5d, 0xd9, 0x6a, 0x74, + 0x6c, 0xa7, 0xa0, 0x03, 0x67, 0x8e, 0xed, 0xad, 0x69, 0xee, 0xa1, 0xa2, 0xda, 0x36, 0xb4, 0xcb, + 0xac, 0x3c, 0xe4, 0x09, 0x8b, 0x39, 0xda, 0x2f, 0x60, 0xb3, 0xcb, 0xc3, 0x67, 0x49, 0x40, 0x04, + 0xce, 0x17, 0xf3, 0x17, 0xac, 0x4a, 0xaf, 0x9e, 0x56, 0x55, 0xa5, 0xfc, 0xec, 0xad, 0x04, 0x73, + 0x30, 0x13, 0x96, 0x31, 0x0e, 0x12, 0x46, 0x63, 0xd1, 0xfa, 0x49, 0x01, 0x74, 0x6c, 0xb7, 0xc1, + 0x2a, 0x16, 0xd7, 0xf6, 0x97, 0xb0, 0xd2, 0xe5, 0xe1, 0x41, 0x8a, 0x44, 0xe0, 0x09, 0x63, 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eb, 0xf6, 0xa0, 0x31, 0x7b, + 0x0f, 0xff, 0x2c, 0x23, 0xce, 0x80, 0xcc, 0xed, 0x6f, 0x00, 0xcd, 0xce, 0xa3, 0x68, 0xf9, 0xb7, + 0xcb, 0xa7, 0xfb, 0x15, 0xb8, 0x7c, 0x1e, 0xf7, 0xac, 0xf6, 0xfe, 0xd3, 0x8f, 0x37, 0x56, 0xe5, + 0xfa, 0xc6, 0xaa, 0x7c, 0xbe, 0xb1, 0x2a, 0x1f, 0x6e, 0xad, 0x85, 0xeb, 0x5b, 0x6b, 0xe1, 0xd3, + 0xad, 0xb5, 0xf0, 0x7c, 0x37, 0xa4, 0xe2, 0x62, 0xd4, 0x77, 0x7c, 0x36, 0x74, 0x87, 0x18, 0xd0, + 0x7e, 0xc4, 0x7c, 0x37, 0x73, 0xd8, 0xf1, 0x59, 0x8a, 0xee, 0xd5, 0xdd, 0x77, 0x57, 0x4c, 0x12, + 0xe4, 0xfd, 0x9a, 0xfa, 0xec, 0xee, 0x7d, 0x09, 0x00, 0x00, 0xff, 0xff, 0xd6, 0xdf, 0xa3, 0xb8, + 0x21, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -746,8 +747,8 @@ type MsgClient interface { CreatePool(ctx context.Context, in *MsgCreatePool, opts ...grpc.CallOption) (*MsgCreatePoolResponse, error) // SellData defines a method for selling data SellData(ctx context.Context, in *MsgSellData, opts ...grpc.CallOption) (*MsgSellDataResponse, error) - // BuyDataAccessNFT defines a method for buying data access NFT - BuyDataAccessNFT(ctx context.Context, in *MsgBuyDataAccessNFT, opts ...grpc.CallOption) (*MsgBuyDataAccessNFTResponse, error) + // BuyDataPass defines a method for buying data access NFT + BuyDataPass(ctx context.Context, in *MsgBuyDataPass, opts ...grpc.CallOption) (*MsgBuyDataPassResponse, error) // RedeemDataAccessNFT defines a method for redeeming data access NFT to get data RedeemDataAccessNFT(ctx context.Context, in *MsgRedeemDataAccessNFT, opts ...grpc.CallOption) (*MsgRedeemDataAccessNFTResponse, error) } @@ -796,9 +797,9 @@ func (c *msgClient) SellData(ctx context.Context, in *MsgSellData, opts ...grpc. return out, nil } -func (c *msgClient) BuyDataAccessNFT(ctx context.Context, in *MsgBuyDataAccessNFT, opts ...grpc.CallOption) (*MsgBuyDataAccessNFTResponse, error) { - out := new(MsgBuyDataAccessNFTResponse) - err := c.cc.Invoke(ctx, "/panacea.datapool.v2.Msg/BuyDataAccessNFT", in, out, opts...) +func (c *msgClient) BuyDataPass(ctx context.Context, in *MsgBuyDataPass, opts ...grpc.CallOption) (*MsgBuyDataPassResponse, error) { + out := new(MsgBuyDataPassResponse) + err := c.cc.Invoke(ctx, "/panacea.datapool.v2.Msg/BuyDataPass", in, out, opts...) if err != nil { return nil, err } @@ -824,8 +825,8 @@ type MsgServer interface { CreatePool(context.Context, *MsgCreatePool) (*MsgCreatePoolResponse, error) // SellData defines a method for selling data SellData(context.Context, *MsgSellData) (*MsgSellDataResponse, error) - // BuyDataAccessNFT defines a method for buying data access NFT - BuyDataAccessNFT(context.Context, *MsgBuyDataAccessNFT) (*MsgBuyDataAccessNFTResponse, error) + // BuyDataPass defines a method for buying data access NFT + BuyDataPass(context.Context, *MsgBuyDataPass) (*MsgBuyDataPassResponse, error) // RedeemDataAccessNFT defines a method for redeeming data access NFT to get data RedeemDataAccessNFT(context.Context, *MsgRedeemDataAccessNFT) (*MsgRedeemDataAccessNFTResponse, error) } @@ -846,8 +847,8 @@ func (*UnimplementedMsgServer) CreatePool(ctx context.Context, req *MsgCreatePoo func (*UnimplementedMsgServer) SellData(ctx context.Context, req *MsgSellData) (*MsgSellDataResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SellData not implemented") } -func (*UnimplementedMsgServer) BuyDataAccessNFT(ctx context.Context, req *MsgBuyDataAccessNFT) (*MsgBuyDataAccessNFTResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BuyDataAccessNFT not implemented") +func (*UnimplementedMsgServer) BuyDataPass(ctx context.Context, req *MsgBuyDataPass) (*MsgBuyDataPassResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BuyDataPass not implemented") } func (*UnimplementedMsgServer) RedeemDataAccessNFT(ctx context.Context, req *MsgRedeemDataAccessNFT) (*MsgRedeemDataAccessNFTResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RedeemDataAccessNFT not implemented") @@ -929,20 +930,20 @@ func _Msg_SellData_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Msg_BuyDataAccessNFT_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgBuyDataAccessNFT) +func _Msg_BuyDataPass_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgBuyDataPass) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).BuyDataAccessNFT(ctx, in) + return srv.(MsgServer).BuyDataPass(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/panacea.datapool.v2.Msg/BuyDataAccessNFT", + FullMethod: "/panacea.datapool.v2.Msg/BuyDataPass", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).BuyDataAccessNFT(ctx, req.(*MsgBuyDataAccessNFT)) + return srv.(MsgServer).BuyDataPass(ctx, req.(*MsgBuyDataPass)) } return interceptor(ctx, in, info, handler) } @@ -986,8 +987,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_SellData_Handler, }, { - MethodName: "BuyDataAccessNFT", - Handler: _Msg_BuyDataAccessNFT_Handler, + MethodName: "BuyDataPass", + Handler: _Msg_BuyDataPass_Handler, }, { MethodName: "RedeemDataAccessNFT", @@ -1273,7 +1274,7 @@ func (m *MsgSellDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgBuyDataAccessNFT) Marshal() (dAtA []byte, err error) { +func (m *MsgBuyDataPass) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1283,12 +1284,12 @@ func (m *MsgBuyDataAccessNFT) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgBuyDataAccessNFT) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgBuyDataPass) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgBuyDataAccessNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgBuyDataPass) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1325,7 +1326,7 @@ func (m *MsgBuyDataAccessNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgBuyDataAccessNFTResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgBuyDataPassResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1335,12 +1336,12 @@ func (m *MsgBuyDataAccessNFTResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgBuyDataAccessNFTResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgBuyDataPassResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgBuyDataAccessNFTResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgBuyDataPassResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1567,7 +1568,7 @@ func (m *MsgSellDataResponse) Size() (n int) { return n } -func (m *MsgBuyDataAccessNFT) Size() (n int) { +func (m *MsgBuyDataPass) Size() (n int) { if m == nil { return 0 } @@ -1590,7 +1591,7 @@ func (m *MsgBuyDataAccessNFT) Size() (n int) { return n } -func (m *MsgBuyDataAccessNFTResponse) Size() (n int) { +func (m *MsgBuyDataPassResponse) Size() (n int) { if m == nil { return 0 } @@ -2378,7 +2379,7 @@ func (m *MsgSellDataResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgBuyDataAccessNFT) Unmarshal(dAtA []byte) error { +func (m *MsgBuyDataPass) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2401,10 +2402,10 @@ func (m *MsgBuyDataAccessNFT) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgBuyDataAccessNFT: wiretype end group for non-group") + return fmt.Errorf("proto: MsgBuyDataPass: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBuyDataAccessNFT: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgBuyDataPass: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2534,7 +2535,7 @@ func (m *MsgBuyDataAccessNFT) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgBuyDataAccessNFTResponse) Unmarshal(dAtA []byte) error { +func (m *MsgBuyDataPassResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2557,10 +2558,10 @@ func (m *MsgBuyDataAccessNFTResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgBuyDataAccessNFTResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgBuyDataPassResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBuyDataAccessNFTResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgBuyDataPassResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: