Revert "remaining record types support" #35

Merged
ABastionOfSanity merged 1 commits from revert-27-murali/record-types into main 2023-03-06 21:54:02 +00:00
20 changed files with 729 additions and 2621 deletions
Showing only changes of commit 11231b5f51 - Show all commits

View File

@ -16,7 +16,7 @@
"jest": "29.0.0",
"protoc-gen-ts": "^0.8.5",
"ts-jest": "^29.0.2",
"typescript": "^4.7.3"
"typescript": "^4.6.2"
},
"dependencies": {
"@cosmjs/amino": "^0.28.1",

View File

@ -5,16 +5,13 @@ import "gogoproto/gogo.proto";
option go_package = "github.com/cerc-io/laconicd/x/registry/types";
message HashReference{
string ref =1;
}
message ServiceProviderRecord {
message ServiceProviderRegistration {
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 {
string common_name = 1 [(gogoproto.moretags) = "json:\"commonName\" yaml:\"commonName\""];
@ -24,90 +21,13 @@ message ServiceProviderRecord {
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\""];
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 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\""];
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;
}

View File

@ -3,7 +3,7 @@ import path from 'path';
import { Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/watcher_registraion_example.yml');
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
@ -97,17 +97,17 @@ const bondTests = () => {
// Create a new record.
version1 = await publishNewWatcherVersion(bondId1);
let [record1] = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
let [record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(record1.bondId).toBe(bondId1);
// Dissociate record, query and confirm.
await registry.dissociateBond({ recordId: record1.id }, privateKey, fee);
[record1] = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
[record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(record1.bondId).toBe('');
// Associate record with bond, query and confirm.
await registry.associateBond({ recordId: record1.id, bondId: bondId1 }, privateKey, fee);
[record1] = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
[record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(record1.bondId).toBe(bondId1);
});
@ -117,9 +117,9 @@ const bondTests = () => {
// Check version1, version2 as associated with bondId1.
let records;
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(records[0].bondId).toBe(bondId1);
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version2 }, true);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true);
expect(records[0].bondId).toBe(bondId1);
// Create another bond.
@ -131,16 +131,16 @@ const bondTests = () => {
// Reassociate records from bondId1 to bondId2, verify change.
await registry.reassociateRecords({ oldBondId: bondId1, newBondId: bondId2 }, privateKey, fee);
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(records[0].bondId).toBe(bondId2);
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version2 }, true);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true);
expect(records[0].bondId).toBe(bondId2);
// Dissociate all records from bond, verify change.
await registry.dissociateRecords({ bondId: bondId2 }, privateKey, fee);
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(records[0].bondId).toBe('');
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version2 }, true);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true);
expect(records[0].bondId).toBe('');
});
};

View File

@ -3,7 +3,7 @@ import path from 'path';
import { Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/git_repo_example.yml');
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
jest.setTimeout(120 * 1000);
@ -40,7 +40,7 @@ const nameserviceExpiryTests = () => {
fee
)
console.log("SetRecordResult: " + result.data.id)
const [record] = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version }, true);
const [record] = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
recordExpiryTime = new Date(record.expiryTime);
const [bond] = await registry.getBondsByIds([bondId]);
@ -63,7 +63,7 @@ const nameserviceExpiryTests = () => {
});
test('Check record expiry time', async() => {
const [record] = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version }, true);
const [record] = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
const updatedExpiryTime = new Date();
expect(updatedExpiryTime.getTime()).toBeGreaterThan(recordExpiryTime.getTime());
recordExpiryTime = updatedExpiryTime;
@ -88,7 +88,7 @@ const nameserviceExpiryTests = () => {
});
test('Check record deleted without bond balance', async() => {
const records = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version }, true);
const records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
expect(records).toHaveLength(0);
})

View File

