diff --git a/app/ante/ante.go b/app/ante/ante.go index a74ae30..de07768 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -29,7 +29,7 @@ func (cm CheckMachineDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate case "/planetmintgo.asset.MsgNotarizeAsset": notarizeMsg, ok := msg.(*assettypes.MsgNotarizeAsset) if ok { - _, found := cm.mk.GetMachineIndexByPubKey(ctx, notarizeMsg.PubKey) + _, found := cm.mk.GetMachineIndexByAddress(ctx, notarizeMsg.GetCreator()) if !found { return ctx, errorsmod.Wrapf(machinetypes.ErrMachineNotFound, "error during CheckTx or ReCheckTx") } @@ -37,6 +37,9 @@ func (cm CheckMachineDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate case "/planetmintgo.machine.MsgAttestMachine": attestMsg, ok := msg.(*machinetypes.MsgAttestMachine) if ok { + if attestMsg.GetCreator() != attestMsg.Machine.GetAddress() { + return ctx, errorsmod.Wrapf(machinetypes.ErrMachineIsNotCreator, "error during CheckTx or ReCheckTx") + } _, activated, found := cm.mk.GetTrustAnchor(ctx, attestMsg.Machine.MachineId) if !found { return ctx, errorsmod.Wrapf(machinetypes.ErrTrustAnchorNotFound, "error during CheckTx or ReCheckTx") diff --git a/app/ante/expected_keepers.go b/app/ante/expected_keepers.go index 874a431..da8e415 100644 --- a/app/ante/expected_keepers.go +++ b/app/ante/expected_keepers.go @@ -9,6 +9,7 @@ import ( type MachineKeeper interface { GetMachineIndexByPubKey(ctx sdk.Context, pubKey string) (val types.MachineIndex, found bool) + GetMachineIndexByAddress(ctx sdk.Context, address string) (val types.MachineIndex, found bool) GetTrustAnchor(ctx sdk.Context, pubKey string) (val types.TrustAnchor, activated bool, found bool) } diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 6f30d41..f7dac45 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -46473,10 +46473,10 @@ paths: additionalProperties: {} tags: - Query - /planetmint/planetmint-go/asset/get_cids_by_pub_key/{extPubKey}/{lookupPeriodInMin}: + /planetmint/planetmint-go/asset/get_cids_by_address/{address}/{lookupPeriodInMin}: get: - summary: Queries a list of GetCIDsByPubKey items. - operationId: PlanetmintgoAssetGetCIDsByPubKey + summary: Queries a list of GetCIDsByAddress items. + operationId: PlanetmintgoAssetGetCIDsByAddress responses: '200': description: A successful response. @@ -46534,7 +46534,7 @@ paths: type: string additionalProperties: {} parameters: - - name: extPubKey + - name: address in: path required: true type: string @@ -75649,7 +75649,7 @@ definitions: planetmintgo.asset.Params: type: object description: Params defines the parameters for the module. - planetmintgo.asset.QueryGetCIDsByPubKeyResponse: + planetmintgo.asset.QueryGetCIDsByAddressResponse: type: object properties: cids: diff --git a/proto/planetmintgo/asset/asset.proto b/proto/planetmintgo/asset/asset.proto index 2bcc7d6..8ef5375 100644 --- a/proto/planetmintgo/asset/asset.proto +++ b/proto/planetmintgo/asset/asset.proto @@ -4,8 +4,5 @@ package planetmintgo.asset; option go_package = "github.com/planetmint/planetmint-go/x/asset/types"; message Asset { - - string hash = 1; - string signature = 2; - string pubkey = 3; + string cid = 1; } diff --git a/proto/planetmintgo/asset/query.proto b/proto/planetmintgo/asset/query.proto index 751bd27..0d210c2 100644 --- a/proto/planetmintgo/asset/query.proto +++ b/proto/planetmintgo/asset/query.proto @@ -18,9 +18,9 @@ service Query { } - // Queries a list of GetCIDsByPubKey items. - rpc GetCIDsByPubKey (QueryGetCIDsByPubKeyRequest) returns (QueryGetCIDsByPubKeyResponse) { - option (google.api.http).get = "/planetmint/planetmint-go/asset/get_cids_by_pub_key/{extPubKey}/{lookupPeriodInMin}"; + // Queries a list of GetCIDsByAddress items. + rpc GetCIDsByAddress (QueryGetCIDsByAddressRequest) returns (QueryGetCIDsByAddressResponse) { + option (google.api.http).get = "/planetmint/planetmint-go/asset/get_cids_by_address/{address}/{lookupPeriodInMin}"; } @@ -40,13 +40,13 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } -message QueryGetCIDsByPubKeyRequest { - string extPubKey = 1; +message QueryGetCIDsByAddressRequest { + string address = 1; uint64 lookupPeriodInMin = 2; cosmos.base.query.v1beta1.PageRequest pagination = 3; } -message QueryGetCIDsByPubKeyResponse { +message QueryGetCIDsByAddressResponse { repeated string cids = 1; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -57,7 +57,6 @@ message QueryGetNotarizedAssetRequest { message QueryGetNotarizedAssetResponse { string cid = 1; - string signature = 2; - string pubkey = 3; + string address = 2; } diff --git a/proto/planetmintgo/asset/tx.proto b/proto/planetmintgo/asset/tx.proto index cf2e879..51b1d82 100644 --- a/proto/planetmintgo/asset/tx.proto +++ b/proto/planetmintgo/asset/tx.proto @@ -10,9 +10,7 @@ service Msg { } message MsgNotarizeAsset { string creator = 1; - string hash = 2; - string signature = 3; - string pubKey = 4; + string cid = 2; } message MsgNotarizeAssetResponse {} diff --git a/tests/e2e/asset/rest.go b/tests/e2e/asset/rest.go index e348aa2..1fe7267 100644 --- a/tests/e2e/asset/rest.go +++ b/tests/e2e/asset/rest.go @@ -1,13 +1,11 @@ package asset import ( - "encoding/hex" "fmt" + "github.com/planetmint/planetmint-go/testutil" "github.com/planetmint/planetmint-go/testutil/sample" - "github.com/btcsuite/btcd/btcutil/hdkeychain" - assettypes "github.com/planetmint/planetmint-go/x/asset/types" txtypes "github.com/cosmos/cosmos-sdk/types/tx" @@ -23,62 +21,39 @@ func (s *E2ETestSuite) TestNotarizeAssetREST() { addr, err := k.GetAddress() s.Require().NoError(err) - - xskKey, _ := hdkeychain.NewKeyFromString(xPrvKey) - privKey, _ := xskKey.ECPrivKey() - byte_key := privKey.Serialize() - sk := hex.EncodeToString(byte_key) - cid, signatureHex := sample.Asset(sk) - + cid := sample.Asset() testCases := []struct { name string msg assettypes.MsgNotarizeAsset rawLog string expectCheckTxErr bool }{ + { + "invalid address", + assettypes.MsgNotarizeAsset{ + Creator: "invalid creator address", + Cid: cid, + }, + "invalid address", + true, + }, { "machine not found", assettypes.MsgNotarizeAsset{ - Creator: addr.String(), - Hash: cid, - Signature: signatureHex, - PubKey: "human pubkey", + Creator: "cosmos12qydd0w5ff4sww54dxm0sreznxlex8wfrg86c5", + Cid: cid, }, "machine not found", true, }, - { - "invalid signature hex string", - assettypes.MsgNotarizeAsset{ - Creator: addr.String(), - Hash: cid, - Signature: "invalid signature", - PubKey: xPubKey, - }, - "invalid signature hex string", - false, - }, - { - "invalid signature", - assettypes.MsgNotarizeAsset{ - Creator: addr.String(), - Hash: cid, - Signature: hex.EncodeToString([]byte("invalid signature")), - PubKey: xPubKey, - }, - "invalid signature", - false, - }, { "valid notarization", assettypes.MsgNotarizeAsset{ - Creator: addr.String(), - Hash: cid, - Signature: signatureHex, - PubKey: xPubKey, + Creator: addr.String(), + Cid: cid, }, - "planetmintgo.asset.MsgNotarizeAsset", - false, + "[]", + true, }, } diff --git a/tests/e2e/asset/suite.go b/tests/e2e/asset/suite.go index 4632056..de0a513 100644 --- a/tests/e2e/asset/suite.go +++ b/tests/e2e/asset/suite.go @@ -1,11 +1,9 @@ package asset import ( - "encoding/hex" "encoding/json" "fmt" - "github.com/planetmint/planetmint-go/config" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" @@ -13,7 +11,6 @@ import ( assetcli "github.com/planetmint/planetmint-go/x/asset/client/cli" machinecli "github.com/planetmint/planetmint-go/x/machine/client/cli" - "github.com/btcsuite/btcd/btcutil/hdkeychain" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -23,10 +20,8 @@ import ( ) var ( - pubKey string - prvKey string - xPubKey string - xPrvKey string + pubKey string + prvKey string ) // E2ETestSuite struct definition of asset suite @@ -63,6 +58,7 @@ func (s *E2ETestSuite) SetupSuite() { "--yes", fmt.Sprintf("--%s=%s", flags.FlagFees, sample.Fees), } + out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, bank.NewSendTxCmd(), args) s.Require().NoError(err) @@ -78,14 +74,13 @@ func (s *E2ETestSuite) SetupSuite() { s.Require().NoError(s.network.WaitForNextBlock()) prvKey, pubKey = sample.KeyPair() - xPrvKey, xPubKey = sample.ExtendedKeyPair(config.PlmntNetParams) ta := sample.TrustAnchor(pubKey) taJSON, err := json.Marshal(&ta) s.Require().NoError(err) args = []string{ fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID), - fmt.Sprintf("--%s=%s", flags.FlagFrom, sample.Name), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr.String()), fmt.Sprintf("--%s=%s", flags.FlagFees, sample.Fees), "--yes", string(taJSON), @@ -95,7 +90,7 @@ func (s *E2ETestSuite) SetupSuite() { s.Require().NoError(s.network.WaitForNextBlock()) - machine := sample.Machine(sample.Name, pubKey, prvKey) + machine := sample.Machine(sample.Name, pubKey, prvKey, addr.String()) machineJSON, err := json.Marshal(&machine) s.Require().NoError(err) @@ -127,12 +122,11 @@ func (s *E2ETestSuite) TearDownSuite() { // TestNotarizeAsset notarizes asset over cli func (s *E2ETestSuite) TestNotarizeAsset() { val := s.network.Validators[0] + k, err := val.ClientCtx.Keyring.Key(sample.Name) + s.Require().NoError(err) - xskKey, _ := hdkeychain.NewKeyFromString(xPrvKey) - privKey, _ := xskKey.ECPrivKey() - byte_key := privKey.Serialize() - sk := hex.EncodeToString(byte_key) - cid, signatureHex := sample.Asset(sk) + addr, _ := k.GetAddress() + cid := sample.Asset() testCases := []struct { name string @@ -140,57 +134,16 @@ func (s *E2ETestSuite) TestNotarizeAsset() { rawLog string expectCheckTxErr bool }{ - { - "machine not found", - []string{ - cid, - signatureHex, - "pubkey", - fmt.Sprintf("--%s=%s", flags.FlagFrom, sample.Name), - fmt.Sprintf("--%s=%s", flags.FlagFees, sample.Fees), - "--yes", - }, - "machine not found", - true, - }, - { - "invalid signature hex string", - []string{ - cid, - "signature", - xPubKey, - fmt.Sprintf("--%s=%s", flags.FlagFrom, sample.Name), - fmt.Sprintf("--%s=%s", flags.FlagFees, sample.Fees), - "--yes", - }, - "invalid signature hex string", - false, - }, - { - "invalid signature", - []string{ - cid, - hex.EncodeToString([]byte("signature")), - xPubKey, - fmt.Sprintf("--%s=%s", flags.FlagFrom, sample.Name), - fmt.Sprintf("--%s=%s", flags.FlagFees, sample.Fees), - "--yes", - }, - "invalid signature", - false, - }, { "valid notarization", []string{ cid, - signatureHex, - xPubKey, - fmt.Sprintf("--%s=%s", flags.FlagFrom, sample.Name), + fmt.Sprintf("--%s=%s", flags.FlagFrom, addr.String()), fmt.Sprintf("--%s=%s", flags.FlagFees, sample.Fees), "--yes", }, - "planetmintgo.asset.MsgNotarizeAsset", - false, + "[]", + true, }, } diff --git a/tests/e2e/machine/rest.go b/tests/e2e/machine/rest.go index 7a64f46..7a31a46 100644 --- a/tests/e2e/machine/rest.go +++ b/tests/e2e/machine/rest.go @@ -2,6 +2,7 @@ package machine import ( "fmt" + "github.com/planetmint/planetmint-go/testutil" "github.com/planetmint/planetmint-go/testutil/sample" machinetypes "github.com/planetmint/planetmint-go/x/machine/types" @@ -37,8 +38,7 @@ func (s *E2ETestSuite) TestAttestMachineREST() { s.Require().NoError(s.network.WaitForNextBlock()) // Create Attest Machine TX - machine := sample.Machine(sample.Name, pubKey, prvKey) - machine.Address = addr.String() + machine := sample.Machine(sample.Name, pubKey, prvKey, addr.String()) msg := machinetypes.MsgAttestMachine{ Creator: addr.String(), Machine: &machine, diff --git a/tests/e2e/machine/suite.go b/tests/e2e/machine/suite.go index f666f31..c59900d 100644 --- a/tests/e2e/machine/suite.go +++ b/tests/e2e/machine/suite.go @@ -3,6 +3,7 @@ package machine import ( "encoding/json" "fmt" + clitestutil "github.com/planetmint/planetmint-go/testutil/cli" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" @@ -97,7 +98,11 @@ func (s *E2ETestSuite) TestAttestMachine() { assert.Contains(s.T(), rawLog, "planetmintgo.machine.MsgRegisterTrustAnchor") - machine := sample.Machine(sample.Name, pubKey, prvKey) + k, err := val.ClientCtx.Keyring.Key(sample.Name) + s.Require().NoError(err) + addr, _ := k.GetAddress() + + machine := sample.Machine(sample.Name, pubKey, prvKey, addr.String()) machineJSON, err := json.Marshal(&machine) s.Require().NoError(err) diff --git a/testutil/keeper/asset.go b/testutil/keeper/asset.go index 19f0847..55e1822 100644 --- a/testutil/keeper/asset.go +++ b/testutil/keeper/asset.go @@ -51,12 +51,13 @@ func AssetKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { sk, pk := sample.KeyPair() _, ppk := sample.ExtendedKeyPair(config.PlmntNetParams) _, lpk := sample.ExtendedKeyPair(config.LiquidNetParams) + id := sample.MachineIndex(pk, ppk, lpk) mk.EXPECT().GetMachineIndexByPubKey(ctx, pk).Return(id, true).AnyTimes() mk.EXPECT().GetMachineIndexByPubKey(ctx, ppk).Return(id, true).AnyTimes() mk.EXPECT().GetMachineIndexByPubKey(ctx, sk).Return(id, false).AnyTimes() - mk.EXPECT().GetMachine(ctx, id).Return(sample.Machine(pk, pk, sk), true).AnyTimes() - mk.EXPECT().GetMachine(ctx, sk).Return(sample.Machine(pk, pk, sk), false).AnyTimes() + mk.EXPECT().GetMachine(ctx, id).Return(sample.Machine(pk, pk, sk, ""), true).AnyTimes() + mk.EXPECT().GetMachine(ctx, sk).Return(sample.Machine(pk, pk, sk, ""), false).AnyTimes() k := keeper.NewKeeper( cdc, diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index a73d1e7..37792c7 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -60,7 +60,7 @@ func Secp256k1AccAddress() sdk.AccAddress { } // TODO: make address deterministic for test cases -func Machine(name, pubKey string, prvKey string) machinetypes.Machine { +func Machine(name, pubKey string, prvKey string, address string) machinetypes.Machine { metadata := Metadata() _, liquidPubKey := ExtendedKeyPair(config.LiquidNetParams) _, planetmintPubKey := ExtendedKeyPair(config.PlmntNetParams) @@ -71,7 +71,9 @@ func Machine(name, pubKey string, prvKey string) machinetypes.Machine { sign, _ := sk.Sign(pubKeyBytes) signatureHex := hex.EncodeToString(sign) - addr := Secp256k1AccAddress() + if address == "" { + address = Secp256k1AccAddress().String() + } m := machinetypes.Machine{ Name: name, @@ -86,7 +88,7 @@ func Machine(name, pubKey string, prvKey string) machinetypes.Machine { Metadata: &metadata, Type: 1, MachineIdSignature: signatureHex, - Address: addr.String(), + Address: address, } return m } @@ -108,16 +110,9 @@ func Metadata() machinetypes.Metadata { } } -func Asset(sk string) (string, string) { - cid := "cid" - - skBytes, _ := hex.DecodeString(sk) - privKey := &secp256k1.PrivKey{Key: skBytes} - - sign, _ := privKey.Sign([]byte(cid)) - signatureHex := hex.EncodeToString(sign) - - return cid, signatureHex +func Asset() string { + cid := "cid0" + return cid } func ExtendedKeyPair(cfg chaincfg.Params) (string, string) { diff --git a/x/asset/client/cli/query.go b/x/asset/client/cli/query.go index d54543d..2636682 100644 --- a/x/asset/client/cli/query.go +++ b/x/asset/client/cli/query.go @@ -25,7 +25,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) - cmd.AddCommand(CmdGetCIDsByPubKey()) + cmd.AddCommand(CmdGetCIDsByAddress()) cmd.AddCommand(CmdGetNotarizedAsset()) diff --git a/x/asset/client/cli/query_get_assets_by_pub_key.go b/x/asset/client/cli/query_get_assets_by_pub_key.go index f9dc2c3..cc35cb0 100644 --- a/x/asset/client/cli/query_get_assets_by_pub_key.go +++ b/x/asset/client/cli/query_get_assets_by_pub_key.go @@ -12,13 +12,13 @@ import ( var _ = strconv.Itoa(0) -func CmdGetCIDsByPubKey() *cobra.Command { +func CmdGetCIDsByAddress() *cobra.Command { cmd := &cobra.Command{ Use: "get-assets-by-pub-key [ext-pub-key] [lookup-period-in-min]", - Short: "Query get_cids_by_pub_key", + Short: "Query get_cids_by_address", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { - reqExtPubKey := args[0] + reqAddress := args[0] reqLookupPeriodInMin, err := cast.ToUint64E(args[1]) if err != nil { return err @@ -31,9 +31,9 @@ func CmdGetCIDsByPubKey() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryGetCIDsByPubKeyRequest{ + params := &types.QueryGetCIDsByAddressRequest{ - ExtPubKey: reqExtPubKey, + Address: reqAddress, LookupPeriodInMin: reqLookupPeriodInMin, } @@ -43,7 +43,7 @@ func CmdGetCIDsByPubKey() *cobra.Command { } params.Pagination = pageReq - res, err := queryClient.GetCIDsByPubKey(cmd.Context(), params) + res, err := queryClient.GetCIDsByAddress(cmd.Context(), params) if err != nil { return err } diff --git a/x/asset/client/cli/tx_notarize_asset.go b/x/asset/client/cli/tx_notarize_asset.go index 9640226..d12023c 100644 --- a/x/asset/client/cli/tx_notarize_asset.go +++ b/x/asset/client/cli/tx_notarize_asset.go @@ -14,13 +14,11 @@ var _ = strconv.Itoa(0) func CmdNotarizeAsset() *cobra.Command { cmd := &cobra.Command{ - Use: "notarize-asset [hash] [signature] [pub-key]", + Use: "notarize-asset [cid] ", Short: "Broadcast message notarize-asset", - Args: cobra.ExactArgs(3), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { - argHash := args[0] - argSignature := args[1] - argPubKey := args[2] + argCid := args[0] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -29,9 +27,7 @@ func CmdNotarizeAsset() *cobra.Command { msg := types.NewMsgNotarizeAsset( clientCtx.GetFromAddress().String(), - argHash, - argSignature, - argPubKey, + argCid, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/asset/keeper/asset.go b/x/asset/keeper/asset.go index a436ed4..1ba7bb9 100644 --- a/x/asset/keeper/asset.go +++ b/x/asset/keeper/asset.go @@ -7,57 +7,39 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) StoreAsset(ctx sdk.Context, asset types.Asset) { +func (k Keeper) StoreAsset(ctx sdk.Context, msg types.MsgNotarizeAsset) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AssetKey)) - appendValue := k.cdc.MustMarshal(&asset) - store.Set(GetAssetHashBytes(asset.Hash), appendValue) + store.Set(GetAssetCIDBytes(msg.GetCid()), []byte(msg.GetCreator())) } -func (k Keeper) GetAsset(ctx sdk.Context, hash string) (val types.Asset, found bool) { +func (k Keeper) GetAsset(ctx sdk.Context, cid string) (msg types.MsgNotarizeAsset, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AssetKey)) - asset := store.Get(GetAssetHashBytes(hash)) - if asset == nil { - return val, false + creator_bytes := store.Get(GetAssetCIDBytes(cid)) + if creator_bytes == nil { + return msg, false } - k.cdc.MustUnmarshal(asset, &val) - return val, true + msg.Cid = cid + msg.Creator = string(creator_bytes) + return msg, true } -func (k Keeper) GetCIDsByPublicKey(ctx sdk.Context, pubkey string) (assetArray []types.Asset, found bool) { +func (k Keeper) GetCidsByAddress(ctx sdk.Context, address string) (cids []string, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AssetKey)) reverseIterator := store.ReverseIterator(nil, nil) defer reverseIterator.Close() - var asset types.Asset for ; reverseIterator.Valid(); reverseIterator.Next() { - lastValue := reverseIterator.Value() + address_bytes := reverseIterator.Value() + cid_bytes := reverseIterator.Key() - k.cdc.MustUnmarshal(lastValue, &asset) - if asset.GetPubkey() == pubkey { - assetArray = append(assetArray, asset) - } - } - return assetArray, len(assetArray) > 0 -} - -func (k Keeper) GetCidsByPublicKey(ctx sdk.Context, pubkey string) (cids []string, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AssetKey)) - - reverseIterator := store.ReverseIterator(nil, nil) - defer reverseIterator.Close() - var asset types.Asset - for ; reverseIterator.Valid(); reverseIterator.Next() { - lastValue := reverseIterator.Value() - - k.cdc.MustUnmarshal(lastValue, &asset) - if asset.GetPubkey() == pubkey { - cids = append(cids, asset.GetHash()) + if string(address_bytes) == address { + cids = append(cids, string(cid_bytes)) } } return cids, len(cids) > 0 } -func GetAssetHashBytes(hash string) []byte { - bz := []byte(hash) +func GetAssetCIDBytes(cid string) []byte { + bz := []byte(cid) return bz } diff --git a/x/asset/keeper/asset_test.go b/x/asset/keeper/asset_test.go index 0019ae6..04f0ffc 100644 --- a/x/asset/keeper/asset_test.go +++ b/x/asset/keeper/asset_test.go @@ -13,17 +13,15 @@ import ( "github.com/stretchr/testify/assert" ) -func createNAsset(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Asset { - items := make([]types.Asset, n) +func createNAsset(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.MsgNotarizeAsset { + items := make([]types.MsgNotarizeAsset, n) for i := range items { hash := sha256.Sum256([]byte(strconv.FormatInt(int64(i), 2))) hashStr := string(hash[:]) - - items[i].Hash = hashStr - items[i].Pubkey = "pubkey" - items[i].Signature = "sign" - if i%2 == 1 { - items[i].Pubkey = "pubkey_search" + items[i].Cid = hashStr + items[i].Creator = "plmnt_address" + if i%2 == 0 { + items[i].Creator = "plmnt_address1" } keeper.StoreAsset(ctx, items[i]) } @@ -34,7 +32,7 @@ func TestGetAsset(t *testing.T) { keeper, ctx := keepertest.AssetKeeper(t) items := createNAsset(keeper, ctx, 10) for _, item := range items { - asset, found := keeper.GetAsset(ctx, item.Hash) + asset, found := keeper.GetAsset(ctx, item.Cid) assert.True(t, found) assert.Equal(t, item, asset) } @@ -43,7 +41,7 @@ func TestGetCids(t *testing.T) { keeper, ctx := keepertest.AssetKeeper(t) items := createNAsset(keeper, ctx, 10) for _, item := range items { - asset, found := keeper.GetAsset(ctx, item.Hash) + asset, found := keeper.GetAsset(ctx, item.Cid) assert.True(t, found) assert.Equal(t, item, asset) } @@ -52,21 +50,10 @@ func TestGetCids(t *testing.T) { func TestGetAssetByPubKeys(t *testing.T) { keeper, ctx := keepertest.AssetKeeper(t) _ = createNAsset(keeper, ctx, 10) - assets, found := keeper.GetCIDsByPublicKey(ctx, "pubkey_search") + assets, found := keeper.GetCidsByAddress(ctx, "plmnt_address") assert.True(t, found) assert.Equal(t, len(assets), 5) - assets, found = keeper.GetCIDsByPublicKey(ctx, "pubkey") - assert.True(t, found) - assert.Equal(t, len(assets), 5) -} - -func TestGetCidsByPubKeys(t *testing.T) { - keeper, ctx := keepertest.AssetKeeper(t) - _ = createNAsset(keeper, ctx, 10) - assets, found := keeper.GetCidsByPublicKey(ctx, "pubkey_search") - assert.True(t, found) - assert.Equal(t, len(assets), 5) - assets, found = keeper.GetCidsByPublicKey(ctx, "pubkey") + assets, found = keeper.GetCidsByAddress(ctx, "plmnt_address1") assert.True(t, found) assert.Equal(t, len(assets), 5) } diff --git a/x/asset/keeper/msg_server_notarize_asset.go b/x/asset/keeper/msg_server_notarize_asset.go index d05a833..6a1be69 100644 --- a/x/asset/keeper/msg_server_notarize_asset.go +++ b/x/asset/keeper/msg_server_notarize_asset.go @@ -2,9 +2,7 @@ package keeper import ( "context" - "errors" - "github.com/planetmint/planetmint-go/util" "github.com/planetmint/planetmint-go/x/asset/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,27 +11,7 @@ import ( func (k msgServer) NotarizeAsset(goCtx context.Context, msg *types.MsgNotarizeAsset) (*types.MsgNotarizeAssetResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - _, found := k.machineKeeper.GetMachineIndexByPubKey(ctx, msg.PubKey) - - if !found { - return nil, errors.New("machine not found") - } - hex_pub_key, err := util.GetHexPubKey(msg.PubKey) - if err != nil { - return nil, errors.New("could not convert xpub key to hex pub key") - } - valid, err := util.ValidateSignatureByteMsg([]byte(msg.Hash), msg.Signature, hex_pub_key) - if !valid { - return nil, err - } - - var asset = types.Asset{ - Hash: msg.Hash, - Signature: msg.Signature, - Pubkey: msg.PubKey, - } - - k.StoreAsset(ctx, asset) + k.StoreAsset(ctx, *msg) return &types.MsgNotarizeAssetResponse{}, nil } diff --git a/x/asset/keeper/msg_server_test.go b/x/asset/keeper/msg_server_test.go index 6f078e6..a50846a 100644 --- a/x/asset/keeper/msg_server_test.go +++ b/x/asset/keeper/msg_server_test.go @@ -29,52 +29,17 @@ func TestMsgServer(t *testing.T) { } func TestMsgServerNotarizeAsset(t *testing.T) { - ext_sk, ppk := sample.ExtendedKeyPair(config.PlmntNetParams) + ext_sk, _ := sample.ExtendedKeyPair(config.PlmntNetParams) xskKey, _ := hdkeychain.NewKeyFromString(ext_sk) privKey, _ := xskKey.ECPrivKey() byte_key := privKey.Serialize() sk := hex.EncodeToString(byte_key) - cid, signatureHex := sample.Asset(sk) + cid := sample.Asset() - msg := types.NewMsgNotarizeAsset(sk, cid, signatureHex, ppk) + msg := types.NewMsgNotarizeAsset(sk, cid) msgServer, ctx := setupMsgServer(t) res, err := msgServer.NotarizeAsset(ctx, msg) if assert.NoError(t, err) { assert.Equal(t, &types.MsgNotarizeAssetResponse{}, res) } } - -func TestMsgServerNotarizeAssetMachineNotFound(t *testing.T) { - sk, _ := sample.KeyPair() - msg := types.NewMsgNotarizeAsset(sk, "cid", "sign", sk) - msgServer, ctx := setupMsgServer(t) - _, err := msgServer.NotarizeAsset(ctx, msg) - assert.EqualError(t, err, "machine not found") -} - -func TestMsgServerNotarizeAssetInvalidAssetSignatureType(t *testing.T) { - _, pk := sample.ExtendedKeyPair(config.PlmntNetParams) - hex_string := hex.EncodeToString([]byte("cid")) - msg := types.NewMsgNotarizeAsset(pk, hex_string, "sign", pk) - msgServer, ctx := setupMsgServer(t) - _, err := msgServer.NotarizeAsset(ctx, msg) - assert.EqualError(t, err, "invalid signature hex string") -} - -func TestMsgServerNotarizeAssetInvalidAssetSignature(t *testing.T) { - _, pk := sample.ExtendedKeyPair(config.PlmntNetParams) - hex_string_cid := hex.EncodeToString([]byte("cid")) - hex_string_sid := hex.EncodeToString([]byte("sign")) - msg := types.NewMsgNotarizeAsset(pk, hex_string_cid, hex_string_sid, pk) - msgServer, ctx := setupMsgServer(t) - _, err := msgServer.NotarizeAsset(ctx, msg) - assert.EqualError(t, err, "invalid signature") -} - -func TestMsgServerNotarizeAssetInvalidXPubKey(t *testing.T) { - _, pk := sample.KeyPair() - msg := types.NewMsgNotarizeAsset(pk, "cid", "sign", pk) - msgServer, ctx := setupMsgServer(t) - _, err := msgServer.NotarizeAsset(ctx, msg) - assert.EqualError(t, err, "could not convert xpub key to hex pub key") -} diff --git a/x/asset/keeper/query_get_cids_by_pub_key.go b/x/asset/keeper/query_get_cids_by_address.go similarity index 60% rename from x/asset/keeper/query_get_cids_by_pub_key.go rename to x/asset/keeper/query_get_cids_by_address.go index c28d65a..cca97a9 100644 --- a/x/asset/keeper/query_get_cids_by_pub_key.go +++ b/x/asset/keeper/query_get_cids_by_address.go @@ -9,17 +9,17 @@ import ( "google.golang.org/grpc/status" ) -func (k Keeper) GetCIDsByPubKey(goCtx context.Context, req *types.QueryGetCIDsByPubKeyRequest) (*types.QueryGetCIDsByPubKeyResponse, error) { +func (k Keeper) GetCIDsByAddress(goCtx context.Context, req *types.QueryGetCIDsByAddressRequest) (*types.QueryGetCIDsByAddressResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } ctx := sdk.UnwrapSDKContext(goCtx) - cids, found := k.GetCidsByPublicKey(ctx, req.GetExtPubKey()) + cids, found := k.GetCidsByAddress(ctx, req.GetAddress()) if !found { return nil, status.Error(codes.NotFound, "no CIDs found") } - return &types.QueryGetCIDsByPubKeyResponse{CIDs: cids}, nil + return &types.QueryGetCIDsByAddressResponse{Cids: cids}, nil } diff --git a/x/asset/keeper/query_get_cids_by_pub_key_test.go b/x/asset/keeper/query_get_cids_by_address_test.go similarity index 62% rename from x/asset/keeper/query_get_cids_by_pub_key_test.go rename to x/asset/keeper/query_get_cids_by_address_test.go index fdba16c..bca2fbd 100644 --- a/x/asset/keeper/query_get_cids_by_pub_key_test.go +++ b/x/asset/keeper/query_get_cids_by_address_test.go @@ -12,31 +12,31 @@ import ( "github.com/stretchr/testify/require" ) -func TestGetNotarizedAssetByPubKey(t *testing.T) { +func TestGetNotarizedAssetByAddress(t *testing.T) { keeper, ctx := keepertest.AssetKeeper(t) wctx := sdk.WrapSDKContext(ctx) _ = createNAsset(keeper, ctx, 10) - assets, _ := keeper.GetCidsByPublicKey(ctx, "pubkey_search") + assets, _ := keeper.GetCidsByAddress(ctx, "plmnt_address") for _, tc := range []struct { desc string - request *types.QueryGetCIDsByPubKeyRequest - response *types.QueryGetCIDsByPubKeyResponse + request *types.QueryGetCIDsByAddressRequest + response *types.QueryGetCIDsByAddressResponse err error }{ { desc: "cid found", - request: &types.QueryGetCIDsByPubKeyRequest{ExtPubKey: "pubkey_search"}, - response: &types.QueryGetCIDsByPubKeyResponse{CIDs: assets}, + request: &types.QueryGetCIDsByAddressRequest{Address: "plmnt_address"}, + response: &types.QueryGetCIDsByAddressResponse{Cids: assets}, }, { desc: "cid not found", - request: &types.QueryGetCIDsByPubKeyRequest{ExtPubKey: "invalid key"}, + request: &types.QueryGetCIDsByAddressRequest{Address: "invalid key"}, err: status.Error(codes.NotFound, "no CIDs found"), }, } { tc := tc t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.GetCIDsByPubKey(wctx, tc.request) + response, err := keeper.GetCIDsByAddress(wctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { diff --git a/x/asset/keeper/query_get_notarized_asset.go b/x/asset/keeper/query_get_notarized_asset.go index ab5e567..01a9e8a 100644 --- a/x/asset/keeper/query_get_notarized_asset.go +++ b/x/asset/keeper/query_get_notarized_asset.go @@ -21,5 +21,5 @@ func (k Keeper) GetNotarizedAsset(goCtx context.Context, req *types.QueryGetNota return nil, status.Error(codes.NotFound, "cid not found") } - return &types.QueryGetNotarizedAssetResponse{Cid: asset.GetHash(), Signature: asset.GetSignature(), Pubkey: asset.GetPubkey()}, nil + return &types.QueryGetNotarizedAssetResponse{Cid: asset.GetCid()}, nil } diff --git a/x/asset/keeper/query_get_notarized_asset_test.go b/x/asset/keeper/query_get_notarized_asset_test.go index 94f02c6..556c0dc 100644 --- a/x/asset/keeper/query_get_notarized_asset_test.go +++ b/x/asset/keeper/query_get_notarized_asset_test.go @@ -24,8 +24,8 @@ func TestGetNotarizedAsset(t *testing.T) { }{ { desc: "cid found", - request: &types.QueryGetNotarizedAssetRequest{Cid: msgs[0].GetHash()}, - response: &types.QueryGetNotarizedAssetResponse{Cid: msgs[0].GetHash(), Signature: msgs[0].GetSignature(), Pubkey: msgs[0].GetPubkey()}, + request: &types.QueryGetNotarizedAssetRequest{Cid: msgs[0].GetCid()}, + response: &types.QueryGetNotarizedAssetResponse{Cid: msgs[0].GetCid()}, }, { desc: "cid not found", diff --git a/x/asset/testutil/expected_keepers_mock.go b/x/asset/testutil/expected_keepers_mock.go index 9965fc3..ad5406d 100644 --- a/x/asset/testutil/expected_keepers_mock.go +++ b/x/asset/testutil/expected_keepers_mock.go @@ -139,3 +139,18 @@ func (mr *MockMachineKeeperMockRecorder) GetMachineIndexByPubKey(ctx, pubKey int mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMachineIndexByPubKey", reflect.TypeOf((*MockMachineKeeper)(nil).GetMachineIndexByPubKey), ctx, pubKey) } + +// GetMachineIndexByPubKey mocks base method. +func (m *MockMachineKeeper) GetMachineIndexByAddress(ctx types.Context, pubKey string) (types1.MachineIndex, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMachineIndexByAddress", ctx, pubKey) + ret0, _ := ret[0].(types1.MachineIndex) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetMachineIndexByPubKey indicates an expected call of GetMachineIndexByPubKey. +func (mr *MockMachineKeeperMockRecorder) GetMachineIndexByAddress(ctx, address interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMachineIndexByAddress", reflect.TypeOf((*MockMachineKeeper)(nil).GetMachineIndexByAddress), ctx, address) +} diff --git a/x/asset/types/asset.pb.go b/x/asset/types/asset.pb.go index 1c2d41b..8ec2af3 100644 --- a/x/asset/types/asset.pb.go +++ b/x/asset/types/asset.pb.go @@ -23,9 +23,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Asset struct { - Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` - Signature string `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` - Pubkey string `protobuf:"bytes,3,opt,name=pubkey,proto3" json:"pubkey,omitempty"` + Cid string `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"` } func (m *Asset) Reset() { *m = Asset{} } @@ -61,23 +59,9 @@ func (m *Asset) XXX_DiscardUnknown() { var xxx_messageInfo_Asset proto.InternalMessageInfo -func (m *Asset) GetHash() string { +func (m *Asset) GetCid() string { if m != nil { - return m.Hash - } - return "" -} - -func (m *Asset) GetSignature() string { - if m != nil { - return m.Signature - } - return "" -} - -func (m *Asset) GetPubkey() string { - if m != nil { - return m.Pubkey + return m.Cid } return "" } @@ -89,19 +73,16 @@ func init() { func init() { proto.RegisterFile("planetmintgo/asset/asset.proto", fileDescriptor_03dd37a25f684e6e) } var fileDescriptor_03dd37a25f684e6e = []byte{ - // 179 bytes of a gzipped FileDescriptorProto + // 143 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0xc8, 0x49, 0xcc, 0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0x81, 0x90, - 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x42, 0xc8, 0xf2, 0x7a, 0x60, 0x19, 0xa5, 0x40, 0x2e, - 0x56, 0x47, 0x10, 0x43, 0x48, 0x88, 0x8b, 0x25, 0x23, 0xb1, 0x38, 0x43, 0x82, 0x51, 0x81, 0x51, - 0x83, 0x33, 0x08, 0xcc, 0x16, 0x92, 0xe1, 0xe2, 0x2c, 0xce, 0x4c, 0xcf, 0x4b, 0x2c, 0x29, 0x2d, - 0x4a, 0x95, 0x60, 0x02, 0x4b, 0x20, 0x04, 0x84, 0xc4, 0xb8, 0xd8, 0x0a, 0x4a, 0x93, 0xb2, 0x53, - 0x2b, 0x25, 0x98, 0xc1, 0x52, 0x50, 0x9e, 0x93, 0xf7, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, - 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, - 0xcb, 0x31, 0x44, 0x19, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x23, - 0xdc, 0x82, 0xc4, 0xd4, 0x4d, 0xcf, 0xd7, 0xaf, 0x80, 0xba, 0xbc, 0xa4, 0xb2, 0x20, 0xb5, 0x38, - 0x89, 0x0d, 0xec, 0x74, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9b, 0xe4, 0xfc, 0x55, 0xdc, - 0x00, 0x00, 0x00, + 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x42, 0xc8, 0xf2, 0x7a, 0x60, 0x19, 0x25, 0x49, 0x2e, + 0x56, 0x47, 0x10, 0x43, 0x48, 0x80, 0x8b, 0x39, 0x39, 0x33, 0x45, 0x82, 0x51, 0x81, 0x51, 0x83, + 0x33, 0x08, 0xc4, 0x74, 0xf2, 0x3e, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, + 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, + 0xc3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x84, 0x99, 0x48, 0x4c, + 0xdd, 0xf4, 0x7c, 0xfd, 0x0a, 0xa8, 0x0b, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x4e, + 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x38, 0x8c, 0xdf, 0xa4, 0x00, 0x00, 0x00, } func (m *Asset) Marshal() (dAtA []byte, err error) { @@ -124,24 +105,10 @@ func (m *Asset) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Pubkey) > 0 { - i -= len(m.Pubkey) - copy(dAtA[i:], m.Pubkey) - i = encodeVarintAsset(dAtA, i, uint64(len(m.Pubkey))) - i-- - dAtA[i] = 0x1a - } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintAsset(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x12 - } - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintAsset(dAtA, i, uint64(len(m.Hash))) + if len(m.Cid) > 0 { + i -= len(m.Cid) + copy(dAtA[i:], m.Cid) + i = encodeVarintAsset(dAtA, i, uint64(len(m.Cid))) i-- dAtA[i] = 0xa } @@ -165,15 +132,7 @@ func (m *Asset) Size() (n int) { } var l int _ = l - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovAsset(uint64(l)) - } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovAsset(uint64(l)) - } - l = len(m.Pubkey) + l = len(m.Cid) if l > 0 { n += 1 + l + sovAsset(uint64(l)) } @@ -217,7 +176,7 @@ func (m *Asset) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -245,71 +204,7 @@ func (m *Asset) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Hash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAsset - } - 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 ErrInvalidLengthAsset - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAsset - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pubkey", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAsset - } - 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 ErrInvalidLengthAsset - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAsset - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Pubkey = string(dAtA[iNdEx:postIndex]) + m.Cid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/asset/types/message_notarize_asset.go b/x/asset/types/message_notarize_asset.go index 255c976..e8b97c1 100644 --- a/x/asset/types/message_notarize_asset.go +++ b/x/asset/types/message_notarize_asset.go @@ -10,12 +10,10 @@ const TypeMsgNotarizeAsset = "notarize_asset" var _ sdk.Msg = &MsgNotarizeAsset{} -func NewMsgNotarizeAsset(creator string, hash string, signature string, pubKey string) *MsgNotarizeAsset { +func NewMsgNotarizeAsset(creator string, cid string) *MsgNotarizeAsset { return &MsgNotarizeAsset{ - Creator: creator, - Hash: hash, - Signature: signature, - PubKey: pubKey, + Creator: creator, + Cid: cid, } } diff --git a/x/asset/types/query.pb.go b/x/asset/types/query.pb.go index 8564701..1122ea7 100644 --- a/x/asset/types/query.pb.go +++ b/x/asset/types/query.pb.go @@ -113,24 +113,24 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } -type QueryGetCIDsByPubKeyRequest struct { - ExtPubKey string `protobuf:"bytes,1,opt,name=extPubKey,proto3" json:"extPubKey,omitempty"` +type QueryGetCIDsByAddressRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` LookupPeriodInMin uint64 `protobuf:"varint,2,opt,name=lookupPeriodInMin,proto3" json:"lookupPeriodInMin,omitempty"` Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryGetCIDsByPubKeyRequest) Reset() { *m = QueryGetCIDsByPubKeyRequest{} } -func (m *QueryGetCIDsByPubKeyRequest) String() string { return proto.CompactTextString(m) } -func (*QueryGetCIDsByPubKeyRequest) ProtoMessage() {} -func (*QueryGetCIDsByPubKeyRequest) Descriptor() ([]byte, []int) { +func (m *QueryGetCIDsByAddressRequest) Reset() { *m = QueryGetCIDsByAddressRequest{} } +func (m *QueryGetCIDsByAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetCIDsByAddressRequest) ProtoMessage() {} +func (*QueryGetCIDsByAddressRequest) Descriptor() ([]byte, []int) { return fileDescriptor_5832a953a81817c0, []int{2} } -func (m *QueryGetCIDsByPubKeyRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryGetCIDsByAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryGetCIDsByPubKeyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryGetCIDsByAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryGetCIDsByPubKeyRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryGetCIDsByAddressRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -140,56 +140,56 @@ func (m *QueryGetCIDsByPubKeyRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryGetCIDsByPubKeyRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetCIDsByPubKeyRequest.Merge(m, src) +func (m *QueryGetCIDsByAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetCIDsByAddressRequest.Merge(m, src) } -func (m *QueryGetCIDsByPubKeyRequest) XXX_Size() int { +func (m *QueryGetCIDsByAddressRequest) XXX_Size() int { return m.Size() } -func (m *QueryGetCIDsByPubKeyRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetCIDsByPubKeyRequest.DiscardUnknown(m) +func (m *QueryGetCIDsByAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetCIDsByAddressRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryGetCIDsByPubKeyRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryGetCIDsByAddressRequest proto.InternalMessageInfo -func (m *QueryGetCIDsByPubKeyRequest) GetExtPubKey() string { +func (m *QueryGetCIDsByAddressRequest) GetAddress() string { if m != nil { - return m.ExtPubKey + return m.Address } return "" } -func (m *QueryGetCIDsByPubKeyRequest) GetLookupPeriodInMin() uint64 { +func (m *QueryGetCIDsByAddressRequest) GetLookupPeriodInMin() uint64 { if m != nil { return m.LookupPeriodInMin } return 0 } -func (m *QueryGetCIDsByPubKeyRequest) GetPagination() *query.PageRequest { +func (m *QueryGetCIDsByAddressRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -type QueryGetCIDsByPubKeyResponse struct { - CIDs []string `protobuf:"bytes,1,rep,name=cids,proto3" json:"cids,omitempty"` +type QueryGetCIDsByAddressResponse struct { + Cids []string `protobuf:"bytes,1,rep,name=cids,proto3" json:"cids,omitempty"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryGetCIDsByPubKeyResponse) Reset() { *m = QueryGetCIDsByPubKeyResponse{} } -func (m *QueryGetCIDsByPubKeyResponse) String() string { return proto.CompactTextString(m) } -func (*QueryGetCIDsByPubKeyResponse) ProtoMessage() {} -func (*QueryGetCIDsByPubKeyResponse) Descriptor() ([]byte, []int) { +func (m *QueryGetCIDsByAddressResponse) Reset() { *m = QueryGetCIDsByAddressResponse{} } +func (m *QueryGetCIDsByAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetCIDsByAddressResponse) ProtoMessage() {} +func (*QueryGetCIDsByAddressResponse) Descriptor() ([]byte, []int) { return fileDescriptor_5832a953a81817c0, []int{3} } -func (m *QueryGetCIDsByPubKeyResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryGetCIDsByAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryGetCIDsByPubKeyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryGetCIDsByAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryGetCIDsByPubKeyResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryGetCIDsByAddressResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -199,26 +199,26 @@ func (m *QueryGetCIDsByPubKeyResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryGetCIDsByPubKeyResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetCIDsByPubKeyResponse.Merge(m, src) +func (m *QueryGetCIDsByAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetCIDsByAddressResponse.Merge(m, src) } -func (m *QueryGetCIDsByPubKeyResponse) XXX_Size() int { +func (m *QueryGetCIDsByAddressResponse) XXX_Size() int { return m.Size() } -func (m *QueryGetCIDsByPubKeyResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetCIDsByPubKeyResponse.DiscardUnknown(m) +func (m *QueryGetCIDsByAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetCIDsByAddressResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryGetCIDsByPubKeyResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryGetCIDsByAddressResponse proto.InternalMessageInfo -func (m *QueryGetCIDsByPubKeyResponse) GetCIDs() []string { +func (m *QueryGetCIDsByAddressResponse) GetCids() []string { if m != nil { - return m.CIDs + return m.Cids } return nil } -func (m *QueryGetCIDsByPubKeyResponse) GetPagination() *query.PageResponse { +func (m *QueryGetCIDsByAddressResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } @@ -270,9 +270,8 @@ func (m *QueryGetNotarizedAssetRequest) GetCid() string { } type QueryGetNotarizedAssetResponse struct { - Cid string `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"` - Signature string `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` - Pubkey string `protobuf:"bytes,3,opt,name=pubkey,proto3" json:"pubkey,omitempty"` + Cid string `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` } func (m *QueryGetNotarizedAssetResponse) Reset() { *m = QueryGetNotarizedAssetResponse{} } @@ -315,16 +314,9 @@ func (m *QueryGetNotarizedAssetResponse) GetCid() string { return "" } -func (m *QueryGetNotarizedAssetResponse) GetSignature() string { +func (m *QueryGetNotarizedAssetResponse) GetAddress() string { if m != nil { - return m.Signature - } - return "" -} - -func (m *QueryGetNotarizedAssetResponse) GetPubkey() string { - if m != nil { - return m.Pubkey + return m.Address } return "" } @@ -332,8 +324,8 @@ func (m *QueryGetNotarizedAssetResponse) GetPubkey() string { func init() { proto.RegisterType((*QueryParamsRequest)(nil), "planetmintgo.asset.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "planetmintgo.asset.QueryParamsResponse") - proto.RegisterType((*QueryGetCIDsByPubKeyRequest)(nil), "planetmintgo.asset.QueryGetCIDsByPubKeyRequest") - proto.RegisterType((*QueryGetCIDsByPubKeyResponse)(nil), "planetmintgo.asset.QueryGetCIDsByPubKeyResponse") + proto.RegisterType((*QueryGetCIDsByAddressRequest)(nil), "planetmintgo.asset.QueryGetCIDsByAddressRequest") + proto.RegisterType((*QueryGetCIDsByAddressResponse)(nil), "planetmintgo.asset.QueryGetCIDsByAddressResponse") proto.RegisterType((*QueryGetNotarizedAssetRequest)(nil), "planetmintgo.asset.QueryGetNotarizedAssetRequest") proto.RegisterType((*QueryGetNotarizedAssetResponse)(nil), "planetmintgo.asset.QueryGetNotarizedAssetResponse") } @@ -341,45 +333,43 @@ func init() { func init() { proto.RegisterFile("planetmintgo/asset/query.proto", fileDescriptor_5832a953a81817c0) } var fileDescriptor_5832a953a81817c0 = []byte{ - // 595 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x6b, 0x13, 0x4f, - 0x1c, 0xcd, 0x26, 0xf9, 0x06, 0x32, 0x5f, 0x0f, 0x76, 0x2c, 0x12, 0x42, 0xdd, 0x86, 0x3d, 0xb4, - 0x41, 0x74, 0x87, 0x4d, 0x2f, 0x16, 0x4f, 0xcd, 0xc1, 0x22, 0x45, 0x8d, 0x0b, 0x22, 0x08, 0x12, - 0x66, 0x93, 0x61, 0xbb, 0x24, 0x99, 0xd9, 0xee, 0xcc, 0x4a, 0xd7, 0x90, 0x8b, 0x77, 0x41, 0xd0, - 0xff, 0xc4, 0x9b, 0xe0, 0xbd, 0xc7, 0x82, 0x17, 0xbd, 0x88, 0x24, 0xfe, 0x21, 0xb2, 0x33, 0x53, - 0x37, 0xe9, 0x26, 0x4d, 0xbd, 0x4d, 0x3e, 0x3f, 0xdf, 0x7b, 0x9f, 0x97, 0x05, 0x66, 0x38, 0xc4, - 0x94, 0x88, 0x51, 0x40, 0x85, 0xcf, 0x10, 0xe6, 0x9c, 0x08, 0x74, 0x12, 0x93, 0x28, 0xb1, 0xc3, - 0x88, 0x09, 0x06, 0xe1, 0x7c, 0xde, 0x96, 0xf9, 0xfa, 0xa6, 0xcf, 0x7c, 0x26, 0xd3, 0x28, 0x7d, - 0xa9, 0xca, 0xfa, 0x96, 0xcf, 0x98, 0x3f, 0x24, 0x08, 0x87, 0x01, 0xc2, 0x94, 0x32, 0x81, 0x45, - 0xc0, 0x28, 0xd7, 0xd9, 0xbb, 0x3d, 0xc6, 0x47, 0x8c, 0x23, 0x0f, 0x73, 0xa2, 0x16, 0xa0, 0x37, - 0x8e, 0x47, 0x04, 0x76, 0x50, 0x88, 0xfd, 0x80, 0xca, 0x62, 0x5d, 0xbb, 0xbd, 0x04, 0x53, 0x88, - 0x23, 0x3c, 0xd2, 0xc3, 0xac, 0x4d, 0x00, 0x9f, 0xa7, 0x23, 0x3a, 0x32, 0xe8, 0x92, 0x93, 0x98, - 0x70, 0x61, 0x3d, 0x03, 0xb7, 0x16, 0xa2, 0x3c, 0x64, 0x94, 0x13, 0xf8, 0x00, 0x54, 0x54, 0x73, - 0xcd, 0x68, 0x18, 0xcd, 0xff, 0x5b, 0x75, 0x3b, 0x4f, 0xc9, 0x56, 0x3d, 0xed, 0xf2, 0xd9, 0xcf, - 0xed, 0x82, 0xab, 0xeb, 0xad, 0xcf, 0x06, 0xb8, 0x23, 0x27, 0x1e, 0x12, 0x71, 0x90, 0x96, 0xf1, - 0x76, 0xd2, 0x89, 0xbd, 0x23, 0x92, 0xe8, 0x95, 0x70, 0x0b, 0x54, 0xc9, 0xa9, 0x50, 0x31, 0x39, - 0xbe, 0xea, 0x66, 0x01, 0x78, 0x0f, 0x6c, 0x0c, 0x19, 0x1b, 0xc4, 0x61, 0x87, 0x44, 0x01, 0xeb, - 0x3f, 0xa6, 0x4f, 0x02, 0x5a, 0x2b, 0x36, 0x8c, 0x66, 0xd9, 0xcd, 0x27, 0xe0, 0x23, 0x00, 0x32, - 0x25, 0x6a, 0x25, 0x89, 0x75, 0xc7, 0x56, 0xb2, 0xd9, 0xa9, 0x6c, 0xb6, 0xba, 0x8b, 0x96, 0xcd, - 0xee, 0x60, 0x9f, 0x68, 0x1c, 0xee, 0x5c, 0xa7, 0xf5, 0xde, 0x00, 0xe6, 0x2a, 0xd4, 0x5a, 0x12, - 0x0b, 0xdc, 0x10, 0x11, 0xa6, 0x1c, 0xf7, 0xe4, 0x89, 0x6a, 0x46, 0xa3, 0xd4, 0xac, 0xba, 0x0b, - 0x31, 0x78, 0xb8, 0x00, 0xa7, 0x28, 0xe1, 0xec, 0xae, 0x85, 0xa3, 0x16, 0x2c, 0xe0, 0x71, 0x32, - 0x11, 0x9f, 0x32, 0x81, 0xa3, 0xe0, 0x2d, 0xe9, 0x4b, 0x5c, 0x17, 0x22, 0xde, 0x04, 0xa5, 0x5e, - 0xd0, 0xd7, 0xf2, 0xa5, 0x4f, 0xeb, 0x38, 0x63, 0x70, 0xb9, 0x45, 0x33, 0xc8, 0xf5, 0xa4, 0xa7, - 0xe0, 0x81, 0x4f, 0xb1, 0x88, 0x23, 0x22, 0xe1, 0x56, 0xdd, 0x2c, 0x00, 0x6f, 0x83, 0x4a, 0x18, - 0x7b, 0x03, 0x92, 0x48, 0x61, 0xab, 0xae, 0xfe, 0xd5, 0xfa, 0x52, 0x06, 0xff, 0xc9, 0x55, 0xf0, - 0x93, 0x01, 0x2a, 0xca, 0x05, 0x70, 0x67, 0x99, 0x43, 0xf2, 0x86, 0xab, 0xef, 0xae, 0xad, 0x53, - 0x68, 0xad, 0xfd, 0x77, 0xdf, 0x7e, 0x7f, 0x2c, 0xee, 0x41, 0x07, 0xf9, 0x81, 0x38, 0x8e, 0x3d, - 0xbb, 0xc7, 0x46, 0x28, 0xeb, 0x9d, 0x7b, 0xde, 0xbf, 0x64, 0x78, 0xf8, 0xc3, 0x00, 0x1b, 0xb9, - 0x43, 0x42, 0x67, 0xe5, 0xe6, 0x55, 0x56, 0xad, 0xb7, 0xfe, 0xa5, 0x45, 0xe3, 0x7e, 0x2d, 0x71, - 0xbf, 0x84, 0x2f, 0xd6, 0x81, 0xf5, 0x89, 0xe8, 0xca, 0x17, 0xef, 0x7a, 0x49, 0x37, 0x8c, 0xbd, - 0xee, 0x80, 0x24, 0x68, 0xfc, 0xf7, 0xaf, 0x30, 0x41, 0xe3, 0x9c, 0xe1, 0x27, 0xf0, 0xab, 0xe2, - 0xb6, 0x78, 0xe2, 0xab, 0xb9, 0x2d, 0x75, 0xd0, 0xd5, 0xdc, 0x96, 0x3b, 0xc8, 0x3a, 0x90, 0xdc, - 0x1e, 0xc2, 0xfd, 0xeb, 0x70, 0xa3, 0x17, 0x33, 0x14, 0x4b, 0x34, 0xee, 0x05, 0xfd, 0x49, 0xfb, - 0xe8, 0x6c, 0x6a, 0x1a, 0xe7, 0x53, 0xd3, 0xf8, 0x35, 0x35, 0x8d, 0x0f, 0x33, 0xb3, 0x70, 0x3e, - 0x33, 0x0b, 0xdf, 0x67, 0x66, 0xe1, 0x95, 0x73, 0x9d, 0x3b, 0x9f, 0xea, 0x05, 0x22, 0x09, 0x09, - 0xf7, 0x2a, 0xf2, 0xd3, 0xb6, 0xf7, 0x27, 0x00, 0x00, 0xff, 0xff, 0x94, 0x73, 0x54, 0x1f, 0x91, - 0x05, 0x00, 0x00, + // 562 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0x8e, 0x93, 0x10, 0xd4, 0x63, 0x69, 0x8f, 0x0e, 0x91, 0x55, 0xdc, 0xca, 0x43, 0x1b, 0x21, + 0xf0, 0xe1, 0x74, 0xa1, 0x62, 0x4a, 0x40, 0x54, 0x15, 0xbf, 0x52, 0x33, 0xc1, 0x12, 0x5d, 0xe2, + 0x93, 0x39, 0x91, 0xdc, 0xb9, 0xbe, 0x0b, 0x22, 0x84, 0x2c, 0xfc, 0x05, 0x48, 0xf0, 0x77, 0xb0, + 0x30, 0xb3, 0x77, 0xac, 0x60, 0x61, 0x42, 0x28, 0xe1, 0x0f, 0x41, 0xbe, 0xbb, 0x28, 0x49, 0x9d, + 0x34, 0xed, 0xf6, 0x7c, 0xef, 0x7d, 0xef, 0xfb, 0xde, 0xf7, 0x9e, 0x0c, 0x9c, 0xb8, 0x83, 0x19, + 0x91, 0x5d, 0xca, 0x64, 0xc4, 0x11, 0x16, 0x82, 0x48, 0x74, 0xd2, 0x23, 0x49, 0xdf, 0x8b, 0x13, + 0x2e, 0x39, 0x84, 0xb3, 0x79, 0x4f, 0xe5, 0xed, 0xcd, 0x88, 0x47, 0x5c, 0xa5, 0x51, 0x1a, 0xe9, + 0x4a, 0x7b, 0x2b, 0xe2, 0x3c, 0xea, 0x10, 0x84, 0x63, 0x8a, 0x30, 0x63, 0x5c, 0x62, 0x49, 0x39, + 0x13, 0x26, 0x7b, 0xbb, 0xcd, 0x45, 0x97, 0x0b, 0xd4, 0xc2, 0x82, 0x68, 0x02, 0xf4, 0xce, 0x6f, + 0x11, 0x89, 0x7d, 0x14, 0xe3, 0x88, 0x32, 0x55, 0x6c, 0x6a, 0xb7, 0x17, 0x68, 0x8a, 0x71, 0x82, + 0xbb, 0xa6, 0x99, 0xbb, 0x09, 0xe0, 0x71, 0xda, 0xa2, 0xa1, 0x1e, 0x03, 0x72, 0xd2, 0x23, 0x42, + 0xba, 0x2f, 0xc0, 0xcd, 0xb9, 0x57, 0x11, 0x73, 0x26, 0x08, 0xbc, 0x0f, 0x4a, 0x1a, 0x5c, 0xb6, + 0x76, 0xac, 0xca, 0x8d, 0xaa, 0xed, 0x65, 0x47, 0xf2, 0x34, 0xa6, 0x5e, 0x3c, 0xfd, 0xb3, 0x9d, + 0x0b, 0x4c, 0xbd, 0xfb, 0xcd, 0x02, 0x5b, 0xaa, 0xe3, 0x21, 0x91, 0x0f, 0x8f, 0x1e, 0x89, 0x7a, + 0xbf, 0x16, 0x86, 0x09, 0x11, 0x13, 0x46, 0x58, 0x06, 0xd7, 0xb1, 0x7e, 0x51, 0xbd, 0xd7, 0x82, + 0xc9, 0x27, 0xbc, 0x03, 0x36, 0x3a, 0x9c, 0xbf, 0xed, 0xc5, 0x0d, 0x92, 0x50, 0x1e, 0x1e, 0xb1, + 0x67, 0x94, 0x95, 0xf3, 0x3b, 0x56, 0xa5, 0x18, 0x64, 0x13, 0xf0, 0x31, 0x00, 0x53, 0x13, 0xca, + 0x05, 0x25, 0x73, 0xd7, 0xd3, 0x8e, 0x79, 0xa9, 0x63, 0x9e, 0x5e, 0x89, 0x71, 0xcc, 0x6b, 0xe0, + 0x88, 0x18, 0x0d, 0xc1, 0x0c, 0xd2, 0xfd, 0x08, 0x6e, 0x2d, 0xd1, 0x6b, 0xbc, 0x80, 0xa0, 0xd8, + 0xa6, 0x61, 0xaa, 0xb6, 0x50, 0x59, 0x0b, 0x54, 0x0c, 0x0f, 0xe7, 0xc8, 0xf3, 0x8a, 0x7c, 0x6f, + 0x25, 0xb9, 0x6e, 0x38, 0xc7, 0xee, 0x4f, 0xd9, 0x9f, 0x73, 0x89, 0x13, 0xfa, 0x81, 0x84, 0xb5, + 0xd4, 0xdd, 0x89, 0x5d, 0xeb, 0xa0, 0xd0, 0xa6, 0xa1, 0xb1, 0x2a, 0x0d, 0xdd, 0xa7, 0xc0, 0x59, + 0x06, 0x31, 0x8a, 0x33, 0x98, 0x59, 0xd3, 0xf3, 0x73, 0xa6, 0x57, 0xbf, 0x17, 0xc1, 0x35, 0xd5, + 0x0e, 0x7e, 0xb5, 0x40, 0x49, 0xaf, 0x14, 0xee, 0x2e, 0x5a, 0x77, 0xf6, 0x7a, 0xec, 0xbd, 0x95, + 0x75, 0x5a, 0x91, 0x7b, 0xf0, 0xe9, 0xd7, 0xbf, 0x2f, 0xf9, 0x7d, 0xe8, 0xa3, 0x88, 0xca, 0x37, + 0xbd, 0x96, 0xd7, 0xe6, 0x5d, 0x34, 0xc5, 0xce, 0x84, 0x77, 0xcf, 0x5d, 0x2f, 0xfc, 0x69, 0x81, + 0xf5, 0xf3, 0xbb, 0x81, 0xf7, 0x96, 0x12, 0x2f, 0x39, 0x3b, 0xdb, 0xbf, 0x02, 0xc2, 0x88, 0x7e, + 0xa5, 0x44, 0xbf, 0x84, 0xc7, 0xab, 0x94, 0x46, 0x44, 0x36, 0xd3, 0xb3, 0x68, 0xb6, 0xfa, 0x4d, + 0xe3, 0x2b, 0x1a, 0x98, 0x60, 0x88, 0x06, 0x99, 0xdb, 0x1d, 0xc2, 0x1f, 0x16, 0xd8, 0xc8, 0xec, + 0x0f, 0x5e, 0xa8, 0x71, 0xe1, 0x79, 0xd8, 0xd5, 0xab, 0x40, 0xcc, 0x5c, 0x35, 0x35, 0xd7, 0x03, + 0x78, 0x70, 0x99, 0xb9, 0xd8, 0xa4, 0x47, 0x53, 0xbf, 0x0d, 0xda, 0x34, 0x1c, 0xd6, 0x9f, 0x9c, + 0x8e, 0x1c, 0xeb, 0x6c, 0xe4, 0x58, 0x7f, 0x47, 0x8e, 0xf5, 0x79, 0xec, 0xe4, 0xce, 0xc6, 0x4e, + 0xee, 0xf7, 0xd8, 0xc9, 0xbd, 0xf6, 0x2f, 0xb3, 0xe0, 0xf7, 0x86, 0x40, 0xf6, 0x63, 0x22, 0x5a, + 0x25, 0xf5, 0x83, 0xda, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x21, 0x7d, 0xdb, 0xca, 0x57, 0x05, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -396,8 +386,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // Queries a list of GetCIDsByPubKey items. - GetCIDsByPubKey(ctx context.Context, in *QueryGetCIDsByPubKeyRequest, opts ...grpc.CallOption) (*QueryGetCIDsByPubKeyResponse, error) + // Queries a list of GetCIDsByAddress items. + GetCIDsByAddress(ctx context.Context, in *QueryGetCIDsByAddressRequest, opts ...grpc.CallOption) (*QueryGetCIDsByAddressResponse, error) // Queries a list of GetNotarizedAsset items. GetNotarizedAsset(ctx context.Context, in *QueryGetNotarizedAssetRequest, opts ...grpc.CallOption) (*QueryGetNotarizedAssetResponse, error) } @@ -419,9 +409,9 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } -func (c *queryClient) GetCIDsByPubKey(ctx context.Context, in *QueryGetCIDsByPubKeyRequest, opts ...grpc.CallOption) (*QueryGetCIDsByPubKeyResponse, error) { - out := new(QueryGetCIDsByPubKeyResponse) - err := c.cc.Invoke(ctx, "/planetmintgo.asset.Query/GetCIDsByPubKey", in, out, opts...) +func (c *queryClient) GetCIDsByAddress(ctx context.Context, in *QueryGetCIDsByAddressRequest, opts ...grpc.CallOption) (*QueryGetCIDsByAddressResponse, error) { + out := new(QueryGetCIDsByAddressResponse) + err := c.cc.Invoke(ctx, "/planetmintgo.asset.Query/GetCIDsByAddress", in, out, opts...) if err != nil { return nil, err } @@ -441,8 +431,8 @@ func (c *queryClient) GetNotarizedAsset(ctx context.Context, in *QueryGetNotariz type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // Queries a list of GetCIDsByPubKey items. - GetCIDsByPubKey(context.Context, *QueryGetCIDsByPubKeyRequest) (*QueryGetCIDsByPubKeyResponse, error) + // Queries a list of GetCIDsByAddress items. + GetCIDsByAddress(context.Context, *QueryGetCIDsByAddressRequest) (*QueryGetCIDsByAddressResponse, error) // Queries a list of GetNotarizedAsset items. GetNotarizedAsset(context.Context, *QueryGetNotarizedAssetRequest) (*QueryGetNotarizedAssetResponse, error) } @@ -454,8 +444,8 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } -func (*UnimplementedQueryServer) GetCIDsByPubKey(ctx context.Context, req *QueryGetCIDsByPubKeyRequest) (*QueryGetCIDsByPubKeyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetCIDsByPubKey not implemented") +func (*UnimplementedQueryServer) GetCIDsByAddress(ctx context.Context, req *QueryGetCIDsByAddressRequest) (*QueryGetCIDsByAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCIDsByAddress not implemented") } func (*UnimplementedQueryServer) GetNotarizedAsset(ctx context.Context, req *QueryGetNotarizedAssetRequest) (*QueryGetNotarizedAssetResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetNotarizedAsset not implemented") @@ -483,20 +473,20 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Query_GetCIDsByPubKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGetCIDsByPubKeyRequest) +func _Query_GetCIDsByAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetCIDsByAddressRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).GetCIDsByPubKey(ctx, in) + return srv.(QueryServer).GetCIDsByAddress(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/planetmintgo.asset.Query/GetCIDsByPubKey", + FullMethod: "/planetmintgo.asset.Query/GetCIDsByAddress", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetCIDsByPubKey(ctx, req.(*QueryGetCIDsByPubKeyRequest)) + return srv.(QueryServer).GetCIDsByAddress(ctx, req.(*QueryGetCIDsByAddressRequest)) } return interceptor(ctx, in, info, handler) } @@ -528,8 +518,8 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_Params_Handler, }, { - MethodName: "GetCIDsByPubKey", - Handler: _Query_GetCIDsByPubKey_Handler, + MethodName: "GetCIDsByAddress", + Handler: _Query_GetCIDsByAddress_Handler, }, { MethodName: "GetNotarizedAsset", @@ -596,7 +586,7 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryGetCIDsByPubKeyRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryGetCIDsByAddressRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -606,12 +596,12 @@ func (m *QueryGetCIDsByPubKeyRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryGetCIDsByPubKeyRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryGetCIDsByAddressRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetCIDsByPubKeyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryGetCIDsByAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -633,17 +623,17 @@ func (m *QueryGetCIDsByPubKeyRequest) MarshalToSizedBuffer(dAtA []byte) (int, er i-- dAtA[i] = 0x10 } - if len(m.ExtPubKey) > 0 { - i -= len(m.ExtPubKey) - copy(dAtA[i:], m.ExtPubKey) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ExtPubKey))) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryGetCIDsByPubKeyResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryGetCIDsByAddressResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -653,12 +643,12 @@ func (m *QueryGetCIDsByPubKeyResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryGetCIDsByPubKeyResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryGetCIDsByAddressResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetCIDsByPubKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryGetCIDsByAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -675,11 +665,11 @@ func (m *QueryGetCIDsByPubKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, e i-- dAtA[i] = 0x12 } - if len(m.CIDs) > 0 { - for iNdEx := len(m.CIDs) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.CIDs[iNdEx]) - copy(dAtA[i:], m.CIDs[iNdEx]) - i = encodeVarintQuery(dAtA, i, uint64(len(m.CIDs[iNdEx]))) + if len(m.Cids) > 0 { + for iNdEx := len(m.Cids) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Cids[iNdEx]) + copy(dAtA[i:], m.Cids[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Cids[iNdEx]))) i-- dAtA[i] = 0xa } @@ -737,17 +727,10 @@ func (m *QueryGetNotarizedAssetResponse) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l - if len(m.Pubkey) > 0 { - i -= len(m.Pubkey) - copy(dAtA[i:], m.Pubkey) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Pubkey))) - i-- - dAtA[i] = 0x1a - } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Signature))) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) i-- dAtA[i] = 0x12 } @@ -792,13 +775,13 @@ func (m *QueryParamsResponse) Size() (n int) { return n } -func (m *QueryGetCIDsByPubKeyRequest) Size() (n int) { +func (m *QueryGetCIDsByAddressRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ExtPubKey) + l = len(m.Address) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -812,14 +795,14 @@ func (m *QueryGetCIDsByPubKeyRequest) Size() (n int) { return n } -func (m *QueryGetCIDsByPubKeyResponse) Size() (n int) { +func (m *QueryGetCIDsByAddressResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.CIDs) > 0 { - for _, s := range m.CIDs { + if len(m.Cids) > 0 { + for _, s := range m.Cids { l = len(s) n += 1 + l + sovQuery(uint64(l)) } @@ -854,11 +837,7 @@ func (m *QueryGetNotarizedAssetResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.Pubkey) + l = len(m.Address) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -1004,7 +983,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetCIDsByPubKeyRequest) Unmarshal(dAtA []byte) error { +func (m *QueryGetCIDsByAddressRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1027,15 +1006,15 @@ func (m *QueryGetCIDsByPubKeyRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetCIDsByPubKeyRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetCIDsByAddressRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetCIDsByPubKeyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetCIDsByAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExtPubKey", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1063,7 +1042,7 @@ func (m *QueryGetCIDsByPubKeyRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ExtPubKey = string(dAtA[iNdEx:postIndex]) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 0 { @@ -1141,7 +1120,7 @@ func (m *QueryGetCIDsByPubKeyRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetCIDsByPubKeyResponse) Unmarshal(dAtA []byte) error { +func (m *QueryGetCIDsByAddressResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1164,15 +1143,15 @@ func (m *QueryGetCIDsByPubKeyResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetCIDsByPubKeyResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetCIDsByAddressResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetCIDsByPubKeyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetCIDsByAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CIDs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Cids", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1200,7 +1179,7 @@ func (m *QueryGetCIDsByPubKeyResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.CIDs = append(m.CIDs, string(dAtA[iNdEx:postIndex])) + m.Cids = append(m.Cids, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 2: if wireType != 2 { @@ -1404,7 +1383,7 @@ func (m *QueryGetNotarizedAssetResponse) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1432,39 +1411,7 @@ func (m *QueryGetNotarizedAssetResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signature = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pubkey", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Pubkey = string(dAtA[iNdEx:postIndex]) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/asset/types/query.pb.gw.go b/x/asset/types/query.pb.gw.go index 67ba62a..46968d5 100644 --- a/x/asset/types/query.pb.gw.go +++ b/x/asset/types/query.pb.gw.go @@ -52,11 +52,11 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } var ( - filter_Query_GetCIDsByPubKey_0 = &utilities.DoubleArray{Encoding: map[string]int{"extPubKey": 0, "lookupPeriodInMin": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} + filter_Query_GetCIDsByAddress_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0, "lookupPeriodInMin": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} ) -func request_Query_GetCIDsByPubKey_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetCIDsByPubKeyRequest +func request_Query_GetCIDsByAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetCIDsByAddressRequest var metadata runtime.ServerMetadata var ( @@ -66,15 +66,15 @@ func request_Query_GetCIDsByPubKey_0(ctx context.Context, marshaler runtime.Mars _ = err ) - val, ok = pathParams["extPubKey"] + val, ok = pathParams["address"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "extPubKey") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") } - protoReq.ExtPubKey, err = runtime.String(val) + protoReq.Address, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "extPubKey", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) } val, ok = pathParams["lookupPeriodInMin"] @@ -91,17 +91,17 @@ func request_Query_GetCIDsByPubKey_0(ctx context.Context, marshaler runtime.Mars if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetCIDsByPubKey_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetCIDsByAddress_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.GetCIDsByPubKey(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.GetCIDsByAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_GetCIDsByPubKey_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetCIDsByPubKeyRequest +func local_request_Query_GetCIDsByAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetCIDsByAddressRequest var metadata runtime.ServerMetadata var ( @@ -111,15 +111,15 @@ func local_request_Query_GetCIDsByPubKey_0(ctx context.Context, marshaler runtim _ = err ) - val, ok = pathParams["extPubKey"] + val, ok = pathParams["address"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "extPubKey") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") } - protoReq.ExtPubKey, err = runtime.String(val) + protoReq.Address, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "extPubKey", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) } val, ok = pathParams["lookupPeriodInMin"] @@ -136,11 +136,11 @@ func local_request_Query_GetCIDsByPubKey_0(ctx context.Context, marshaler runtim if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetCIDsByPubKey_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetCIDsByAddress_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.GetCIDsByPubKey(ctx, &protoReq) + msg, err := server.GetCIDsByAddress(ctx, &protoReq) return msg, metadata, err } @@ -228,7 +228,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_GetCIDsByPubKey_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_GetCIDsByAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -239,7 +239,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_GetCIDsByPubKey_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_GetCIDsByAddress_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -247,7 +247,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_GetCIDsByPubKey_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_GetCIDsByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -335,7 +335,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_GetCIDsByPubKey_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_GetCIDsByAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -344,14 +344,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_GetCIDsByPubKey_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_GetCIDsByAddress_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_GetCIDsByPubKey_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_GetCIDsByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -381,7 +381,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"github.com", "planetmint", "planetmint-go", "asset", "params"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_GetCIDsByPubKey_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"planetmint", "planetmint-go", "asset", "get_cids_by_pub_key", "extPubKey", "lookupPeriodInMin"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_GetCIDsByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"planetmint", "planetmint-go", "asset", "get_cids_by_address", "address", "lookupPeriodInMin"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_GetNotarizedAsset_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"planetmint", "planetmint-go", "asset", "get_notarized_asset", "cid"}, "", runtime.AssumeColonVerbOpt(true))) ) @@ -389,7 +389,7 @@ var ( var ( forward_Query_Params_0 = runtime.ForwardResponseMessage - forward_Query_GetCIDsByPubKey_0 = runtime.ForwardResponseMessage + forward_Query_GetCIDsByAddress_0 = runtime.ForwardResponseMessage forward_Query_GetNotarizedAsset_0 = runtime.ForwardResponseMessage ) diff --git a/x/asset/types/tx.pb.go b/x/asset/types/tx.pb.go index 2a39239..50a2bb1 100644 --- a/x/asset/types/tx.pb.go +++ b/x/asset/types/tx.pb.go @@ -28,10 +28,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgNotarizeAsset struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` - Signature string `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"` - PubKey string `protobuf:"bytes,4,opt,name=pubKey,proto3" json:"pubKey,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Cid string `protobuf:"bytes,2,opt,name=cid,proto3" json:"cid,omitempty"` } func (m *MsgNotarizeAsset) Reset() { *m = MsgNotarizeAsset{} } @@ -74,23 +72,9 @@ func (m *MsgNotarizeAsset) GetCreator() string { return "" } -func (m *MsgNotarizeAsset) GetHash() string { +func (m *MsgNotarizeAsset) GetCid() string { if m != nil { - return m.Hash - } - return "" -} - -func (m *MsgNotarizeAsset) GetSignature() string { - if m != nil { - return m.Signature - } - return "" -} - -func (m *MsgNotarizeAsset) GetPubKey() string { - if m != nil { - return m.PubKey + return m.Cid } return "" } @@ -139,23 +123,21 @@ func init() { func init() { proto.RegisterFile("planetmintgo/asset/tx.proto", fileDescriptor_1b35a44a96ae014b) } var fileDescriptor_1b35a44a96ae014b = []byte{ - // 249 bytes of a gzipped FileDescriptorProto + // 213 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0xc8, 0x49, 0xcc, 0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0xd1, 0x2f, - 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x42, 0x96, 0xd4, 0x03, 0x4b, 0x2a, 0x95, + 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x42, 0x96, 0xd4, 0x03, 0x4b, 0x2a, 0xd9, 0x71, 0x09, 0xf8, 0x16, 0xa7, 0xfb, 0xe5, 0x97, 0x24, 0x16, 0x65, 0x56, 0xa5, 0x3a, 0x82, 0xc4, 0x84, 0x24, 0xb8, 0xd8, 0x93, 0x8b, 0x52, 0x13, 0x4b, 0xf2, 0x8b, 0x24, 0x18, 0x15, 0x18, 0x35, - 0x38, 0x83, 0x60, 0x5c, 0x21, 0x21, 0x2e, 0x96, 0x8c, 0xc4, 0xe2, 0x0c, 0x09, 0x26, 0xb0, 0x30, - 0x98, 0x2d, 0x24, 0xc3, 0xc5, 0x59, 0x9c, 0x99, 0x9e, 0x97, 0x58, 0x52, 0x5a, 0x94, 0x2a, 0xc1, - 0x0c, 0x96, 0x40, 0x08, 0x08, 0x89, 0x71, 0xb1, 0x15, 0x94, 0x26, 0x79, 0xa7, 0x56, 0x4a, 0xb0, - 0x80, 0xa5, 0xa0, 0x3c, 0x25, 0x29, 0x2e, 0x09, 0x74, 0x7b, 0x83, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, - 0x8a, 0x53, 0x8d, 0xb2, 0xb8, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0x92, 0xb9, 0x78, 0x51, 0xdd, 0xa5, - 0xa2, 0x87, 0xe9, 0x01, 0x3d, 0x74, 0x53, 0xa4, 0x74, 0x88, 0x51, 0x05, 0xb3, 0xcb, 0xc9, 0xfb, - 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, - 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, - 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x11, 0x26, 0x22, 0x31, 0x75, 0xd3, 0xf3, 0xf5, 0x2b, 0x60, - 0x61, 0x5c, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x67, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x74, 0x66, 0x6a, 0x3f, 0x86, 0x01, 0x00, 0x00, + 0x38, 0x83, 0x60, 0x5c, 0x21, 0x01, 0x2e, 0xe6, 0xe4, 0xcc, 0x14, 0x09, 0x26, 0xb0, 0x28, 0x88, + 0xa9, 0x24, 0xc5, 0x25, 0x81, 0xae, 0x3f, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0x28, + 0x8b, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x99, 0x8b, 0x17, 0xd5, 0x7c, 0x15, 0x3d, 0x4c, 0x87, + 0xe8, 0xa1, 0x9b, 0x22, 0xa5, 0x43, 0x8c, 0x2a, 0x98, 0x5d, 0x4e, 0xde, 0x27, 0x1e, 0xc9, 0x31, + 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, + 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x98, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, + 0x9f, 0xab, 0x8f, 0x30, 0x11, 0x89, 0xa9, 0x9b, 0x9e, 0xaf, 0x5f, 0x01, 0x0b, 0xab, 0xca, 0x82, + 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x78, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xcd, 0x3f, 0xf0, + 0xac, 0x4e, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -258,24 +240,10 @@ func (m *MsgNotarizeAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.PubKey) > 0 { - i -= len(m.PubKey) - copy(dAtA[i:], m.PubKey) - i = encodeVarintTx(dAtA, i, uint64(len(m.PubKey))) - i-- - dAtA[i] = 0x22 - } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x1a - } - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintTx(dAtA, i, uint64(len(m.Hash))) + if len(m.Cid) > 0 { + i -= len(m.Cid) + copy(dAtA[i:], m.Cid) + i = encodeVarintTx(dAtA, i, uint64(len(m.Cid))) i-- dAtA[i] = 0x12 } @@ -333,15 +301,7 @@ func (m *MsgNotarizeAsset) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.PubKey) + l = len(m.Cid) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -426,7 +386,7 @@ func (m *MsgNotarizeAsset) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -454,71 +414,7 @@ func (m *MsgNotarizeAsset) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Hash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", 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.Signature = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubKey", 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.PubKey = string(dAtA[iNdEx:postIndex]) + m.Cid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/machine/keeper/machine.go b/x/machine/keeper/machine.go index 79428e0..e027105 100644 --- a/x/machine/keeper/machine.go +++ b/x/machine/keeper/machine.go @@ -43,6 +43,7 @@ func (k Keeper) StoreMachineIndex(ctx sdk.Context, machine types.Machine) { issuerPlanetmintIndexKey := GetMachineBytes(machine.IssuerPlanetmint) issuerLiquidIndexKey := GetMachineBytes(machine.IssuerLiquid) addressIndexKey := GetMachineBytes(machine.Address) + indexAppendValue := k.cdc.MustMarshal(&index) taIndexStore.Set(machineIdIndexKey, indexAppendValue) issuerPlanetmintIndexStore.Set(issuerPlanetmintIndexKey, indexAppendValue) diff --git a/x/machine/keeper/msg_server_test.go b/x/machine/keeper/msg_server_test.go index 16c4d08..417f1e9 100644 --- a/x/machine/keeper/msg_server_test.go +++ b/x/machine/keeper/msg_server_test.go @@ -30,7 +30,7 @@ func TestMsgServerAttestMachine(t *testing.T) { sk, pk := sample.KeyPair() ta := sample.TrustAnchor(pk) taMsg := types.NewMsgRegisterTrustAnchor(pk, &ta) - machine := sample.Machine(pk, pk, sk) + machine := sample.Machine(pk, pk, sk, "") msg := types.NewMsgAttestMachine(pk, &machine) msgServer, ctx := setupMsgServer(t) _, err := msgServer.RegisterTrustAnchor(ctx, taMsg) @@ -45,7 +45,7 @@ func TestMsgServerAttestMachineInvalidLiquidKey(t *testing.T) { sk, pk := sample.KeyPair() ta := sample.TrustAnchor(pk) taMsg := types.NewMsgRegisterTrustAnchor(pk, &ta) - machine := sample.Machine(pk, pk, sk) + machine := sample.Machine(pk, pk, sk, "") machine.IssuerLiquid = "invalidkey" msg := types.NewMsgAttestMachine(pk, &machine) msgServer, ctx := setupMsgServer(t) diff --git a/x/machine/types/errors.go b/x/machine/types/errors.go index bd684f8..74533e2 100644 --- a/x/machine/types/errors.go +++ b/x/machine/types/errors.go @@ -11,4 +11,5 @@ var ( ErrMachineNotFound = errorsmod.Register(ModuleName, 2, "machine not found") ErrTrustAnchorNotFound = errorsmod.Register(ModuleName, 3, "trust anchor not found") ErrTrustAnchorAlreadyInUse = errorsmod.Register(ModuleName, 4, "trust anchor already in use") + ErrMachineIsNotCreator = errorsmod.Register(ModuleName, 5, "the machine.address is no the message creator address") )