diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c13696543..77cf812d2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * Truncate hashes used in metadata addresses for Record, Record Specification #132 * Add support for creating, updating, removing, finding, and iterating over `Session`s #55 +* Add support for creating, updating, removing, finding, and iterating over `RecordSpecification`s #59 ## [v0.1.10](https://github.com/provenance-io/provenance/releases/tag/v0.1.10) - 2021-03-04 diff --git a/proto/provenance/metadata/v1/query.proto b/proto/provenance/metadata/v1/query.proto index c5ef2ad2fd..1a1b5fda8f 100644 --- a/proto/provenance/metadata/v1/query.proto +++ b/proto/provenance/metadata/v1/query.proto @@ -55,15 +55,34 @@ service Query { option (google.api.http).get = "/provenance/metadata/v1/valueownership/{address}"; } - // ScopeSpecification returns a scope specification for the given specification id + // ScopeSpecification returns a scope specification for the given specification uuid rpc ScopeSpecification(ScopeSpecificationRequest) returns (ScopeSpecificationResponse) { option (google.api.http).get = "/provenance/metadata/v1/scopespec/{specification_uuid}"; } - // ContractSpecification returns a contract specification for the given specification id + // ContractSpecification returns a contract specification for the given specification uuid rpc ContractSpecification(ContractSpecificationRequest) returns (ContractSpecificationResponse) { option (google.api.http).get = "/provenance/metadata/v1/contractspec/{specification_uuid}"; } + + // ContractSpecification returns a contract specification and record specifications for the given contract + // specification uuid + rpc ContractSpecificationExtended(ContractSpecificationExtendedRequest) + returns (ContractSpecificationExtendedResponse) { + option (google.api.http).get = "/provenance/metadata/v1/contractspec/{specification_uuid}/extended"; + } + + // RecordSpecificationsForContractSpecification returns the record specifications for the given contract specification + // uuid + rpc RecordSpecificationsForContractSpecification(RecordSpecificationsForContractSpecificationRequest) + returns (RecordSpecificationsForContractSpecificationResponse) { + option (google.api.http).get = "/provenance/metadata/v1/contractspec/{contract_specification_uuid}/recordspecs"; + } + + // RecordSpecification returns a record specification for the given specification uuid + rpc RecordSpecification(RecordSpecificationRequest) returns (RecordSpecificationResponse) { + option (google.api.http).get = "/provenance/metadata/v1/recordspec/{contract_specification_uuid}/{name}"; + } } // QueryParamsRequest is the request type for the Query/Params RPC method. @@ -195,3 +214,37 @@ message ContractSpecificationRequest { message ContractSpecificationResponse { ContractSpecification contract_specification = 1 [(gogoproto.moretags) = "yaml:\"contract_specification\""]; } + +// ContractSpecificationExtendedRequest is used for requesting a contract specification with extended data by contract +// specification uuid +message ContractSpecificationExtendedRequest { + string specification_uuid = 1 [(gogoproto.moretags) = "yaml:\"specification_uuid\""]; +} + +// ContractSpecificationExtendedResponse is the response to a contract specification extended request. +message ContractSpecificationExtendedResponse { + ContractSpecification contract_specification = 1 [(gogoproto.moretags) = "yaml:\"contract_specification\""]; + repeated RecordSpecification record_specifications = 2 [(gogoproto.moretags) = "yaml:\"record_specifications\""]; +} + +// RecordSpecificationsForContractSpecificationRequest is used for requesting record specifications by contract +// specification uuid +message RecordSpecificationsForContractSpecificationRequest { + string contract_specification_uuid = 1 [(gogoproto.moretags) = "yaml:\"contract_specification_uuid\""]; +} + +// RecordSpecificationResponseResponse is the response to a record specification for contract specification request. +message RecordSpecificationsForContractSpecificationResponse { + repeated RecordSpecification record_specifications = 1 [(gogoproto.moretags) = "yaml:\"record_specifications\""]; +} + +// RecordSpecificationRequest is used for requesting a record specification by uuid +message RecordSpecificationRequest { + string contract_specification_uuid = 1 [(gogoproto.moretags) = "yaml:\"contract_specification_uuid\""]; + string name = 2; +} + +// RecordSpecificationResponse is the response to a record specification request. +message RecordSpecificationResponse { + RecordSpecification record_specification = 1 [(gogoproto.moretags) = "yaml:\"record_specification\""]; +} diff --git a/proto/provenance/metadata/v1/specification.proto b/proto/provenance/metadata/v1/specification.proto index 7cbad9bb31..1308d059f8 100644 --- a/proto/provenance/metadata/v1/specification.proto +++ b/proto/provenance/metadata/v1/specification.proto @@ -83,17 +83,12 @@ message ContractSpecification { } // name of the class/type of this contract executable string class_name = 7 [(gogoproto.moretags) = "yaml:\"class_name\""]; - // a collection of ids of checks (RecordSpecifications) that must be satisfied against a scope prior to - // allowing a record to be added under this specification - repeated bytes record_spec_ids = 8 [ - (gogoproto.nullable) = false, - (gogoproto.customtype) = "MetadataAddress", - (gogoproto.moretags) = "yaml:\"record_spec_ids\"" - ]; } // RecordSpecification defines the specification for a Record including allowed/required inputs/outputs message RecordSpecification { + option (gogoproto.goproto_stringer) = false; + // unique identifier for this specification on chain bytes specification_id = 1 [ (gogoproto.nullable) = false, @@ -109,12 +104,14 @@ message RecordSpecification { // Type of result for this record specification (must be RECORD or RECORD_LIST) DefinitionType result_type = 5 [(gogoproto.moretags) = "yaml:\"result_type\""]; // Type of party responsible for this record - PartyType responsible_party = 6 [(gogoproto.moretags) = "yaml:\"responsible_party\""]; + repeated PartyType responsible_parties = 6 [(gogoproto.moretags) = "yaml:\"responsible_parties\""]; } // InputSpecification defines a name, type_name, and source reference (either on or off chain) to define an input // parameter message InputSpecification { + option (gogoproto.goproto_stringer) = false; + // name for this input string name = 1; // a type_name (typically a proto name or class_name) diff --git a/proto/provenance/metadata/v1/tx.proto b/proto/provenance/metadata/v1/tx.proto index 711cc5755c..00b4b3c893 100644 --- a/proto/provenance/metadata/v1/tx.proto +++ b/proto/provenance/metadata/v1/tx.proto @@ -42,6 +42,11 @@ service Msg { // DeleteContractSpecification deletes a contract specification rpc DeleteContractSpecification(MsgDeleteContractSpecificationRequest) returns (MsgDeleteContractSpecificationResponse); + + // AddRecordSpecification adds a record specification + rpc AddRecordSpecification(MsgAddRecordSpecificationRequest) returns (MsgAddRecordSpecificationResponse); + // DeleteRecordSpecification deletes a record specification + rpc DeleteRecordSpecification(MsgDeleteRecordSpecificationRequest) returns (MsgDeleteRecordSpecificationResponse); } // MsgMemorializeContractRequest is a request from a P8e execution environment to record results of a contract @@ -201,7 +206,7 @@ message MsgDeleteScopeSpecificationRequest { option (gogoproto.stringer) = false; option (gogoproto.goproto_getters) = false; - // Unique ID for the scope specification to delete. + // MetadataAddress for the scope specification to delete. bytes specification_id = 1 [ (gogoproto.nullable) = false, (gogoproto.customtype) = "MetadataAddress", @@ -234,7 +239,7 @@ message MsgDeleteContractSpecificationRequest { option (gogoproto.stringer) = false; option (gogoproto.goproto_getters) = false; - // Unique ID for the scope specification to delete. + // MetadataAddress for the contract specification to delete. bytes specification_id = 1 [ (gogoproto.nullable) = false, (gogoproto.customtype) = "MetadataAddress", @@ -245,3 +250,36 @@ message MsgDeleteContractSpecificationRequest { // MsgDeleteContractSpecificationResponse from a delete contract specification request message MsgDeleteContractSpecificationResponse {} + +// MsgAddRecordSpecificationRequest is a request to add a record specification +message MsgAddRecordSpecificationRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = false; + option (gogoproto.goproto_getters) = false; + + RecordSpecification specification = 1 [(gogoproto.nullable) = false]; + repeated string signers = 2; +} + +// MsgAddRecordSpecificationResponse from an add record specification request +message MsgAddRecordSpecificationResponse {} + +// MsgDeleteRecordSpecificationRequest deletes a record specification +message MsgDeleteRecordSpecificationRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = false; + option (gogoproto.goproto_getters) = false; + + // MetadataAddress for the record specification to delete. + bytes specification_id = 1 [ + (gogoproto.nullable) = false, + (gogoproto.customtype) = "MetadataAddress", + (gogoproto.moretags) = "yaml:\"specification_id\"" + ]; + repeated string signers = 2; +} + +// MsgDeleteRecordSpecificationResponse from a delete record specification request +message MsgDeleteRecordSpecificationResponse {} diff --git a/x/metadata/handler.go b/x/metadata/handler.go index 6588b94e06..9ba91437b1 100644 --- a/x/metadata/handler.go +++ b/x/metadata/handler.go @@ -29,6 +29,26 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgAddSessionRequest: res, err := msgServer.AddSession(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + + case *types.MsgAddScopeSpecificationRequest: + res, err := msgServer.AddScopeSpecification(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgDeleteScopeSpecificationRequest: + res, err := msgServer.DeleteScopeSpecification(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgAddContractSpecificationRequest: + res, err := msgServer.AddContractSpecification(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgDeleteContractSpecificationRequest: + res, err := msgServer.DeleteContractSpecification(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgAddRecordSpecificationRequest: + res, err := msgServer.AddRecordSpecification(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgDeleteRecordSpecificationRequest: + res, err := msgServer.DeleteRecordSpecification(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown message type: %v", msg.Type()) } diff --git a/x/metadata/keeper/genesis.go b/x/metadata/keeper/genesis.go index 4f3d595fda..6f709e1f27 100644 --- a/x/metadata/keeper/genesis.go +++ b/x/metadata/keeper/genesis.go @@ -36,7 +36,11 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { k.SetContractSpecification(ctx, s) } } - // TODO: data.RecordSpecifications + if data.RecordSpecifications != nil { + for _, s := range data.RecordSpecifications { + k.SetRecordSpecification(ctx, s) + } + } } // ExportGenesis exports the current keeper state of the metadata module.ExportGenesis @@ -45,6 +49,9 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (data *types.GenesisState) { scopes := make([]types.Scope, 0) sessions := make([]types.Session, 0) records := make([]types.Record, 0) + scopeSpecs := make([]types.ScopeSpecification, 0) + contractSpecs := make([]types.ContractSpecification, 0) + recordSpecs := make([]types.RecordSpecification, 0) appendToScopes := func(scope types.Scope) bool { scopes = append(scopes, scope) @@ -61,6 +68,21 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (data *types.GenesisState) { return false } + appendToScopeSpecs := func(scopeSpec types.ScopeSpecification) bool { + scopeSpecs = append(scopeSpecs, scopeSpec) + return false + } + + appendToContractSpecs := func(contractSpec types.ContractSpecification) bool { + contractSpecs = append(contractSpecs, contractSpec) + return false + } + + appendToRecordSpecs := func(recordSpec types.RecordSpecification) bool { + recordSpecs = append(recordSpecs, recordSpec) + return false + } + if err := k.IterateScopes(ctx, appendToScopes); err != nil { panic(err) } @@ -70,7 +92,15 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (data *types.GenesisState) { if err := k.IterateRecords(ctx, types.MetadataAddress{}, appendToRecords); err != nil { panic(err) } - // TODO iterate over existing scope, group specifications and collect here for export + if err := k.IterateScopeSpecs(ctx, appendToScopeSpecs); err != nil { + panic(err) + } + if err := k.IterateContractSpecs(ctx, appendToContractSpecs); err != nil { + panic(err) + } + if err := k.IterateRecordSpecs(ctx, appendToRecordSpecs); err != nil { + panic(err) + } - return types.NewGenesisState(params, scopes, sessions, records, []types.ScopeSpecification{}, []types.ContractSpecification{}) + return types.NewGenesisState(params, scopes, sessions, records, scopeSpecs, contractSpecs, recordSpecs) } diff --git a/x/metadata/keeper/keeper.go b/x/metadata/keeper/keeper.go index 2481b81ffb..38514bce9e 100644 --- a/x/metadata/keeper/keeper.go +++ b/x/metadata/keeper/keeper.go @@ -3,17 +3,14 @@ package keeper import ( "fmt" - "github.com/tendermint/tendermint/libs/log" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/provenance-io/provenance/x/metadata/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/provenance-io/provenance/x/metadata/types" + "github.com/tendermint/tendermint/libs/log" ) // MetadataKeeperI is the internal state api for the metadata module. @@ -52,7 +49,7 @@ type MetadataKeeperI interface { // SetScopeSpecification persists the provided scope specification SetScopeSpecification(sdk.Context, types.ScopeSpecification) // RemoveScopeSpecification removes a scope specification from the module kv store. - RemoveScopeSpecification(sdk.Context, types.MetadataAddress) + RemoveScopeSpecification(sdk.Context, types.MetadataAddress) error // IterateScopeSpecs processes all scope specs using a given handler. IterateScopeSpecs(ctx sdk.Context, handler func(specification types.ScopeSpecification) (stop bool)) error @@ -66,12 +63,28 @@ type MetadataKeeperI interface { // SetContractSpecification persists the provided contract specification SetContractSpecification(sdk.Context, types.ContractSpecification) // RemoveContractSpecification removes a contract specification from the module kv store. - RemoveContractSpecification(sdk.Context, types.MetadataAddress) + RemoveContractSpecification(sdk.Context, types.MetadataAddress) error // IterateContractSpecs processes all contract specs using the given handler. IterateContractSpecs(ctx sdk.Context, handler func(specification types.ContractSpecification) (stop bool)) error // IterateContractSpecsForOwner processes all contract specs owned by an address using a given handler. IterateContractSpecsForOwner(ctx sdk.Context, ownerAddress sdk.AccAddress, handler func(contractSpecID types.MetadataAddress) (stop bool)) error + + // GetRecordSpecification returns the record specification with the given address. + GetRecordSpecification(sdk.Context, types.MetadataAddress) (types.RecordSpecification, bool) + // SetRecordSpecification persists the provided record specification + SetRecordSpecification(sdk.Context, types.RecordSpecification) + // RemoveRecordSpecification removes a record specification from the module kv store. + RemoveRecordSpecification(sdk.Context, types.MetadataAddress) error + + // IterateRecordSpecs processes all record specs using a given handler. + IterateRecordSpecs(ctx sdk.Context, handler func(specification types.RecordSpecification) (stop bool)) error + // IterateRecordSpecsForOwner processes all record specs owned by an address using a given handler. + IterateRecordSpecsForOwner(ctx sdk.Context, ownerAddress sdk.AccAddress, handler func(recordSpecID types.MetadataAddress) (stop bool)) error + // IterateRecordSpecsForContractSpec processes all record specs for a contract spec using a given handler. + IterateRecordSpecsForContractSpec(ctx sdk.Context, contractSpecID types.MetadataAddress, handler func(recordSpecID types.MetadataAddress) (stop bool)) error + // GetRecordSpecificationsForContractSpecificationID returns all the record specifications associated with given contractSpecID + GetRecordSpecificationsForContractSpecificationID(ctx sdk.Context, contractSpecID types.MetadataAddress) ([]*types.RecordSpecification, error) } // Keeper is the concrete state-based API for the metadata module. diff --git a/x/metadata/keeper/keeper_test.go b/x/metadata/keeper/keeper_test.go index d323668516..9280e705b0 100644 --- a/x/metadata/keeper/keeper_test.go +++ b/x/metadata/keeper/keeper_test.go @@ -104,6 +104,10 @@ func (s *KeeperTestSuite) SetupTest() { s.queryClient = queryClient } +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + func (s *KeeperTestSuite) TestMetadataScopeGetSet() { scope, found := s.app.MetadataKeeper.GetScope(s.ctx, s.scopeID) s.NotNil(scope) @@ -558,7 +562,7 @@ func (s *KeeperTestSuite) TestMetadataValidateSessionUpdate() { invalidNameSession := types.NewSession("invalid", s.sessionId, s.contractSpecId, parties, types.AuditFields{}) partiesInvolved := []types.PartyType{types.PartyType_PARTY_TYPE_AFFILIATE} - contractSpec := types.NewContractSpecification(s.contractSpecId, types.NewDescription("name", "desc", "url", "icon"), []string{s.user1}, partiesInvolved, &types.ContractSpecification_Hash{"hash"}, "processname", []types.MetadataAddress{}) + contractSpec := types.NewContractSpecification(s.contractSpecId, types.NewDescription("name", "desc", "url", "icon"), []string{s.user1}, partiesInvolved, &types.ContractSpecification_Hash{"hash"}, "processname") s.app.MetadataKeeper.SetContractSpecification(s.ctx, *contractSpec) cases := map[string]struct { @@ -828,7 +832,3 @@ func (s *KeeperTestSuite) TestValidateAllOwnersAreSigners() { }) } } - -func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) -} diff --git a/x/metadata/keeper/msg_server.go b/x/metadata/keeper/msg_server.go index b5a3c21cf0..94a4575318 100644 --- a/x/metadata/keeper/msg_server.go +++ b/x/metadata/keeper/msg_server.go @@ -196,8 +196,11 @@ func (k msgServer) AddScopeSpecification( var existing *types.ScopeSpecification = nil if e, found := k.GetScopeSpecification(ctx, msg.Specification.SpecificationId); found { existing = &e + if err := k.ValidateAllOwnersAreSigners(existing.OwnerAddresses, msg.Signers); err != nil { + return nil, err + } } - if err := k.ValidateScopeSpecUpdate(ctx, existing, msg.Specification, msg.Signers); err != nil { + if err := k.ValidateScopeSpecUpdate(ctx, existing, msg.Specification); err != nil { return nil, err } @@ -228,7 +231,9 @@ func (k msgServer) DeleteScopeSpecification( return nil, err } - k.RemoveScopeSpecification(ctx, msg.SpecificationId) + if err := k.RemoveScopeSpecification(ctx, msg.SpecificationId); err != nil { + return nil, fmt.Errorf("cannot delete scope specification with id %s: %w", msg.SpecificationId, err) + } ctx.EventManager().EmitEvent( sdk.NewEvent( @@ -250,8 +255,11 @@ func (k msgServer) AddContractSpecification( var existing *types.ContractSpecification = nil if e, found := k.GetContractSpecification(ctx, msg.Specification.SpecificationId); found { existing = &e + if err := k.ValidateAllOwnersAreSigners(existing.OwnerAddresses, msg.Signers); err != nil { + return nil, err + } } - if err := k.ValidateContractSpecUpdate(ctx, existing, msg.Specification, msg.Signers); err != nil { + if err := k.ValidateContractSpecUpdate(ctx, existing, msg.Specification); err != nil { return nil, err } @@ -282,7 +290,34 @@ func (k msgServer) DeleteContractSpecification( return nil, err } - k.RemoveContractSpecification(ctx, msg.SpecificationId) + // Remove all record specifications associated with this contract specification. + recSpecs, recSpecErr := k.GetRecordSpecificationsForContractSpecificationID(ctx, msg.SpecificationId) + if recSpecErr != nil { + return nil, fmt.Errorf("could not get record specifications to delete with contract specification with id %s: %w", + msg.SpecificationId, recSpecErr) + } + var delRecSpecErr error = nil + removedRecSpecs := []*types.RecordSpecification{} + for _, recSpec := range recSpecs { + if err := k.RemoveRecordSpecification(ctx, recSpec.SpecificationId); err != nil { + delRecSpecErr = fmt.Errorf("failed to delete record specification %s (name: %s) while trying to delete contract specification %d: %w", + recSpec.SpecificationId, recSpec.Name, msg.SpecificationId, err) + break + } + removedRecSpecs = append(removedRecSpecs, recSpec) + } + if delRecSpecErr != nil { + // Put the deleted record specifications back since not all of them could be deleted (and neither can this contract spec) + for _, recSpec := range removedRecSpecs { + k.SetRecordSpecification(ctx, *recSpec) + } + return nil, delRecSpecErr + } + + // Remove the contract specification itself + if err := k.RemoveContractSpecification(ctx, msg.SpecificationId); err != nil { + return nil, fmt.Errorf("cannot delete contract specification with id %s: %w", msg.SpecificationId, err) + } ctx.EventManager().EmitEvent( sdk.NewEvent( @@ -294,3 +329,76 @@ func (k msgServer) DeleteContractSpecification( return &types.MsgDeleteContractSpecificationResponse{}, nil } + +func (k msgServer) AddRecordSpecification( + goCtx context.Context, + msg *types.MsgAddRecordSpecificationRequest, +) (*types.MsgAddRecordSpecificationResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + contractSpecID := msg.Specification.SpecificationId.GetContractSpecAddress() + contractSpec, contractSpecFound := k.GetContractSpecification(ctx, contractSpecID) + if !contractSpecFound { + contractSpecUUID, _ := contractSpecID.ContractSpecUUID() + return nil, fmt.Errorf("contract specification not found with id %s (uuid %s) required for adding or updating record specification with id %s", + contractSpecID, contractSpecUUID, msg.Specification.SpecificationId) + } + if err := k.ValidateAllOwnersAreSigners(contractSpec.OwnerAddresses, msg.Signers); err != nil { + return nil, err + } + + var existing *types.RecordSpecification = nil + if e, found := k.GetRecordSpecification(ctx, msg.Specification.SpecificationId); found { + existing = &e + } + if err := k.ValidateRecordSpecUpdate(ctx, existing, msg.Specification); err != nil { + return nil, err + } + + k.SetRecordSpecification(ctx, msg.Specification) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, strings.Join(msg.Signers, ",")), + ), + ) + + return &types.MsgAddRecordSpecificationResponse{}, nil +} + +func (k msgServer) DeleteRecordSpecification( + goCtx context.Context, + msg *types.MsgDeleteRecordSpecificationRequest, +) (*types.MsgDeleteRecordSpecificationResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + _, found := k.GetRecordSpecification(ctx, msg.SpecificationId) + if !found { + return nil, fmt.Errorf("record specification not found with id %s", msg.SpecificationId) + } + contractSpecID := msg.SpecificationId.GetContractSpecAddress() + contractSpec, contractSpecFound := k.GetContractSpecification(ctx, contractSpecID) + if !contractSpecFound { + return nil, fmt.Errorf("contract specification not found with id %s required for deleting record specification with id %s", + contractSpecID, msg.SpecificationId) + } + if err := k.ValidateAllOwnersAreSigners(contractSpec.OwnerAddresses, msg.Signers); err != nil { + return nil, err + } + + if err := k.RemoveRecordSpecification(ctx, msg.SpecificationId); err != nil { + return nil, fmt.Errorf("cannot delete record specification with id %s: %w", msg.SpecificationId, err) + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, strings.Join(msg.Signers, ",")), + ), + ) + + return &types.MsgDeleteRecordSpecificationResponse{}, nil +} diff --git a/x/metadata/keeper/msg_server_test.go b/x/metadata/keeper/msg_server_test.go new file mode 100644 index 0000000000..0d75000dd9 --- /dev/null +++ b/x/metadata/keeper/msg_server_test.go @@ -0,0 +1,70 @@ +package keeper_test + +import ( + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "testing" + + "github.com/provenance-io/provenance/app" + simapp "github.com/provenance-io/provenance/app" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/provenance-io/provenance/x/metadata/types" +) + +type MsgServerTestSuite struct { + suite.Suite + + app *app.App + ctx sdk.Context + queryClient types.QueryClient + + pubkey1 cryptotypes.PubKey + user1 string + user1Addr sdk.AccAddress + + pubkey2 cryptotypes.PubKey + user2 string + user2Addr sdk.AccAddress +} + +func (s *MsgServerTestSuite) SetupTest() { + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + s.pubkey1 = secp256k1.GenPrivKey().PubKey() + s.user1Addr = sdk.AccAddress(s.pubkey1.Address()) + s.user1 = s.user1Addr.String() + + s.pubkey2 = secp256k1.GenPrivKey().PubKey() + s.user2Addr = sdk.AccAddress(s.pubkey2.Address()) + s.user2 = s.user2Addr.String() + + s.app.AccountKeeper.SetAccount(s.ctx, s.app.AccountKeeper.NewAccountWithAddress(s.ctx, s.user1Addr)) + + queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, app.MetadataKeeper) + queryClient := types.NewQueryClient(queryHelper) + s.queryClient = queryClient +} + +func TestMsgServerTestSuite(t *testing.T) { + suite.Run(t, new(MsgServerTestSuite)) +} + +// TODO: MemorializeContract tests +// TODO: ChangeOwnership tests +// TODO: AddScope tests +// TODO: DeleteScope tests +// TODO: AddRecordGroup tests +// TODO: AddRecord tests +// TODO: AddScopeSpecification tests +// TODO: DeleteScopeSpecification tests +// TODO: AddContractSpecification tests +// TODO: DeleteContractSpecification tests +// TODO: AddRecordSpecification tests +// TODO: DeleteRecordSpecification tests \ No newline at end of file diff --git a/x/metadata/keeper/querier.go b/x/metadata/keeper/querier.go index 2b989d17df..2064a665fa 100644 --- a/x/metadata/keeper/querier.go +++ b/x/metadata/keeper/querier.go @@ -27,6 +27,8 @@ func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { return queryParams(ctx, k, legacyQuerierCdc) case types.QueryScopeSpec: return queryScopeSpecification(ctx, path, k, legacyQuerierCdc) + // TODO: add contract spec stuff + // TODO: add record spec stuff default: return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown query endpoint") diff --git a/x/metadata/keeper/query_server.go b/x/metadata/keeper/query_server.go index 161a820f57..2c98f5a683 100644 --- a/x/metadata/keeper/query_server.go +++ b/x/metadata/keeper/query_server.go @@ -289,7 +289,7 @@ func (k Keeper) ScopeSpecification(c context.Context, req *types.ScopeSpecificat return nil, status.Error(codes.InvalidArgument, "empty request") } - if req.SpecificationUuid == "" { + if len(req.SpecificationUuid) == 0 { return nil, status.Error(codes.InvalidArgument, "specification uuid cannot be empty") } @@ -308,27 +308,126 @@ func (k Keeper) ScopeSpecification(c context.Context, req *types.ScopeSpecificat return &types.ScopeSpecificationResponse{ScopeSpecification: &spec}, nil } -// ContractSpecification returns a specific scope specification by id +// ContractSpecification returns a specific contract specification by id func (k Keeper) ContractSpecification(c context.Context, req *types.ContractSpecificationRequest) (*types.ContractSpecificationResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - if req.SpecificationUuid == "" { - return nil, status.Error(codes.InvalidArgument, "specification id cannot be empty") + if len(req.SpecificationUuid) == 0 { + return nil, status.Error(codes.InvalidArgument, "specification uuid cannot be empty") } - id, err := uuid.Parse(req.SpecificationUuid) + specUUID, err := uuid.Parse(req.SpecificationUuid) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "invalid specification id: %s", err.Error()) + return nil, status.Errorf(codes.InvalidArgument, "invalid specification uuid: %s", err.Error()) } - addr := types.ContractSpecMetadataAddress(id) + specID := types.ContractSpecMetadataAddress(specUUID) ctx := sdk.UnwrapSDKContext(c) - spec, found := k.GetContractSpecification(ctx, addr) + spec, found := k.GetContractSpecification(ctx, specID) if !found { - return nil, status.Errorf(codes.NotFound, "contract specification %s not found", req.SpecificationUuid) + return nil, status.Errorf(codes.NotFound, "contract specification with id %s (uuid %s) not found", + specID, req.SpecificationUuid) } return &types.ContractSpecificationResponse{ContractSpecification: &spec}, nil } + +// ContractSpecificationExtended returns a specific contract specification and record specifications by contract specification id +func (k Keeper) ContractSpecificationExtended(c context.Context, req *types.ContractSpecificationExtendedRequest) (*types.ContractSpecificationExtendedResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if len(req.SpecificationUuid) == 0 { + return nil, status.Error(codes.InvalidArgument, "specification uuid cannot be empty") + } + + contractSpecUUID, err := uuid.Parse(req.SpecificationUuid) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid specification uuid: %s", err.Error()) + } + contractSpecID := types.ContractSpecMetadataAddress(contractSpecUUID) + ctx := sdk.UnwrapSDKContext(c) + + contractSpec, found := k.GetContractSpecification(ctx, contractSpecID) + if !found { + return nil, status.Errorf(codes.NotFound, "contract specification with id %s (uuid %s) not found", + contractSpecID, req.SpecificationUuid) + } + + recSpecs, err := k.GetRecordSpecificationsForContractSpecificationID(ctx, contractSpecID) + if err != nil { + return nil, status.Errorf(codes.Aborted, "error getting record specifications for contract spec uuid %s: %s", + contractSpecUUID, err.Error()) + } + + return &types.ContractSpecificationExtendedResponse{ + ContractSpecification: &contractSpec, + RecordSpecifications: recSpecs, + }, nil +} + +// RecordSpecificationsForContractSpecification returns the record specifications associated with a contract specification +func (k Keeper) RecordSpecificationsForContractSpecification( + c context.Context, + req *types.RecordSpecificationsForContractSpecificationRequest, +) (*types.RecordSpecificationsForContractSpecificationResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if len(req.ContractSpecificationUuid) == 0 { + return nil, status.Error(codes.InvalidArgument, "contract specification uuid cannot be empty") + } + contractSpecUUID, err := uuid.Parse(req.ContractSpecificationUuid) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid contract specification uuid: %s", err.Error()) + } + contractSpecID := types.ContractSpecMetadataAddress(contractSpecUUID) + + ctx := sdk.UnwrapSDKContext(c) + + recSpecs, err := k.GetRecordSpecificationsForContractSpecificationID(ctx, contractSpecID) + if err != nil { + return nil, status.Errorf(codes.Aborted, "error getting record specifications for contract spec uuid %s: %s", + contractSpecUUID, err.Error()) + } + + if len(recSpecs) == 0 { + return nil, status.Errorf(codes.NotFound, "no record specifications found for contract spec uuid %s", contractSpecUUID) + } + + return &types.RecordSpecificationsForContractSpecificationResponse{RecordSpecifications: recSpecs}, err +} + +// RecordSpecification returns a specific record specification by contract spec id and name +func (k Keeper) RecordSpecification(c context.Context, req *types.RecordSpecificationRequest) (*types.RecordSpecificationResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if len(req.ContractSpecificationUuid) == 0 { + return nil, status.Error(codes.InvalidArgument, "contract specification uuid cannot be empty") + } + contractSpecUUID, err := uuid.Parse(req.ContractSpecificationUuid) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid contract specification uuid: %s", err.Error()) + } + + if len(req.Name) == 0 { + return nil, status.Error(codes.InvalidArgument, "name cannot be empty") + } + + specID := types.RecordSpecMetadataAddress(contractSpecUUID, req.Name) + ctx := sdk.UnwrapSDKContext(c) + + spec, found := k.GetRecordSpecification(ctx, specID) + if !found { + return nil, status.Errorf(codes.NotFound, "record specification not found for id %s (contract spec uuid %s and name %s)", + specID, req.ContractSpecificationUuid, req.Name) + } + + return &types.RecordSpecificationResponse{RecordSpecification: &spec}, nil +} diff --git a/x/metadata/keeper/query_server_test.go b/x/metadata/keeper/query_server_test.go index 5ba0ec4120..8f2fecb80b 100644 --- a/x/metadata/keeper/query_server_test.go +++ b/x/metadata/keeper/query_server_test.go @@ -96,6 +96,10 @@ func (s *QueryServerTestSuite) SetupTest() { s.queryClient = queryClient } +func TestQuerierTestSuite(t *testing.T) { + suite.Run(t, new(QueryServerTestSuite)) +} + func (s *QueryServerTestSuite) TestScopeQuery() { app, ctx, queryClient, user1, user2, recordName := s.app, s.ctx, s.queryClient, s.user1, s.user2, s.recordName @@ -265,9 +269,11 @@ func (s *QueryServerTestSuite) TestSessionQuery() { s.Equal(1, len(scrs.Sessions), "should be 1 sessions in set for session context query by scope id and session id") s.Equal(scopeID.String(), scrs.ScopeId) s.Equal(sessionID.String(), scrs.SessionId) - } -func TestQuerierTestSuite(t *testing.T) { - suite.Run(t, new(QueryServerTestSuite)) -} +// TODO: ScopeSpecification tests +// TODO: ContractSpecification tests +// TODO: ContractSpecificationExtended tests +// TODO: RecordSpecificationsForContractSpecification test +// TODO: RecordSpecification tests + diff --git a/x/metadata/keeper/specification.go b/x/metadata/keeper/specification.go index d221854560..26206193c5 100644 --- a/x/metadata/keeper/specification.go +++ b/x/metadata/keeper/specification.go @@ -7,14 +7,188 @@ import ( "github.com/provenance-io/provenance/x/metadata/types" ) +// IterateRecordSpecs processes all record specs using a given handler. +func (k Keeper) IterateRecordSpecs(ctx sdk.Context, handler func(specification types.RecordSpecification) (stop bool)) error { + store := ctx.KVStore(k.storeKey) + it := sdk.KVStorePrefixIterator(store, types.RecordSpecificationKeyPrefix) + defer it.Close() + for ; it.Valid(); it.Next() { + var recordSpec types.RecordSpecification + err := k.cdc.UnmarshalBinaryBare(it.Value(), &recordSpec) + if err != nil { + return err + } + if handler(recordSpec) { + break + } + } + return nil +} + +// IterateRecordSpecsForOwner processes all record specs owned by an address using a given handler. +func (k Keeper) IterateRecordSpecsForOwner(ctx sdk.Context, ownerAddress sdk.AccAddress, handler func(recordSpecID types.MetadataAddress) (stop bool)) error { + var recordItErr error = nil + contractItErr := k.IterateContractSpecsForOwner(ctx, ownerAddress, func(contractSpecID types.MetadataAddress) bool { + needToStop := false + recordItErr = k.IterateRecordSpecsForContractSpec(ctx, contractSpecID, func(recordSpecID types.MetadataAddress) bool { + needToStop = handler(recordSpecID) + return needToStop + }) + if recordItErr != nil { + return true + } + return needToStop + }) + if recordItErr != nil { + return recordItErr + } + if contractItErr != nil { + return contractItErr + } + return nil +} + +// IterateRecordSpecsForContractSpec processes all record specs for a contract spec using a given handler. +func (k Keeper) IterateRecordSpecsForContractSpec(ctx sdk.Context, contractSpecID types.MetadataAddress, handler func(recordSpecID types.MetadataAddress) (stop bool)) error { + store := ctx.KVStore(k.storeKey) + prefix, err := contractSpecID.ContractSpecRecordSpecIteratorPrefix() + if err != nil { + return err + } + it := sdk.KVStorePrefixIterator(store, prefix) + defer it.Close() + for ; it.Valid(); it.Next() { + var recordSpecID types.MetadataAddress + if err := recordSpecID.Unmarshal(it.Key()); err != nil { + return err + } + if handler(recordSpecID) { + break + } + } + return nil +} + +// GetRecordSpecificationsForContractSpecificationID returns all the record specifications associated with given contractSpecID +func (k Keeper) GetRecordSpecificationsForContractSpecificationID(ctx sdk.Context, contractSpecID types.MetadataAddress) ([]*types.RecordSpecification, error) { + retval := []*types.RecordSpecification{} + err := k.IterateRecordSpecsForContractSpec(ctx, contractSpecID, func(recordSpecID types.MetadataAddress) bool { + recordSpec, found := k.GetRecordSpecification(ctx, recordSpecID) + if found { + retval = append(retval, &recordSpec) + } else { + k.Logger(ctx).Error(fmt.Sprintf("iterator found record spec id %s but no record spec was found with that id", recordSpecID)) + } + return false + }) + return retval, err +} + +// GetRecordSpecification returns the record spec with the given id. +func (k Keeper) GetRecordSpecification(ctx sdk.Context, recordSpecID types.MetadataAddress) (spec types.RecordSpecification, found bool) { + if !recordSpecID.IsRecordSpecificationAddress() { + return spec, false + } + store := ctx.KVStore(k.storeKey) + b := store.Get(recordSpecID) + if b == nil { + return types.RecordSpecification{}, false + } + k.cdc.MustUnmarshalBinaryBare(b, &spec) + return spec, true +} + +// SetRecordSpecification stores a record specification in the module kv store. +func (k Keeper) SetRecordSpecification(ctx sdk.Context, spec types.RecordSpecification) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshalBinaryBare(&spec) + + eventType := types.EventTypeRecordSpecificationCreated + if store.Has(spec.SpecificationId) { + if oldBytes := store.Get(spec.SpecificationId); oldBytes != nil { + var oldSpec types.RecordSpecification + if err := k.cdc.UnmarshalBinaryBare(oldBytes, &oldSpec); err == nil { + eventType = types.EventTypeRecordSpecificationUpdated + } + } + } + + store.Set(spec.SpecificationId, b) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + eventType, + sdk.NewAttribute(types.AttributeKeyRecordSpecID, spec.SpecificationId.String()), + sdk.NewAttribute(types.AttributeKeyRecordSpec, spec.String()), + ), + ) +} + +// RemoveRecordSpecification removes a record specification from the module kv store. +func (k Keeper) RemoveRecordSpecification(ctx sdk.Context, recordSpecID types.MetadataAddress) error { + if k.isRecordSpecUsed(ctx, recordSpecID) { + return fmt.Errorf("record specification with id %s still in use", recordSpecID) + } + + store := ctx.KVStore(k.storeKey) + + recordSpec, found := k.GetRecordSpecification(ctx, recordSpecID) + if !found { + return fmt.Errorf("record specification with id %s not found", recordSpecID) + } + + store.Delete(recordSpecID) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeRecordSpecificationRemoved, + sdk.NewAttribute(types.AttributeKeyRecordSpecID, recordSpec.SpecificationId.String()), + sdk.NewAttribute(types.AttributeKeyRecordSpec, recordSpec.String()), + ), + ) + + return nil +} + +// ValidateRecordSpecUpdate full validation of a proposed record spec possibly against an existing one. +func (k Keeper) ValidateRecordSpecUpdate(ctx sdk.Context, existing *types.RecordSpecification, proposed types.RecordSpecification) error { + // Must pass basic validation. + if err := proposed.ValidateBasic(); err != nil { + return err + } + + if existing != nil { + // IDs must match + if !proposed.SpecificationId.Equals(existing.SpecificationId) { + return fmt.Errorf("cannot update record spec identifier. expected %s, got %s", + existing.SpecificationId, proposed.SpecificationId) + } + // Names must match + if proposed.Name != existing.Name { + return fmt.Errorf("cannot update record spec name. expected %s, got %s", + existing.Name, proposed.Name) + } + } + + return nil +} + +func (k Keeper) isRecordSpecUsed(ctx sdk.Context, recordSpecID types.MetadataAddress) bool { + // TODO: Check for records created from this spec. + return false +} + // IterateContractSpecs processes all contract specs using a given handler. func (k Keeper) IterateContractSpecs(ctx sdk.Context, handler func(specification types.ContractSpecification) (stop bool)) error { store := ctx.KVStore(k.storeKey) - it := sdk.KVStorePrefixIterator(store, types.ScopeSpecificationKeyPrefix) + it := sdk.KVStorePrefixIterator(store, types.ContractSpecificationKeyPrefix) defer it.Close() for ; it.Valid(); it.Next() { var contractSpec types.ContractSpecification - k.cdc.MustUnmarshalBinaryBare(it.Value(), &contractSpec) + err := k.cdc.UnmarshalBinaryBare(it.Value(), &contractSpec) + if err != nil { + return err + } if handler(contractSpec) { break } @@ -76,19 +250,23 @@ func (k Keeper) SetContractSpecification(ctx sdk.Context, spec types.ContractSpe ctx.EventManager().EmitEvent( sdk.NewEvent( eventType, - sdk.NewAttribute(types.AttributeKeyScopeSpecID, spec.SpecificationId.String()), - sdk.NewAttribute(types.AttributeKeyScopeSpec, spec.String()), + sdk.NewAttribute(types.AttributeKeyContractSpecID, spec.SpecificationId.String()), + sdk.NewAttribute(types.AttributeKeyContractSpec, spec.String()), ), ) } // RemoveContractSpecification removes a contract specification from the module kv store. -func (k Keeper) RemoveContractSpecification(ctx sdk.Context, contractSpecID types.MetadataAddress) { +func (k Keeper) RemoveContractSpecification(ctx sdk.Context, contractSpecID types.MetadataAddress) error { + if k.isContractSpecUsed(ctx, contractSpecID) { + return fmt.Errorf("contract specification with id %s still in use", contractSpecID) + } + store := ctx.KVStore(k.storeKey) contractSpec, found := k.GetContractSpecification(ctx, contractSpecID) - if !found || k.isContractSpecUsed(ctx, contractSpecID) { - return + if !found { + return fmt.Errorf("contract specification with id %s not found", contractSpecID) } k.clearContractSpecificationIndex(ctx, contractSpec) @@ -97,10 +275,12 @@ func (k Keeper) RemoveContractSpecification(ctx sdk.Context, contractSpecID type ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeContractSpecificationRemoved, - sdk.NewAttribute(types.AttributeKeyScopeSpecID, contractSpec.SpecificationId.String()), - sdk.NewAttribute(types.AttributeKeyScopeSpec, contractSpec.String()), + sdk.NewAttribute(types.AttributeKeyContractSpecID, contractSpec.SpecificationId.String()), + sdk.NewAttribute(types.AttributeKeyContractSpec, contractSpec.String()), ), ) + + return nil } // indexContractSpecification adds all desired indexes for a contract specification. @@ -133,22 +313,30 @@ func (k Keeper) clearContractSpecificationIndex(ctx sdk.Context, spec types.Cont // isContractSpecUsed checks to see if a contract spec is referenced by anything else (e.g. scope spec or session) func (k Keeper) isContractSpecUsed(ctx sdk.Context, contractSpecID types.MetadataAddress) bool { contractSpecReferenceFound := false - err := k.IterateScopeSpecsForContractSpec(ctx, contractSpecID, func(scopeID types.MetadataAddress) (stop bool) { + itScopeSpecErr := k.IterateScopeSpecsForContractSpec(ctx, contractSpecID, func(scopeID types.MetadataAddress) (stop bool) { contractSpecReferenceFound = true return true }) // If there was an error, that indicates there was probably at least one entry to iterate over. // So, to err on the side of caution, return true in that case. - if err != nil || contractSpecReferenceFound { + if itScopeSpecErr != nil || contractSpecReferenceFound { return true } - // TODO: iterate over the sessions to look for one used by this contractSpecID. - return false + // TODO: Look for sessions used by this contractSpecID. + + // Look for a used record spec that is part of this contract spec + hasUsedRecordSpec := false + itRecSpecErr := k.IterateRecordSpecsForContractSpec(ctx, contractSpecID, func(recordSpecID types.MetadataAddress) bool { + hasUsedRecordSpec = k.isRecordSpecUsed(ctx, recordSpecID) + return hasUsedRecordSpec + }) + + return itRecSpecErr != nil || hasUsedRecordSpec } // ValidateContractSpecUpdate full validation of a proposed contract spec possibly against an existing one. -func (k Keeper) ValidateContractSpecUpdate(ctx sdk.Context, existing *types.ContractSpecification, proposed types.ContractSpecification, signers []string) error { +func (k Keeper) ValidateContractSpecUpdate(ctx sdk.Context, existing *types.ContractSpecification, proposed types.ContractSpecification) error { // IDS must match if there's an existing entry if existing != nil && !proposed.SpecificationId.Equals(existing.SpecificationId) { return fmt.Errorf("cannot update contract spec identifier. expected %s, got %s", @@ -160,23 +348,6 @@ func (k Keeper) ValidateContractSpecUpdate(ctx sdk.Context, existing *types.Cont return err } - // Make sure the needed signers have signed. - if existing != nil { - if err := k.ValidateAllOwnersAreSigners(existing.OwnerAddresses, signers); err != nil { - return err - } - } - - store := ctx.KVStore(k.storeKey) - - // Validate the proposed record spec ids. - for _, recordSpecID := range proposed.RecordSpecIds { - // Make sure that all record spec ids exist - if !store.Has(recordSpecID) { - return fmt.Errorf("no record spec exists with id %s", recordSpecID) - } - } - return nil } @@ -187,7 +358,10 @@ func (k Keeper) IterateScopeSpecs(ctx sdk.Context, handler func(specification ty defer it.Close() for ; it.Valid(); it.Next() { var scopeSpec types.ScopeSpecification - k.cdc.MustUnmarshalBinaryBare(it.Value(), &scopeSpec) + err := k.cdc.UnmarshalBinaryBare(it.Value(), &scopeSpec) + if err != nil { + return err + } if handler(scopeSpec) { break } @@ -274,16 +448,19 @@ func (k Keeper) SetScopeSpecification(ctx sdk.Context, spec types.ScopeSpecifica } // RemoveScopeSpecification removes a scope specification from the module kv store. -func (k Keeper) RemoveScopeSpecification(ctx sdk.Context, scopeSpecID types.MetadataAddress) { +func (k Keeper) RemoveScopeSpecification(ctx sdk.Context, scopeSpecID types.MetadataAddress) error { + if k.isScopeSpecUsed(ctx, scopeSpecID) { + return fmt.Errorf("scope specification with id %s still in use", scopeSpecID) + } + store := ctx.KVStore(k.storeKey) scopeSpec, found := k.GetScopeSpecification(ctx, scopeSpecID) - if !found || k.isScopeSpecUsed(ctx, scopeSpecID) { - return + if !found { + return fmt.Errorf("scope specification with id %s not found", scopeSpecID) } k.clearScopeSpecificationIndex(ctx, scopeSpec) - store.Delete(scopeSpecID) ctx.EventManager().EmitEvent( @@ -293,6 +470,8 @@ func (k Keeper) RemoveScopeSpecification(ctx sdk.Context, scopeSpecID types.Meta sdk.NewAttribute(types.AttributeKeyScopeSpec, scopeSpec.String()), ), ) + + return nil } // indexScopeSpecification adds all desired indexes for a scope specification. @@ -345,7 +524,7 @@ func (k Keeper) isScopeSpecUsed(ctx sdk.Context, scopeSpecID types.MetadataAddre } // ValidateScopeSpecUpdate - full validation of a scope specification. -func (k Keeper) ValidateScopeSpecUpdate(ctx sdk.Context, existing *types.ScopeSpecification, proposed types.ScopeSpecification, signers []string) error { +func (k Keeper) ValidateScopeSpecUpdate(ctx sdk.Context, existing *types.ScopeSpecification, proposed types.ScopeSpecification) error { // IDS must match if there's an existing entry if existing != nil && !proposed.SpecificationId.Equals(existing.SpecificationId) { return fmt.Errorf("cannot update scope spec identifier. expected %s, got %s", @@ -357,13 +536,6 @@ func (k Keeper) ValidateScopeSpecUpdate(ctx sdk.Context, existing *types.ScopeSp return err } - // Signatures required of all existing data owners. - if existing != nil { - if err := k.ValidateAllOwnersAreSigners(existing.OwnerAddresses, signers); err != nil { - return err - } - } - store := ctx.KVStore(k.storeKey) // Validate the proposed contract spec ids. diff --git a/x/metadata/keeper/specification_test.go b/x/metadata/keeper/specification_test.go index e2de20d63a..d7712979b1 100644 --- a/x/metadata/keeper/specification_test.go +++ b/x/metadata/keeper/specification_test.go @@ -99,205 +99,314 @@ func areEquivalentSetsOfMetaAddresses(arr1 []types.MetadataAddress, arr2 []types return true } -func (s *SpecKeeperTestSuite) TestGetSetDeleteContractSpecification() { - newSpec := types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestGetSetDeleteContractSpecification", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", - ), - []string{s.user1Addr.String()}, +func containsRecSpec(arr []*types.RecordSpecification, newVal *types.RecordSpecification) bool { + found := false + for _, v := range arr { + if v.SpecificationId.Equals(newVal.SpecificationId) { + found = true + break + } + } + return found +} + +func areEquivalentSetsOfRecSpecs(arr1 []*types.RecordSpecification, arr2 []*types.RecordSpecification) bool { + if len(arr1) != len(arr2) { + return false + } + for _, v2 := range arr2 { + if !containsRecSpec(arr1, v2) { + return false + } + } + return true +} + +func (s *SpecKeeperTestSuite) TestGetSetRemoveRecordSpecification() { + recordName := "record name" + recSpecID := types.RecordSpecMetadataAddress(s.contractSpecUUID1, recordName) + newSpec := types.NewRecordSpecification( + recSpecID, + recordName, + []*types.InputSpecification{ + types.NewInputSpecification( + "input name 1", "type name 1", + types.NewInputSpecificationSourceHash("source hash 1"), + ), + types.NewInputSpecification( + "input name 2", "type name 2", + types.NewInputSpecificationSourceHash("source hash 2"), + ), + }, + "type name", + types.DefinitionType_DEFINITION_TYPE_RECORD, []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, ) - require.NotNil(s.T(), newSpec, "test setup failure: NewContractSpecification should not return nil") + require.NotNil(s.T(), newSpec, "test setup failure: NewRecordSpecification should not return nil") - spec1, found1 := s.app.MetadataKeeper.GetContractSpecification(s.ctx, s.contractSpecID1) - s.False(found1, "1: get contract spec should return false before it has been saved") - s.NotNil(spec1, "1: get contract spec should always return a non-nil scope spec") + spec1, found1 := s.app.MetadataKeeper.GetRecordSpecification(s.ctx, recSpecID) + s.False(found1, "1: get record spec should return false before it has been saved") + s.NotNil(spec1, "1: get record spec should always return a non-nil record spec") - s.app.MetadataKeeper.SetContractSpecification(s.ctx, *newSpec) + s.app.MetadataKeeper.SetRecordSpecification(s.ctx, *newSpec) - spec2, found2 := s.app.MetadataKeeper.GetContractSpecification(s.ctx, s.contractSpecID1) - s.True(found2, "get contract spec should return true after it has been saved") - s.NotNil(spec2, "get contract spec should always return a non-nil scope spec") - s.Equal(s.contractSpecID1, spec2.SpecificationId, "2: get contract spec should return a spec containing id provided") + spec2, found2 := s.app.MetadataKeeper.GetRecordSpecification(s.ctx,recSpecID) + s.True(found2, "get record spec should return true after it has been saved") + s.NotNil(spec2, "get record spec should always return a non-nil record spec") + s.Equal(recSpecID, spec2.SpecificationId, "2: get record spec should return a spec containing id provided") - spec3, found3 := s.app.MetadataKeeper.GetContractSpecification(s.ctx, types.ContractSpecMetadataAddress(uuid.New())) - s.False(found3, "3: get contract spec should return false for an unknown address") - s.NotNil(spec3, "3: get contract spec should always return a non-nil scope spec") + spec3, found3 := s.app.MetadataKeeper.GetRecordSpecification(s.ctx, types.RecordSpecMetadataAddress(s.contractSpecUUID1, "nope")) + s.False(found3, "3: get record spec should return false for an unknown address") + s.NotNil(spec3, "3: get record spec should always return a non-nil record spec") - s.app.MetadataKeeper.RemoveContractSpecification(s.ctx, newSpec.SpecificationId) + spec4, found4 := s.app.MetadataKeeper.GetRecordSpecification(s.ctx, types.RecordSpecMetadataAddress(uuid.New(), recordName)) + s.False(found4, "4: get record spec should return false for an unknown address") + s.NotNil(spec4, "4: get record spec should always return a non-nil record spec") - spec4, found4 := s.app.MetadataKeeper.GetContractSpecification(s.ctx, s.contractSpecID1) - s.False(found4, "4: get contract spec should return false after it has been deleted") - s.NotNil(spec4, "4: get contract spec should always return a non-nil scope spec") + remErr1 := s.app.MetadataKeeper.RemoveRecordSpecification(s.ctx, newSpec.SpecificationId) + s.Nil(remErr1, "5: remove should not return any error") + + spec6, found6 := s.app.MetadataKeeper.GetRecordSpecification(s.ctx, recSpecID) + s.False(found6, "6: get record spec should return false after it has been removed") + s.NotNil(spec6, "6: get record spec should always return a non-nil record spec") + + remErr2 := s.app.MetadataKeeper.RemoveRecordSpecification(s.ctx, recSpecID) + s.Equal( + fmt.Errorf("record specification with id %s not found", recSpecID), + remErr2, + "7: remove error message when not found", + ) } -func (s *SpecKeeperTestSuite) TestIterateContractSpecs() { +func (s *SpecKeeperTestSuite) TestIterateRecordSpecs() { size := 10 - specs := make([]*types.ContractSpecification, size) + specs := make([]*types.RecordSpecification, size) for i := 0; i < size; i++ { - specs[i] = types.NewContractSpecification( - types.ScopeSpecMetadataAddress(uuid.New()), - types.NewDescription( - fmt.Sprintf("TestIterateContractSpecs[%d]", i), - fmt.Sprintf("The description for entry [%d] in a unit test contract specification", i), - fmt.Sprintf("http://%d.test.net", i), - fmt.Sprintf("http://%d.test.net/ico.png", i), - ), - []string{s.user1Addr.String()}, + contractSpecUUID := uuid.New() + recordName := fmt.Sprintf("record name %d", i) + specs[i] = types.NewRecordSpecification( + types.RecordSpecMetadataAddress(contractSpecUUID, recordName), + recordName, + []*types.InputSpecification{ + types.NewInputSpecification( + fmt.Sprintf("input name [%d] 1", i), + fmt.Sprintf("type name [%d] 1", i), + types.NewInputSpecificationSourceHash(fmt.Sprintf("source hash [%d] 1", i),), + ), + types.NewInputSpecification( + fmt.Sprintf("input name [%d] 2", i), + fmt.Sprintf("type name [%d] 2", i), + types.NewInputSpecificationSourceHash(fmt.Sprintf("source hash [%d] 2", i),), + ), + types.NewInputSpecification( + fmt.Sprintf("input name [%d] 3", i), + fmt.Sprintf("type name [%d] 3", i), + types.NewInputSpecificationSourceRecordID(types.RecordMetadataAddress(uuid.New(), recordName)), + ), + }, + fmt.Sprintf("type name %d", i), + types.DefinitionType_DEFINITION_TYPE_RECORD, []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash(fmt.Sprintf("somehash%d", i)), - fmt.Sprintf("someclass_%d", i), - []types.MetadataAddress{}, ) - s.app.MetadataKeeper.SetContractSpecification(s.ctx, *specs[i]) + s.app.MetadataKeeper.SetRecordSpecification(s.ctx, *specs[i]) } - visitedContractSpecIDs := make([]types.MetadataAddress, size) + visitedRecordSpecIDs := make([]types.MetadataAddress, size) count := 0 - err1 := s.app.MetadataKeeper.IterateContractSpecs(s.ctx, func(spec types.ContractSpecification) (stop bool) { - if containsMetadataAddress(visitedContractSpecIDs, spec.SpecificationId) { - s.Fail("function IterateContractSpecs visited the same scope specification twice: %s", spec.SpecificationId.String()) + err1 := s.app.MetadataKeeper.IterateRecordSpecs(s.ctx, func(spec types.RecordSpecification) (stop bool) { + if containsMetadataAddress(visitedRecordSpecIDs, spec.SpecificationId) { + s.Fail("function IterateRecordSpecs visited the same record specification twice: %s", spec.SpecificationId.String()) } - visitedContractSpecIDs[count] = spec.SpecificationId + visitedRecordSpecIDs[count] = spec.SpecificationId count++ return false }) - s.Nil(err1, "1: function IterateContractSpecs should not have returned an error") - s.Equal(size, count, "number of contract specs iterated through") + s.Nil(err1, "1: function IterateRecordSpecs should not have returned an error") + s.Equal(size, count, "number of record specs iterated through") shortCount := 0 - err2 := s.app.MetadataKeeper.IterateContractSpecs(s.ctx, func(spec types.ContractSpecification) (stop bool) { + err2 := s.app.MetadataKeeper.IterateRecordSpecs(s.ctx, func(spec types.RecordSpecification) (stop bool) { shortCount++ if shortCount == 5 { return true } return false }) - s.Nil(err2, "2: function IterateContractSpecs should not have returned an error") - s.Equal(5, shortCount, "function IterateContractSpecs ignored (stop bool) return value") + s.Nil(err2, "2: function IterateRecordSpecs should not have returned an error") + s.Equal(5, shortCount, "function IterateRecordSpecs ignored (stop bool) return value") } -func (s *SpecKeeperTestSuite) TestIterateContractSpecsForOwner() { - // Create 5 contract specs. Two owned by user1, Two owned by user2, and One owned by both user1 and user2. - specs := make([]*types.ContractSpecification, 5) - user1SpecIDs := make([]types.MetadataAddress, 3) - user2SpecIDs := make([]types.MetadataAddress, 3) - specs[0] = types.NewContractSpecification( - types.ContractSpecMetadataAddress(uuid.New()), - types.NewDescription( - "TestIterateContractSpecsForOwner[0]", - "A description for a unit test contract specification - owner: user1", - "http://test.net", - "http://test.net/ico.png", +func (s *SpecKeeperTestSuite) TestIterateRecordSpecsForOwner() { + // Create 3 contract specs. One owned by user1, One owned by user2, and One owned by both user1 and user2. + contractSpecs := []*types.ContractSpecification{ + types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[0]", + "A description for a unit test contract specification - owner: user1", + "http://test.net", + "http://test.net/ico.png", + ), + []string{s.user1Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash0"), + "someclass_0", ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash0"), - "someclass_0", - []types.MetadataAddress{}, - ) - user1SpecIDs[0] = specs[0].SpecificationId - specs[1] = types.NewContractSpecification( - types.ContractSpecMetadataAddress(uuid.New()), - types.NewDescription( - "TestIterateContractSpecsForOwner[1]", - "A description for a unit test contract specification - owner: user2", - "http://test.net", - "http://test.net/ico.png", + types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[1]", + "A description for a unit test contract specification - owner: user2", + "http://test.net", + "http://test.net/ico.png", + ), + []string{s.user2Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash1"), + "someclass_1", ), - []string{s.user2Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash1"), - "someclass_1", - []types.MetadataAddress{}, - ) - user2SpecIDs[0] = specs[1].SpecificationId - specs[2] = types.NewContractSpecification( - types.ContractSpecMetadataAddress(uuid.New()), - types.NewDescription( - "TestIterateContractSpecsForOwner[2]", - "A description for a unit test contract specification - owner: user1", - "http://test.net", - "http://test.net/ico.png", + types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[2]", + "A description for a unit test contract specification - owners: user1, user2", + "http://test.net", + "http://test.net/ico.png", + ), + []string{s.user1Addr.String(), s.user2Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash2"), + "someclass_2", ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash2"), - "someclass_2", - []types.MetadataAddress{}, - ) - user1SpecIDs[1] = specs[2].SpecificationId - specs[3] = types.NewContractSpecification( - types.ContractSpecMetadataAddress(uuid.New()), - types.NewDescription( - "TestIterateContractSpecsForOwner[3]", - "A description for a unit test contract specification - owner: user2", - "http://test.net", - "http://test.net/ico.png", + } + for _, spec := range contractSpecs { + s.app.MetadataKeeper.SetContractSpecification(s.ctx, *spec) + } + + // Create 2 record specifications for each contract specification + recordSpecs := []*types.RecordSpecification{ + types.NewRecordSpecification( + contractSpecs[0].SpecificationId.GetRecordSpecAddress("contractspec0recspec0"), + "contractspec0recspec0", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec0", "inputspectypename0", + types.NewInputSpecificationSourceHash("sourcehash0"), + ), + }, + "typename0", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, ), - []string{s.user2Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash3"), - "someclass_3", - []types.MetadataAddress{}, - ) - user2SpecIDs[1] = specs[3].SpecificationId - specs[4] = types.NewContractSpecification( - types.ContractSpecMetadataAddress(uuid.New()), - types.NewDescription( - "TestIterateContractSpecsForOwner[4]", - "A description for a unit test contract specification - owners: user1, user2", - "http://test.net", - "http://test.net/ico.png", + types.NewRecordSpecification( + contractSpecs[0].SpecificationId.GetRecordSpecAddress("contractspec0recspec1"), + "contractspec0recspec1", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec1", "inputspectypename1", + types.NewInputSpecificationSourceHash("sourcehash1"), + ), + }, + "typename1", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, ), - []string{s.user1Addr.String(), s.user2Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash4"), - "someclass_4", - []types.MetadataAddress{}, - ) - user1SpecIDs[2] = specs[4].SpecificationId - user2SpecIDs[2] = specs[4].SpecificationId - for _, spec := range specs { - s.app.MetadataKeeper.SetContractSpecification(s.ctx, *spec) + types.NewRecordSpecification( + contractSpecs[1].SpecificationId.GetRecordSpecAddress("contractspec1recspec2"), + "contractspec1recspec2", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec2", "inputspectypename2", + types.NewInputSpecificationSourceHash("sourcehash2"), + ), + }, + "typename2", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + types.NewRecordSpecification( + contractSpecs[1].SpecificationId.GetRecordSpecAddress("contractspec1recspec3"), + "contractspec1recspec3", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec3", "inputspectypename3", + types.NewInputSpecificationSourceHash("sourcehash3"), + ), + }, + "typename3", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + + types.NewRecordSpecification( + contractSpecs[2].SpecificationId.GetRecordSpecAddress("contractspec2recspec4"), + "contractspec2recspec4", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec4", "inputspectypename4", + types.NewInputSpecificationSourceHash("sourcehash4"), + ), + }, + "typename4", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + types.NewRecordSpecification( + contractSpecs[2].SpecificationId.GetRecordSpecAddress("contractspec2recspec5"), + "contractspec2recspec5", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec5", "inputspectypename5", + types.NewInputSpecificationSourceHash("sourcehash5"), + ), + }, + "typename5", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + } + for _, spec := range recordSpecs { + s.app.MetadataKeeper.SetRecordSpecification(s.ctx, *spec) } - // Make sure all user1 scope specs are iterated over + user1SpecIDs := []types.MetadataAddress{ + recordSpecs[0].SpecificationId, recordSpecs[1].SpecificationId, + recordSpecs[4].SpecificationId, recordSpecs[5].SpecificationId, + } + user2SpecIDs := []types.MetadataAddress{ + recordSpecs[2].SpecificationId, recordSpecs[3].SpecificationId, + recordSpecs[4].SpecificationId, recordSpecs[5].SpecificationId, + } + + // Make sure all user1 record specs are iterated over user1SpecIDsIterated := []types.MetadataAddress{} - errUser1 := s.app.MetadataKeeper.IterateContractSpecsForOwner(s.ctx, s.user1Addr, func(specID types.MetadataAddress) (stop bool) { + errUser1 := s.app.MetadataKeeper.IterateRecordSpecsForOwner(s.ctx, s.user1Addr, func(specID types.MetadataAddress) (stop bool) { user1SpecIDsIterated = append(user1SpecIDsIterated, specID) return false }) s.Nil(errUser1, "user1: should not have returned an error") - s.Equal(3, len(user1SpecIDsIterated), "user1: iteration count") + s.Equal(4, len(user1SpecIDsIterated), "user1: iteration count") s.True(areEquivalentSetsOfMetaAddresses(user1SpecIDs, user1SpecIDsIterated), - "user1: iterated over unexpected contract specs:\n expected: %v\n actual: %v\n", + "user1: iterated over unexpected record specs:\n expected: %v\n actual: %v\n", user1SpecIDs, user1SpecIDsIterated) - // Make sure all user2 scope specs are iterated over + // Make sure all user2 record specs are iterated over user2SpecIDsIterated := []types.MetadataAddress{} - errUser2 := s.app.MetadataKeeper.IterateContractSpecsForOwner(s.ctx, s.user2Addr, func(specID types.MetadataAddress) (stop bool) { + errUser2 := s.app.MetadataKeeper.IterateRecordSpecsForOwner(s.ctx, s.user2Addr, func(specID types.MetadataAddress) (stop bool) { user2SpecIDsIterated = append(user2SpecIDsIterated, specID) return false }) s.Nil(errUser2, "user2: should not have returned an error") - s.Equal(3, len(user2SpecIDsIterated), "user2: iteration count") + s.Equal(4, len(user2SpecIDsIterated), "user2: iteration count") s.True(areEquivalentSetsOfMetaAddresses(user2SpecIDs, user2SpecIDsIterated), - "user2: iterated over unexpected contract specs:\n expected: %v\n actual: %v\n", + "user2: iterated over unexpected record specs:\n expected: %v\n actual: %v\n", user2SpecIDs, user2SpecIDsIterated) // Make sure an unknown user address results in zero iterations. user3Addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) user3Count := 0 - errUser3 := s.app.MetadataKeeper.IterateContractSpecsForOwner(s.ctx, user3Addr, func(specID types.MetadataAddress) (stop bool) { + errUser3 := s.app.MetadataKeeper.IterateRecordSpecsForOwner(s.ctx, user3Addr, func(specID types.MetadataAddress) (stop bool) { user3Count++ return false }) @@ -306,7 +415,7 @@ func (s *SpecKeeperTestSuite) TestIterateContractSpecsForOwner() { // Make sure the stop bool is being recognized. countStop := 0 - errStop := s.app.MetadataKeeper.IterateContractSpecsForOwner(s.ctx, s.user1Addr, func(specID types.MetadataAddress) (stop bool) { + errStop := s.app.MetadataKeeper.IterateRecordSpecsForOwner(s.ctx, s.user1Addr, func(specID types.MetadataAddress) (stop bool) { countStop++ if countStop == 2 { return true @@ -317,277 +426,655 @@ func (s *SpecKeeperTestSuite) TestIterateContractSpecsForOwner() { s.Equal(2, countStop, "stop bool: iteration count") } -func (s *SpecKeeperTestSuite) TestValidateContractSpecUpdate() { - recordSpecIDe := s.contractSpecID1.GetRecordSpecAddress("exists") - recordSpecIDm := s.contractSpecID1.GetRecordSpecAddress("missing") - - // Trick the store into thinking that recordSpecIDe exists. - metadataStoreKey := s.app.GetKey(types.StoreKey) - store := s.ctx.KVStore(metadataStoreKey) - store.Set(recordSpecIDe, []byte{0x01}) - - otherContractSpecID := types.ContractSpecMetadataAddress(uuid.New()) - tests := []struct { - name string - existing *types.ContractSpecification - proposed *types.ContractSpecification - signers []string - want string - }{ - { - "existing specificationID does not match proposed specificationID causes error", - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", - ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, - ), - types.NewContractSpecification( - otherContractSpecID, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", - ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, +func (s *SpecKeeperTestSuite) TestIterateRecordSpecsForContractSpec() { + // Create 3 contract specs. + contractSpecs := []*types.ContractSpecification{ + types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[0]", + "A description for a unit test contract specification - owner: user1", + "http://test.net", + "http://test.net/ico.png", ), []string{s.user1Addr.String()}, - fmt.Sprintf("cannot update contract spec identifier. expected %s, got %s", - s.contractSpecID1, otherContractSpecID), - }, - { - "proposed basic validation causes error", - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", - ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash0"), + "someclass_0", + ), + types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[1]", + "A description for a unit test contract specification - owner: user2", + "http://test.net", + "http://test.net/ico.png", ), - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", - ), - []string{}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, + []string{s.user2Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash1"), + "someclass_1", + ), + types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[2]", + "A description for a unit test contract specification - owner: user1, user2", + "http://test.net", + "http://test.net/ico.png", ), - []string{s.user1Addr.String()}, - "invalid owner addresses count (expected > 0 got: 0)", - }, - { - "basic validation not done on existing", - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", + []string{s.user1Addr.String(), s.user2Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash2"), + "someclass_2", + ), + } + for _, spec := range contractSpecs { + s.app.MetadataKeeper.SetContractSpecification(s.ctx, *spec) + } + + // Create 3 record specs for the 1st contract spec, 2 for the 2nd, and none for the 3rd. + recordSpecs := []*types.RecordSpecification{ + types.NewRecordSpecification( + contractSpecs[0].SpecificationId.GetRecordSpecAddress("contractspec0recspec0"), + "contractspec0recspec0", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec0", "inputspectypename0", + types.NewInputSpecificationSourceHash("sourcehash0"), ), - []string{}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, - ), - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", + }, + "typename0", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + types.NewRecordSpecification( + contractSpecs[0].SpecificationId.GetRecordSpecAddress("contractspec0recspec1"), + "contractspec0recspec1", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec1", "inputspectypename1", + types.NewInputSpecificationSourceHash("sourcehash1"), ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, - ), - []string{s.user1Addr.String()}, - "", - }, - { - "changing owner, only signed by new owner - error", - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", + }, + "typename1", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + types.NewRecordSpecification( + contractSpecs[0].SpecificationId.GetRecordSpecAddress("contractspec1recspec2"), + "contractspec0recspec2", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec2", "inputspectypename2", + types.NewInputSpecificationSourceHash("sourcehash2"), ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, - ), - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", + }, + "typename2", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + + types.NewRecordSpecification( + contractSpecs[1].SpecificationId.GetRecordSpecAddress("contractspec1recspec3"), + "contractspec1recspec3", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec3", "inputspectypename3", + types.NewInputSpecificationSourceHash("sourcehash3"), ), - []string{s.user2Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, + }, + "typename3", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + types.NewRecordSpecification( + contractSpecs[1].SpecificationId.GetRecordSpecAddress("contractspec1recspec4"), + "contractspec1recspec4", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec4", "inputspectypename4", + types.NewInputSpecificationSourceHash("sourcehash4"), + ), + }, + "typename4", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + } + for _, spec := range recordSpecs { + s.app.MetadataKeeper.SetRecordSpecification(s.ctx, *spec) + } + + contractSpec0RecSpecIDs := []types.MetadataAddress{ + recordSpecs[0].SpecificationId, recordSpecs[1].SpecificationId, recordSpecs[2].SpecificationId, + } + contractSpec1RecSpecIDs := []types.MetadataAddress{ + recordSpecs[3].SpecificationId, recordSpecs[4].SpecificationId, + } + contractSpec2RecSpecIDs := []types.MetadataAddress{} + + // Make sure all contract spec 0 record specs are iterated over + contractSpec0SpecIDsIterated := []types.MetadataAddress{} + errContractSpec0 := s.app.MetadataKeeper.IterateRecordSpecsForContractSpec(s.ctx, contractSpecs[0].SpecificationId, func(specID types.MetadataAddress) (stop bool) { + contractSpec0SpecIDsIterated = append(contractSpec0SpecIDsIterated, specID) + return false + }) + s.Nil(errContractSpec0, "contract spec 0: should not have returned an error") + s.Equal(3, len(contractSpec0SpecIDsIterated), "contract spec 0: iteration count") + s.True(areEquivalentSetsOfMetaAddresses(contractSpec0RecSpecIDs, contractSpec0SpecIDsIterated), + "contract spec 0: iterated over unexpected record specs:\n expected: %v\n actual: %v\n", + contractSpec0RecSpecIDs, contractSpec0SpecIDsIterated) + + // Make sure all contract spec 1 record specs are iterated over + contractSpec1SpecIDsIterated := []types.MetadataAddress{} + errContractSpec1 := s.app.MetadataKeeper.IterateRecordSpecsForContractSpec(s.ctx, contractSpecs[1].SpecificationId, func(specID types.MetadataAddress) (stop bool) { + contractSpec1SpecIDsIterated = append(contractSpec1SpecIDsIterated, specID) + return false + }) + s.Nil(errContractSpec1, "contract spec 1: should not have returned an error") + s.Equal(2, len(contractSpec1SpecIDsIterated), "contract spec 1: iteration count") + s.True(areEquivalentSetsOfMetaAddresses(contractSpec1RecSpecIDs, contractSpec1SpecIDsIterated), + "contract spec 1: iterated over unexpected record specs:\n expected: %v\n actual: %v\n", + contractSpec1RecSpecIDs, contractSpec1SpecIDsIterated) + + // Make sure no contract spec 2 record specs are iterated over + contractSpec2SpecIDsIterated := []types.MetadataAddress{} + errContractSpec2 := s.app.MetadataKeeper.IterateRecordSpecsForContractSpec(s.ctx, contractSpecs[2].SpecificationId, func(specID types.MetadataAddress) (stop bool) { + contractSpec2SpecIDsIterated = append(contractSpec2SpecIDsIterated, specID) + return false + }) + s.Nil(errContractSpec2, "contract spec 2: should not have returned an error") + s.Equal(0, len(contractSpec2SpecIDsIterated), "contract spec 2: iteration count") + s.True(areEquivalentSetsOfMetaAddresses(contractSpec2RecSpecIDs, contractSpec2SpecIDsIterated), + "contract spec 2: iterated over unexpected record specs:\n expected: %v\n actual: %v\n", + contractSpec2RecSpecIDs, contractSpec2SpecIDsIterated) + + // Make sure an unknown contract spec results in zero iterations. + unknownContractSpecID := types.ContractSpecMetadataAddress(uuid.New()) + unknownContractSpecIDCount := 0 + errUnknownContractSpecID := s.app.MetadataKeeper.IterateRecordSpecsForContractSpec(s.ctx, unknownContractSpecID, func(specID types.MetadataAddress) (stop bool) { + unknownContractSpecIDCount++ + return false + }) + s.Nil(errUnknownContractSpecID, "unknown contract spec id: should not have returned an error") + s.Equal(0, unknownContractSpecIDCount, "unknown contract spec id: iteration count") + + // Make sure the stop bool is being recognized. + countStop := 0 + errStop := s.app.MetadataKeeper.IterateRecordSpecsForContractSpec(s.ctx, contractSpecs[0].SpecificationId, func(specID types.MetadataAddress) (stop bool) { + countStop++ + if countStop == 2 { + return true + } + return false + }) + s.Nil(errStop, "stop bool: should not have returned an error") + s.Equal(2, countStop, "stop bool: iteration count") +} + +func (s *SpecKeeperTestSuite) TestGetRecordSpecificationsForContractSpecificationID() { + // Create 3 contract specs. + contractSpecs := []*types.ContractSpecification{ + types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[0]", + "A description for a unit test contract specification - owner: user1", + "http://test.net", + "http://test.net/ico.png", + ), + []string{s.user1Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash0"), + "someclass_0", + ), + types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[1]", + "A description for a unit test contract specification - owner: user2", + "http://test.net", + "http://test.net/ico.png", ), []string{s.user2Addr.String()}, - fmt.Sprintf("missing signature from existing owner %s; required for update", s.user1Addr.String()), - }, - { - "adding owner, only existing owner needs to sign", - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", - ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash1"), + "someclass_1", + ), + types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[2]", + "A description for a unit test contract specification - owner: user1, user2", + "http://test.net", + "http://test.net/ico.png", ), - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", + []string{s.user1Addr.String(), s.user2Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash2"), + "someclass_2", + ), + } + for _, spec := range contractSpecs { + s.app.MetadataKeeper.SetContractSpecification(s.ctx, *spec) + } + + // Create 3 record specs for the 1st contract spec, 2 for the 2nd, and none for the 3rd. + recordSpecs := []*types.RecordSpecification{ + types.NewRecordSpecification( + contractSpecs[0].SpecificationId.GetRecordSpecAddress("contractspec0recspec0"), + "contractspec0recspec0", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec0", "inputspectypename0", + types.NewInputSpecificationSourceHash("sourcehash0"), ), - []string{s.user1Addr.String(), s.user2Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, - ), - []string{s.user1Addr.String()}, - "", - }, - { - "adding owner, both signed - ok too", - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", + }, + "typename0", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + types.NewRecordSpecification( + contractSpecs[0].SpecificationId.GetRecordSpecAddress("contractspec0recspec1"), + "contractspec0recspec1", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec1", "inputspectypename1", + types.NewInputSpecificationSourceHash("sourcehash1"), ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, - ), - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", + }, + "typename1", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + types.NewRecordSpecification( + contractSpecs[0].SpecificationId.GetRecordSpecAddress("contractspec1recspec2"), + "contractspec0recspec2", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec2", "inputspectypename2", + types.NewInputSpecificationSourceHash("sourcehash2"), ), - []string{s.user1Addr.String(), s.user2Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, + }, + "typename2", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + + types.NewRecordSpecification( + contractSpecs[1].SpecificationId.GetRecordSpecAddress("contractspec1recspec3"), + "contractspec1recspec3", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec3", "inputspectypename3", + types.NewInputSpecificationSourceHash("sourcehash3"), + ), + }, + "typename3", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + types.NewRecordSpecification( + contractSpecs[1].SpecificationId.GetRecordSpecAddress("contractspec1recspec4"), + "contractspec1recspec4", + []*types.InputSpecification{ + types.NewInputSpecification( + "inputspec4", "inputspectypename4", + types.NewInputSpecificationSourceHash("sourcehash4"), + ), + }, + "typename4", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + ), + } + for _, spec := range recordSpecs { + s.app.MetadataKeeper.SetRecordSpecification(s.ctx, *spec) + } + + contractSpec0Expected := recordSpecs[0:3] + contractSpec1Expected := recordSpecs[3:5] + contractSpec2Expected := []*types.RecordSpecification{} + + // Make sure all contract spec 0 record specs are returned + contractSpecs0Actual, contractSpecs0ActualErr := s.app.MetadataKeeper.GetRecordSpecificationsForContractSpecificationID(s.ctx, contractSpecs[0].SpecificationId) + s.Nil(contractSpecs0ActualErr, "contract spec 0: should not have returned an error") + s.True(areEquivalentSetsOfRecSpecs(contractSpec0Expected, contractSpecs0Actual), + "contract spec 0: unexpected record specs:\n expected: %v\n actual: %v\n", + contractSpec0Expected, contractSpecs0Actual) + + // Make sure all contract spec 1 record specs are returned + contractSpecs1Actual, contractSpecs1ActualErr := s.app.MetadataKeeper.GetRecordSpecificationsForContractSpecificationID(s.ctx, contractSpecs[1].SpecificationId) + s.Nil(contractSpecs1ActualErr, "contract spec 1: should not have returned an error") + s.True(areEquivalentSetsOfRecSpecs(contractSpec1Expected, contractSpecs1Actual), + "contract spec 1: unexpected record specs:\n expected: %v\n actual: %v\n", + contractSpec1Expected, contractSpecs1Actual) + + // Make sure all contract spec 2 record specs are returned (none) + contractSpecs2Actual, contractSpecs2ActualErr := s.app.MetadataKeeper.GetRecordSpecificationsForContractSpecificationID(s.ctx, contractSpecs[2].SpecificationId) + s.Nil(contractSpecs2ActualErr, "contract spec 2: should not have returned an error") + s.True(areEquivalentSetsOfRecSpecs(contractSpec2Expected, contractSpecs2Actual), + "contract spec 2: unexpected record specs:\n expected: %v\n actual: %v\n", + contractSpec2Expected, contractSpecs2Actual) + + // Make sure an unknown contract spec returns empty. + unknownContractSpecID := types.ContractSpecMetadataAddress(uuid.New()) + unknownContractSpecIDActual, unknownContractSpecIDActualErr := s.app.MetadataKeeper.GetRecordSpecificationsForContractSpecificationID(s.ctx, unknownContractSpecID) + s.Nil(unknownContractSpecIDActualErr, "unknown contract spec id: should not have returned an error") + s.Equal(0, len(unknownContractSpecIDActual), "unknown contract spec id: count") +} + +func (s *SpecKeeperTestSuite) TestValidateRecordSpecUpdate() { + contractSpecUUIDOther := uuid.New() + tests := []struct { + name string + existing *types.RecordSpecification + proposed *types.RecordSpecification + want string + }{ + { + "validate basic called on proposed", + nil, + types.NewRecordSpecification( + types.RecordSpecMetadataAddress(s.contractSpecUUID1, "name"), + "name", + []*types.InputSpecification{}, + "", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_SERVICER}, ), - []string{s.user1Addr.String(), s.user2Addr.String()}, - "", + "record specification type name cannot be empty", }, { - "new entry, no signers required", - nil, - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", - ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, + "validate basic not called on existing", + types.NewRecordSpecification( + types.RecordSpecMetadataAddress(s.contractSpecUUID1, "name"), + "name", + []*types.InputSpecification{}, + "", // should cause error if ValidateBasic called on it + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_SERVICER}, + ), + types.NewRecordSpecification( + types.RecordSpecMetadataAddress(s.contractSpecUUID1, "name"), + "name", + []*types.InputSpecification{}, + "typename", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_SERVICER}, ), - []string{}, "", }, { - "RecordSpecIds - proposed index 0 does not exist - fail", - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", - ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{}, + "SpecificationIDs must match", + types.NewRecordSpecification( + types.RecordSpecMetadataAddress(s.contractSpecUUID1, "foo"), + "foo", + []*types.InputSpecification{}, + "", // should cause error if ValidateBasic called on it + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_SERVICER}, ), - types.NewContractSpecification( - s.contractSpecID1, - types.NewDescription( - "TestValidateContractSpecUpdate", - "A description for a unit test contract specification", - "http://test.net", - "http://test.net/ico.png", - ), - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), - "someclass", - []types.MetadataAddress{recordSpecIDm}, + types.NewRecordSpecification( + types.RecordSpecMetadataAddress(contractSpecUUIDOther, "foo"), + "foo", + []*types.InputSpecification{}, + "typename", + types.DefinitionType_DEFINITION_TYPE_RECORD, + []types.PartyType{types.PartyType_PARTY_TYPE_SERVICER}, + ), + fmt.Sprintf("cannot update record spec identifier. expected %s, got %s", + types.RecordSpecMetadataAddress(s.contractSpecUUID1, "foo"), + types.RecordSpecMetadataAddress(contractSpecUUIDOther, "foo")), + }, + // Names must match - cannot be tested. A changed name will change the spec id. + // So either ValidateBasic will catch that the hashed name doesn't match its part in the ID, + // or the ValidateRecordSpecUpdate will catch the changing specification id. + } + + for _, tt := range tests { + tt := tt + s.T().Run(tt.name, func(t *testing.T) { + err := s.app.MetadataKeeper.ValidateRecordSpecUpdate(s.ctx, tt.existing, *tt.proposed) + if err != nil { + require.Equal(t, tt.want, err.Error(), "RecordSpec Keeper ValidateRecordSpecUpdate error") + } else if len(tt.want) > 0 { + t.Errorf("RecordSpec Keeper ValidateRecordSpecUpdate error = nil, expected: %s", tt.want) + } + }) + } +} + +func (s *SpecKeeperTestSuite) TestGetSetRemoveContractSpecification() { + newSpec := types.NewContractSpecification( + s.contractSpecID1, + types.NewDescription( + "TestGetSetRemoveContractSpecification", + "A description for a unit test contract specification", + "http://test.net", + "http://test.net/ico.png", + ), + []string{s.user1Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash"), + "someclass", + ) + require.NotNil(s.T(), newSpec, "test setup failure: NewContractSpecification should not return nil") + + spec1, found1 := s.app.MetadataKeeper.GetContractSpecification(s.ctx, s.contractSpecID1) + s.False(found1, "1: get contract spec should return false before it has been saved") + s.NotNil(spec1, "1: get contract spec should always return a non-nil contract spec") + + s.app.MetadataKeeper.SetContractSpecification(s.ctx, *newSpec) + + spec2, found2 := s.app.MetadataKeeper.GetContractSpecification(s.ctx, s.contractSpecID1) + s.True(found2, "get contract spec should return true after it has been saved") + s.NotNil(spec2, "get contract spec should always return a non-nil contract spec") + s.Equal(s.contractSpecID1, spec2.SpecificationId, "2: get contract spec should return a spec containing id provided") + + spec3, found3 := s.app.MetadataKeeper.GetContractSpecification(s.ctx, types.ContractSpecMetadataAddress(uuid.New())) + s.False(found3, "3: get contract spec should return false for an unknown address") + s.NotNil(spec3, "3: get contract spec should always return a non-nil contract spec") + + remErr := s.app.MetadataKeeper.RemoveContractSpecification(s.ctx, newSpec.SpecificationId) + s.Nil(remErr, "4: remove should not return any error") + + spec5, found5 := s.app.MetadataKeeper.GetContractSpecification(s.ctx, s.contractSpecID1) + s.False(found5, "5: get contract spec should return false after it has been removed") + s.NotNil(spec5, "5: get contract spec should always return a non-nil contract spec") + + remErr2 := s.app.MetadataKeeper.RemoveContractSpecification(s.ctx, s.contractSpecID1) + s.Equal( + fmt.Errorf("contract specification with id %s not found", s.contractSpecID1), + remErr2, + "6: remove error message when not found", + ) +} + +func (s *SpecKeeperTestSuite) TestIterateContractSpecs() { + size := 10 + specs := make([]*types.ContractSpecification, size) + for i := 0; i < size; i++ { + specs[i] = types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + fmt.Sprintf("TestIterateContractSpecs[%d]", i), + fmt.Sprintf("The description for entry [%d] in a unit test contract specification", i), + fmt.Sprintf("http://%d.test.net", i), + fmt.Sprintf("http://%d.test.net/ico.png", i), ), []string{s.user1Addr.String()}, - fmt.Sprintf("no record spec exists with id %s", recordSpecIDm), - }, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash(fmt.Sprintf("somehash%d", i)), + fmt.Sprintf("someclass_%d", i), + ) + s.app.MetadataKeeper.SetContractSpecification(s.ctx, *specs[i]) + } + + visitedContractSpecIDs := make([]types.MetadataAddress, size) + count := 0 + err1 := s.app.MetadataKeeper.IterateContractSpecs(s.ctx, func(spec types.ContractSpecification) (stop bool) { + if containsMetadataAddress(visitedContractSpecIDs, spec.SpecificationId) { + s.Fail("function IterateContractSpecs visited the same contract specification twice: %s", spec.SpecificationId.String()) + } + visitedContractSpecIDs[count] = spec.SpecificationId + count++ + return false + }) + s.Nil(err1, "1: function IterateContractSpecs should not have returned an error") + s.Equal(size, count, "number of contract specs iterated through") + + shortCount := 0 + err2 := s.app.MetadataKeeper.IterateContractSpecs(s.ctx, func(spec types.ContractSpecification) (stop bool) { + shortCount++ + if shortCount == 5 { + return true + } + return false + }) + s.Nil(err2, "2: function IterateContractSpecs should not have returned an error") + s.Equal(5, shortCount, "function IterateContractSpecs ignored (stop bool) return value") +} + +func (s *SpecKeeperTestSuite) TestIterateContractSpecsForOwner() { + // Create 5 contract specs. Two owned by user1, Two owned by user2, and One owned by both user1 and user2. + specs := make([]*types.ContractSpecification, 5) + user1SpecIDs := make([]types.MetadataAddress, 3) + user2SpecIDs := make([]types.MetadataAddress, 3) + specs[0] = types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[0]", + "A description for a unit test contract specification - owner: user1", + "http://test.net", + "http://test.net/ico.png", + ), + []string{s.user1Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash0"), + "someclass_0", + ) + user1SpecIDs[0] = specs[0].SpecificationId + specs[1] = types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[1]", + "A description for a unit test contract specification - owner: user2", + "http://test.net", + "http://test.net/ico.png", + ), + []string{s.user2Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash1"), + "someclass_1", + ) + user2SpecIDs[0] = specs[1].SpecificationId + specs[2] = types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[2]", + "A description for a unit test contract specification - owner: user1", + "http://test.net", + "http://test.net/ico.png", + ), + []string{s.user1Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash2"), + "someclass_2", + ) + user1SpecIDs[1] = specs[2].SpecificationId + specs[3] = types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[3]", + "A description for a unit test contract specification - owner: user2", + "http://test.net", + "http://test.net/ico.png", + ), + []string{s.user2Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash3"), + "someclass_3", + ) + user2SpecIDs[1] = specs[3].SpecificationId + specs[4] = types.NewContractSpecification( + types.ContractSpecMetadataAddress(uuid.New()), + types.NewDescription( + "TestIterateContractSpecsForOwner[4]", + "A description for a unit test contract specification - owners: user1, user2", + "http://test.net", + "http://test.net/ico.png", + ), + []string{s.user1Addr.String(), s.user2Addr.String()}, + []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, + types.NewContractSpecificationSourceHash("somehash4"), + "someclass_4", + ) + user1SpecIDs[2] = specs[4].SpecificationId + user2SpecIDs[2] = specs[4].SpecificationId + + for _, spec := range specs { + s.app.MetadataKeeper.SetContractSpecification(s.ctx, *spec) + } + + // Make sure all user1 contract specs are iterated over + user1SpecIDsIterated := []types.MetadataAddress{} + errUser1 := s.app.MetadataKeeper.IterateContractSpecsForOwner(s.ctx, s.user1Addr, func(specID types.MetadataAddress) (stop bool) { + user1SpecIDsIterated = append(user1SpecIDsIterated, specID) + return false + }) + s.Nil(errUser1, "user1: should not have returned an error") + s.Equal(3, len(user1SpecIDsIterated), "user1: iteration count") + s.True(areEquivalentSetsOfMetaAddresses(user1SpecIDs, user1SpecIDsIterated), + "user1: iterated over unexpected contract specs:\n expected: %v\n actual: %v\n", + user1SpecIDs, user1SpecIDsIterated) + + // Make sure all user2 contract specs are iterated over + user2SpecIDsIterated := []types.MetadataAddress{} + errUser2 := s.app.MetadataKeeper.IterateContractSpecsForOwner(s.ctx, s.user2Addr, func(specID types.MetadataAddress) (stop bool) { + user2SpecIDsIterated = append(user2SpecIDsIterated, specID) + return false + }) + s.Nil(errUser2, "user2: should not have returned an error") + s.Equal(3, len(user2SpecIDsIterated), "user2: iteration count") + s.True(areEquivalentSetsOfMetaAddresses(user2SpecIDs, user2SpecIDsIterated), + "user2: iterated over unexpected contract specs:\n expected: %v\n actual: %v\n", + user2SpecIDs, user2SpecIDsIterated) + + // Make sure an unknown user address results in zero iterations. + user3Addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + user3Count := 0 + errUser3 := s.app.MetadataKeeper.IterateContractSpecsForOwner(s.ctx, user3Addr, func(specID types.MetadataAddress) (stop bool) { + user3Count++ + return false + }) + s.Nil(errUser3, "user3: should not have returned an error") + s.Equal(0, user3Count, "user3: iteration count") + + // Make sure the stop bool is being recognized. + countStop := 0 + errStop := s.app.MetadataKeeper.IterateContractSpecsForOwner(s.ctx, s.user1Addr, func(specID types.MetadataAddress) (stop bool) { + countStop++ + if countStop == 2 { + return true + } + return false + }) + s.Nil(errStop, "stop bool: should not have returned an error") + s.Equal(2, countStop, "stop bool: iteration count") +} + +func (s *SpecKeeperTestSuite) TestValidateContractSpecUpdate() { + otherContractSpecID := types.ContractSpecMetadataAddress(uuid.New()) + tests := []struct { + name string + existing *types.ContractSpecification + proposed *types.ContractSpecification + want string + }{ { - "RecordSpecIds - existing index 0 does not exist - ok", + "existing specificationID does not match proposed specificationID causes error", types.NewContractSpecification( s.contractSpecID1, types.NewDescription( @@ -598,12 +1085,11 @@ func (s *SpecKeeperTestSuite) TestValidateContractSpecUpdate() { ), []string{s.user1Addr.String()}, []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), + types.NewContractSpecificationSourceHash("somehash"), "someclass", - []types.MetadataAddress{recordSpecIDm}, ), types.NewContractSpecification( - s.contractSpecID1, + otherContractSpecID, types.NewDescription( "TestValidateContractSpecUpdate", "A description for a unit test contract specification", @@ -612,15 +1098,14 @@ func (s *SpecKeeperTestSuite) TestValidateContractSpecUpdate() { ), []string{s.user1Addr.String()}, []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), + types.NewContractSpecificationSourceHash("somehash"), "someclass", - []types.MetadataAddress{}, ), - []string{s.user1Addr.String()}, - "", + fmt.Sprintf("cannot update contract spec identifier. expected %s, got %s", + s.contractSpecID1, otherContractSpecID), }, { - "RecordSpecIds - proposed index 0 does not exist - fail", + "proposed basic validation causes error", types.NewContractSpecification( s.contractSpecID1, types.NewDescription( @@ -631,9 +1116,8 @@ func (s *SpecKeeperTestSuite) TestValidateContractSpecUpdate() { ), []string{s.user1Addr.String()}, []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), + types.NewContractSpecificationSourceHash("somehash"), "someclass", - []types.MetadataAddress{recordSpecIDe, recordSpecIDe}, ), types.NewContractSpecification( s.contractSpecID1, @@ -643,17 +1127,15 @@ func (s *SpecKeeperTestSuite) TestValidateContractSpecUpdate() { "http://test.net", "http://test.net/ico.png", ), - []string{s.user1Addr.String()}, + []string{}, []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), + types.NewContractSpecificationSourceHash("somehash"), "someclass", - []types.MetadataAddress{recordSpecIDe, recordSpecIDe, recordSpecIDm}, ), - []string{s.user1Addr.String()}, - fmt.Sprintf("no record spec exists with id %s", recordSpecIDm), + "invalid owner addresses count (expected > 0 got: 0)", }, { - "RecordSpecIds - existing index 2 does not exist - ok", + "basic validation not done on existing", types.NewContractSpecification( s.contractSpecID1, types.NewDescription( @@ -662,11 +1144,10 @@ func (s *SpecKeeperTestSuite) TestValidateContractSpecUpdate() { "http://test.net", "http://test.net/ico.png", ), - []string{s.user1Addr.String()}, + []string{}, []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), + types.NewContractSpecificationSourceHash("somehash"), "someclass", - []types.MetadataAddress{recordSpecIDe, recordSpecIDe, recordSpecIDm}, ), types.NewContractSpecification( s.contractSpecID1, @@ -678,11 +1159,9 @@ func (s *SpecKeeperTestSuite) TestValidateContractSpecUpdate() { ), []string{s.user1Addr.String()}, []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - types.NewSourceHash("somehash"), + types.NewContractSpecificationSourceHash("somehash"), "someclass", - []types.MetadataAddress{recordSpecIDe, recordSpecIDe}, ), - []string{s.user1Addr.String()}, "", }, } @@ -690,25 +1169,21 @@ func (s *SpecKeeperTestSuite) TestValidateContractSpecUpdate() { for _, tt := range tests { tt := tt s.T().Run(tt.name, func(t *testing.T) { - err := s.app.MetadataKeeper.ValidateContractSpecUpdate(s.ctx, tt.existing, *tt.proposed, tt.signers) + err := s.app.MetadataKeeper.ValidateContractSpecUpdate(s.ctx, tt.existing, *tt.proposed) if err != nil { - require.Equal(t, tt.want, err.Error(), "ScopeSpec Keeper ValidateContractSpecUpdate error") + require.Equal(t, tt.want, err.Error(), "ContractSpec Keeper ValidateContractSpecUpdate error") } else if len(tt.want) > 0 { - t.Errorf("ScopeSpec Keeper ValidateContractSpecUpdate error = nil, expected: %s", tt.want) + t.Errorf("ContractSpec Keeper ValidateContractSpecUpdate error = nil, expected: %s", tt.want) } }) } - - // I'm not really sure what all gets shared between unit tests. - // So just to be on the safe side... - store.Delete(recordSpecIDe) } -func (s *SpecKeeperTestSuite) TestGetSetDeleteScopeSpecification() { +func (s *SpecKeeperTestSuite) TestGetSetRemoveScopeSpecification() { newSpec := types.NewScopeSpecification( s.scopeSpecID, types.NewDescription( - "TestGetSetScopeSpecification", + "TestGetSetRemoveScopeSpecification", "A description for a unit test scope specification", "http://test.net", "http://test.net/ico.png", @@ -734,11 +1209,19 @@ func (s *SpecKeeperTestSuite) TestGetSetDeleteScopeSpecification() { s.False(found3, "3: get scope spec should return false for an unknown address") s.NotNil(spec3, "3: get scope spec should always return a non-nil scope spec") - s.app.MetadataKeeper.RemoveScopeSpecification(s.ctx, newSpec.SpecificationId) + remErr := s.app.MetadataKeeper.RemoveScopeSpecification(s.ctx, newSpec.SpecificationId) + s.Nil(remErr, "4: remove should not return any error") + + spec5, found5 := s.app.MetadataKeeper.GetScopeSpecification(s.ctx, s.scopeSpecID) + s.False(found5, "5: get scope spec should return false after it has been removed") + s.NotNil(spec5, "5: get scope spec should always return a non-nil scope spec") - spec4, found4 := s.app.MetadataKeeper.GetScopeSpecification(s.ctx, s.scopeSpecID) - s.False(found4, "4: get scope spec should return false after it has been deleted") - s.NotNil(spec4, "4: get scope spec should always return a non-nil scope spec") + remErr2 := s.app.MetadataKeeper.RemoveScopeSpecification(s.ctx, s.scopeSpecID) + s.Equal( + fmt.Errorf("scope specification with id %s not found", s.scopeSpecID), + remErr2, + "6: remove error message when not found", + ) } func (s *SpecKeeperTestSuite) TestIterateScopeSpecs() { @@ -1044,7 +1527,6 @@ func (s *SpecKeeperTestSuite) TestValidateScopeSpecUpdate() { name string existing *types.ScopeSpecification proposed *types.ScopeSpecification - signers []string want string }{ { @@ -1063,7 +1545,6 @@ func (s *SpecKeeperTestSuite) TestValidateScopeSpecUpdate() { []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, []types.MetadataAddress{s.contractSpecID1}, ), - []string{s.user1Addr.String()}, fmt.Sprintf("cannot update scope spec identifier. expected %s, got %s", s.scopeSpecID, otherScopeSpecID), }, @@ -1083,7 +1564,6 @@ func (s *SpecKeeperTestSuite) TestValidateScopeSpecUpdate() { []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, []types.MetadataAddress{s.contractSpecID1}, ), - []string{s.user1Addr.String()}, "the ScopeSpecification must have at least one owner", }, { @@ -1102,77 +1582,6 @@ func (s *SpecKeeperTestSuite) TestValidateScopeSpecUpdate() { []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, []types.MetadataAddress{s.contractSpecID1}, ), - []string{s.user1Addr.String()}, - "", - }, - { - "changing owner, only signed by new owner - error", - types.NewScopeSpecification( - s.scopeSpecID, - nil, - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - []types.MetadataAddress{s.contractSpecID1}, - ), - types.NewScopeSpecification( - s.scopeSpecID, - nil, - []string{s.user2Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - []types.MetadataAddress{s.contractSpecID1}, - ), - []string{s.user2Addr.String()}, - fmt.Sprintf("missing signature from existing owner %s; required for update", s.user1Addr.String()), - }, - { - "adding signer, only existing owner needs to sign", - types.NewScopeSpecification( - s.scopeSpecID, - nil, - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - []types.MetadataAddress{s.contractSpecID1}, - ), - types.NewScopeSpecification( - s.scopeSpecID, - nil, - []string{s.user1Addr.String(), s.user2Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - []types.MetadataAddress{s.contractSpecID1}, - ), - []string{s.user1Addr.String()}, - "", - }, - { - "adding signer, both signed - ok too", - types.NewScopeSpecification( - s.scopeSpecID, - nil, - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - []types.MetadataAddress{s.contractSpecID1}, - ), - types.NewScopeSpecification( - s.scopeSpecID, - nil, - []string{s.user1Addr.String(), s.user2Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - []types.MetadataAddress{s.contractSpecID1}, - ), - []string{s.user1Addr.String(), s.user2Addr.String()}, - "", - }, - { - "new entry, no signers required", - nil, - types.NewScopeSpecification( - s.scopeSpecID, - nil, - []string{s.user1Addr.String()}, - []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, - []types.MetadataAddress{s.contractSpecID1}, - ), - []string{}, "", }, { @@ -1191,7 +1600,6 @@ func (s *SpecKeeperTestSuite) TestValidateScopeSpecUpdate() { []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, []types.MetadataAddress{s.contractSpecID1, otherContractSpecID}, ), - []string{s.user1Addr.String()}, fmt.Sprintf("no contract spec exists with id %s", otherContractSpecID), }, { @@ -1210,7 +1618,6 @@ func (s *SpecKeeperTestSuite) TestValidateScopeSpecUpdate() { []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, []types.MetadataAddress{s.contractSpecID1, s.contractSpecID2}, ), - []string{s.user1Addr.String()}, "", }, { @@ -1229,7 +1636,6 @@ func (s *SpecKeeperTestSuite) TestValidateScopeSpecUpdate() { []types.PartyType{types.PartyType_PARTY_TYPE_OWNER}, []types.MetadataAddress{s.contractSpecID2}, ), - []string{s.user1Addr.String()}, "", }, } @@ -1237,7 +1643,7 @@ func (s *SpecKeeperTestSuite) TestValidateScopeSpecUpdate() { for _, tt := range tests { tt := tt s.T().Run(tt.name, func(t *testing.T) { - err := s.app.MetadataKeeper.ValidateScopeSpecUpdate(s.ctx, tt.existing, *tt.proposed, tt.signers) + err := s.app.MetadataKeeper.ValidateScopeSpecUpdate(s.ctx, tt.existing, *tt.proposed) if err != nil { require.Equal(t, tt.want, err.Error(), "ScopeSpec Keeper ValidateScopeSpecUpdate error") } else if len(tt.want) > 0 { diff --git a/x/metadata/legacy/v040/migrate.go b/x/metadata/legacy/v040/migrate.go index 87cb74b1a9..fbc69f2edd 100644 --- a/x/metadata/legacy/v040/migrate.go +++ b/x/metadata/legacy/v040/migrate.go @@ -382,24 +382,22 @@ func convertContractSpec(old *v039metadata.ContractSpec) ( Source: &v040metadata.ContractSpecification_Hash{ Hash: old.Definition.ResourceLocation.Ref.Hash, }, - ClassName: old.Definition.ResourceLocation.Classname, - RecordSpecIds: make([]v040metadata.MetadataAddress, len(old.ConsiderationSpecs)), + ClassName: old.Definition.ResourceLocation.Classname, } newRecords = make([]v040metadata.RecordSpecification, len(old.ConsiderationSpecs)) for i := range old.ConsiderationSpecs { - newSpec.RecordSpecIds[i] = newSpec.SpecificationId.GetRecordSpecAddress(old.ConsiderationSpecs[i].OutputSpec.Spec.Name) recordInputs, err := convertInputSpecs(old.ConsiderationSpecs[i].InputSpecs) if err != nil { return newSpec, nil, err } newRecords[i] = v040metadata.RecordSpecification{ - SpecificationId: newSpec.SpecificationId, - Name: old.ConsiderationSpecs[i].OutputSpec.Spec.Name, - TypeName: old.ConsiderationSpecs[i].OutputSpec.Spec.ResourceLocation.Classname, - ResultType: v040metadata.DefinitionType(old.ConsiderationSpecs[i].OutputSpec.Spec.Type), - Inputs: recordInputs, - ResponsibleParty: v040metadata.PartyType(old.ConsiderationSpecs[i].ResponsibleParty), + SpecificationId: newSpec.SpecificationId, + Name: old.ConsiderationSpecs[i].OutputSpec.Spec.Name, + TypeName: old.ConsiderationSpecs[i].OutputSpec.Spec.ResourceLocation.Classname, + ResultType: v040metadata.DefinitionType(old.ConsiderationSpecs[i].OutputSpec.Spec.Type), + Inputs: recordInputs, + ResponsibleParties: []v040metadata.PartyType{v040metadata.PartyType(old.ConsiderationSpecs[i].ResponsibleParty)}, } } diff --git a/x/metadata/legacy/v040/migrate_test.go b/x/metadata/legacy/v040/migrate_test.go index 6ba7933c25..8b81ce6055 100644 --- a/x/metadata/legacy/v040/migrate_test.go +++ b/x/metadata/legacy/v040/migrate_test.go @@ -167,10 +167,6 @@ func TestMigrate(t *testing.T) { "parties_involved": [ "PARTY_TYPE_ORIGINATOR" ], - "record_spec_ids": [ - "recspec1q5fha8nex5j0qeshr9uvsmv5um32y0aeyhnus90eqmv3xfwwugdwqt2xfzw", - "recspec1q5fha8nex5j0qeshr9uvsmv5um3fk945f58q5h9vf7tghmaskk67kve3mq3" - ], "specification_id": "contractspec1qvfha8nex5j0qeshr9uvsmv5um3q7sghss" } ], @@ -190,7 +186,9 @@ func TestMigrate(t *testing.T) { } ], "name": "additional_parties", - "responsible_party": "PARTY_TYPE_ORIGINATOR", + "responsible_parties": [ + "PARTY_TYPE_ORIGINATOR" + ], "result_type": "DEFINITION_TYPE_PROPOSED", "specification_id": "contractspec1qvfha8nex5j0qeshr9uvsmv5um3q7sghss", "type_name": "io.provenance.loan.LoanProtos$PartiesList" @@ -209,7 +207,9 @@ func TestMigrate(t *testing.T) { } ], "name": "documents", - "responsible_party": "PARTY_TYPE_ORIGINATOR", + "responsible_parties": [ + "PARTY_TYPE_ORIGINATOR" + ], "result_type": "DEFINITION_TYPE_PROPOSED", "specification_id": "contractspec1qvfha8nex5j0qeshr9uvsmv5um3q7sghss", "type_name": "io.provenance.common.DocumentProtos$DocumentList" diff --git a/x/metadata/types/address.go b/x/metadata/types/address.go index da63c91cd4..4e9f5076e8 100644 --- a/x/metadata/types/address.go +++ b/x/metadata/types/address.go @@ -447,6 +447,15 @@ func (ma MetadataAddress) GetRecordSpecAddress(name string) MetadataAddress { return RecordSpecMetadataAddress(contractSpecUUID, name) } +// GetContractSpecAddress returns the MetadataAddress for a contract spec given the UUID in the current record spec context +func (ma MetadataAddress) GetContractSpecAddress() MetadataAddress { + contractSpecUUID, err := ma.ContractSpecUUID() + if err != nil { + panic(err) + } + return ContractSpecMetadataAddress(contractSpecUUID) +} + // ScopeSessionIteratorPrefix returns an iterator prefix that finds all Sessions assigned to the metadata address scope // if the current address is empty then returns a prefix to iterate through all sessions func (ma MetadataAddress) ScopeSessionIteratorPrefix() ([]byte, error) { diff --git a/x/metadata/types/codec.go b/x/metadata/types/codec.go index 7ee972acfe..a1e46c985a 100644 --- a/x/metadata/types/codec.go +++ b/x/metadata/types/codec.go @@ -20,6 +20,8 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgDeleteScopeSpecificationRequest{}, "provenance/metadata/DeleteScopeSpecificationRequest", nil) cdc.RegisterConcrete(&MsgAddContractSpecificationRequest{}, "provenance/metadata/AddContractSpecificationRequest", nil) cdc.RegisterConcrete(&MsgDeleteContractSpecificationRequest{}, "provenance/metadata/DeleteContractSpecificationRequest", nil) + cdc.RegisterConcrete(&MsgAddRecordSpecificationRequest{}, "provenance/metadata/AddRecordSpecificationRequest", nil) + cdc.RegisterConcrete(&MsgDeleteRecordSpecificationRequest{}, "provenance/metadata/DeleteRecordSpecificationRequest", nil) } // RegisterInterfaces registers implementations for the tx messages @@ -35,6 +37,8 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &MsgDeleteScopeSpecificationRequest{}, &MsgAddContractSpecificationRequest{}, &MsgDeleteContractSpecificationRequest{}, + &MsgAddRecordSpecificationRequest{}, + &MsgDeleteRecordSpecificationRequest{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/metadata/types/events.go b/x/metadata/types/events.go index eed9c8df2a..38a6f148ad 100644 --- a/x/metadata/types/events.go +++ b/x/metadata/types/events.go @@ -38,6 +38,13 @@ const ( // EventTypeContractSpecificationRemoved is the event type generated when a contract specification is removed. EventTypeContractSpecificationRemoved string = "contract_specification_removed" + // EventTypeRecordSpecificationCreated is the event type generated when a new record specification is created. + EventTypeRecordSpecificationCreated string = "record_specification_created" + // EventTypeRecordSpecificationUpdated is the event type generated when an existing record specifications is updated. + EventTypeRecordSpecificationUpdated string = "record_specification_updated" + // EventTypeRecordSpecificationRemoved is the event type generated when a record specification is removed. + EventTypeRecordSpecificationRemoved string = "record_specification_removed" + // AttributeKeyScopeID is the attribute key for a scope ID attribute JSON value. AttributeKeyScopeID string = "scope_id" // AttributeKeyScope is the attribute key for a scope attribute JSON value. @@ -52,10 +59,18 @@ const ( AttributeKeyModuleName string = "module" // AttributeKeyTxHash is the attribute for the transaction hash. AttributeKeyTxHash = "tx_hash" - // AttributeKeyScopeID is the attribute key for a scope ID attribute JSON value. + // AttributeKeyScopeSpecID is the attribute key for a scope spec ID attribute JSON value. AttributeKeyScopeSpecID string = "scope_spec_id" - // AttributeKeyScope is the attribute key for a scope attribute JSON value. + // AttributeKeyScopeSpec is the attribute key for a scope spec attribute JSON value. AttributeKeyScopeSpec string = "scope_spec" + // AttributeKeyContractSpecID is the attribute key for a contract spec ID attribute JSON value. + AttributeKeyContractSpecID string = "contract_spec_id" + // AttributeKeyContractSpec is the attribute key for a contract spec attribute JSON value. + AttributeKeyContractSpec string = "contract_spec" + // AttributeKeyRecordSpecID is the attribute key for a record spec ID attribute JSON value. + AttributeKeyRecordSpecID string = "record_spec_id" + // AttributeKeyRecordSpec is the attribute key for a record spec attribute JSON value. + AttributeKeyRecordSpec string = "record_spec" // AttributeValueCategory indicates the category for this value AttributeValueCategory = ModuleName diff --git a/x/metadata/types/genesis.go b/x/metadata/types/genesis.go index 5cf7db0971..766dea8664 100644 --- a/x/metadata/types/genesis.go +++ b/x/metadata/types/genesis.go @@ -13,6 +13,7 @@ func NewGenesisState( records []Record, scopeSpecs []ScopeSpecification, contracSpecs []ContractSpecification, + recordSpecs []RecordSpecification, ) *GenesisState { return &GenesisState{ Params: params, @@ -21,6 +22,7 @@ func NewGenesisState( Records: records, ScopeSpecifications: scopeSpecs, ContractSpecifications: contracSpecs, + RecordSpecifications: recordSpecs, } } diff --git a/x/metadata/types/msg.go b/x/metadata/types/msg.go index 90f9d6222e..3b84dafff3 100644 --- a/x/metadata/types/msg.go +++ b/x/metadata/types/msg.go @@ -20,6 +20,8 @@ const ( TypeMsgDeleteScopeSpecificationRequest = "delete_scope_specification_request" TypeMsgAddContractSpecificationRequest = "add_contract_specification_request" TypeMsgDeleteContractSpecificationRequest = "delete_contract_specification_request" + TypeMsgAddRecordSpecificationRequest = "add_record_specification_request" + TypeMsgDeleteRecordSpecificationRequest = "delete_record_specification_request" ) // Compile time interface checks. @@ -32,7 +34,11 @@ var ( _ sdk.Msg = &MsgAddRecordRequest{} _ sdk.Msg = &MsgDeleteRecordRequest{} _ sdk.Msg = &MsgAddScopeSpecificationRequest{} + _ sdk.Msg = &MsgDeleteScopeSpecificationRequest{} _ sdk.Msg = &MsgAddContractSpecificationRequest{} + _ sdk.Msg = &MsgDeleteContractSpecificationRequest{} + _ sdk.Msg = &MsgAddRecordSpecificationRequest{} + _ sdk.Msg = &MsgDeleteRecordSpecificationRequest{} ) // private method to convert an array of strings into an array of Acc Addresses. @@ -536,3 +542,83 @@ func (msg MsgDeleteContractSpecificationRequest) ValidateBasic() error { } return nil } + +// ------------------ MsgAddRecordSpecificationRequest ------------------ + +// NewMsgAddRecordSpecificationRequest creates a new msg instance +func NewMsgAddRecordSpecificationRequest() *MsgAddRecordSpecificationRequest { + return &MsgAddRecordSpecificationRequest{} +} + +func (msg MsgAddRecordSpecificationRequest) String() string { + out, _ := yaml.Marshal(msg) + return string(out) +} + +// Route returns the module route +func (msg MsgAddRecordSpecificationRequest) Route() string { + return ModuleName +} + +// Type returns the type name for this msg +func (msg MsgAddRecordSpecificationRequest) Type() string { + return TypeMsgAddRecordSpecificationRequest +} + +// GetSigners returns the address(es) that must sign over msg.GetSignBytes() +func (msg MsgAddRecordSpecificationRequest) GetSigners() []sdk.AccAddress { + return stringsToAccAddresses(msg.Signers) +} + +// GetSignBytes gets the bytes for the message signer to sign on +func (msg MsgAddRecordSpecificationRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// ValidateBasic performs a quick validity check +func (msg MsgAddRecordSpecificationRequest) ValidateBasic() error { + if len(msg.Signers) < 1 { + return fmt.Errorf("at least one signer is required") + } + return nil +} + +// ------------------ MsgDeleteRecordSpecificationRequest ------------------ + +// NewMsgDeleteRecordSpecificationRequest creates a new msg instance +func NewMsgDeleteRecordSpecificationRequest() *MsgDeleteRecordSpecificationRequest { + return &MsgDeleteRecordSpecificationRequest{} +} + +func (msg MsgDeleteRecordSpecificationRequest) String() string { + out, _ := yaml.Marshal(msg) + return string(out) +} + +// Route returns the module route +func (msg MsgDeleteRecordSpecificationRequest) Route() string { + return ModuleName +} + +// Type returns the type name for this msg +func (msg MsgDeleteRecordSpecificationRequest) Type() string { + return TypeMsgDeleteRecordSpecificationRequest +} + +// GetSigners returns the address(es) that must sign over msg.GetSignBytes() +func (msg MsgDeleteRecordSpecificationRequest) GetSigners() []sdk.AccAddress { + return stringsToAccAddresses(msg.Signers) +} + +// GetSignBytes gets the bytes for the message signer to sign on +func (msg MsgDeleteRecordSpecificationRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// ValidateBasic performs a quick validity check +func (msg MsgDeleteRecordSpecificationRequest) ValidateBasic() error { + if len(msg.Signers) < 1 { + return fmt.Errorf("at least one signer is required") + } + return nil +} diff --git a/x/metadata/types/query.pb.go b/x/metadata/types/query.pb.go index fcb7b895ce..d84ae3c940 100644 --- a/x/metadata/types/query.pb.go +++ b/x/metadata/types/query.pb.go @@ -1077,6 +1077,302 @@ func (m *ContractSpecificationResponse) GetContractSpecification() *ContractSpec return nil } +// ContractSpecificationExtendedRequest is used for requesting a contract specification with extended data by contract +// specification uuid +type ContractSpecificationExtendedRequest struct { + SpecificationUuid string `protobuf:"bytes,1,opt,name=specification_uuid,json=specificationUuid,proto3" json:"specification_uuid,omitempty" yaml:"specification_uuid"` +} + +func (m *ContractSpecificationExtendedRequest) Reset() { *m = ContractSpecificationExtendedRequest{} } +func (m *ContractSpecificationExtendedRequest) String() string { return proto.CompactTextString(m) } +func (*ContractSpecificationExtendedRequest) ProtoMessage() {} +func (*ContractSpecificationExtendedRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a68790bc0b96eeb9, []int{20} +} +func (m *ContractSpecificationExtendedRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ContractSpecificationExtendedRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ContractSpecificationExtendedRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ContractSpecificationExtendedRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ContractSpecificationExtendedRequest.Merge(m, src) +} +func (m *ContractSpecificationExtendedRequest) XXX_Size() int { + return m.Size() +} +func (m *ContractSpecificationExtendedRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ContractSpecificationExtendedRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ContractSpecificationExtendedRequest proto.InternalMessageInfo + +func (m *ContractSpecificationExtendedRequest) GetSpecificationUuid() string { + if m != nil { + return m.SpecificationUuid + } + return "" +} + +// ContractSpecificationExtendedResponse is the response to a contract specification extended request. +type ContractSpecificationExtendedResponse struct { + ContractSpecification *ContractSpecification `protobuf:"bytes,1,opt,name=contract_specification,json=contractSpecification,proto3" json:"contract_specification,omitempty" yaml:"contract_specification"` + RecordSpecifications []*RecordSpecification `protobuf:"bytes,2,rep,name=record_specifications,json=recordSpecifications,proto3" json:"record_specifications,omitempty" yaml:"record_specifications"` +} + +func (m *ContractSpecificationExtendedResponse) Reset() { *m = ContractSpecificationExtendedResponse{} } +func (m *ContractSpecificationExtendedResponse) String() string { return proto.CompactTextString(m) } +func (*ContractSpecificationExtendedResponse) ProtoMessage() {} +func (*ContractSpecificationExtendedResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a68790bc0b96eeb9, []int{21} +} +func (m *ContractSpecificationExtendedResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ContractSpecificationExtendedResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ContractSpecificationExtendedResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ContractSpecificationExtendedResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ContractSpecificationExtendedResponse.Merge(m, src) +} +func (m *ContractSpecificationExtendedResponse) XXX_Size() int { + return m.Size() +} +func (m *ContractSpecificationExtendedResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ContractSpecificationExtendedResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ContractSpecificationExtendedResponse proto.InternalMessageInfo + +func (m *ContractSpecificationExtendedResponse) GetContractSpecification() *ContractSpecification { + if m != nil { + return m.ContractSpecification + } + return nil +} + +func (m *ContractSpecificationExtendedResponse) GetRecordSpecifications() []*RecordSpecification { + if m != nil { + return m.RecordSpecifications + } + return nil +} + +// RecordSpecificationsForContractSpecificationRequest is used for requesting record specifications by contract +// specification uuid +type RecordSpecificationsForContractSpecificationRequest struct { + ContractSpecificationUuid string `protobuf:"bytes,1,opt,name=contract_specification_uuid,json=contractSpecificationUuid,proto3" json:"contract_specification_uuid,omitempty" yaml:"contract_specification_uuid"` +} + +func (m *RecordSpecificationsForContractSpecificationRequest) Reset() { + *m = RecordSpecificationsForContractSpecificationRequest{} +} +func (m *RecordSpecificationsForContractSpecificationRequest) String() string { + return proto.CompactTextString(m) +} +func (*RecordSpecificationsForContractSpecificationRequest) ProtoMessage() {} +func (*RecordSpecificationsForContractSpecificationRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a68790bc0b96eeb9, []int{22} +} +func (m *RecordSpecificationsForContractSpecificationRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecordSpecificationsForContractSpecificationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecordSpecificationsForContractSpecificationRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RecordSpecificationsForContractSpecificationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecordSpecificationsForContractSpecificationRequest.Merge(m, src) +} +func (m *RecordSpecificationsForContractSpecificationRequest) XXX_Size() int { + return m.Size() +} +func (m *RecordSpecificationsForContractSpecificationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_RecordSpecificationsForContractSpecificationRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_RecordSpecificationsForContractSpecificationRequest proto.InternalMessageInfo + +func (m *RecordSpecificationsForContractSpecificationRequest) GetContractSpecificationUuid() string { + if m != nil { + return m.ContractSpecificationUuid + } + return "" +} + +// RecordSpecificationResponseResponse is the response to a record specification for contract specification request. +type RecordSpecificationsForContractSpecificationResponse struct { + RecordSpecifications []*RecordSpecification `protobuf:"bytes,1,rep,name=record_specifications,json=recordSpecifications,proto3" json:"record_specifications,omitempty" yaml:"record_specifications"` +} + +func (m *RecordSpecificationsForContractSpecificationResponse) Reset() { + *m = RecordSpecificationsForContractSpecificationResponse{} +} +func (m *RecordSpecificationsForContractSpecificationResponse) String() string { + return proto.CompactTextString(m) +} +func (*RecordSpecificationsForContractSpecificationResponse) ProtoMessage() {} +func (*RecordSpecificationsForContractSpecificationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a68790bc0b96eeb9, []int{23} +} +func (m *RecordSpecificationsForContractSpecificationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecordSpecificationsForContractSpecificationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecordSpecificationsForContractSpecificationResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RecordSpecificationsForContractSpecificationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecordSpecificationsForContractSpecificationResponse.Merge(m, src) +} +func (m *RecordSpecificationsForContractSpecificationResponse) XXX_Size() int { + return m.Size() +} +func (m *RecordSpecificationsForContractSpecificationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RecordSpecificationsForContractSpecificationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RecordSpecificationsForContractSpecificationResponse proto.InternalMessageInfo + +func (m *RecordSpecificationsForContractSpecificationResponse) GetRecordSpecifications() []*RecordSpecification { + if m != nil { + return m.RecordSpecifications + } + return nil +} + +// RecordSpecificationRequest is used for requesting a record specification by uuid +type RecordSpecificationRequest struct { + ContractSpecificationUuid string `protobuf:"bytes,1,opt,name=contract_specification_uuid,json=contractSpecificationUuid,proto3" json:"contract_specification_uuid,omitempty" yaml:"contract_specification_uuid"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (m *RecordSpecificationRequest) Reset() { *m = RecordSpecificationRequest{} } +func (m *RecordSpecificationRequest) String() string { return proto.CompactTextString(m) } +func (*RecordSpecificationRequest) ProtoMessage() {} +func (*RecordSpecificationRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a68790bc0b96eeb9, []int{24} +} +func (m *RecordSpecificationRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecordSpecificationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecordSpecificationRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RecordSpecificationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecordSpecificationRequest.Merge(m, src) +} +func (m *RecordSpecificationRequest) XXX_Size() int { + return m.Size() +} +func (m *RecordSpecificationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_RecordSpecificationRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_RecordSpecificationRequest proto.InternalMessageInfo + +func (m *RecordSpecificationRequest) GetContractSpecificationUuid() string { + if m != nil { + return m.ContractSpecificationUuid + } + return "" +} + +func (m *RecordSpecificationRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +// RecordSpecificationResponse is the response to a record specification request. +type RecordSpecificationResponse struct { + RecordSpecification *RecordSpecification `protobuf:"bytes,1,opt,name=record_specification,json=recordSpecification,proto3" json:"record_specification,omitempty" yaml:"record_specification"` +} + +func (m *RecordSpecificationResponse) Reset() { *m = RecordSpecificationResponse{} } +func (m *RecordSpecificationResponse) String() string { return proto.CompactTextString(m) } +func (*RecordSpecificationResponse) ProtoMessage() {} +func (*RecordSpecificationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a68790bc0b96eeb9, []int{25} +} +func (m *RecordSpecificationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecordSpecificationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecordSpecificationResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RecordSpecificationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecordSpecificationResponse.Merge(m, src) +} +func (m *RecordSpecificationResponse) XXX_Size() int { + return m.Size() +} +func (m *RecordSpecificationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RecordSpecificationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RecordSpecificationResponse proto.InternalMessageInfo + +func (m *RecordSpecificationResponse) GetRecordSpecification() *RecordSpecification { + if m != nil { + return m.RecordSpecification + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "provenance.metadata.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "provenance.metadata.v1.QueryParamsResponse") @@ -1098,6 +1394,12 @@ func init() { proto.RegisterType((*ScopeSpecificationResponse)(nil), "provenance.metadata.v1.ScopeSpecificationResponse") proto.RegisterType((*ContractSpecificationRequest)(nil), "provenance.metadata.v1.ContractSpecificationRequest") proto.RegisterType((*ContractSpecificationResponse)(nil), "provenance.metadata.v1.ContractSpecificationResponse") + proto.RegisterType((*ContractSpecificationExtendedRequest)(nil), "provenance.metadata.v1.ContractSpecificationExtendedRequest") + proto.RegisterType((*ContractSpecificationExtendedResponse)(nil), "provenance.metadata.v1.ContractSpecificationExtendedResponse") + proto.RegisterType((*RecordSpecificationsForContractSpecificationRequest)(nil), "provenance.metadata.v1.RecordSpecificationsForContractSpecificationRequest") + proto.RegisterType((*RecordSpecificationsForContractSpecificationResponse)(nil), "provenance.metadata.v1.RecordSpecificationsForContractSpecificationResponse") + proto.RegisterType((*RecordSpecificationRequest)(nil), "provenance.metadata.v1.RecordSpecificationRequest") + proto.RegisterType((*RecordSpecificationResponse)(nil), "provenance.metadata.v1.RecordSpecificationResponse") } func init() { @@ -1105,82 +1407,98 @@ func init() { } var fileDescriptor_a68790bc0b96eeb9 = []byte{ - // 1199 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x98, 0xdd, 0x6e, 0x1b, 0x45, - 0x14, 0xc7, 0x33, 0x49, 0xdb, 0x34, 0x27, 0xa5, 0x34, 0x27, 0x1f, 0x75, 0x4c, 0x62, 0x87, 0x11, - 0x2d, 0x21, 0x25, 0xbb, 0x8d, 0x13, 0x20, 0xa4, 0x55, 0x55, 0x96, 0x2a, 0x34, 0x12, 0x82, 0xb0, - 0x51, 0xb8, 0x40, 0x42, 0x68, 0x63, 0x0f, 0xee, 0x8a, 0xd8, 0xeb, 0x7a, 0xd7, 0xa1, 0x96, 0x95, - 0x0b, 0xb8, 0xa1, 0x5c, 0x81, 0x84, 0x7a, 0x01, 0x6f, 0xd0, 0x47, 0xe0, 0x43, 0x42, 0x08, 0x21, - 0x7a, 0x19, 0xc4, 0x0d, 0x57, 0x16, 0x4a, 0x78, 0x02, 0x3f, 0x01, 0xda, 0x99, 0xb1, 0x77, 0xd7, - 0xde, 0x71, 0xec, 0x54, 0x2a, 0xf4, 0x6e, 0xd7, 0x73, 0xce, 0x9c, 0xdf, 0xff, 0xcc, 0xc7, 0x39, - 0x6b, 0xa0, 0xa5, 0xb2, 0xb3, 0xc7, 0x8a, 0x56, 0x31, 0xcb, 0xf4, 0x02, 0xf3, 0xac, 0x9c, 0xe5, - 0x59, 0xfa, 0xde, 0x92, 0x7e, 0xb7, 0xc2, 0xca, 0x55, 0xad, 0x54, 0x76, 0x3c, 0x07, 0xa7, 0x02, - 0x1b, 0xad, 0x69, 0xa3, 0xed, 0x2d, 0x25, 0x27, 0xf2, 0x4e, 0xde, 0xe1, 0x26, 0xba,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 0x39, 0x8d, 0xaa, 0x82, 0xde, - 0xe5, 0x34, 0x2a, 0xeb, 0x32, 0xbd, 0xc1, 0xb9, 0x57, 0xf1, 0xd5, 0xae, 0xbb, 0xc0, 0x2f, 0x26, - 0x7a, 0xad, 0xb3, 0xfe, 0xed, 0xe3, 0xef, 0x04, 0x26, 0x63, 0x8b, 0x12, 0xae, 0xf4, 0x55, 0xc3, - 0x9a, 0x1a, 0x5e, 0xe9, 0xd3, 0x4b, 0xca, 0x78, 0x83, 0xcb, 0xb8, 0x86, 0xaf, 0xab, 0x64, 0x34, - 0xcb, 0x9f, 0x52, 0x89, 0xf1, 0xc9, 0xa3, 0xc3, 0x14, 0x39, 0x38, 0x4c, 0x91, 0xbf, 0x0f, 0x53, - 0xe4, 0xeb, 0xa3, 0xd4, 0xc0, 0xc1, 0x51, 0x6a, 0xe0, 0xaf, 0xa3, 0xd4, 0x00, 0x4c, 0xdb, 0x8e, - 0x82, 0x6a, 0x93, 0x7c, 0xb0, 0x92, 0xb7, 0xbd, 0x3b, 0x95, 0x1d, 0x2d, 0xeb, 0x14, 0x42, 0xb1, - 0x17, 0x6d, 0x27, 0x4c, 0x72, 0x2f, 0x60, 0xf1, 0xaa, 0x25, 0xe6, 0xee, 0x9c, 0xe1, 0xff, 0x13, - 0x2d, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x4c, 0x2e, 0x36, 0x3c, 0x13, 0x00, 0x00, + // 1450 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x99, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xc7, 0x33, 0x4e, 0x7f, 0xe5, 0xa5, 0x40, 0xfb, 0x9c, 0xa4, 0x89, 0x93, 0x78, 0xc3, 0xa8, + 0x2d, 0xa1, 0x3f, 0xbc, 0x8d, 0x13, 0xa0, 0xb4, 0xa5, 0x2a, 0xa6, 0xa4, 0x0d, 0x54, 0x6d, 0xd8, + 0xaa, 0x3d, 0x20, 0x21, 0xb4, 0xb1, 0xa7, 0xae, 0x45, 0xe2, 0x75, 0xbd, 0x9b, 0xd0, 0x28, 0x8a, + 0x10, 0xbd, 0x00, 0x27, 0x90, 0x50, 0x25, 0x40, 0x02, 0x89, 0x63, 0xff, 0x01, 0x24, 0x28, 0x12, + 0x42, 0x08, 0xd1, 0x1b, 0x45, 0x5c, 0x38, 0x59, 0xa8, 0xe5, 0x00, 0x57, 0xff, 0x05, 0x68, 0x67, + 0x67, 0xed, 0x5d, 0x7b, 0x66, 0xed, 0x4d, 0x21, 0x6d, 0x6f, 0xbb, 0xde, 0xf7, 0x66, 0x3e, 0xdf, + 0xef, 0xfc, 0xd8, 0x37, 0x6b, 0xa0, 0x95, 0xaa, 0xb5, 0xc2, 0xca, 0x66, 0x39, 0xcf, 0xf4, 0x25, + 0xe6, 0x98, 0x05, 0xd3, 0x31, 0xf5, 0x95, 0x29, 0xfd, 0xda, 0x32, 0xab, 0xae, 0x66, 0x2a, 0x55, + 0xcb, 0xb1, 0x70, 0xa8, 0x19, 0x93, 0xf1, 0x63, 0x32, 0x2b, 0x53, 0xa9, 0x81, 0xa2, 0x55, 0xb4, + 0x78, 0x88, 0xee, 0x5e, 0x79, 0xd1, 0xa9, 0x03, 0x79, 0xcb, 0x5e, 0xb2, 0x6c, 0x7d, 0xc1, 0xb4, + 0x99, 0xd7, 0x8c, 0xbe, 0x32, 0xb5, 0xc0, 0x1c, 0x73, 0x4a, 0xaf, 0x98, 0xc5, 0x52, 0xd9, 0x74, + 0x4a, 0x56, 0x59, 0xc4, 0x8e, 0x15, 0x2d, 0xab, 0xb8, 0xc8, 0x74, 0xb3, 0x52, 0xd2, 0xcd, 0x72, + 0xd9, 0x72, 0xf8, 0x43, 0x5b, 0x3c, 0xdd, 0xa7, 0x60, 0x6b, 0x30, 0x78, 0x61, 0x2a, 0x09, 0x76, + 0xde, 0xaa, 0x30, 0x1f, 0x4a, 0x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84, 0x2f, 0x97, 0xb9, + 0x2f, 0xf3, 0x78, 0xbe, 0x3b, 0x5f, 0x22, 0xaa, 0xbb, 0xc6, 0xee, 0x56, 0x61, 0x79, 0x1b, 0x7f, + 0x25, 0x90, 0x94, 0x00, 0x61, 0x36, 0x06, 0xbd, 0xaf, 0x78, 0x3a, 0x56, 0x8e, 0x10, 0x76, 0x81, + 0x0b, 0x9b, 0xc3, 0x33, 0x2a, 0x61, 0x4d, 0xda, 0x0e, 0xb2, 0xbc, 0xcd, 0x3a, 0xf7, 0xce, 0x9d, + 0x7b, 0x69, 0x72, 0xf7, 0x5e, 0x9a, 0xfc, 0x79, 0x2f, 0x4d, 0x3e, 0xb9, 0x9f, 0xee, 0xb9, 0x7b, + 0x3f, 0xdd, 0xf3, 0xc7, 0xfd, 0x74, 0x0f, 0x8c, 0x94, 0x2c, 0x05, 0xe1, 0x3c, 0x79, 0x73, 0xa6, + 0x58, 0x72, 0xae, 0x2e, 0x2f, 0x64, 0xf2, 0xd6, 0x52, 0x80, 0xe4, 0x70, 0xc9, 0x0a, 0x72, 0x5d, + 0x6f, 0x92, 0x39, 0xab, 0x15, 0x66, 0x2f, 0x6c, 0xe3, 0xff, 0xa8, 0x4c, 0xff, 0x1b, 0x00, 0x00, + 0xff, 0xff, 0x43, 0x68, 0x79, 0xb7, 0x66, 0x1a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1211,10 +1529,18 @@ type QueryClient interface { Ownership(ctx context.Context, in *OwnershipRequest, opts ...grpc.CallOption) (*OwnershipResponse, error) // ValueOwnership returns a list of scope identifiers that list the given address as the value owner ValueOwnership(ctx context.Context, in *ValueOwnershipRequest, opts ...grpc.CallOption) (*ValueOwnershipResponse, error) - // ScopeSpecification returns a scope specification for the given specification id + // ScopeSpecification returns a scope specification for the given specification uuid ScopeSpecification(ctx context.Context, in *ScopeSpecificationRequest, opts ...grpc.CallOption) (*ScopeSpecificationResponse, error) - // ContractSpecification returns a contract specification for the given specification id + // ContractSpecification returns a contract specification for the given specification uuid ContractSpecification(ctx context.Context, in *ContractSpecificationRequest, opts ...grpc.CallOption) (*ContractSpecificationResponse, error) + // ContractSpecification returns a contract specification and record specifications for the given contract + // specification uuid + ContractSpecificationExtended(ctx context.Context, in *ContractSpecificationExtendedRequest, opts ...grpc.CallOption) (*ContractSpecificationExtendedResponse, error) + // RecordSpecificationsForContractSpecification returns the record specifications for the given contract specification + // uuid + RecordSpecificationsForContractSpecification(ctx context.Context, in *RecordSpecificationsForContractSpecificationRequest, opts ...grpc.CallOption) (*RecordSpecificationsForContractSpecificationResponse, error) + // RecordSpecification returns a record specification for the given specification uuid + RecordSpecification(ctx context.Context, in *RecordSpecificationRequest, opts ...grpc.CallOption) (*RecordSpecificationResponse, error) } type queryClient struct { @@ -1315,6 +1641,33 @@ func (c *queryClient) ContractSpecification(ctx context.Context, in *ContractSpe return out, nil } +func (c *queryClient) ContractSpecificationExtended(ctx context.Context, in *ContractSpecificationExtendedRequest, opts ...grpc.CallOption) (*ContractSpecificationExtendedResponse, error) { + out := new(ContractSpecificationExtendedResponse) + err := c.cc.Invoke(ctx, "/provenance.metadata.v1.Query/ContractSpecificationExtended", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RecordSpecificationsForContractSpecification(ctx context.Context, in *RecordSpecificationsForContractSpecificationRequest, opts ...grpc.CallOption) (*RecordSpecificationsForContractSpecificationResponse, error) { + out := new(RecordSpecificationsForContractSpecificationResponse) + err := c.cc.Invoke(ctx, "/provenance.metadata.v1.Query/RecordSpecificationsForContractSpecification", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RecordSpecification(ctx context.Context, in *RecordSpecificationRequest, opts ...grpc.CallOption) (*RecordSpecificationResponse, error) { + out := new(RecordSpecificationResponse) + err := c.cc.Invoke(ctx, "/provenance.metadata.v1.Query/RecordSpecification", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Params queries the parameters of x/metadata module. @@ -1333,10 +1686,18 @@ type QueryServer interface { Ownership(context.Context, *OwnershipRequest) (*OwnershipResponse, error) // ValueOwnership returns a list of scope identifiers that list the given address as the value owner ValueOwnership(context.Context, *ValueOwnershipRequest) (*ValueOwnershipResponse, error) - // ScopeSpecification returns a scope specification for the given specification id + // ScopeSpecification returns a scope specification for the given specification uuid ScopeSpecification(context.Context, *ScopeSpecificationRequest) (*ScopeSpecificationResponse, error) - // ContractSpecification returns a contract specification for the given specification id + // ContractSpecification returns a contract specification for the given specification uuid ContractSpecification(context.Context, *ContractSpecificationRequest) (*ContractSpecificationResponse, error) + // ContractSpecification returns a contract specification and record specifications for the given contract + // specification uuid + ContractSpecificationExtended(context.Context, *ContractSpecificationExtendedRequest) (*ContractSpecificationExtendedResponse, error) + // RecordSpecificationsForContractSpecification returns the record specifications for the given contract specification + // uuid + RecordSpecificationsForContractSpecification(context.Context, *RecordSpecificationsForContractSpecificationRequest) (*RecordSpecificationsForContractSpecificationResponse, error) + // RecordSpecification returns a record specification for the given specification uuid + RecordSpecification(context.Context, *RecordSpecificationRequest) (*RecordSpecificationResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1373,6 +1734,15 @@ func (*UnimplementedQueryServer) ScopeSpecification(ctx context.Context, req *Sc func (*UnimplementedQueryServer) ContractSpecification(ctx context.Context, req *ContractSpecificationRequest) (*ContractSpecificationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ContractSpecification not implemented") } +func (*UnimplementedQueryServer) ContractSpecificationExtended(ctx context.Context, req *ContractSpecificationExtendedRequest) (*ContractSpecificationExtendedResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ContractSpecificationExtended not implemented") +} +func (*UnimplementedQueryServer) RecordSpecificationsForContractSpecification(ctx context.Context, req *RecordSpecificationsForContractSpecificationRequest) (*RecordSpecificationsForContractSpecificationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecordSpecificationsForContractSpecification not implemented") +} +func (*UnimplementedQueryServer) RecordSpecification(ctx context.Context, req *RecordSpecificationRequest) (*RecordSpecificationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecordSpecification not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1558,6 +1928,60 @@ func _Query_ContractSpecification_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _Query_ContractSpecificationExtended_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ContractSpecificationExtendedRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ContractSpecificationExtended(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.metadata.v1.Query/ContractSpecificationExtended", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ContractSpecificationExtended(ctx, req.(*ContractSpecificationExtendedRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RecordSpecificationsForContractSpecification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RecordSpecificationsForContractSpecificationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RecordSpecificationsForContractSpecification(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.metadata.v1.Query/RecordSpecificationsForContractSpecification", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RecordSpecificationsForContractSpecification(ctx, req.(*RecordSpecificationsForContractSpecificationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RecordSpecification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RecordSpecificationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RecordSpecification(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.metadata.v1.Query/RecordSpecification", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RecordSpecification(ctx, req.(*RecordSpecificationRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "provenance.metadata.v1.Query", HandlerType: (*QueryServer)(nil), @@ -1602,6 +2026,18 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ContractSpecification", Handler: _Query_ContractSpecification_Handler, }, + { + MethodName: "ContractSpecificationExtended", + Handler: _Query_ContractSpecificationExtended_Handler, + }, + { + MethodName: "RecordSpecificationsForContractSpecification", + Handler: _Query_RecordSpecificationsForContractSpecification_Handler, + }, + { + MethodName: "RecordSpecification", + Handler: _Query_RecordSpecification_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "provenance/metadata/v1/query.proto", @@ -2410,16 +2846,234 @@ func (m *ContractSpecificationResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *ContractSpecificationExtendedRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil +} + +func (m *ContractSpecificationExtendedRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ContractSpecificationExtendedRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpecificationUuid) > 0 { + i -= len(m.SpecificationUuid) + copy(dAtA[i:], m.SpecificationUuid) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SpecificationUuid))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ContractSpecificationExtendedResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ContractSpecificationExtendedResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ContractSpecificationExtendedResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RecordSpecifications) > 0 { + for iNdEx := len(m.RecordSpecifications) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RecordSpecifications[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.ContractSpecification != nil { + { + size, err := m.ContractSpecification.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RecordSpecificationsForContractSpecificationRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RecordSpecificationsForContractSpecificationRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecordSpecificationsForContractSpecificationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ContractSpecificationUuid) > 0 { + i -= len(m.ContractSpecificationUuid) + copy(dAtA[i:], m.ContractSpecificationUuid) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ContractSpecificationUuid))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RecordSpecificationsForContractSpecificationResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RecordSpecificationsForContractSpecificationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecordSpecificationsForContractSpecificationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RecordSpecifications) > 0 { + for iNdEx := len(m.RecordSpecifications) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RecordSpecifications[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *RecordSpecificationRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RecordSpecificationRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecordSpecificationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.ContractSpecificationUuid) > 0 { + i -= len(m.ContractSpecificationUuid) + copy(dAtA[i:], m.ContractSpecificationUuid) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ContractSpecificationUuid))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RecordSpecificationResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RecordSpecificationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecordSpecificationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RecordSpecification != nil { + { + size, err := m.RecordSpecification.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base } func (m *QueryParamsRequest) Size() (n int) { if m == nil { @@ -2763,41 +3417,450 @@ func (m *ContractSpecificationResponse) Size() (n int) { return n } -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 +func (m *ContractSpecificationExtendedRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpecificationUuid) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + +func (m *ContractSpecificationExtendedResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ContractSpecification != nil { + l = m.ContractSpecification.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.RecordSpecifications) > 0 { + for _, e := range m.RecordSpecifications { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + +func (m *RecordSpecificationsForContractSpecificationRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ContractSpecificationUuid) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *RecordSpecificationsForContractSpecificationResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RecordSpecifications) > 0 { + for _, e := range m.RecordSpecifications { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *RecordSpecificationRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ContractSpecificationUuid) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *RecordSpecificationResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RecordSpecification != nil { + l = m.RecordSpecification.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ScopeRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ScopeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ScopeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuid", 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.ScopeUuid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ScopeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ScopeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ScopeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Scope == nil { + m.Scope = &Scope{} + } + if err := m.Scope.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sessions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sessions = append(m.Sessions, &Session{}) + if err := m.Sessions[len(m.Sessions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Records = append(m.Records, &Record{}) + if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2819,7 +3882,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { +func (m *OwnershipRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2842,15 +3905,47 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: OwnershipRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OwnershipRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2877,7 +3972,10 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2902,7 +4000,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *ScopeRequest) Unmarshal(dAtA []byte) error { +func (m *OwnershipResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2925,15 +4023,15 @@ func (m *ScopeRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ScopeRequest: wiretype end group for non-group") + return fmt.Errorf("proto: OwnershipResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ScopeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OwnershipResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuid", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuids", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2961,7 +4059,43 @@ func (m *ScopeRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ScopeUuid = string(dAtA[iNdEx:postIndex]) + m.ScopeUuids = append(m.ScopeUuids, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -2984,7 +4118,7 @@ func (m *ScopeRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *ScopeResponse) Unmarshal(dAtA []byte) error { +func (m *ValueOwnershipRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3007,17 +4141,17 @@ func (m *ScopeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ScopeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: ValueOwnershipRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ScopeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ValueOwnershipRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3027,31 +4161,27 @@ func (m *ScopeResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Scope == nil { - m.Scope = &Scope{} - } - if err := m.Scope.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sessions", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3078,14 +4208,98 @@ func (m *ScopeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sessions = append(m.Sessions, &Session{}) - if err := m.Sessions[len(m.Sessions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValueOwnershipResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ValueOwnershipResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValueOwnershipResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuids", 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.ScopeUuids = append(m.ScopeUuids, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3112,8 +4326,10 @@ func (m *ScopeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Records = append(m.Records, &Record{}) - if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3138,7 +4354,7 @@ func (m *ScopeResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *OwnershipRequest) Unmarshal(dAtA []byte) error { +func (m *SessionContextByUUIDRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3161,15 +4377,15 @@ func (m *OwnershipRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OwnershipRequest: wiretype end group for non-group") + return fmt.Errorf("proto: SessionContextByUUIDRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OwnershipRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SessionContextByUUIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3197,13 +4413,13 @@ func (m *OwnershipRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.ScopeUuid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SessionUuid", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3213,27 +4429,23 @@ func (m *OwnershipRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SessionUuid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3256,7 +4468,7 @@ func (m *OwnershipRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *OwnershipResponse) Unmarshal(dAtA []byte) error { +func (m *SessionContextByUUIDResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3279,15 +4491,15 @@ func (m *OwnershipResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OwnershipResponse: wiretype end group for non-group") + return fmt.Errorf("proto: SessionContextByUUIDResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OwnershipResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SessionContextByUUIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuids", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3315,11 +4527,43 @@ func (m *OwnershipResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ScopeUuids = append(m.ScopeUuids, string(dAtA[iNdEx:postIndex])) + m.ScopeId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SessionId", 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.SessionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sessions", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3346,10 +4590,8 @@ func (m *OwnershipResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Sessions = append(m.Sessions, &Session{}) + if err := m.Sessions[len(m.Sessions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3374,7 +4616,7 @@ func (m *OwnershipResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *ValueOwnershipRequest) Unmarshal(dAtA []byte) error { +func (m *SessionContextByIDRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3397,15 +4639,15 @@ func (m *ValueOwnershipRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ValueOwnershipRequest: wiretype end group for non-group") + return fmt.Errorf("proto: SessionContextByIDRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ValueOwnershipRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SessionContextByIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3433,13 +4675,13 @@ func (m *ValueOwnershipRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.ScopeId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SessionId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3449,27 +4691,23 @@ func (m *ValueOwnershipRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.SessionId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3492,7 +4730,7 @@ func (m *ValueOwnershipRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *ValueOwnershipResponse) Unmarshal(dAtA []byte) error { +func (m *SessionContextByIDResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3515,15 +4753,15 @@ func (m *ValueOwnershipResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ValueOwnershipResponse: wiretype end group for non-group") + return fmt.Errorf("proto: SessionContextByIDResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ValueOwnershipResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SessionContextByIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuids", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3551,11 +4789,43 @@ func (m *ValueOwnershipResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ScopeUuids = append(m.ScopeUuids, string(dAtA[iNdEx:postIndex])) + m.ScopeId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SessionId", 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.SessionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sessions", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3582,10 +4852,8 @@ func (m *ValueOwnershipResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Sessions = append(m.Sessions, &Session{}) + if err := m.Sessions[len(m.Sessions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3610,7 +4878,7 @@ func (m *ValueOwnershipResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *SessionContextByUUIDRequest) Unmarshal(dAtA []byte) error { +func (m *RecordsByScopeUUIDRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3633,10 +4901,10 @@ func (m *SessionContextByUUIDRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SessionContextByUUIDRequest: wiretype end group for non-group") + return fmt.Errorf("proto: RecordsByScopeUUIDRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SessionContextByUUIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RecordsByScopeUUIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3673,7 +4941,7 @@ func (m *SessionContextByUUIDRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SessionUuid", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3701,7 +4969,7 @@ func (m *SessionContextByUUIDRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SessionUuid = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3724,7 +4992,7 @@ func (m *SessionContextByUUIDRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *SessionContextByUUIDResponse) Unmarshal(dAtA []byte) error { +func (m *RecordsByScopeUUIDResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3747,15 +5015,15 @@ func (m *SessionContextByUUIDResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SessionContextByUUIDResponse: wiretype end group for non-group") + return fmt.Errorf("proto: RecordsByScopeUUIDResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SessionContextByUUIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RecordsByScopeUUIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3783,11 +5051,11 @@ func (m *SessionContextByUUIDResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ScopeId = string(dAtA[iNdEx:postIndex]) + m.ScopeUuid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SessionId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3815,11 +5083,11 @@ func (m *SessionContextByUUIDResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SessionId = string(dAtA[iNdEx:postIndex]) + m.ScopeId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sessions", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3846,8 +5114,8 @@ func (m *SessionContextByUUIDResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sessions = append(m.Sessions, &Session{}) - if err := m.Sessions[len(m.Sessions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Records = append(m.Records, &Record{}) + if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3872,7 +5140,7 @@ func (m *SessionContextByUUIDResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *SessionContextByIDRequest) Unmarshal(dAtA []byte) error { +func (m *RecordsByScopeIDRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3895,10 +5163,10 @@ func (m *SessionContextByIDRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SessionContextByIDRequest: wiretype end group for non-group") + return fmt.Errorf("proto: RecordsByScopeIDRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SessionContextByIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RecordsByScopeIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3935,7 +5203,7 @@ func (m *SessionContextByIDRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SessionId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3963,7 +5231,7 @@ func (m *SessionContextByIDRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SessionId = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3986,7 +5254,7 @@ func (m *SessionContextByIDRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *SessionContextByIDResponse) Unmarshal(dAtA []byte) error { +func (m *RecordsByScopeIDResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4009,15 +5277,15 @@ func (m *SessionContextByIDResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SessionContextByIDResponse: wiretype end group for non-group") + return fmt.Errorf("proto: RecordsByScopeIDResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SessionContextByIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RecordsByScopeIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4045,11 +5313,11 @@ func (m *SessionContextByIDResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ScopeId = string(dAtA[iNdEx:postIndex]) + m.ScopeUuid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SessionId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4077,11 +5345,11 @@ func (m *SessionContextByIDResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SessionId = string(dAtA[iNdEx:postIndex]) + m.ScopeId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sessions", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4108,8 +5376,8 @@ func (m *SessionContextByIDResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sessions = append(m.Sessions, &Session{}) - if err := m.Sessions[len(m.Sessions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Records = append(m.Records, &Record{}) + if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4134,7 +5402,7 @@ func (m *SessionContextByIDResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *RecordsByScopeUUIDRequest) Unmarshal(dAtA []byte) error { +func (m *ScopeSpecificationRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4157,15 +5425,15 @@ func (m *RecordsByScopeUUIDRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RecordsByScopeUUIDRequest: wiretype end group for non-group") + return fmt.Errorf("proto: ScopeSpecificationRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RecordsByScopeUUIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ScopeSpecificationRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuid", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SpecificationUuid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4193,13 +5461,63 @@ func (m *RecordsByScopeUUIDRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ScopeUuid = string(dAtA[iNdEx:postIndex]) + m.SpecificationUuid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ScopeSpecificationResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ScopeSpecificationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ScopeSpecificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ScopeSpecification", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4209,23 +5527,27 @@ func (m *RecordsByScopeUUIDRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Name = string(dAtA[iNdEx:postIndex]) + if m.ScopeSpecification == nil { + m.ScopeSpecification = &ScopeSpecification{} + } + if err := m.ScopeSpecification.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -4248,7 +5570,7 @@ func (m *RecordsByScopeUUIDRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *RecordsByScopeUUIDResponse) Unmarshal(dAtA []byte) error { +func (m *ContractSpecificationRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4271,15 +5593,15 @@ func (m *RecordsByScopeUUIDResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RecordsByScopeUUIDResponse: wiretype end group for non-group") + return fmt.Errorf("proto: ContractSpecificationRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RecordsByScopeUUIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ContractSpecificationRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuid", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SpecificationUuid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4307,43 +5629,61 @@ func (m *RecordsByScopeUUIDResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ScopeUuid = string(dAtA[iNdEx:postIndex]) + m.SpecificationUuid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeId", 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 - } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err } - intStringLen := int(stringLen) - if intStringLen < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF } - if postIndex > l { + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ContractSpecificationResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { return io.ErrUnexpectedEOF } - m.ScopeId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ContractSpecificationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ContractSpecificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ContractSpecification", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4370,8 +5710,10 @@ func (m *RecordsByScopeUUIDResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Records = append(m.Records, &Record{}) - if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.ContractSpecification == nil { + m.ContractSpecification = &ContractSpecification{} + } + if err := m.ContractSpecification.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4396,7 +5738,7 @@ func (m *RecordsByScopeUUIDResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *RecordsByScopeIDRequest) Unmarshal(dAtA []byte) error { +func (m *ContractSpecificationExtendedRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4419,47 +5761,15 @@ func (m *RecordsByScopeIDRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RecordsByScopeIDRequest: wiretype end group for non-group") + return fmt.Errorf("proto: ContractSpecificationExtendedRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RecordsByScopeIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ContractSpecificationExtendedRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeId", 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.ScopeId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SpecificationUuid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4487,7 +5797,7 @@ func (m *RecordsByScopeIDRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Name = string(dAtA[iNdEx:postIndex]) + m.SpecificationUuid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -4510,7 +5820,7 @@ func (m *RecordsByScopeIDRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *RecordsByScopeIDResponse) Unmarshal(dAtA []byte) error { +func (m *ContractSpecificationExtendedResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4533,17 +5843,17 @@ func (m *RecordsByScopeIDResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RecordsByScopeIDResponse: wiretype end group for non-group") + return fmt.Errorf("proto: ContractSpecificationExtendedResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RecordsByScopeIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ContractSpecificationExtendedResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeUuid", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ContractSpecification", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4553,59 +5863,31 @@ func (m *RecordsByScopeIDResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.ScopeUuid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeId", 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 m.ContractSpecification == nil { + m.ContractSpecification = &ContractSpecification{} } - if postIndex > l { - return io.ErrUnexpectedEOF + if err := m.ContractSpecification.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.ScopeId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RecordSpecifications", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4632,8 +5914,8 @@ func (m *RecordsByScopeIDResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Records = append(m.Records, &Record{}) - if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.RecordSpecifications = append(m.RecordSpecifications, &RecordSpecification{}) + if err := m.RecordSpecifications[len(m.RecordSpecifications)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4658,7 +5940,7 @@ func (m *RecordsByScopeIDResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *ScopeSpecificationRequest) Unmarshal(dAtA []byte) error { +func (m *RecordSpecificationsForContractSpecificationRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4681,15 +5963,15 @@ func (m *ScopeSpecificationRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ScopeSpecificationRequest: wiretype end group for non-group") + return fmt.Errorf("proto: RecordSpecificationsForContractSpecificationRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ScopeSpecificationRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RecordSpecificationsForContractSpecificationRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpecificationUuid", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ContractSpecificationUuid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4717,7 +5999,7 @@ func (m *ScopeSpecificationRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SpecificationUuid = string(dAtA[iNdEx:postIndex]) + m.ContractSpecificationUuid = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -4740,7 +6022,7 @@ func (m *ScopeSpecificationRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *ScopeSpecificationResponse) Unmarshal(dAtA []byte) error { +func (m *RecordSpecificationsForContractSpecificationResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4763,15 +6045,15 @@ func (m *ScopeSpecificationResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ScopeSpecificationResponse: wiretype end group for non-group") + return fmt.Errorf("proto: RecordSpecificationsForContractSpecificationResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ScopeSpecificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RecordSpecificationsForContractSpecificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeSpecification", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RecordSpecifications", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4798,10 +6080,8 @@ func (m *ScopeSpecificationResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.ScopeSpecification == nil { - m.ScopeSpecification = &ScopeSpecification{} - } - if err := m.ScopeSpecification.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.RecordSpecifications = append(m.RecordSpecifications, &RecordSpecification{}) + if err := m.RecordSpecifications[len(m.RecordSpecifications)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4826,7 +6106,7 @@ func (m *ScopeSpecificationResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *ContractSpecificationRequest) Unmarshal(dAtA []byte) error { +func (m *RecordSpecificationRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4849,15 +6129,15 @@ func (m *ContractSpecificationRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ContractSpecificationRequest: wiretype end group for non-group") + return fmt.Errorf("proto: RecordSpecificationRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ContractSpecificationRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RecordSpecificationRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpecificationUuid", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ContractSpecificationUuid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4885,7 +6165,39 @@ func (m *ContractSpecificationRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SpecificationUuid = string(dAtA[iNdEx:postIndex]) + m.ContractSpecificationUuid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -4908,7 +6220,7 @@ func (m *ContractSpecificationRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *ContractSpecificationResponse) Unmarshal(dAtA []byte) error { +func (m *RecordSpecificationResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4931,15 +6243,15 @@ func (m *ContractSpecificationResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ContractSpecificationResponse: wiretype end group for non-group") + return fmt.Errorf("proto: RecordSpecificationResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ContractSpecificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RecordSpecificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContractSpecification", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RecordSpecification", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4966,10 +6278,10 @@ func (m *ContractSpecificationResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.ContractSpecification == nil { - m.ContractSpecification = &ContractSpecification{} + if m.RecordSpecification == nil { + m.RecordSpecification = &RecordSpecification{} } - if err := m.ContractSpecification.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.RecordSpecification.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/metadata/types/query.pb.gw.go b/x/metadata/types/query.pb.gw.go index fe28608101..ca2a657b3e 100644 --- a/x/metadata/types/query.pb.gw.go +++ b/x/metadata/types/query.pb.gw.go @@ -661,6 +661,190 @@ func local_request_Query_ContractSpecification_0(ctx context.Context, marshaler } +func request_Query_ContractSpecificationExtended_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ContractSpecificationExtendedRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["specification_uuid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "specification_uuid") + } + + protoReq.SpecificationUuid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "specification_uuid", err) + } + + msg, err := client.ContractSpecificationExtended(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ContractSpecificationExtended_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ContractSpecificationExtendedRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["specification_uuid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "specification_uuid") + } + + protoReq.SpecificationUuid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "specification_uuid", err) + } + + msg, err := server.ContractSpecificationExtended(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_RecordSpecificationsForContractSpecification_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RecordSpecificationsForContractSpecificationRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["contract_specification_uuid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "contract_specification_uuid") + } + + protoReq.ContractSpecificationUuid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "contract_specification_uuid", err) + } + + msg, err := client.RecordSpecificationsForContractSpecification(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RecordSpecificationsForContractSpecification_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RecordSpecificationsForContractSpecificationRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["contract_specification_uuid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "contract_specification_uuid") + } + + protoReq.ContractSpecificationUuid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "contract_specification_uuid", err) + } + + msg, err := server.RecordSpecificationsForContractSpecification(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_RecordSpecification_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RecordSpecificationRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["contract_specification_uuid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "contract_specification_uuid") + } + + protoReq.ContractSpecificationUuid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "contract_specification_uuid", err) + } + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.RecordSpecification(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RecordSpecification_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RecordSpecificationRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["contract_specification_uuid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "contract_specification_uuid") + } + + protoReq.ContractSpecificationUuid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "contract_specification_uuid", err) + } + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := server.RecordSpecification(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -897,6 +1081,75 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ContractSpecificationExtended_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ContractSpecificationExtended_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ContractSpecificationExtended_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecordSpecificationsForContractSpecification_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RecordSpecificationsForContractSpecification_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecordSpecificationsForContractSpecification_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecordSpecification_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RecordSpecification_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecordSpecification_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1138,6 +1391,66 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ContractSpecificationExtended_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ContractSpecificationExtended_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_ContractSpecificationExtended_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecordSpecificationsForContractSpecification_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RecordSpecificationsForContractSpecification_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_RecordSpecificationsForContractSpecification_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecordSpecification_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RecordSpecification_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_RecordSpecification_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1161,6 +1474,12 @@ var ( pattern_Query_ScopeSpecification_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"provenance", "metadata", "v1", "scopespec", "specification_uuid"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_ContractSpecification_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"provenance", "metadata", "v1", "contractspec", "specification_uuid"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ContractSpecificationExtended_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"provenance", "metadata", "v1", "contractspec", "specification_uuid", "extended"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_RecordSpecificationsForContractSpecification_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"provenance", "metadata", "v1", "contractspec", "contract_specification_uuid", "recordspecs"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_RecordSpecification_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{"provenance", "metadata", "v1", "recordspec", "contract_specification_uuid", "name"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1183,4 +1502,10 @@ var ( forward_Query_ScopeSpecification_0 = runtime.ForwardResponseMessage forward_Query_ContractSpecification_0 = runtime.ForwardResponseMessage + + forward_Query_ContractSpecificationExtended_0 = runtime.ForwardResponseMessage + + forward_Query_RecordSpecificationsForContractSpecification_0 = runtime.ForwardResponseMessage + + forward_Query_RecordSpecification_0 = runtime.ForwardResponseMessage ) diff --git a/x/metadata/types/scope_test.go b/x/metadata/types/scope_test.go index 19e674aac8..3ac1d385b5 100644 --- a/x/metadata/types/scope_test.go +++ b/x/metadata/types/scope_test.go @@ -459,7 +459,7 @@ func (s *scopeTestSuite) TestSessionString() { Message: "message", }) - println(session.String()) + // println(session.String()) s.T().Run("session string", func(t *testing.T) { require.Equal(t, fmt.Sprintf(`session_id: %s specification_id: %s diff --git a/x/metadata/types/specification.go b/x/metadata/types/specification.go index 8e1e856dcf..83141c4903 100644 --- a/x/metadata/types/specification.go +++ b/x/metadata/types/specification.go @@ -11,12 +11,21 @@ import ( const ( // TODO: Move these to params. + // Default max length for Description.Name maxDescriptionNameLength = 200 // Default max length for Description.Description maxDescriptionDescriptionLength = 5000 // Default max length for a ContractSpecification.ClassName maxContractSpecificationClassNameLength = 1000 + // Default max length for RecordSpecification.Name + maxRecordSpecificationNameLength = 200 + // Default max length for a RecordSpecification.TypeName + maxRecordSpecificationTypeNameLength = 1000 + // Default max length for InputSpecification.Name + maxInputSpecificationNameLength = 200 + // Default max length for a InputSpecification.TypeName + maxInputSpecificationTypeNameLength = 1000 // Default max url length maxURLLength = 2048 ) @@ -99,7 +108,6 @@ func NewContractSpecification( partiesInvolved []PartyType, source isContractSpecification_Source, className string, - recordSpecIDs []MetadataAddress, ) *ContractSpecification { return &ContractSpecification{ SpecificationId: specificationID, @@ -108,21 +116,20 @@ func NewContractSpecification( PartiesInvolved: partiesInvolved, Source: source, ClassName: className, - RecordSpecIds: recordSpecIDs, } } -// NewSourceResourceID creates a new source (for a ContractSpecification) with a resource id -func NewSourceResourceID(resourceID MetadataAddress) *ContractSpecification_ResourceId { +// NewContractSpecificationSourceResourceID creates a new source (for a ContractSpecification) with a resource id +func NewContractSpecificationSourceResourceID(resourceID MetadataAddress) *ContractSpecification_ResourceId { return &ContractSpecification_ResourceId{ResourceId: resourceID} } -// NewSourceHash creates a new source (for a ContractSpecification) with a hash -func NewSourceHash(hash string) *ContractSpecification_Hash { +// NewContractSpecificationSourceHash creates a new source (for a ContractSpecification) with a hash +func NewContractSpecificationSourceHash(hash string) *ContractSpecification_Hash { return &ContractSpecification_Hash{Hash: hash} } -// ValidateBasic performs basic format checking of data in a ScopeSpecification +// ValidateBasic performs basic format checking of data in a ContractSpecification func (s *ContractSpecification) ValidateBasic() error { prefix, err := VerifyMetadataAddressFormat(s.SpecificationId) if err != nil { @@ -131,7 +138,6 @@ func (s *ContractSpecification) ValidateBasic() error { if prefix != PrefixContractSpecification { return fmt.Errorf("invalid contract specification id prefix (expected: %s, got %s)", PrefixContractSpecification, prefix) } - contractSpecUUID, _ := s.SpecificationId.ContractSpecUUID() if s.Description != nil { err = s.Description.ValidateBasic("ContractSpecification.Description") if err != nil { @@ -172,21 +178,6 @@ func (s *ContractSpecification) ValidateBasic() error { return fmt.Errorf("class name exceeds maximum length (expected <= %d got: %d)", maxContractSpecificationClassNameLength, len(s.ClassName)) } - for i, recordSpecID := range s.RecordSpecIds { - prefix, err = VerifyMetadataAddressFormat(recordSpecID) - if err != nil { - return fmt.Errorf("invalid record specification id at index %d: %w", i, err) - } - if prefix != PrefixRecordSpecification { - return fmt.Errorf("invalid record specification id prefix at index %d (expected: %s, got %s)", - i, PrefixRecordSpecification, prefix) - } - recSpecContractSpecUUID, _ := recordSpecID.ContractSpecUUID() - if recSpecContractSpecUUID != contractSpecUUID { - return fmt.Errorf("invalid record specification id contract specification uuid value at index %d (expected :%s, got %s)", - i, contractSpecUUID.String(), recSpecContractSpecUUID.String()) - } - } return nil } @@ -196,11 +187,141 @@ func (s ContractSpecification) String() string { return string(out) } +// NewRecordSpecification creates a new RecordSpecification instance +func NewRecordSpecification( + specificationID MetadataAddress, + name string, + inputs []*InputSpecification, + typeName string, + resultType DefinitionType, + responsibleParties []PartyType, +) *RecordSpecification { + return &RecordSpecification{ + SpecificationId: specificationID, + Name: name, + Inputs: inputs, + TypeName: typeName, + ResultType: resultType, + ResponsibleParties: responsibleParties, + } +} + +// ValidateBasic performs basic format checking of data in a RecordSpecification func (s *RecordSpecification) ValidateBasic() error { - // TODO: implement + prefix, err := VerifyMetadataAddressFormat(s.SpecificationId) + if err != nil { + return fmt.Errorf("invalid record specification id: %w", err) + } + if prefix != PrefixRecordSpecification { + return fmt.Errorf("invalid record specification id prefix (expected: %s, got %s)", + PrefixRecordSpecification, prefix) + } + if len(s.Name) == 0 { + return errors.New("record specification name cannot be empty") + } + if len(s.Name) > maxRecordSpecificationNameLength { + return fmt.Errorf("record specification name exceeds maximum length (expected <= %d got: %d)", + maxRecordSpecificationNameLength, len(s.Name)) + } + // Make sure the provided specification id is correct. + contractSpecUUID, _ := s.SpecificationId.ContractSpecUUID() + expectedID := RecordSpecMetadataAddress(contractSpecUUID, s.Name) + if !s.SpecificationId.Equals(expectedID) { + return fmt.Errorf("invalid record specification id value (expected: %s, got %s)", + expectedID, s.SpecificationId) + } + for i, inputSpec := range s.Inputs { + if err := inputSpec.ValidateBasic(); err != nil { + return fmt.Errorf("invalid input specification at index %d: %w", i, err) + } + } + if len(s.TypeName) == 0 { + return errors.New("record specification type name cannot be empty") + } + if len(s.TypeName) > maxRecordSpecificationTypeNameLength { + return fmt.Errorf("record specification type name exceeds maximum length (expected <= %d got: %d)", + maxRecordSpecificationTypeNameLength, len(s.TypeName)) + } + if len(s.ResponsibleParties) == 0 { + return fmt.Errorf("invalid responsible parties count (expected > 0 got: %d)", len(s.ResponsibleParties)) + } + return nil +} + +// String implements stringer interface +func (s RecordSpecification) String() string { + out, _ := yaml.Marshal(s) + return string(out) +} + +// NewInputSpecification creates a new InputSpecification instance +func NewInputSpecification( + name string, + typeName string, + source isInputSpecification_Source, +) *InputSpecification { + return &InputSpecification{ + Name: name, + TypeName: typeName, + Source: source, + } +} + +// NewInputSpecificationSourceRecordID creates a new source (for an InputSpecification) with a resource id +func NewInputSpecificationSourceRecordID(recordID MetadataAddress) *InputSpecification_RecordId { + return &InputSpecification_RecordId{RecordId: recordID} +} + +// NewContractSpecificationSourceHash creates a new source (for a InputSpecification) with a hash +func NewInputSpecificationSourceHash(hash string) *InputSpecification_Hash { + return &InputSpecification_Hash{Hash: hash} +} + +// ValidateBasic performs basic format checking of data in a InputSpecification +func (s *InputSpecification) ValidateBasic() error { + if len(s.Name) == 0 { + return errors.New("input specification name cannot be empty") + } + if len(s.Name) > maxInputSpecificationNameLength { + return fmt.Errorf("input specification name exceeds maximum length (expected <= %d got: %d)", + maxInputSpecificationNameLength, len(s.Name)) + } + if len(s.TypeName) == 0 { + return errors.New("input specification type name cannot be empty") + } + if len(s.TypeName) > maxInputSpecificationTypeNameLength { + return fmt.Errorf("input specification type name exceeds maximum length (expected <= %d got: %d)", + maxInputSpecificationTypeNameLength, len(s.TypeName)) + } + if s.Source == nil { + return errors.New("input specification source is required") + } + switch source := s.Source.(type) { + case *InputSpecification_RecordId: + prefix, err := VerifyMetadataAddressFormat(source.RecordId) + if err != nil { + return fmt.Errorf("invalid input specification source record id: %w", err) + } + if prefix != PrefixRecord { + return fmt.Errorf("invalid input specification source record id prefix (expected: %s, got: %s)", + PrefixRecord, prefix) + } + case *InputSpecification_Hash: + if len(source.Hash) == 0 { + return errors.New("input specification source hash cannot be empty") + } + default: + return errors.New("unknown input specification source type") + } return nil } +// String implements stringer interface +func (s InputSpecification) String() string { + out, _ := yaml.Marshal(s) + return string(out) +} + // NewDescription creates a new Description instance. func NewDescription(name, description, websiteURL, iconURL string) *Description { return &Description{ diff --git a/x/metadata/types/specification.pb.go b/x/metadata/types/specification.pb.go index 8b609b8d52..ee4c61691e 100644 --- a/x/metadata/types/specification.pb.go +++ b/x/metadata/types/specification.pb.go @@ -202,9 +202,6 @@ type ContractSpecification struct { Source isContractSpecification_Source `protobuf_oneof:"source"` // name of the class/type of this contract executable ClassName string `protobuf:"bytes,7,opt,name=class_name,json=className,proto3" json:"class_name,omitempty" yaml:"class_name"` - // a collection of ids of checks (RecordSpecifications) that must be satisfied against a scope prior to - // allowing a record to be added under this specification - RecordSpecIds []MetadataAddress `protobuf:"bytes,8,rep,name=record_spec_ids,json=recordSpecIds,proto3,customtype=MetadataAddress" json:"record_spec_ids" yaml:"record_spec_ids"` } func (m *ContractSpecification) Reset() { *m = ContractSpecification{} } @@ -318,12 +315,11 @@ type RecordSpecification struct { // Type of result for this record specification (must be RECORD or RECORD_LIST) ResultType DefinitionType `protobuf:"varint,5,opt,name=result_type,json=resultType,proto3,enum=provenance.metadata.v1.DefinitionType" json:"result_type,omitempty" yaml:"result_type"` // Type of party responsible for this record - ResponsibleParty PartyType `protobuf:"varint,6,opt,name=responsible_party,json=responsibleParty,proto3,enum=provenance.metadata.v1.PartyType" json:"responsible_party,omitempty" yaml:"responsible_party"` + ResponsibleParties []PartyType `protobuf:"varint,6,rep,packed,name=responsible_parties,json=responsibleParties,proto3,enum=provenance.metadata.v1.PartyType" json:"responsible_parties,omitempty" yaml:"responsible_parties"` } -func (m *RecordSpecification) Reset() { *m = RecordSpecification{} } -func (m *RecordSpecification) String() string { return proto.CompactTextString(m) } -func (*RecordSpecification) ProtoMessage() {} +func (m *RecordSpecification) Reset() { *m = RecordSpecification{} } +func (*RecordSpecification) ProtoMessage() {} func (*RecordSpecification) Descriptor() ([]byte, []int) { return fileDescriptor_1e2d1042057ea889, []int{2} } @@ -382,11 +378,11 @@ func (m *RecordSpecification) GetResultType() DefinitionType { return DefinitionType_DEFINITION_TYPE_UNSPECIFIED } -func (m *RecordSpecification) GetResponsibleParty() PartyType { +func (m *RecordSpecification) GetResponsibleParties() []PartyType { if m != nil { - return m.ResponsibleParty + return m.ResponsibleParties } - return PartyType_PARTY_TYPE_UNSPECIFIED + return nil } // InputSpecification defines a name, type_name, and source reference (either on or off chain) to define an input @@ -404,9 +400,8 @@ type InputSpecification struct { Source isInputSpecification_Source `protobuf_oneof:"source"` } -func (m *InputSpecification) Reset() { *m = InputSpecification{} } -func (m *InputSpecification) String() string { return proto.CompactTextString(m) } -func (*InputSpecification) ProtoMessage() {} +func (m *InputSpecification) Reset() { *m = InputSpecification{} } +func (*InputSpecification) ProtoMessage() {} func (*InputSpecification) Descriptor() ([]byte, []int) { return fileDescriptor_1e2d1042057ea889, []int{3} } @@ -576,68 +571,67 @@ func init() { } var fileDescriptor_1e2d1042057ea889 = []byte{ - // 976 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xcd, 0x6e, 0xe2, 0x56, - 0x14, 0xc6, 0x31, 0x21, 0x70, 0x99, 0x06, 0xe7, 0x86, 0x30, 0x9e, 0xcc, 0x08, 0xa8, 0x2b, 0xb5, - 0x34, 0x52, 0x41, 0x61, 0x46, 0xaa, 0x34, 0x3b, 0x7e, 0x4c, 0xe7, 0x4a, 0x19, 0x83, 0x2e, 0x90, - 0x2a, 0x95, 0x2a, 0xcb, 0xb1, 0xef, 0x24, 0x57, 0x35, 0xb6, 0x65, 0x1b, 0xa6, 0xbc,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7, 0x09, 0x00, 0x00, + // 957 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xcd, 0x8e, 0xda, 0x56, + 0x14, 0xc6, 0x63, 0x86, 0x81, 0x4b, 0x34, 0x38, 0x77, 0x18, 0xe2, 0x4c, 0x2a, 0x4c, 0x5d, 0xa9, + 0xa5, 0x23, 0x15, 0x34, 0x24, 0x52, 0xa5, 0xec, 0xf8, 0x31, 0xcd, 0x95, 0x26, 0x06, 0x5d, 0x60, + 0xaa, 0x54, 0xaa, 0x2c, 0x8f, 0x7d, 0x33, 0x63, 0x15, 0x6c, 0xcb, 0x36, 0xa4, 0xf3, 0x0e, 0x5d, + 0x74, 0xd7, 0x2e, 0xfb, 0x0c, 0x7d, 0x8a, 0x74, 0x97, 0xee, 0xaa, 0x2c, 0x50, 0x35, 0xf3, 0x04, + 0xe5, 0x09, 0xaa, 0x7b, 0x6d, 0xc0, 0x78, 0x40, 0xca, 0xa6, 0x5d, 0x65, 0x77, 0xcf, 0xf9, 0xbe, + 0x73, 0x7c, 0xfc, 0x9d, 0xcf, 0x57, 0x06, 0xa7, 0xae, 0xe7, 0xcc, 0x88, 0xad, 0xdb, 0x06, 0xa9, + 0x4f, 0x48, 0xa0, 0x9b, 0x7a, 0xa0, 0xd7, 0x67, 0x67, 0x75, 0xdf, 0x25, 0x86, 0xf5, 0xda, 0x32, + 0xf4, 0xc0, 0x72, 0xec, 0x9a, 0xeb, 0x39, 0x81, 0x03, 0x4b, 0x6b, 0x6e, 0x6d, 0xc9, 0xad, 0xcd, + 0xce, 0x4e, 0x8a, 0x57, 0xce, 0x95, 0xc3, 0x28, 0x75, 0x7a, 0x0a, 0xd9, 0xf2, 0x9f, 0x3c, 0x80, + 0x03, 0xc3, 0x71, 0xc9, 0x20, 0xde, 0x0a, 0x7e, 0x0f, 0x84, 0x8d, 0xde, 0x9a, 0x65, 0x8a, 0x5c, +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 0x14, 0x78, 0x6c, 0x39, 0x3b, 0x3e, 0xbe, 0x3e, 0xf7, + 0xdd, 0xb3, 0x2b, 0x2b, 0xb8, 0x9e, 0x5e, 0xd6, 0x0c, 0x67, 0x52, 0x5f, 0x93, 0xbe, 0xb2, 0x9c, + 0x58, 0x54, 0xff, 0x71, 0xfd, 0xeb, 0x45, 0xbf, 0x0a, 0xff, 0x32, 0xc3, 0x7e, 0xa1, 0x9e, 0xfe, + 0x1b, 0x00, 0x00, 0xff, 0xff, 0x02, 0x4e, 0x99, 0x71, 0x9e, 0x09, 0x00, 0x00, } func (m *ScopeSpecification) Marshal() (dAtA []byte, err error) { @@ -746,20 +740,6 @@ func (m *ContractSpecification) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.RecordSpecIds) > 0 { - for iNdEx := len(m.RecordSpecIds) - 1; iNdEx >= 0; iNdEx-- { - { - size := m.RecordSpecIds[iNdEx].Size() - i -= size - if _, err := m.RecordSpecIds[iNdEx].MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintSpecification(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } - } if len(m.ClassName) > 0 { i -= len(m.ClassName) copy(dAtA[i:], m.ClassName) @@ -881,10 +861,23 @@ func (m *RecordSpecification) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.ResponsibleParty != 0 { - i = encodeVarintSpecification(dAtA, i, uint64(m.ResponsibleParty)) + if len(m.ResponsibleParties) > 0 { + dAtA8 := make([]byte, len(m.ResponsibleParties)*10) + var j7 int + for _, num := range m.ResponsibleParties { + for num >= 1<<7 { + dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j7++ + } + dAtA8[j7] = uint8(num) + j7++ + } + i -= j7 + copy(dAtA[i:], dAtA8[:j7]) + i = encodeVarintSpecification(dAtA, i, uint64(j7)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x32 } if m.ResultType != 0 { i = encodeVarintSpecification(dAtA, i, uint64(m.ResultType)) @@ -1139,12 +1132,6 @@ func (m *ContractSpecification) Size() (n int) { if l > 0 { n += 1 + l + sovSpecification(uint64(l)) } - if len(m.RecordSpecIds) > 0 { - for _, e := range m.RecordSpecIds { - l = e.Size() - n += 1 + l + sovSpecification(uint64(l)) - } - } return n } @@ -1193,8 +1180,12 @@ func (m *RecordSpecification) Size() (n int) { if m.ResultType != 0 { n += 1 + sovSpecification(uint64(m.ResultType)) } - if m.ResponsibleParty != 0 { - n += 1 + sovSpecification(uint64(m.ResponsibleParty)) + if len(m.ResponsibleParties) > 0 { + l = 0 + for _, e := range m.ResponsibleParties { + l += sovSpecification(uint64(e)) + } + n += 1 + sovSpecification(uint64(l)) + l } return n } @@ -1824,41 +1815,6 @@ func (m *ContractSpecification) Unmarshal(dAtA []byte) error { } m.ClassName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RecordSpecIds", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSpecification - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSpecification - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSpecification - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v MetadataAddress - m.RecordSpecIds = append(m.RecordSpecIds, v) - if err := m.RecordSpecIds[len(m.RecordSpecIds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSpecification(dAtA[iNdEx:]) @@ -2060,23 +2016,73 @@ func (m *RecordSpecification) Unmarshal(dAtA []byte) error { } } case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ResponsibleParty", wireType) - } - m.ResponsibleParty = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSpecification + if wireType == 0 { + var v PartyType + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpecification + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= PartyType(b&0x7F) << shift + if b < 0x80 { + break + } } - if iNdEx >= l { + m.ResponsibleParties = append(m.ResponsibleParties, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpecification + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthSpecification + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthSpecification + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - m.ResponsibleParty |= PartyType(b&0x7F) << shift - if b < 0x80 { - break + var elementCount int + if elementCount != 0 && len(m.ResponsibleParties) == 0 { + m.ResponsibleParties = make([]PartyType, 0, elementCount) + } + for iNdEx < postIndex { + var v PartyType + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpecification + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= PartyType(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ResponsibleParties = append(m.ResponsibleParties, v) } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ResponsibleParties", wireType) } default: iNdEx = preIndex diff --git a/x/metadata/types/specification_test.go b/x/metadata/types/specification_test.go index cbc0c72c3a..ba25b71e97 100644 --- a/x/metadata/types/specification_test.go +++ b/x/metadata/types/specification_test.go @@ -38,7 +38,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { name string spec *ScopeSpecification want string - wantErr bool }{ // SpecificationId tests. { @@ -48,7 +47,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { nil, []string{}, []PartyType{}, []MetadataAddress{}, ), "invalid scope specification id: invalid metadata address type: 133", - true, }, { "invalid scope specification id - identifier", @@ -57,7 +55,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { nil, []string{}, []PartyType{}, []MetadataAddress{}, ), "invalid scope specification id prefix (expected: scopespec, got scope)", - true, }, // Description test to make sure Description.ValidateBasic is being used. { @@ -67,8 +64,7 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { NewDescription(strings.Repeat("x", maxDescriptionNameLength+1), "", "", ""), []string{}, []PartyType{}, []MetadataAddress{}, ), - fmt.Sprintf("description (ScopeSpecification.Description) Name exceeds maximum length (expected <= %d got: %d)", maxDescriptionNameLength, maxDescriptionNameLength+1), - true, + fmt.Sprintf("description (ScopeSpecification.Description) Name exceeds maximum length (expected <= %d got: %d)", maxDescriptionNameLength, maxDescriptionNameLength + 1), }, // OwnerAddresses tests { @@ -80,7 +76,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { []PartyType{}, []MetadataAddress{}, ), "the ScopeSpecification must have at least one owner", - true, }, { "owner addresses - invalid address at index 0", @@ -91,7 +86,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { []PartyType{}, []MetadataAddress{}, ), "invalid owner address at index 0 on ScopeSpecification: decoding bech32 failed: invalid index of 1", - true, }, { "owner addresses - invalid address at index 3", @@ -102,7 +96,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { []PartyType{}, []MetadataAddress{}, ), "invalid owner address at index 3 on ScopeSpecification: decoding bech32 failed: invalid index of 1", - true, }, // parties involved - cannot be empty { @@ -115,7 +108,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { []MetadataAddress{}, ), "the ScopeSpecification must have at least one party involved", - true, }, // contract spec ids - must all pass same tests as scope spec id (contractspec prefix) { @@ -128,7 +120,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { []MetadataAddress{MetadataAddress(specTestAddr)}, ), "invalid contract specification id at index 0: invalid metadata address type: 133", - true, }, { "contract spec ids - wrong prefix at index 0", @@ -140,7 +131,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { []MetadataAddress{ScopeMetadataAddress(uuid.New())}, ), "invalid contract specification id prefix at index 0 (expected: contractspec, got scope)", - true, }, { "contract spec ids - wrong address type at index 2", @@ -152,7 +142,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { []MetadataAddress{ContractSpecMetadataAddress(uuid.New()), ContractSpecMetadataAddress(uuid.New()), MetadataAddress(specTestAddr)}, ), "invalid contract specification id at index 2: invalid metadata address type: 133", - true, }, { "contract spec ids - wrong prefix at index 2", @@ -164,7 +153,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { []MetadataAddress{ContractSpecMetadataAddress(uuid.New()), ContractSpecMetadataAddress(uuid.New()), ScopeMetadataAddress(uuid.New())}, ), "invalid contract specification id prefix at index 2 (expected: contractspec, got scope)", - true, }, // Simple valid case { @@ -177,7 +165,6 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { []MetadataAddress{ContractSpecMetadataAddress(uuid.New())}, ), "", - false, }, } @@ -185,12 +172,10 @@ func (s *specificationTestSuite) TestScopeSpecValidateBasic() { tt := tt s.T().Run(tt.name, func(t *testing.T) { err := tt.spec.ValidateBasic() - if (err != nil) != tt.wantErr { - t.Errorf("ScopeSpec ValidateBasic error = %v, wantErr %v", err, tt.wantErr) - return - } - if tt.wantErr { - require.Equal(t, tt.want, err.Error()) + if err != nil { + require.Equal(t, tt.want, err.Error(), "ScopeSpecification ValidateBasic error") + } else if len(tt.want) > 0 { + t.Errorf("ScopeSpecification ValidateBasic error = nil, expected: %s", tt.want) } }) } @@ -211,8 +196,10 @@ func encodeVarintSpecTests(dAtA []byte, offset int, v uint64) int { return base } -// WeirdSoure is a thing that satisfies all needed pieces of the isContractSpecification_Source interface -// but isn't a valid thing to use as a Source according to the ContractSpecification.ValidateBasic() method. +// WeirdSource is a thing that satisfies all needed pieces of the +// isContractSpecification_Source and isRecordSpecification_Source interfaces. +// But it isn't a valid thing to use as a Source according to the +// ContractSpecification.ValidateBasic() and RecordSpecification.ValidateBasic() methods. type WeirdSource struct { Value uint32 } @@ -223,6 +210,7 @@ func NewWeirdSource(value uint32) *WeirdSource { } } func (*WeirdSource) isContractSpecification_Source() {} +func (*WeirdSource) isInputSpecification_Source() {} func (m *WeirdSource) Size() (n int) { return 1 + sovSpecTests(uint64(n)) } @@ -242,7 +230,6 @@ func (m *WeirdSource) MarshalToSizedBuffer(dAtA []byte) (int, error) { func (s *specificationTestSuite) TestContractSpecValidateBasic() { contractSpecUuid1 := uuid.New() - contractSpecUuid2 := uuid.New() tests := []struct { name string spec *ContractSpecification @@ -256,9 +243,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{specTestBech32}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), + NewContractSpecificationSourceHash("somehash"), "someclass", - []MetadataAddress{}, ), "invalid contract specification id: invalid metadata address type: 133", }, @@ -269,9 +255,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{specTestBech32}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), + NewContractSpecificationSourceHash("somehash"), "someclass", - []MetadataAddress{}, ), "invalid contract specification id prefix (expected: contractspec, got scopespec)", }, @@ -284,9 +269,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { NewDescription(strings.Repeat("x", maxDescriptionNameLength+1), "", "", ""), []string{specTestBech32}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), + NewContractSpecificationSourceHash("somehash"), "someclass", - []MetadataAddress{}, ), fmt.Sprintf("description (ContractSpecification.Description) Name exceeds maximum length (expected <= %d got: %d)", maxDescriptionNameLength, maxDescriptionNameLength+1), }, @@ -299,9 +283,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), + NewContractSpecificationSourceHash("somehash"), "someclass", - []MetadataAddress{}, ), "invalid owner addresses count (expected > 0 got: 0)", }, @@ -312,9 +295,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{":invalid"}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), + NewContractSpecificationSourceHash("somehash"), "someclass", - []MetadataAddress{}, ), fmt.Sprintf("invalid owner address at index %d: %s", 0, "decoding bech32 failed: invalid index of 1"), @@ -326,9 +308,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{specTestBech32, specTestBech32, ":invalid"}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), + NewContractSpecificationSourceHash("somehash"), "someclass", - []MetadataAddress{}, ), fmt.Sprintf("invalid owner address at index %d: %s", 2, "decoding bech32 failed: invalid index of 1"), @@ -342,9 +323,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{specTestBech32}, []PartyType{}, - NewSourceHash("somehash"), + NewContractSpecificationSourceHash("somehash"), "someclass", - []MetadataAddress{}, ), "invalid parties involved count (expected > 0 got: 0)", }, @@ -359,7 +339,6 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { []PartyType{PartyType_PARTY_TYPE_OWNER}, nil, "someclass", - []MetadataAddress{}, ), "a source is required", }, @@ -370,9 +349,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{specTestBech32}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceResourceID(MetadataAddress(specTestAddr)), + NewContractSpecificationSourceResourceID(MetadataAddress(specTestAddr)), "someclass", - []MetadataAddress{}, ), fmt.Sprintf("invalid source resource id: %s", "invalid metadata address type: 133"), }, @@ -383,9 +361,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{specTestBech32}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash(""), + NewContractSpecificationSourceHash(""), "someclass", - []MetadataAddress{}, ), "source hash cannot be empty", }, @@ -398,7 +375,6 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { []PartyType{PartyType_PARTY_TYPE_OWNER}, NewWeirdSource(3), "someclass", - []MetadataAddress{}, ), "unknown source type", }, @@ -411,9 +387,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{specTestBech32}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), + NewContractSpecificationSourceHash("somehash"), "", - []MetadataAddress{}, ), "class name cannot be empty", }, @@ -424,9 +399,8 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{specTestBech32}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), - strings.Repeat("l", maxContractSpecificationClassNameLength+1), - []MetadataAddress{}, + NewContractSpecificationSourceHash("somehash"), + strings.Repeat("l", maxContractSpecificationClassNameLength + 1), ), fmt.Sprintf("class name exceeds maximum length (expected <= %d got: %d)", maxContractSpecificationClassNameLength, maxContractSpecificationClassNameLength+1), @@ -438,121 +412,264 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { nil, []string{specTestBech32}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), + NewContractSpecificationSourceHash("somehash"), strings.Repeat("m", maxContractSpecificationClassNameLength), - []MetadataAddress{}, ), "", }, - // RecordSpecIDs tests + // A simple valid ContractSpecification { - "RecordSpecIDs - invalid address at index 0", + "simple valid test case", NewContractSpecification( - ContractSpecMetadataAddress(uuid.New()), + ContractSpecMetadataAddress(contractSpecUuid1), nil, []string{specTestBech32}, []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), + NewContractSpecificationSourceHash("somehash"), "someclass", - []MetadataAddress{MetadataAddress(specTestAddr)}, ), - fmt.Sprintf("invalid record specification id at index %d: %s", - 0, "invalid metadata address type: 133"), + "", }, + } + + for _, tt := range tests { + tt := tt + s.T().Run(tt.name, func(t *testing.T) { + err := tt.spec.ValidateBasic() + if err != nil { + require.Equal(t, tt.want, err.Error(), "ContractSpecification ValidateBasic error") + } else if len(tt.want) > 0 { + t.Errorf("ContractSpecification ValidateBasic error = nil, expected: %s", tt.want) + } + }) + } +} + +func (s *specificationTestSuite) TestRecordSpecValidateBasic() { + contractSpecUUID := uuid.New() + tests := []struct { + name string + spec *RecordSpecification + want string + }{ + // SpecificationId tests { - "RecordSpecIDs - invalid address prefix at index 0", - NewContractSpecification( - ContractSpecMetadataAddress(uuid.New()), - nil, - []string{specTestBech32}, - []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), - "someclass", - []MetadataAddress{ContractSpecMetadataAddress(uuid.New())}, - ), - "invalid record specification id prefix at index 0 (expected: recspec, got contractspec)", + "SpecificationId - invalid format", + &RecordSpecification{ + SpecificationId: MetadataAddress(specTestAddr), + Name: "recspecname", + Inputs: []*InputSpecification{}, + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + "invalid record specification id: invalid metadata address type: 133", }, { - "RecordSpecIDs - wrong contract spec uuid at index 0", - NewContractSpecification( - ContractSpecMetadataAddress(contractSpecUuid1), - nil, - []string{specTestBech32}, - []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), - "someclass", - []MetadataAddress{RecordSpecMetadataAddress(contractSpecUuid2, "cs2")}, - ), - fmt.Sprintf("invalid record specification id contract specification uuid value at index %d (expected :%s, got %s)", - 0, contractSpecUuid1.String(), contractSpecUuid2.String()), + "SpecificationId - invalid prefix (record)", + &RecordSpecification{ + SpecificationId: RecordMetadataAddress(contractSpecUUID, "recspecname"), + Name: "recspecname", + Inputs: []*InputSpecification{}, + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + fmt.Sprintf("invalid record specification id prefix (expected: %s, got %s)", + PrefixRecordSpecification, PrefixRecord), }, { - "RecordSpecIDs - invalid address at index 2", - NewContractSpecification( - ContractSpecMetadataAddress(contractSpecUuid1), - nil, - []string{specTestBech32}, - []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), - "someclass", - []MetadataAddress{ - RecordSpecMetadataAddress(contractSpecUuid1, "name1"), - RecordSpecMetadataAddress(contractSpecUuid1, "name2"), - MetadataAddress(specTestAddr), - }, - ), - fmt.Sprintf("invalid record specification id at index %d: %s", - 2, "invalid metadata address type: 133"), + "SpecificationId - invalid prefix (contract spec)", + &RecordSpecification{ + SpecificationId: ContractSpecMetadataAddress(contractSpecUUID), + Name: "recspecname", + Inputs: []*InputSpecification{}, + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + fmt.Sprintf("invalid record specification id prefix (expected: %s, got %s)", + PrefixRecordSpecification, PrefixContractSpecification), }, { - "RecordSpecIDs - invalid address prefix at index 2", - NewContractSpecification( - ContractSpecMetadataAddress(contractSpecUuid1), - nil, - []string{specTestBech32}, - []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), - "someclass", - []MetadataAddress{ - RecordSpecMetadataAddress(contractSpecUuid1, "name1"), - RecordSpecMetadataAddress(contractSpecUuid1, "name2"), - ContractSpecMetadataAddress(contractSpecUuid1), + "SpecificationId - incorrect name hash", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, "recspecothername"), + Name: "recspecname", + Inputs: []*InputSpecification{}, + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + fmt.Sprintf("invalid record specification id value (expected: %s, got %s)", + RecordSpecMetadataAddress(contractSpecUUID, "recspecname"), + RecordSpecMetadataAddress(contractSpecUUID, "recspecothername")), + }, + + // Name tests + { + "Name - empty", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, "recspecname"), + Name: "", + Inputs: []*InputSpecification{}, + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + "record specification name cannot be empty", + }, + { + "Name - too long", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, "recspecname"), + Name: strings.Repeat("r", maxRecordSpecificationNameLength + 1), + Inputs: []*InputSpecification{}, + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + fmt.Sprintf("record specification name exceeds maximum length (expected <= %d got: %d)", + maxRecordSpecificationNameLength, maxRecordSpecificationNameLength + 1), + }, + { + "Name - max length - okay", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, strings.Repeat("r", maxRecordSpecificationNameLength)), + Name: strings.Repeat("r", maxRecordSpecificationNameLength), + Inputs: []*InputSpecification{}, + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + "", + }, + + // Inputs tests + { + "Inputs - invalid name at index 0", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, "recspecname"), + Name: "recspecname", + Inputs: []*InputSpecification{ + { + Name: "", + TypeName: "typename1", + Source: NewInputSpecificationSourceHash("inputspecsourcehash1"), + }, + { + Name: "name2", + TypeName: "typename2", + Source: NewInputSpecificationSourceHash("inputspecsourcehash2"), + }, + { + Name: "name3", + TypeName: "typename3", + Source: NewInputSpecificationSourceHash("inputspecsourcehash3"), + }, }, - ), - "invalid record specification id prefix at index 2 (expected: recspec, got contractspec)", + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + fmt.Sprintf("invalid input specification at index %d: %s", + 0, "input specification name cannot be empty"), }, { - "RecordSpecIDs - wrong contract spec uuid at index 0", - NewContractSpecification( - ContractSpecMetadataAddress(contractSpecUuid1), - nil, - []string{specTestBech32}, - []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), - "someclass", - []MetadataAddress{ - RecordSpecMetadataAddress(contractSpecUuid1, "name1"), - RecordSpecMetadataAddress(contractSpecUuid1, "name2"), - RecordSpecMetadataAddress(contractSpecUuid2, "name3"), + "Inputs - invalid name at index 2", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, "recspecname"), + Name: "recspecname", + Inputs: []*InputSpecification{ + { + Name: "name1", + TypeName: "typename1", + Source: NewInputSpecificationSourceHash("inputspecsourcehash1"), + }, + { + Name: "name2", + TypeName: "typename2", + Source: NewInputSpecificationSourceHash("inputspecsourcehash2"), + }, + { + Name: "", + TypeName: "typename3", + Source: NewInputSpecificationSourceHash("inputspecsourcehash3"), + }, }, - ), - fmt.Sprintf("invalid record specification id contract specification uuid value at index %d (expected :%s, got %s)", - 2, contractSpecUuid1.String(), contractSpecUuid2.String()), + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + fmt.Sprintf("invalid input specification at index %d: %s", + 2, "input specification name cannot be empty"), }, - // A simple valid ContractSpecification + // TypeName tests { - "simple valid test case", - NewContractSpecification( - ContractSpecMetadataAddress(contractSpecUuid1), - nil, - []string{specTestBech32}, - []PartyType{PartyType_PARTY_TYPE_OWNER}, - NewSourceHash("somehash"), - "someclass", - []MetadataAddress{RecordSpecMetadataAddress(contractSpecUuid1, "recspecname")}, - ), + "TypeName - empty", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, "recspecname"), + Name: "recspecname", + Inputs: []*InputSpecification{}, + TypeName: "", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + "record specification type name cannot be empty", + }, + { + "TypeName - too long", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, "recspecname"), + Name: "recspecname", + Inputs: []*InputSpecification{}, + TypeName: strings.Repeat("t", maxRecordSpecificationTypeNameLength + 1), + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + fmt.Sprintf("record specification type name exceeds maximum length (expected <= %d got: %d)", + maxRecordSpecificationTypeNameLength, maxRecordSpecificationTypeNameLength + 1), + }, + { + "TypeName - max length - okay", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, "recspecname"), + Name: "recspecname", + Inputs: []*InputSpecification{}, + TypeName: strings.Repeat("t", maxRecordSpecificationTypeNameLength), + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, + "", + }, + + // ResponsibleParties tests + { + "ResponsibleParties - empty", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, "recspecname"), + Name: "recspecname", + Inputs: []*InputSpecification{}, + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{}, + }, + "invalid responsible parties count (expected > 0 got: 0)", + }, + + // A simple valid RecordSpecification + { + "simple valid RecordSpecification", + &RecordSpecification{ + SpecificationId: RecordSpecMetadataAddress(contractSpecUUID, "recspecname"), + Name: "recspecname", + Inputs: []*InputSpecification{}, + TypeName: "recspectypename", + ResultType: DefinitionType_DEFINITION_TYPE_RECORD, + ResponsibleParties: []PartyType{PartyType_PARTY_TYPE_OWNER}, + }, "", }, } @@ -562,9 +679,148 @@ func (s *specificationTestSuite) TestContractSpecValidateBasic() { s.T().Run(tt.name, func(t *testing.T) { err := tt.spec.ValidateBasic() if err != nil { - require.Equal(t, tt.want, err.Error(), "ContractSpecification ValidateBasic error") + require.Equal(t, tt.want, err.Error(), "RecordSpecification ValidateBasic error") } else if len(tt.want) > 0 { - t.Errorf("ContractSpecification ValidateBasic error = nil, expected: %s", tt.want) + t.Errorf("RecordSpecification ValidateBasic error = nil, expected: %s", tt.want) + } + }) + } +} + +func (s *specificationTestSuite) TestInputSpecValidateBasic() { + tests := []struct { + name string + spec *InputSpecification + want string + }{ + // Name tests + { + "Name - empty", + &InputSpecification{ + Name: "", + TypeName: "typename", + Source: NewInputSpecificationSourceHash("inputspecsourcehash"), + }, + "input specification name cannot be empty", + }, + { + "Name - too long", + &InputSpecification{ + Name: strings.Repeat("i", maxInputSpecificationNameLength + 1), + TypeName: "typename", + Source: NewInputSpecificationSourceHash("inputspecsourcehash"), + }, + fmt.Sprintf("input specification name exceeds maximum length (expected <= %d got: %d)", + maxInputSpecificationNameLength, maxInputSpecificationNameLength + 1), + }, + { + "Name - at max length - okay", + &InputSpecification{ + Name: strings.Repeat("i", maxInputSpecificationNameLength), + TypeName: "typename", + Source: NewInputSpecificationSourceHash("inputspecsourcehash"), + }, + "", + }, + + // TypeName tests + { + "TypeName - empty", + &InputSpecification{ + Name: "name", + TypeName: "", + Source: NewInputSpecificationSourceHash("inputspecsourcehash"), + }, + "input specification type name cannot be empty", + }, + { + "TypeName - too long", + &InputSpecification{ + Name: "name", + TypeName: strings.Repeat("i", maxInputSpecificationTypeNameLength + 1), + Source: NewInputSpecificationSourceHash("inputspecsourcehash"), + }, + fmt.Sprintf("input specification type name exceeds maximum length (expected <= %d got: %d)", + maxInputSpecificationTypeNameLength, maxInputSpecificationTypeNameLength + 1), + }, + { + "TypeName - at max length - okay", + &InputSpecification{ + Name: "name", + TypeName: strings.Repeat("i", maxInputSpecificationTypeNameLength), + Source: NewInputSpecificationSourceHash("inputspecsourcehash"), + }, + "", + }, + + // Source tests + { + "Source - nil", + &InputSpecification{ + Name: "name", + TypeName: "typename", + Source: nil, + }, + "input specification source is required", + }, + { + "Source - RecordId - not a metadata address", + &InputSpecification{ + Name: "name", + TypeName: "typename", + Source: NewInputSpecificationSourceRecordID(MetadataAddress(specTestAddr)), + }, + "invalid input specification source record id: invalid metadata address type: 133", + }, + { + "Source - RecordId - wrong prefix", + &InputSpecification{ + Name: "name", + TypeName: "typename", + Source: NewInputSpecificationSourceRecordID(ContractSpecMetadataAddress(uuid.New())), + }, + fmt.Sprintf("invalid input specification source record id prefix (expected: %s, got: %s)", + PrefixRecord, PrefixContractSpecification), + }, + { + "Source - Hash - empty", + &InputSpecification{ + Name: "name", + TypeName: "typename", + Source: NewInputSpecificationSourceHash(""), + }, + "input specification source hash cannot be empty", + }, + { + "Source - Weird", + &InputSpecification{ + Name: "name", + TypeName: "typename", + Source: NewWeirdSource(8), + }, + "unknown input specification source type", + }, + + // A simple valid InputSpecification + { + "simple valid InputSpecification", + &InputSpecification{ + Name: "name", + TypeName: "typename", + Source: NewInputSpecificationSourceHash("inputspecsourcehash"), + }, + "", + }, + } + + for _, tt := range tests { + tt := tt + s.T().Run(tt.name, func(t *testing.T) { + err := tt.spec.ValidateBasic() + if err != nil { + require.Equal(t, tt.want, err.Error(), "InputSpecification ValidateBasic error") + } else if len(tt.want) > 0 { + t.Errorf("InputSpecification ValidateBasic error = nil, expected: %s", tt.want) } }) } @@ -575,7 +831,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { name string desc *Description want string - wantErr bool }{ // Name tests { @@ -587,7 +842,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), fmt.Sprintf("description Name cannot be empty"), - true, }, { "invalid name - too long", @@ -597,8 +851,7 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", "", ), - fmt.Sprintf("description Name exceeds maximum length (expected <= %d got: %d)", maxDescriptionNameLength, maxDescriptionNameLength+1), - true, + fmt.Sprintf("description Name exceeds maximum length (expected <= %d got: %d)", maxDescriptionNameLength, maxDescriptionNameLength + 1), }, { "valid name - 1 char", @@ -609,7 +862,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, { "valid name - exactly max length", @@ -620,7 +872,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, // Description tests @@ -632,8 +883,7 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", "", ), - fmt.Sprintf("description Description exceeds maximum length (expected <= %d got: %d)", maxDescriptionDescriptionLength, maxDescriptionDescriptionLength+1), - true, + fmt.Sprintf("description Description exceeds maximum length (expected <= %d got: %d)", maxDescriptionDescriptionLength, maxDescriptionDescriptionLength + 1), }, { "valid description - empty", @@ -644,7 +894,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, { "valid description - 1 char", @@ -655,7 +904,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, { "valid description - exactly max length", @@ -666,7 +914,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, // Website url tests @@ -678,8 +925,7 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { strings.Repeat("h", maxURLLength+1), "", ), - fmt.Sprintf("url WebsiteUrl exceeds maximum length (expected <= %d got: %d)", maxURLLength, maxURLLength+1), - true, + fmt.Sprintf("url WebsiteUrl exceeds maximum length (expected <= %d got: %d)", maxURLLength, maxURLLength + 1), }, { "invalid website url - no protocol", @@ -690,7 +936,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), fmt.Sprintf("url WebsiteUrl must use the http, https, or data protocol"), - true, }, { "valid website url - http", @@ -701,7 +946,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, { "valid website url - http at max length", @@ -712,7 +956,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, { "valid website url - https", @@ -723,7 +966,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, { "valid website url - https at max length", @@ -734,7 +976,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, { "valid website url - data", @@ -745,7 +986,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, { "valid website url - data minimal", @@ -756,7 +996,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, { "valid website url - data at max length", @@ -767,7 +1006,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", ), "", - false, }, // Icon url tests @@ -779,8 +1017,7 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "", strings.Repeat("h", maxURLLength+1), ), - fmt.Sprintf("url IconUrl exceeds maximum length (expected <= %d got: %d)", maxURLLength, maxURLLength+1), - true, + fmt.Sprintf("url IconUrl exceeds maximum length (expected <= %d got: %d)", maxURLLength, maxURLLength + 1), }, { "invalid icon url - no protocol", @@ -791,7 +1028,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "www.test.com", ), fmt.Sprintf("url IconUrl must use the http, https, or data protocol"), - true, }, { "valid icon url - http", @@ -802,7 +1038,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "http://www.test.com", ), "", - false, }, { "valid icon url - http at max length", @@ -813,7 +1048,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "http://"+strings.Repeat("f", maxURLLength-7), ), "", - false, }, { "valid icon url - https", @@ -824,7 +1058,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "https://www.test.com", ), "", - false, }, { "valid icon url - https at max length", @@ -835,7 +1068,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "https://"+strings.Repeat("s", maxURLLength-8), ), "", - false, }, { "valid website url - data", @@ -846,7 +1078,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", ), "", - false, }, { "valid website url - data minimal", @@ -857,7 +1088,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "data:,", ), "", - false, }, { "valid website url - data at max length", @@ -868,7 +1098,6 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { "data:image/png;base64,"+strings.Repeat("d", maxURLLength-22), ), "", - false, }, } @@ -876,12 +1105,10 @@ func (s *specificationTestSuite) TestDescriptionValidateBasic() { tt := tt s.T().Run(tt.name, func(t *testing.T) { err := tt.desc.ValidateBasic("") - if (err != nil) != tt.wantErr { - t.Errorf("Scope ValidateBasic error = %v, wantErr %v", err, tt.wantErr) - return - } - if tt.wantErr { - require.Equal(t, tt.want, err.Error()) + if err != nil { + require.Equal(t, tt.want, err.Error(), "Description ValidateBasic error") + } else if len(tt.want) > 0 { + t.Errorf("Description ValidateBasic error = nil, expected: %s", tt.want) } }) } @@ -934,7 +1161,6 @@ func (s *specificationTestSuite) TestContractSpecString() { []PartyType{PartyType_PARTY_TYPE_OWNER}, nil, "CS 201: Intro to Blockchain", - []MetadataAddress{RecordSpecMetadataAddress(contractSpecUuid, "somename")}, ) expected := `specification_id: contractspec1qd2qmt038k7yc0azq46htdlhgwzqg6cr9l description: @@ -948,14 +1174,111 @@ parties_involved: - 5 source: null class_name: 'CS 201: Intro to Blockchain' -record_spec_ids: -- recspec1q42qmt038k7yc0azq46htdlhgwzg5052mucgmerfku3gf5e7t3ej5fjh7rr ` actual := contractSpec.String() // fmt.Printf("Actual:\n%s\n-----\n", actual) require.Equal(s.T(), expected, actual) } +func (s *specificationTestSuite) TestRecordSpecString() { + contractSpecUuid := uuid.MustParse("540dadf1-3dbc-4c3f-a205-7575b7f74384") + recordName := "somename" + recordSpec := NewRecordSpecification( + RecordSpecMetadataAddress(contractSpecUuid, recordName), + recordName, + []*InputSpecification{ + { + "inputSpecName1", + "inputSpecTypeName1", + NewInputSpecificationSourceHash("inputSpecSourceHash1"), + }, + { + "inputSpecName2", + "inputSpecTypeName2", + NewInputSpecificationSourceRecordID(RecordMetadataAddress( + uuid.MustParse("1784AE79-77F1-421C-AAF9-ECA4DD79E571"), + "inputSpecRecordIdSource", + )), + }, + }, + "sometype", + DefinitionType_DEFINITION_TYPE_RECORD, + []PartyType{PartyType_PARTY_TYPE_CUSTODIAN, PartyType_PARTY_TYPE_INVESTOR}, + ) + expected := `specification_id: recspec1q42qmt038k7yc0azq46htdlhgwzg5052mucgmerfku3gf5e7t3ej5fjh7rr +name: somename +inputs: +- name: inputSpecName1 + type_name: inputSpecTypeName1 + source: + hash: inputSpecSourceHash1 +- name: inputSpecName2 + type_name: inputSpecTypeName2 + source: + record_id: record1qgtcftnewlc5y892l8k2fhteu4ceth857yw3fprr4lvhfptn5gg4cv4ure3 +type_name: sometype +result_type: 2 +responsible_parties: +- 4 +- 3 +` + actual := recordSpec.String() + // fmt.Printf("Actual:\n%s\n-----\n", actual) + require.Equal(s.T(), expected, actual) +} + +func (s *specificationTestSuite) TestInputSpecString() { + tests := []struct { + name string + outputActual bool + spec *InputSpecification + expected string + }{ + { + "source is record id", + false, + NewInputSpecification( + "inputSpecRecordIdSource", + "inputSpecRecordIdSourceTypeName", + NewInputSpecificationSourceRecordID(RecordMetadataAddress( + uuid.MustParse("1784AE79-77F1-421C-AAF9-ECA4DD79E571"), + "inputSpecRecordIdSource", + )), + ), + `name: inputSpecRecordIdSource +type_name: inputSpecRecordIdSourceTypeName +source: + record_id: record1qgtcftnewlc5y892l8k2fhteu4ceth857yw3fprr4lvhfptn5gg4cv4ure3 +`, + }, + { + "source is hash", + false, + NewInputSpecification( + "inputSpecHashSource", + "inputSpecHashSourceTypeName", + NewInputSpecificationSourceHash("somehash"), + ), + `name: inputSpecHashSource +type_name: inputSpecHashSourceTypeName +source: + hash: somehash +`, + }, + } + + for _, tt := range tests { + tt := tt + s.T().Run(tt.name, func(t *testing.T) { + actual := tt.spec.String() + if (tt.outputActual) { + fmt.Printf("Actual [%s]:\n%s\n-----\n", tt.name, actual) + } + require.Equal(t, tt.expected, actual) + }) + } +} + func (s *specificationTestSuite) TestDescriptionString() { description := NewDescription( "TestDescriptionString", diff --git a/x/metadata/types/tx.pb.go b/x/metadata/types/tx.pb.go index 2f2ea1df9c..ff74605698 100644 --- a/x/metadata/types/tx.pb.go +++ b/x/metadata/types/tx.pb.go @@ -655,7 +655,7 @@ var xxx_messageInfo_MsgAddScopeSpecificationResponse proto.InternalMessageInfo // MsgDeleteScopeSpecificationRequest deletes a scope specification type MsgDeleteScopeSpecificationRequest struct { - // Unique ID for the scope specification to delete. + // MetadataAddress for the scope specification to delete. SpecificationId MetadataAddress `protobuf:"bytes,1,opt,name=specification_id,json=specificationId,proto3,customtype=MetadataAddress" json:"specification_id" yaml:"specification_id"` Signers []string `protobuf:"bytes,2,rep,name=signers,proto3" json:"signers,omitempty"` } @@ -806,7 +806,7 @@ var xxx_messageInfo_MsgAddContractSpecificationResponse proto.InternalMessageInf // MsgDeleteContractSpecificationRequest deletes a contract specification type MsgDeleteContractSpecificationRequest struct { - // Unique ID for the scope specification to delete. + // MetadataAddress for the contract specification to delete. SpecificationId MetadataAddress `protobuf:"bytes,1,opt,name=specification_id,json=specificationId,proto3,customtype=MetadataAddress" json:"specification_id" yaml:"specification_id"` Signers []string `protobuf:"bytes,2,rep,name=signers,proto3" json:"signers,omitempty"` } @@ -882,6 +882,157 @@ func (m *MsgDeleteContractSpecificationResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDeleteContractSpecificationResponse proto.InternalMessageInfo +// MsgAddRecordSpecificationRequest is a request to add a record specification +type MsgAddRecordSpecificationRequest struct { + Specification RecordSpecification `protobuf:"bytes,1,opt,name=specification,proto3" json:"specification"` + Signers []string `protobuf:"bytes,2,rep,name=signers,proto3" json:"signers,omitempty"` +} + +func (m *MsgAddRecordSpecificationRequest) Reset() { *m = MsgAddRecordSpecificationRequest{} } +func (*MsgAddRecordSpecificationRequest) ProtoMessage() {} +func (*MsgAddRecordSpecificationRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3a3a0892f91e3036, []int{22} +} +func (m *MsgAddRecordSpecificationRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddRecordSpecificationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddRecordSpecificationRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgAddRecordSpecificationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddRecordSpecificationRequest.Merge(m, src) +} +func (m *MsgAddRecordSpecificationRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgAddRecordSpecificationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddRecordSpecificationRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddRecordSpecificationRequest proto.InternalMessageInfo + +// MsgAddRecordSpecificationResponse from an add record specification request +type MsgAddRecordSpecificationResponse struct { +} + +func (m *MsgAddRecordSpecificationResponse) Reset() { *m = MsgAddRecordSpecificationResponse{} } +func (m *MsgAddRecordSpecificationResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddRecordSpecificationResponse) ProtoMessage() {} +func (*MsgAddRecordSpecificationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3a3a0892f91e3036, []int{23} +} +func (m *MsgAddRecordSpecificationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddRecordSpecificationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddRecordSpecificationResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgAddRecordSpecificationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddRecordSpecificationResponse.Merge(m, src) +} +func (m *MsgAddRecordSpecificationResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddRecordSpecificationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddRecordSpecificationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddRecordSpecificationResponse proto.InternalMessageInfo + +// MsgDeleteRecordSpecificationRequest deletes a record specification +type MsgDeleteRecordSpecificationRequest struct { + // MetadataAddress for the record specification to delete. + SpecificationId MetadataAddress `protobuf:"bytes,1,opt,name=specification_id,json=specificationId,proto3,customtype=MetadataAddress" json:"specification_id" yaml:"specification_id"` + Signers []string `protobuf:"bytes,2,rep,name=signers,proto3" json:"signers,omitempty"` +} + +func (m *MsgDeleteRecordSpecificationRequest) Reset() { *m = MsgDeleteRecordSpecificationRequest{} } +func (*MsgDeleteRecordSpecificationRequest) ProtoMessage() {} +func (*MsgDeleteRecordSpecificationRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3a3a0892f91e3036, []int{24} +} +func (m *MsgDeleteRecordSpecificationRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteRecordSpecificationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteRecordSpecificationRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDeleteRecordSpecificationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteRecordSpecificationRequest.Merge(m, src) +} +func (m *MsgDeleteRecordSpecificationRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteRecordSpecificationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteRecordSpecificationRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteRecordSpecificationRequest proto.InternalMessageInfo + +// MsgDeleteRecordSpecificationResponse from a delete record specification request +type MsgDeleteRecordSpecificationResponse struct { +} + +func (m *MsgDeleteRecordSpecificationResponse) Reset() { *m = MsgDeleteRecordSpecificationResponse{} } +func (m *MsgDeleteRecordSpecificationResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteRecordSpecificationResponse) ProtoMessage() {} +func (*MsgDeleteRecordSpecificationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3a3a0892f91e3036, []int{25} +} +func (m *MsgDeleteRecordSpecificationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteRecordSpecificationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteRecordSpecificationResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDeleteRecordSpecificationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteRecordSpecificationResponse.Merge(m, src) +} +func (m *MsgDeleteRecordSpecificationResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteRecordSpecificationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteRecordSpecificationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteRecordSpecificationResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgMemorializeContractRequest)(nil), "provenance.metadata.v1.MsgMemorializeContractRequest") proto.RegisterType((*MsgMemorializeContractResponse)(nil), "provenance.metadata.v1.MsgMemorializeContractResponse") @@ -905,81 +1056,90 @@ func init() { proto.RegisterType((*MsgAddContractSpecificationResponse)(nil), "provenance.metadata.v1.MsgAddContractSpecificationResponse") proto.RegisterType((*MsgDeleteContractSpecificationRequest)(nil), "provenance.metadata.v1.MsgDeleteContractSpecificationRequest") proto.RegisterType((*MsgDeleteContractSpecificationResponse)(nil), "provenance.metadata.v1.MsgDeleteContractSpecificationResponse") + proto.RegisterType((*MsgAddRecordSpecificationRequest)(nil), "provenance.metadata.v1.MsgAddRecordSpecificationRequest") + proto.RegisterType((*MsgAddRecordSpecificationResponse)(nil), "provenance.metadata.v1.MsgAddRecordSpecificationResponse") + proto.RegisterType((*MsgDeleteRecordSpecificationRequest)(nil), "provenance.metadata.v1.MsgDeleteRecordSpecificationRequest") + proto.RegisterType((*MsgDeleteRecordSpecificationResponse)(nil), "provenance.metadata.v1.MsgDeleteRecordSpecificationResponse") } func init() { proto.RegisterFile("provenance/metadata/v1/tx.proto", fileDescriptor_3a3a0892f91e3036) } var fileDescriptor_3a3a0892f91e3036 = []byte{ - // 1101 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0x4d, 0x6c, 0xe3, 0x44, - 0x14, 0x8e, 0xb7, 0xdb, 0xb4, 0x7d, 0x29, 0x6a, 0x99, 0x6e, 0xdb, 0xd4, 0xd0, 0x38, 0x18, 0x15, - 0xaa, 0x6e, 0x6b, 0x2b, 0x61, 0x59, 0xa0, 0xfc, 0x48, 0xcd, 0x2e, 0x12, 0x15, 0x8a, 0x40, 0xa9, - 0x40, 0x02, 0x09, 0x21, 0xd7, 0x9e, 0x75, 0x2d, 0x12, 0x4f, 0xf0, 0xb8, 0x25, 0x05, 0x21, 0x71, - 0xe0, 0x80, 0x38, 0x20, 0x24, 0x2e, 0x1c, 0x38, 0xf4, 0xc2, 0x89, 0x03, 0x12, 0x47, 0x6e, 0x5c, - 0xd0, 0x1e, 0xf7, 0x88, 0x10, 0x8a, 0x50, 0x7b, 0xe1, 0x5c, 0x89, 0x3b, 0xb2, 0xfd, 0x9c, 0xd8, - 0xa9, 0x7f, 0x92, 0xd5, 0x1e, 0xb8, 0xd5, 0x9e, 0xef, 0xcd, 0xfb, 0xbe, 0xf7, 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0x0f, 0xe8, 0x35, 0x3e, - 0xba, 0x7f, 0x5e, 0x11, 0x1e, 0x9c, 0x57, 0x84, 0xbf, 0xcf, 0x2b, 0xc2, 0xb7, 0x17, 0x95, 0xc2, - 0x83, 0x8b, 0x4a, 0xe1, 0x8f, 0x8b, 0x4a, 0x01, 0xd6, 0x2c, 0x96, 0xb2, 0xf7, 0xdb, 0xc2, 0xfb, - 0xb7, 0x4c, 0xcb, 0x3d, 0x3a, 0x3e, 0x54, 0x74, 0xd6, 0x51, 0x87, 0xa0, 0x1d, 0x8b, 0x45, 0x9e, - 0xd4, 0xde, 0xf0, 0x87, 0x01, 0xf7, 0xb4, 0x4b, 0xf9, 0x61, 0xd1, 0xff, 0x2f, 0xff, 0xb9, 0xff, - 0x02, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x13, 0x0f, 0x8b, 0xd6, 0x10, 0x00, 0x00, + // 1182 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6b, 0xe4, 0x64, + 0x18, 0x9e, 0xb4, 0xdb, 0x5f, 0x6f, 0xbb, 0xb4, 0x7e, 0xdd, 0xb6, 0xd3, 0xd1, 0x4e, 0x66, 0xb3, + 0x76, 0x2d, 0xfd, 0x91, 0xd0, 0x71, 0x5d, 0x77, 0xbb, 0xab, 0xd0, 0xd9, 0x15, 0x2c, 0x32, 0x28, + 0x53, 0x54, 0x14, 0x44, 0xd2, 0xe4, 0xdb, 0x34, 0xd8, 0xe6, 0x1b, 0xf3, 0xa5, 0x75, 0xaa, 0x08, + 0x1e, 0x3c, 0x88, 0xa0, 0x08, 0x82, 0x78, 0x10, 0xe9, 0x45, 0x3c, 0x78, 0x50, 0x3c, 0x7a, 0xf3, + 0x22, 0x7b, 0xdc, 0xa3, 0x88, 0x14, 0x69, 0x2f, 0x9e, 0xfb, 0x17, 0x2c, 0x49, 0xde, 0xcc, 0x24, + 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x8b, + 0x39, 0x8c, 0x8f, 0xfb, 0x4a, 0x94, 0x6e, 0xf5, 0x1e, 0x88, 0x64, 0xbe, 0x15, 0xa0, 0x98, 0xb4, + 0x2f, 0xc9, 0x5a, 0xbe, 0xee, 0x88, 0xa5, 0x74, 0xe7, 0x5c, 0xb1, 0x21, 0x56, 0x49, 0x0b, 0x2f, + 0x95, 0x55, 0xc6, 0x4a, 0x4f, 0x65, 0x95, 0xb5, 0x61, 0xc9, 0x0f, 0x02, 0x3c, 0x9d, 0xb2, 0xaa, + 0xc8, 0x4b, 0x99, 0x92, 0x53, 0xb9, 0xbd, 0x7c, 0xde, 0x70, 0xa4, 0xf7, 0x95, 0x00, 0xd3, 0xf1, + 0x5b, 0x87, 0xdc, 0xca, 0x33, 0x11, 0xb1, 0xa4, 0x6e, 0x9f, 0x23, 0x12, 0xf9, 0x7c, 0x27, 0xc0, + 0x6c, 0xe2, 0xb6, 0x20, 0x77, 0x72, 0x8e, 0x4d, 0x2c, 0xab, 0xbb, 0xe7, 0x0b, 0xf6, 0x89, 0xd5, + 0x3e, 0x78, 0x78, 0x5c, 0x16, 0x1e, 0x1d, 0x97, 0x85, 0xff, 0x8e, 0xcb, 0xc2, 0x37, 0x27, 0xe5, + 0xc2, 0xa3, 0x93, 0x72, 0xe1, 0xef, 0x93, 0x72, 0x01, 0x66, 0x4d, 0x96, 0x70, 0xf2, 0x1b, 0xc2, + 0xbb, 0x37, 0x0c, 0xd3, 0xd9, 0xde, 0xdb, 0x92, 0x35, 0xb6, 0xab, 0x74, 0x40, 0x2b, 0x26, 0x0b, + 0x3d, 0x29, 0xad, 0xce, 0xff, 0xba, 0x9c, 0x83, 0x26, 0xe5, 0x5b, 0x83, 0xde, 0x3f, 0xae, 0x9e, + 0x7f, 0x1c, 0x00, 0x00, 0xff, 0xff, 0x86, 0xd3, 0x8c, 0x5f, 0xa9, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1016,6 +1176,10 @@ type MsgClient interface { AddContractSpecification(ctx context.Context, in *MsgAddContractSpecificationRequest, opts ...grpc.CallOption) (*MsgAddContractSpecificationResponse, error) // DeleteContractSpecification deletes a contract specification DeleteContractSpecification(ctx context.Context, in *MsgDeleteContractSpecificationRequest, opts ...grpc.CallOption) (*MsgDeleteContractSpecificationResponse, error) + // AddRecordSpecification adds a record specification + AddRecordSpecification(ctx context.Context, in *MsgAddRecordSpecificationRequest, opts ...grpc.CallOption) (*MsgAddRecordSpecificationResponse, error) + // DeleteRecordSpecification deletes a record specification + DeleteRecordSpecification(ctx context.Context, in *MsgDeleteRecordSpecificationRequest, opts ...grpc.CallOption) (*MsgDeleteRecordSpecificationResponse, error) } type msgClient struct { @@ -1125,6 +1289,24 @@ func (c *msgClient) DeleteContractSpecification(ctx context.Context, in *MsgDele return out, nil } +func (c *msgClient) AddRecordSpecification(ctx context.Context, in *MsgAddRecordSpecificationRequest, opts ...grpc.CallOption) (*MsgAddRecordSpecificationResponse, error) { + out := new(MsgAddRecordSpecificationResponse) + err := c.cc.Invoke(ctx, "/provenance.metadata.v1.Msg/AddRecordSpecification", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DeleteRecordSpecification(ctx context.Context, in *MsgDeleteRecordSpecificationRequest, opts ...grpc.CallOption) (*MsgDeleteRecordSpecificationResponse, error) { + out := new(MsgDeleteRecordSpecificationResponse) + err := c.cc.Invoke(ctx, "/provenance.metadata.v1.Msg/DeleteRecordSpecification", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // MemorializeContract records the results of a P8e contract execution as a session and set of records in a scope @@ -1149,6 +1331,10 @@ type MsgServer interface { AddContractSpecification(context.Context, *MsgAddContractSpecificationRequest) (*MsgAddContractSpecificationResponse, error) // DeleteContractSpecification deletes a contract specification DeleteContractSpecification(context.Context, *MsgDeleteContractSpecificationRequest) (*MsgDeleteContractSpecificationResponse, error) + // AddRecordSpecification adds a record specification + AddRecordSpecification(context.Context, *MsgAddRecordSpecificationRequest) (*MsgAddRecordSpecificationResponse, error) + // DeleteRecordSpecification deletes a record specification + DeleteRecordSpecification(context.Context, *MsgDeleteRecordSpecificationRequest) (*MsgDeleteRecordSpecificationResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1188,6 +1374,12 @@ func (*UnimplementedMsgServer) AddContractSpecification(ctx context.Context, req func (*UnimplementedMsgServer) DeleteContractSpecification(ctx context.Context, req *MsgDeleteContractSpecificationRequest) (*MsgDeleteContractSpecificationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteContractSpecification not implemented") } +func (*UnimplementedMsgServer) AddRecordSpecification(ctx context.Context, req *MsgAddRecordSpecificationRequest) (*MsgAddRecordSpecificationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddRecordSpecification not implemented") +} +func (*UnimplementedMsgServer) DeleteRecordSpecification(ctx context.Context, req *MsgDeleteRecordSpecificationRequest) (*MsgDeleteRecordSpecificationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteRecordSpecification not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1391,6 +1583,42 @@ func _Msg_DeleteContractSpecification_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +func _Msg_AddRecordSpecification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddRecordSpecificationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddRecordSpecification(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.metadata.v1.Msg/AddRecordSpecification", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddRecordSpecification(ctx, req.(*MsgAddRecordSpecificationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DeleteRecordSpecification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeleteRecordSpecificationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeleteRecordSpecification(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provenance.metadata.v1.Msg/DeleteRecordSpecification", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeleteRecordSpecification(ctx, req.(*MsgDeleteRecordSpecificationRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "provenance.metadata.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -1439,6 +1667,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "DeleteContractSpecification", Handler: _Msg_DeleteContractSpecification_Handler, }, + { + MethodName: "AddRecordSpecification", + Handler: _Msg_AddRecordSpecification_Handler, + }, + { + MethodName: "DeleteRecordSpecification", + Handler: _Msg_DeleteRecordSpecification_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "provenance/metadata/v1/tx.proto", @@ -2245,6 +2481,136 @@ func (m *MsgDeleteContractSpecificationResponse) MarshalToSizedBuffer(dAtA []byt return len(dAtA) - i, nil } +func (m *MsgAddRecordSpecificationRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgAddRecordSpecificationRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddRecordSpecificationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signers) > 0 { + for iNdEx := len(m.Signers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Signers[iNdEx]) + copy(dAtA[i:], m.Signers[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signers[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Specification.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgAddRecordSpecificationResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgAddRecordSpecificationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddRecordSpecificationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDeleteRecordSpecificationRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeleteRecordSpecificationRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteRecordSpecificationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signers) > 0 { + for iNdEx := len(m.Signers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Signers[iNdEx]) + copy(dAtA[i:], m.Signers[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signers[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + { + size := m.SpecificationId.Size() + i -= size + if _, err := m.SpecificationId.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgDeleteRecordSpecificationResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeleteRecordSpecificationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteRecordSpecificationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -2578,14 +2944,66 @@ func (m *MsgDeleteContractSpecificationResponse) Size() (n int) { return n } -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgMemorializeContractRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) +func (m *MsgAddRecordSpecificationRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Specification.Size() + n += 1 + l + sovTx(uint64(l)) + if len(m.Signers) > 0 { + for _, s := range m.Signers { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgAddRecordSpecificationResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeleteRecordSpecificationRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.SpecificationId.Size() + n += 1 + l + sovTx(uint64(l)) + if len(m.Signers) > 0 { + for _, s := range m.Signers { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgDeleteRecordSpecificationResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgMemorializeContractRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx @@ -4735,6 +5153,336 @@ func (m *MsgDeleteContractSpecificationResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgAddRecordSpecificationRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgAddRecordSpecificationRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddRecordSpecificationRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Specification", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Specification.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signers", 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.Signers = append(m.Signers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgAddRecordSpecificationResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgAddRecordSpecificationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddRecordSpecificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeleteRecordSpecificationRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDeleteRecordSpecificationRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteRecordSpecificationRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpecificationId", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SpecificationId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signers", 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.Signers = append(m.Signers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeleteRecordSpecificationResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDeleteRecordSpecificationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteRecordSpecificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0