@ -5,7 +5,7 @@ import { Account } from './account';
import { Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/git_repo_example.yml');
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
jest.setTimeout(120 * 1000);
@ -119,7 +119,7 @@ const namingTests = () => {
await registry.setName({ crn, cid: watcherId }, privateKey, fee);
// Query records should return it (some CRN points to it).
const records = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version });
const records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
expect(records).toBeDefined();
expect(records).toHaveLength(1);
});
@ -229,12 +229,12 @@ const namingTests = () => {
expect(latest.height).toBeDefined();
// Query records should NOT return it (no CRN points to it).
records = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version });
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
expect(records).toBeDefined();
expect(records).toHaveLength(0);
// Query all records should return it (all: true).
records = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version }, true);
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
});

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ import path from 'path';
import { Registry } from './index';
import { getConfig, ensureUpdatedConfig, provisionBondId } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/website_registration_example.yml');
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
jest.setTimeout(40 * 1000);
@ -45,17 +45,17 @@ describe('Querying', () => {
});
test('Query records by reference.', async () => {
const { ref } = watcher.record.repo_reference;
const records = await registry.queryRecords({ "repo_reference---ref---": ref}, true);
const { repo_registration_record_cid } = watcher.record;
const records = await registry.queryRecords({ repo_registration_record_cid }, true);
expect(records.length).toBeGreaterThanOrEqual(1);
const { attributes: { repo_reference: {ref: record_repo_registration_record_cid} } } = records[0];
expect(ref).toBe(record_repo_registration_record_cid);
const { attributes: { repo_registration_record_cid: record_repo_registration_record_cid } } = records[0];
expect(repo_registration_record_cid).toBe(record_repo_registration_record_cid);
});
test('Query records by attributes.', async () => {
const { version, name } = watcher.record;
const records = await registry.queryRecords({ "version---": version, "name---": name }, true);
const records = await registry.queryRecords({ version, name }, true);
expect(records.length).toBe(1);
[ watcher ] = records;
@ -74,7 +74,7 @@ describe('Querying', () => {
const [record] = await registry.getRecordsByIds([watcher.id], true);
expect(record.id).toBe(watcher.id);
// temp fix
expect(record.attributes.repo_reference.ref).toBeDefined();
expect(record.attributes.repo_reference.ref).toHaveLength(46);
expect(record.attributes.repo_registration_record_cid).toBeDefined();
expect(record.attributes.repo_registration_record_cid).toHaveLength(46);
});
});

View File

@ -1,9 +0,0 @@
record:
hash_reference:
ref: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
targeted_arch: x86_64
runtime_version: go 1.18
repo_reference:
ref: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
version: 1.0.0
type: Binary

View File

@ -1,13 +0,0 @@
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:
ref: f6fbe71210275adc7c7ef585a72c065cdb85f0c8d13dea0f229fd7c22d445a26

View File

@ -1,8 +0,0 @@
record:
image_id: 77af4d6b9913
binary_reference:
ref: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
repo_reference:
ref: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
version: 1.0.0
type: DockerImage

View File

@ -1,7 +0,0 @@
record:
attr1: value1
attr2: value2
link1:
ref: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
link2:
ref: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9

View File

@ -1,6 +0,0 @@
record:
name: cosmos-sdk
repo_reference: 'https://github.com/cosmos/cosmos-sdk'
description: This is a description string
version: 0.46.31
type: GitRepository

View File

@ -1,8 +0,0 @@
record:
repo_reference:
ref: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
js_package_ref:
ref: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
version: 1.0.0
type: JSPackage
name: test-JSPackage

View File

@ -1,9 +0,0 @@
record:
service_provider_ref:
ref: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
auction_ref:
ref: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
watcher_ref:
ref: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
version: 1.0.0
type: ResponderContract

View File

@ -1,12 +0,0 @@
record:
type: ServiceProviderRecord
bond_id: madeUpBondID
laconic_id: madeUpLaconicID
version: 1.0.12
x500:
common_name: cerc-io
organization_unit: xyz
organization_name: abc
state_name: california
country: US
locality_name: local

View File

@ -1,15 +0,0 @@
record:
metadata:
version: 0.32.0
chain_reference:
ref: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
repo_reference:
ref: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
wasm:
hash_reference:
ref: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
metadata:
compiler_version: 1.15.0
execution_engine_version: 0.16.1
version: 1.0.3
type: WatcherRegistrationRecord

View File

@ -1,10 +0,0 @@
record:
type: WebsiteRegistrationRecord
url: 'https://cerc.io'
repo_reference:
ref: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
build_artifact_ref:
ref: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
tls_cert_ref:
ref: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
version: 1.0.28

View File

