feat: remaining record content types to support #79

Closed
0xmuralik wants to merge 35 commits from murali/record-attributes into main
6 changed files with 52 additions and 10 deletions
Showing only changes of commit 2e986c4d5e - Show all commits

View File

@ -1,6 +1,6 @@
record: record:
type: ServiceProviderRegistration type: ServiceProviderRecord
bond_id: madeUpBondID bond_id: madeUpBondID
laconic_id: madeUpLaconicID laconic_id: madeUpLaconicID
version: 1.0.0 version: 1.0.0

View File

@ -1,6 +1,6 @@
record: record:
type: ServiceProviderRegistration type: ServiceProviderRecord
bond_id: madeUpBondID bond_id: madeUpBondID
laconic_id: madeUpLaconicID laconic_id: madeUpLaconicID
version: 1.0.0 version: 1.0.0

View File

@ -87,7 +87,7 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
1, 1,
}, },
{ {
"Filter with attributes ServiceProviderRegistration", "Filter with attributes ServiceProviderRecord",
&registrytypes.QueryListRecordsRequest{ &registrytypes.QueryListRecordsRequest{
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{ Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
{ {

View File

@ -317,7 +317,7 @@ func (k Keeper) PutRecord(ctx sdk.Context, record types.Record) {
func (k Keeper) ProcessAttributes(ctx sdk.Context, record types.RecordType) error { func (k Keeper) ProcessAttributes(ctx sdk.Context, record types.RecordType) error {
switch record.Attributes["type"] { switch record.Attributes["type"] {
case "ServiceProviderRegistration": case "ServiceProviderRecord":
{ {
// #nosec G705 // #nosec G705
for key := range record.Attributes { for key := range record.Attributes {

View File

@ -40,9 +40,9 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
) )
registry.RegisterInterface( registry.RegisterInterface(
"vulcanize.registry.v1beta1.ServiceProvideRegistration", "vulcanize.registry.v1beta1.ServiceProviderRecord",
(*Attributes)(nil), (*Attributes)(nil),
&ServiceProviderRegistration{}, &ServiceProviderRecord{},
) )
registry.RegisterInterface( registry.RegisterInterface(
@ -50,6 +50,48 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
(*Attributes)(nil), (*Attributes)(nil),
&WebsiteRegistrationRecord{}, &WebsiteRegistrationRecord{},
) )
registry.RegisterInterface(
"vulcanize.registry.v1beta1.GitRepository",
(*Attributes)(nil),
&GitRepository{},
)
registry.RegisterInterface(
"vulcanize.registry.v1beta1.Binary",
(*Attributes)(nil),
&Binary{},
)
registry.RegisterInterface(
"vulcanize.registry.v1beta1.DockerImage",
(*Attributes)(nil),
&DockerImage{},
)
registry.RegisterInterface(
"vulcanize.registry.v1beta1.WatcherRegistrationRecord",
(*Attributes)(nil),
&WatcherRegistrationRecord{},
)
registry.RegisterInterface(
"vulcanize.registry.v1beta1.ResponderContract",
(*Attributes)(nil),
&ResponderContract{},
)
registry.RegisterInterface(
"vulcanize.registry.v1beta1.JSPackage",
(*Attributes)(nil),
&JSPackage{},
)
registry.RegisterInterface(
"vulcanize.registry.v1beta1.ChainRegistrationRecord",
(*Attributes)(nil),
&ChainRegistrationRecord{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
} }

View File

@ -50,9 +50,9 @@ func payLoadAttributes(recordPayLoad map[string]interface{}) (*codectypes.Any, e
bz := helpers.MarshalMapToJSONBytes(recordPayLoad) bz := helpers.MarshalMapToJSONBytes(recordPayLoad)
switch recordType.(string) { switch recordType.(string) {
case "ServiceProviderRegistration": case "ServiceProviderRecord":
{ {
var attributes ServiceProviderRegistration var attributes ServiceProviderRecord
err := json.Unmarshal(bz, &attributes) err := json.Unmarshal(bz, &attributes)
if err != nil { if err != nil {
return &codectypes.Any{}, err return &codectypes.Any{}, err
@ -114,9 +114,9 @@ func GetJSONBytesFromAny(any codectypes.Any) ([]byte, error) {
var bz []byte var bz []byte
s := strings.Split(any.TypeUrl, ".") s := strings.Split(any.TypeUrl, ".")
switch s[len(s)-1] { switch s[len(s)-1] {
case "ServiceProviderRegistration": case "ServiceProviderRecord":
{ {
var attributes ServiceProviderRegistration var attributes ServiceProviderRecord
err := proto.Unmarshal(any.Value, &attributes) err := proto.Unmarshal(any.Value, &attributes)
if err != nil { if err != nil {
panic("Proto unmarshal error") panic("Proto unmarshal error")