Compare commits
35 Commits
main
...
murali/rec
Author | SHA1 | Date | |
---|---|---|---|
|
bbb6d2a7ab | ||
|
656b8dc79b | ||
|
f827ea46b8 | ||
|
5cd07d9104 | ||
|
30cbba44e7 | ||
|
b59eb6878d | ||
|
b90bb05b3f | ||
|
beb1ad2df7 | ||
|
6025fadc71 | ||
|
fa406be65f | ||
|
e18541523d | ||
|
4d5568bf83 | ||
|
ff10aac7d7 | ||
|
38c77c10f6 | ||
|
bd04a6307e | ||
|
6e272334e4 | ||
|
bf1670be78 | ||
|
67208b08af | ||
|
2e986c4d5e | ||
|
e38ed67657 | ||
|
145d52f92e | ||
|
4ba723a384 | ||
|
420042b9de | ||
|
d44ab22d87 | ||
|
66cf0f758c | ||
|
c3774a3b96 | ||
|
39038980cc | ||
|
26300b0738 | ||
|
021ab7df1f | ||
|
6eeed3de91 | ||
|
9e91a70f31 | ||
|
961f0f737a | ||
|
930cca939f | ||
|
e8fe95114a | ||
|
82b2c32575 |
@ -5,29 +5,109 @@ import "gogoproto/gogo.proto";
|
||||
|
||||
option go_package = "github.com/cerc-io/laconicd/x/registry/types";
|
||||
|
||||
message ServiceProviderRegistration {
|
||||
message HashReference{
|
||||
string ref =1 [(gogoproto.jsontag) = "/"];
|
||||
}
|
||||
|
||||
message ServiceProviderRecord {
|
||||
string bond_id = 1 [(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""];
|
||||
string laconic_id = 2 [(gogoproto.moretags) = "json:\"laconicId\" yaml:\"laconicId\""];
|
||||
X500 x500 = 3 [(gogoproto.moretags) = "json:\"x500\" yaml:\"x500\""];
|
||||
string type = 4 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string version = 6 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
}
|
||||
|
||||
message X500 {
|
||||
message X500 {
|
||||
string common_name = 1 [(gogoproto.moretags) = "json:\"commonName\" yaml:\"commonName\""];
|
||||
string organization_unit = 2 [(gogoproto.moretags) = "json:\"organizationUnit\" yaml:\"organizationUnit\""];
|
||||
string organization_name = 3 [(gogoproto.moretags) = "json:\"organizationName\" yaml:\"organizationName\""];
|
||||
string locality_name = 4 [(gogoproto.moretags) = "json:\"localityName\" yaml:\"localityName\""];
|
||||
string state_name = 5 [(gogoproto.moretags) = "json:\"stateName\" yaml:\"stateName\""];
|
||||
string country = 6 [(gogoproto.moretags) = "json:\"country\" yaml:\"country\""];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
message WebsiteRegistrationRecord {
|
||||
string url = 1 [(gogoproto.moretags) = "json:\"url\" yaml:\"url\""];
|
||||
string repo_registration_record_cid = 2
|
||||
[(gogoproto.moretags) = "json:\"repoRegistrationRecordCID\" yaml:\"repoRegistrationRecordCID\""];
|
||||
string build_artifact_cid = 3 [(gogoproto.moretags) = "json:\"buildArtifactCID\" yaml:\"buildArtifactCID\""];
|
||||
string tls_cert_cid = 4 [(gogoproto.moretags) = "json:\"TLSCertCID\" yaml:\"TLSCertCID\""];
|
||||
HashReference repo_reference = 2
|
||||
[(gogoproto.moretags) = "json:\"repoReference\" yaml:\"repoReference\""];
|
||||
HashReference build_artifact_ref = 3 [(gogoproto.moretags) = "json:\"buildArtifactRef\" yaml:\"buildArtifactRef\""];
|
||||
HashReference tls_cert_ref = 4 [(gogoproto.moretags) = "json:\"tlsCertRef\" yaml:\"tlsCertRef\""];
|
||||
string type = 5 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string version = 6 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
}
|
||||
|
||||
message GitRepository{
|
||||
string name =1 [(gogoproto.moretags) = "json:\"name\" yaml:\"name\""];
|
||||
string repo_reference=2 [(gogoproto.moretags) = "json:\"repo_reference\" yaml:\"repo_reference\""];
|
||||
string description=3 [(gogoproto.moretags) = "json:\"description\" yaml:\"description\""];
|
||||
string version = 4 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
string type =5 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
}
|
||||
|
||||
message Binary{
|
||||
HashReference hash_reference=1;
|
||||
string targeted_arch=2;
|
||||
string runtime_version=3;
|
||||
HashReference repo_reference=4;
|
||||
string version=5;
|
||||
string type=6;
|
||||
}
|
||||
|
||||
message DockerImage{
|
||||
string image_id=1;
|
||||
HashReference binary_reference=2;
|
||||
HashReference repo_reference=3;
|
||||
string version=4;
|
||||
string type=5;
|
||||
}
|
||||
|
||||
message WatcherRegistrationRecord{
|
||||
WatcherMetadata metadata =1;
|
||||
HashReference repo_reference=2;
|
||||
WASMBinary wasm=3;
|
||||
string version=4;
|
||||
string type=5;
|
||||
|
||||
message WatcherMetadata{
|
||||
string version=1;
|
||||
HashReference chain_reference=2;
|
||||
}
|
||||
|
||||
message WASMBinary{
|
||||
HashReference hash_reference=1;
|
||||
WASMBinaryMetadata metadata=2;
|
||||
}
|
||||
|
||||
message WASMBinaryMetadata{
|
||||
string compiler_version=1;
|
||||
string execution_engine_version=2;
|
||||
}
|
||||
}
|
||||
|
||||
message ResponderContract{
|
||||
HashReference service_provider_ref=1;
|
||||
HashReference auction_ref=2;
|
||||
HashReference watcher_ref=3;
|
||||
string version=4;
|
||||
string type=5;
|
||||
}
|
||||
|
||||
message JSPackage{
|
||||
HashReference repo_reference=1;
|
||||
HashReference js_package_ref=2;
|
||||
string version=3;
|
||||
string type=4;
|
||||
string name =5;
|
||||
}
|
||||
|
||||
message ChainRegistrationRecord{
|
||||
string name=1;
|
||||
repeated string ipld_types=2;
|
||||
string type=3;
|
||||
string version=4;
|
||||
string chain_id=5;
|
||||
string network_id=6;
|
||||
HashReference genesis_hash=7;
|
||||
}
|
@ -60,7 +60,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() {
|
||||
}
|
||||
}
|
||||
|
||||
//nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@ -180,7 +180,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
||||
}
|
||||
}
|
||||
|
||||
//nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@ -209,7 +209,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
||||
func(bondId string) {
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
@ -252,7 +252,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
//nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@ -324,7 +324,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
//nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@ -353,7 +353,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
|
||||
func(bondId string) {
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
@ -626,7 +626,7 @@ func createRecord(bondID string, s *IntegrationTestSuite) {
|
||||
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
|
@ -79,7 +79,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryForRecords() {
|
||||
bondID := GetBondID(s)
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
args := []string{
|
||||
payloadPath, bondID,
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
|
@ -1,13 +0,0 @@
|
||||
|
||||
record:
|
||||
type: ServiceProviderRegistration
|
||||
bond_id: madeUpBondID
|
||||
laconic_id: madeUpLaconicID
|
||||
version: 1.0.0
|
||||
x500:
|
||||
common_name: cerc-io
|
||||
organization_unit: xyz
|
||||
organization_name: abc
|
||||
state_name: california
|
||||
country: US
|
||||
locality_name: local
|
@ -198,7 +198,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
|
||||
bondID := GetBondID(s)
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/watcher_registration_example.yml"
|
||||
|
||||
tc.args = append([]string{payloadPath, bondID}, tc.args...)
|
||||
}
|
||||
@ -580,7 +580,7 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
||||
bondID := GetBondID(s)
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
|
||||
args := []string{
|
||||
payloadPath, bondID,
|
||||
@ -822,7 +822,7 @@ func (s *IntegrationTestSuite) TestGetCmdAssociateBond() {
|
||||
bondID := GetBondID(s)
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
|
||||
txArgs := []string{
|
||||
payloadPath, bondID,
|
||||
|
@ -1,7 +0,0 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: https://cerc.io
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.0
|
9
x/registry/helpers/examples/binary_example.yml
Normal file
9
x/registry/helpers/examples/binary_example.yml
Normal file
@ -0,0 +1,9 @@
|
||||
record:
|
||||
hash_reference:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
targeted_arch: x86_64
|
||||
runtime_version: go 1.18
|
||||
repo_reference:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
version: 1.0.0
|
||||
type: Binary
|
13
x/registry/helpers/examples/chain_registration_example.yml
Normal file
13
x/registry/helpers/examples/chain_registration_example.yml
Normal file
@ -0,0 +1,13 @@
|
||||
record:
|
||||
name: Laconic
|
||||
ipld_types:
|
||||
- type3
|
||||
- type11
|
||||
- schema2
|
||||
- codec5
|
||||
type: ChainRegistrationRecord
|
||||
version: 0.11.2
|
||||
chain_id: laconic_9000-1
|
||||
network_id: "1392"
|
||||
genesis_hash:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
8
x/registry/helpers/examples/docker_image_example.yml
Normal file
8
x/registry/helpers/examples/docker_image_example.yml
Normal file
@ -0,0 +1,8 @@
|
||||
record:
|
||||
image_id: 77af4d6b9913
|
||||
binary_reference:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
repo_reference:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
version: 1.0.0
|
||||
type: DockerImage
|
6
x/registry/helpers/examples/git_repo_example.yml
Normal file
6
x/registry/helpers/examples/git_repo_example.yml
Normal file
@ -0,0 +1,6 @@
|
||||
record:
|
||||
name: cosmos-sdk
|
||||
repo_reference: https://github.com/cosmos/cosmos-sdk
|
||||
description: This is a description string
|
||||
version: 0.46.7
|
||||
type: GitRepository
|
@ -1,7 +1,8 @@
|
||||
record:
|
||||
attr1: value1
|
||||
attr2: value2
|
||||
link1:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
link2:
|
||||
repo_reference:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
js_package_ref:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
version: 1.0.0
|
||||
type: JSPackage
|
||||
name: test-JSPackage
|
@ -0,0 +1,9 @@
|
||||
record:
|
||||
service_provider_ref:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
auction_ref:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
watcher_ref:
|
||||
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.0
|
||||
type: ResponderContract
|
@ -1,6 +1,6 @@
|
||||
|
||||
record:
|
||||
type: ServiceProviderRegistration
|
||||
type: ServiceProviderRecord
|
||||
bond_id: madeUpBondID
|
||||
laconic_id: madeUpLaconicID
|
||||
version: 1.0.0
|
||||
|
15
x/registry/helpers/examples/watcher_registration_example.yml
Normal file
15
x/registry/helpers/examples/watcher_registration_example.yml
Normal file
@ -0,0 +1,15 @@
|
||||
record:
|
||||
metadata:
|
||||
version: 0.32.0
|
||||
chain_reference:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
repo_reference:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
wasm:
|
||||
hash_reference:
|
||||
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
metadata:
|
||||
compiler_version: 1.15.0
|
||||
execution_engine_version: 0.16.1
|
||||
version: 1.0.0
|
||||
type: WatcherRegistrationRecord
|
@ -1,7 +1,10 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: https://cerc.io
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cerc_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
repo_reference:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_ref:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_ref:
|
||||
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.0
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/cerc-io/laconicd/x/registry/client/cli"
|
||||
"github.com/cerc-io/laconicd/x/registry/helpers"
|
||||
@ -37,7 +38,14 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
sr := suite.Require()
|
||||
var recordId string
|
||||
examples := []string{
|
||||
"/../helpers/examples/binary_example.yml",
|
||||
"/../helpers/examples/chain_registration_example.yml",
|
||||
"/../helpers/examples/docker_image_example.yml",
|
||||
"/../helpers/examples/git_repo_example.yml",
|
||||
"/../helpers/examples/js_package_example.yml",
|
||||
"/../helpers/examples/responder_contract_example.yml",
|
||||
"/../helpers/examples/service_provider_example.yml",
|
||||
"/../helpers/examples/watcher_registration_example.yml",
|
||||
"/../helpers/examples/website_registration_example.yml",
|
||||
}
|
||||
testCases := []struct {
|
||||
@ -59,14 +67,14 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
®istrytypes.QueryListRecordsRequest{},
|
||||
true,
|
||||
false,
|
||||
2,
|
||||
len(examples),
|
||||
},
|
||||
{
|
||||
"Filter with type",
|
||||
®istrytypes.QueryListRecordsRequest{
|
||||
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||
{
|
||||
Key: "type",
|
||||
Key: "type---",
|
||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||
Type: "string",
|
||||
String_: "WebsiteRegistrationRecord",
|
||||
@ -80,11 +88,11 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
1,
|
||||
},
|
||||
{
|
||||
"Filter with attributes ServiceProviderRegistration",
|
||||
"Filter with attributes ServiceProviderRecord",
|
||||
®istrytypes.QueryListRecordsRequest{
|
||||
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||
{
|
||||
Key: "x500state_name",
|
||||
Key: "x500---state_name---",
|
||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||
Type: "string",
|
||||
String_: "california",
|
||||
@ -97,6 +105,42 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
false,
|
||||
1,
|
||||
},
|
||||
{
|
||||
"Filter with attributes WatcherRegistrationRecord",
|
||||
®istrytypes.QueryListRecordsRequest{
|
||||
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||
{
|
||||
Key: "metadata---chain_reference---/---",
|
||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||
Type: "string",
|
||||
String_: "QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9",
|
||||
},
|
||||
},
|
||||
},
|
||||
All: true,
|
||||
},
|
||||
true,
|
||||
false,
|
||||
1,
|
||||
},
|
||||
{
|
||||
"Filter with attributes version",
|
||||
®istrytypes.QueryListRecordsRequest{
|
||||
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||
{
|
||||
Key: "version---",
|
||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||
Type: "string",
|
||||
String_: "1.0.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
All: true,
|
||||
},
|
||||
true,
|
||||
false,
|
||||
7,
|
||||
},
|
||||
}
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s ", test.msg), func() {
|
||||
@ -133,11 +177,7 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
sr.NoError(err)
|
||||
recAttr := helpers.UnMarshalMapFromJSONBytes(bz)
|
||||
for _, attr := range test.req.GetAttributes() {
|
||||
if attr.Key[:4] == "x500" {
|
||||
sr.Equal(keeper.GetAttributeValue(attr.Value), recAttr["x500"].(map[string]interface{})[attr.Key[4:]])
|
||||
} else {
|
||||
sr.Equal(keeper.GetAttributeValue(attr.Value), recAttr[attr.Key])
|
||||
}
|
||||
sr.Equal(keeper.GetAttributeValue(attr.Value), getAttributesFromRecord(recAttr, attr.Key))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,6 +268,17 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
}
|
||||
}
|
||||
|
||||
func getAttributesFromRecord(recordAttr map[string]interface{}, key string) interface{} {
|
||||
keys := strings.Split(key, "---")
|
||||
for i, str := range keys {
|
||||
if i == len(keys)-2 {
|
||||
return recordAttr[str].(string)
|
||||
}
|
||||
recordAttr = recordAttr[str].(map[string]interface{})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcQueryRegistryModuleBalance() {
|
||||
grpcClient, ctx := suite.queryClient, suite.ctx
|
||||
sr := suite.Require()
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect" // #nosec G702 This is also used in eip712 antehandler code. No new risk introduced.
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
@ -317,45 +318,34 @@ func (k Keeper) PutRecord(ctx sdk.Context, record types.Record) {
|
||||
}
|
||||
|
||||
func (k Keeper) ProcessAttributes(ctx sdk.Context, record types.RecordType) error {
|
||||
switch record.Attributes["type"] {
|
||||
case "ServiceProviderRegistration":
|
||||
{
|
||||
if err := k.insertAttributes(ctx, record.ID, record.Attributes, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
expiryTimeKey := GetAttributesIndexKey(ExpiryTimeAttributeName, record.ExpiryTime)
|
||||
if err := k.setAttributeMapping(ctx, expiryTimeKey, record.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k Keeper) insertAttributes(ctx sdk.Context, recordID string, attr interface{}, keyPrefix string) error {
|
||||
if reflect.TypeOf(attr).Kind() == reflect.Map {
|
||||
val := attr.(map[string]interface{})
|
||||
// #nosec G705
|
||||
for key := range record.Attributes {
|
||||
if key == "x500" {
|
||||
// #nosec G705
|
||||
for x500Key, x500Val := range record.Attributes[key].(map[string]interface{}) {
|
||||
indexKey := GetAttributesIndexKey(fmt.Sprintf("x500%s", x500Key), x500Val)
|
||||
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
|
||||
for key := range val {
|
||||
newKeyPrefix := fmt.Sprint(keyPrefix + key + "---")
|
||||
if err := k.insertAttributes(ctx, recordID, val[key], newKeyPrefix); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
indexKey := GetAttributesIndexKey(key, record.Attributes[key])
|
||||
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
|
||||
indexKey := GetAttributesIndexKey(keyPrefix, attr)
|
||||
if err := k.setAttributeMapping(ctx, indexKey, recordID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case "WebsiteRegistrationRecord":
|
||||
{
|
||||
// #nosec G705
|
||||
for key := range record.Attributes {
|
||||
indexKey := GetAttributesIndexKey(key, record.Attributes[key])
|
||||
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported record type %s", record.Attributes["type"])
|
||||
}
|
||||
|
||||
expiryTimeKey := GetAttributesIndexKey(ExpiryTimeAttributeName, record.ExpiryTime)
|
||||
if err := k.SetAttributeMapping(ctx, expiryTimeKey, record.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -365,7 +355,7 @@ func GetAttributesIndexKey(key string, value interface{}) []byte {
|
||||
return append(PrefixAttributesIndex, []byte(keyString)...)
|
||||
}
|
||||
|
||||
func (k Keeper) SetAttributeMapping(ctx sdk.Context, key []byte, recordID string) error {
|
||||
func (k Keeper) setAttributeMapping(ctx sdk.Context, key []byte, recordID string) error {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
var recordIds []string
|
||||
if store.Has(key) {
|
||||
|
4136
x/registry/types/attributes.pb.go
generated
4136
x/registry/types/attributes.pb.go
generated
File diff suppressed because it is too large
Load Diff
@ -40,9 +40,9 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
"vulcanize.registry.v1beta1.ServiceProvideRegistration",
|
||||
"vulcanize.registry.v1beta1.ServiceProviderRecord",
|
||||
(*Attributes)(nil),
|
||||
&ServiceProviderRegistration{},
|
||||
&ServiceProviderRecord{},
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
@ -50,6 +50,48 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
(*Attributes)(nil),
|
||||
&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)
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,9 @@ func payLoadAttributes(recordPayLoad map[string]interface{}) (*codectypes.Any, e
|
||||
bz := helpers.MarshalMapToJSONBytes(recordPayLoad)
|
||||
|
||||
switch recordType.(string) {
|
||||
case "ServiceProviderRegistration":
|
||||
case "ServiceProviderRecord":
|
||||
{
|
||||
var attributes ServiceProviderRegistration
|
||||
var attributes ServiceProviderRecord
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
@ -68,6 +68,69 @@ func payLoadAttributes(recordPayLoad map[string]interface{}) (*codectypes.Any, e
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "GitRepository":
|
||||
{
|
||||
var attributes GitRepository
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "Binary":
|
||||
{
|
||||
var attributes Binary
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "DockerImage":
|
||||
{
|
||||
var attributes DockerImage
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "WatcherRegistrationRecord":
|
||||
{
|
||||
var attributes WatcherRegistrationRecord
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "ResponderContract":
|
||||
{
|
||||
var attributes ResponderContract
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "JSPackage":
|
||||
{
|
||||
var attributes JSPackage
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "ChainRegistrationRecord":
|
||||
{
|
||||
var attributes ChainRegistrationRecord
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
default:
|
||||
return &codectypes.Any{}, fmt.Errorf("unsupported record type %s", recordType.(string))
|
||||
}
|
||||
@ -114,9 +177,9 @@ func GetJSONBytesFromAny(any codectypes.Any) ([]byte, error) {
|
||||
var bz []byte
|
||||
s := strings.Split(any.TypeUrl, ".")
|
||||
switch s[len(s)-1] {
|
||||
case "ServiceProviderRegistration":
|
||||
case "ServiceProviderRecord":
|
||||
{
|
||||
var attributes ServiceProviderRegistration
|
||||
var attributes ServiceProviderRecord
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
@ -135,6 +198,97 @@ func GetJSONBytesFromAny(any codectypes.Any) ([]byte, error) {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "GitRepository":
|
||||
{
|
||||
var attributes GitRepository
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "Binary":
|
||||
{
|
||||
var attributes Binary
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "DockerImage":
|
||||
{
|
||||
var attributes DockerImage
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "WatcherRegistrationRecord":
|
||||
{
|
||||
var attributes WatcherRegistrationRecord
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "ResponderContract":
|
||||
{
|
||||
var attributes ResponderContract
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "JSPackage":
|
||||
{
|
||||
var attributes JSPackage
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "ChainRegistrationRecord":
|
||||
{
|
||||
var attributes ChainRegistrationRecord
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
|
Loading…
Reference in New Issue
Block a user