@ -32,147 +32,12 @@ export class Record {
var a = new any.google.protobuf.Any()
switch (this._record.type){
case "WebsiteRegistrationRecord": {
var webAttr= new attributes.vulcanize.registry.v1beta1.WebsiteRegistrationRecord({
url: this._record.url,
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.repo_reference),
build_artifact_ref: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.build_artifact_ref),
tls_cert_ref:new attributes.vulcanize.registry.v1beta1.HashReference(this._record.tls_cert_ref),
type: this._record.type,
version:this._record.version,
})
if (this._record.type=="WebsiteRegistrationRecord"){
var attr= new attributes.vulcanize.registry.v1beta1.WebsiteRegistrationRecord(this._record)
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.WebsiteRegistrationRecord",
value: webAttr.serialize()
value: attr.serialize()
})
};
break;
case "ServiceProviderRecord": {
var serAttr= new attributes.vulcanize.registry.v1beta1.ServiceProviderRecord({
bond_id:this._record.bond_id,
laconic_id:this._record.laconic_id,
type:this._record.type,
version:this._record.version,
x500: new attributes.vulcanize.registry.v1beta1.ServiceProviderRecord.X500(this._record.x500)
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.ServiceProviderRecord",
value: serAttr.serialize()
})
};
break;
case "GitRepository": {
var gitAttr= new attributes.vulcanize.registry.v1beta1.GitRepository(this._record)
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.GitRepository",
value: gitAttr.serialize()
})
};
break;
case "Binary": {
var binaryAttr= new attributes.vulcanize.registry.v1beta1.Binary({
hash_reference: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.hash_reference),
targeted_arch: this._record.targeted_arch,
runtime_version: this._record.runtime_version,
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.repo_reference),
version: this._record.version,
type: this._record.type,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.Binary",
value: binaryAttr.serialize()
})
};
break;
case "DockerImage": {
var dockerAttr= new attributes.vulcanize.registry.v1beta1.DockerImage({
image_id: this._record.image_id,
binary_reference: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.binary_reference),
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.repo_reference),
version: this._record.version,
type: this._record.type,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.DockerImage",
value: dockerAttr.serialize()
})
};
break;
case "WatcherRegistrationRecord": {
var watcherAttr= new attributes.vulcanize.registry.v1beta1.WatcherRegistrationRecord({
metadata: new attributes.vulcanize.registry.v1beta1.WatcherRegistrationRecord.WatcherMetadata({
version: this._record.metadata.version,
chain_reference: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.metadata.chain_reference),
}),
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.repo_reference),
wasm: new attributes.vulcanize.registry.v1beta1.WatcherRegistrationRecord.WASMBinary({
hash_reference: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.wasm.hash_reference),
metadata: new attributes.vulcanize.registry.v1beta1.WatcherRegistrationRecord.WASMBinaryMetadata(this._record.wasm.metadata),
}),
version: this._record.version,
type: this._record.type,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.WatcherRegistrationRecord",
value: watcherAttr.serialize()
})
};
break;
case "ResponderContract": {
var respAttr= new attributes.vulcanize.registry.v1beta1.ResponderContract({
service_provider_ref: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.service_provider_ref),
auction_ref: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.auction_ref),
watcher_ref: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.watcher_ref),
version: this._record.version,
type: this._record.type,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.ResponderContract",
value: respAttr.serialize()
})
};
break;
case "JSPackage": {
var jsAttr= new attributes.vulcanize.registry.v1beta1.JSPackage({
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.repo_reference),
js_package_ref: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.js_package_ref),
version: this._record.version,
type: this._record.type,
name: this._record.name,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.JSPackage",
value: jsAttr.serialize()
})
};
break;
case "ChainRegistrationRecord": {
var chainAttr= new attributes.vulcanize.registry.v1beta1.ChainRegistrationRecord({
name: this._record.name,
ipld_types: this._record.ipld_types,
type: this._record.type,
version: this._record.version,
chain_id: this._record.chain_id,
network_id: this._record.network_id,
genesis_hash: new attributes.vulcanize.registry.v1beta1.HashReference(this._record.genesis_hash),
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.ChainRegistrationRecord",
value: chainAttr.serialize()
})
};
break;
default:
}
return a
}

View File

@ -4,7 +4,7 @@ import { Registry } from './index';
import { getBaseConfig, getConfig } from './testing/helper';
import { Util } from './util';
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/git_repo_example.yml');
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
jest.setTimeout(90 * 1000);

910
yarn.lock

File diff suppressed because it is too large Load Diff