forked from cerc-io/laconic-sdk
Compare commits
9 Commits
main
...
murali/rec
Author | SHA1 | Date | |
---|---|---|---|
|
0f6a17527b | ||
|
76897789e9 | ||
|
f622b40ca4 | ||
|
73af07c49f | ||
|
578ed5956e | ||
|
a7fc72ad31 | ||
|
97994856ff | ||
|
37c577fb1d | ||
|
12dfc4362b |
@ -1,36 +0,0 @@
|
||||
name: Publish npm package to gitea
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
jobs:
|
||||
npm_publish:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [ 18.x ]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Download yarn
|
||||
run: |
|
||||
curl -fsSL -o /usr/local/bin/yarn https://github.com/yarnpkg/yarn/releases/download/v1.22.21/yarn-1.22.21.js
|
||||
chmod +x /usr/local/bin/yarn
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: yarn
|
||||
- name: Run yarn build
|
||||
run: |
|
||||
yarn build
|
||||
- name: Configure git.vdb.to npm registry
|
||||
run: |
|
||||
npm config set registry https://git.vdb.to/api/packages/cerc-io/npm/
|
||||
- name: Authenticate to git.vdb.to registry
|
||||
run: |
|
||||
npm config set -- '//git.vdb.to/api/packages/cerc-io/npm/:_authToken' "${{ secrets.CICD_PUBLISH_TOKEN }}"
|
||||
- name: npm publish
|
||||
run: |
|
||||
npm publish
|
@ -1,81 +0,0 @@
|
||||
name: Tests
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- release/**
|
||||
|
||||
env:
|
||||
DOCKER_HOST: unix:///var/run/dind.sock
|
||||
|
||||
jobs:
|
||||
sdk_tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Checkout laconicd
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: "./laconicd/"
|
||||
repository: cerc-io/laconicd
|
||||
fetch-depth: 0
|
||||
ref: main
|
||||
- name: Environment
|
||||
run: ls -tlh && env
|
||||
- name: Start dockerd
|
||||
run: |
|
||||
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
||||
sleep 5
|
||||
- name: build containers scripts
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: ./build-laconicd-container.sh
|
||||
- name: build test-container
|
||||
run: docker build -t cerc-io/laconic-sdk-tester:local-test -f laconicd/tests/sdk_tests/Dockerfile-sdk .
|
||||
- name: start containers
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: docker compose up -d
|
||||
- name: run basic tests
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: |
|
||||
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
||||
cosmos_chain_id=laconic_9000-1
|
||||
laconicd_rest_endpoint=http://laconicd:1317
|
||||
laconicd_gql_endpoint=http://laconicd:9473/api
|
||||
sleep 30s
|
||||
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test"
|
||||
- name: stop containers
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: docker compose down
|
||||
- name: start auction containers
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: docker compose -f docker-compose-auctions.yml up -d
|
||||
- name: run auction tests
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: |
|
||||
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
||||
cosmos_chain_id=laconic_9000-1
|
||||
laconicd_rest_endpoint=http://laconicd:1317
|
||||
laconicd_gql_endpoint=http://laconicd:9473/api
|
||||
sleep 30s
|
||||
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test:auctions"
|
||||
- name: start containers
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: docker compose down
|
||||
- name: start containers
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: docker compose -f docker-compose-nameservice.yml up -d
|
||||
- name: run nameservice expiry tests
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: |
|
||||
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
||||
cosmos_chain_id=laconic_9000-1
|
||||
laconicd_rest_endpoint=http://laconicd:1317
|
||||
laconicd_gql_endpoint=http://laconicd:9473/api
|
||||
sleep 30s
|
||||
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test:nameservice-expiry"
|
||||
- name: stop nameservice containers
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: docker compose down
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cerc-io/laconic-sdk",
|
||||
"version": "0.1.13",
|
||||
"version": "0.1.6",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"repository": "git@github.com:cerc-io/laconic-sdk.git",
|
||||
@ -14,9 +14,9 @@
|
||||
"dotenv": "^16.0.0",
|
||||
"google-protobuf": "^3.21.0",
|
||||
"jest": "29.0.0",
|
||||
"protoc-gen-ts": "^0.8.7",
|
||||
"protoc-gen-ts": "^0.8.5",
|
||||
"ts-jest": "^29.0.2",
|
||||
"typescript": "^4.6.2"
|
||||
"typescript": "^4.7.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cosmjs/amino": "^0.28.1",
|
||||
|
@ -5,127 +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 {
|
||||
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 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 ApplicationRecord {
|
||||
string type = 1 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string name = 2 [(gogoproto.moretags) = "json:\"name\" yaml:\"name\""];
|
||||
string description = 3 [(gogoproto.moretags) = "json:\"description\" yaml:\"description\""];
|
||||
string version = 4 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
string homepage = 5 [(gogoproto.moretags) = "json:\"homepage\" yaml:\"homepage\""];
|
||||
string license = 6 [(gogoproto.moretags) = "json:\"license\" yaml:\"license\""];
|
||||
string author = 7 [(gogoproto.moretags) = "json:\"author\" yaml:\"author\""];
|
||||
repeated string repository = 8 [(gogoproto.moretags) = "json:\"repository\" yaml:\"repository\""];
|
||||
string repository_ref = 9 [(gogoproto.moretags) = "json:\"repositoryRef\" yaml:\"repositoryRef\""];
|
||||
string app_version = 10 [(gogoproto.moretags) = "json:\"appVersion\" yaml:\"appVersion\""];
|
||||
string app_type = 11 [(gogoproto.moretags) = "json:\"appType\" yaml:\"appType\""];
|
||||
string engines = 12 [(gogoproto.moretags) = "json:\"engines\" yaml:\"engines\""];
|
||||
repeated string os = 13 [(gogoproto.moretags) = "json:\"os\" yaml:\"os\""];
|
||||
repeated string cpu = 14 [(gogoproto.moretags) = "json:\"cpu\" yaml:\"cpu\""];
|
||||
string meta = 20 [(gogoproto.moretags) = "json:\"meta\" yaml:\"meta\""];
|
||||
repeated string tags = 21 [(gogoproto.moretags) = "json:\"tags\" yaml:\"tags\""];
|
||||
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 ApplicationArtifact {
|
||||
string type = 1 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string name = 2 [(gogoproto.moretags) = "json:\"name\" yaml:\"name\""];
|
||||
string description = 4 [(gogoproto.moretags) = "json:\"description\" yaml:\"description\""];
|
||||
string version = 5 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
string application = 6 [(gogoproto.moretags) = "json:\"application\" yaml:\"application\""];
|
||||
string content_type = 7 [(gogoproto.moretags) = "json:\"contentType\" yaml:\"contentType\""];
|
||||
string os = 8 [(gogoproto.moretags) = "json:\"os\" yaml:\"os\""];
|
||||
string cpu = 9 [(gogoproto.moretags) = "json:\"cpu\" yaml:\"cpu\""];
|
||||
repeated string uri = 10 [(gogoproto.moretags) = "json:\"uri\" yaml:\"uri\""];
|
||||
string meta = 20 [(gogoproto.moretags) = "json:\"meta\" yaml:\"meta\""];
|
||||
repeated string tags = 21 [(gogoproto.moretags) = "json:\"tags\" yaml:\"tags\""];
|
||||
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 DnsRecord {
|
||||
string type = 1 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string name = 2 [(gogoproto.moretags) = "json:\"name\" yaml:\"name\""];
|
||||
string version = 3 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
string resource_type = 4 [(gogoproto.moretags) = "json:\"resourceType\" yaml:\"resourceType\""];
|
||||
string value = 5 [(gogoproto.moretags) = "json:\"value\" yaml:\"value\""];
|
||||
string request = 6 [(gogoproto.moretags) = "json:\"request\" yaml:\"request\""];
|
||||
string meta = 20 [(gogoproto.moretags) = "json:\"meta\" yaml:\"meta\""];
|
||||
repeated string tags = 21 [(gogoproto.moretags) = "json:\"tags\" yaml:\"tags\""];
|
||||
message DockerImage{
|
||||
string image_id=1;
|
||||
HashReference binary_reference=2;
|
||||
HashReference repo_reference=3;
|
||||
string version=4;
|
||||
string type=5;
|
||||
}
|
||||
|
||||
message ApplicationDeploymentRequest {
|
||||
string type = 1 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string name = 2 [(gogoproto.moretags) = "json:\"name\" yaml:\"name\""];
|
||||
string version = 3 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
string application = 4 [(gogoproto.moretags) = "json:\"application\" yaml:\"application\""];
|
||||
string dns = 5 [(gogoproto.moretags) = "json:\"dns\" yaml:\"dns\""];
|
||||
string config = 6 [(gogoproto.moretags) = "json:\"config\" yaml:\"config\""];
|
||||
string deployment = 7 [(gogoproto.moretags) = "json:\"deployment\" yaml:\"deployment\""];
|
||||
string meta = 20 [(gogoproto.moretags) = "json:\"meta\" yaml:\"meta\""];
|
||||
repeated string tags = 21 [(gogoproto.moretags) = "json:\"tags\" yaml:\"tags\""];
|
||||
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 ApplicationDeploymentRecord {
|
||||
string type = 1 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string name = 2 [(gogoproto.moretags) = "json:\"name\" yaml:\"name\""];
|
||||
string description = 3 [(gogoproto.moretags) = "json:\"description\" yaml:\"description\""];
|
||||
string version = 4 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
string application = 5 [(gogoproto.moretags) = "json:\"application\" yaml:\"application\""];
|
||||
string url = 6 [(gogoproto.moretags) = "json:\"url\" yaml:\"url\""];
|
||||
string dns = 7 [(gogoproto.moretags) = "json:\"dns\" yaml:\"dns\""];
|
||||
string request = 8 [(gogoproto.moretags) = "json:\"request\" yaml:\"request\""];
|
||||
string meta = 20 [(gogoproto.moretags) = "json:\"meta\" yaml:\"meta\""];
|
||||
repeated string tags = 21 [(gogoproto.moretags) = "json:\"tags\" yaml:\"tags\""];
|
||||
message ResponderContract{
|
||||
HashReference service_provider_ref=1;
|
||||
HashReference auction_ref=2;
|
||||
HashReference watcher_ref=3;
|
||||
string version=4;
|
||||
string type=5;
|
||||
}
|
||||
|
||||
message ApplicationDeploymentRemovalRequest {
|
||||
string type = 1 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string version = 2 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
string deployment = 3 [(gogoproto.moretags) = "json:\"deployment\" yaml:\"deployment\""];
|
||||
string request = 4 [(gogoproto.moretags) = "json:\"request\" yaml:\"request\""];
|
||||
string meta = 20 [(gogoproto.moretags) = "json:\"meta\" yaml:\"meta\""];
|
||||
repeated string tags = 21 [(gogoproto.moretags) = "json:\"tags\" yaml:\"tags\""];
|
||||
message JSPackage{
|
||||
HashReference repo_reference=1;
|
||||
HashReference js_package_ref=2;
|
||||
string version=3;
|
||||
string type=4;
|
||||
string name =5;
|
||||
}
|
||||
|
||||
message ApplicationDeploymentRemovalRecord {
|
||||
string type = 1 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string version = 2 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
string deployment = 3 [(gogoproto.moretags) = "json:\"deployment\" yaml:\"deployment\""];
|
||||
string request = 4 [(gogoproto.moretags) = "json:\"request\" yaml:\"request\""];
|
||||
string meta = 20 [(gogoproto.moretags) = "json:\"meta\" yaml:\"meta\""];
|
||||
repeated string tags = 21 [(gogoproto.moretags) = "json:\"tags\" yaml:\"tags\""];
|
||||
}
|
||||
|
||||
message GeneralRecord {
|
||||
string type = 1 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string name = 2 [(gogoproto.moretags) = "json:\"name\" yaml:\"name\""];
|
||||
string description = 3 [(gogoproto.moretags) = "json:\"description\" yaml:\"description\""];
|
||||
string version = 4 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
string category = 5 [(gogoproto.moretags) = "json:\"category\" yaml:\"category\""];
|
||||
string value = 6 [(gogoproto.moretags) = "json:\"value\" yaml:\"value\""];
|
||||
string meta = 20 [(gogoproto.moretags) = "json:\"meta\" yaml:\"meta\""];
|
||||
repeated string tags = 21 [(gogoproto.moretags) = "json:\"tags\" yaml:\"tags\""];
|
||||
}
|
||||
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;
|
||||
}
|
@ -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/data/watcher.yml');
|
||||
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/watcher_registration_example.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('');
|
||||
});
|
||||
};
|
||||
|
@ -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/data/watcher.yml');
|
||||
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/git_repo_example.yml');
|
||||
|
||||
jest.setTimeout(120 * 1000);
|
||||
|
||||
@ -40,7 +40,7 @@ const nameserviceExpiryTests = () => {
|
||||
fee
|
||||
)
|
||||
console.log("SetRecordResult: " + result.data.id)
|
||||
const [record] = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
|
||||
const [record] = await registry.queryRecords({ "type---": watcher.record.type, "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: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
|
||||
const [record] = await registry.queryRecords({ "type---": watcher.record.type, "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: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
|
||||
const records = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version }, true);
|
||||
expect(records).toHaveLength(0);
|
||||
})
|
||||
|
||||
|
@ -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/data/watcher.yml');
|
||||
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/git_repo_example.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: 'WebsiteRegistrationRecord', version: watcher.record.version });
|
||||
const records = await registry.queryRecords({ "type---": watcher.record.type, "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: 'WebsiteRegistrationRecord', version: watcher.record.version });
|
||||
records = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version });
|
||||
expect(records).toBeDefined();
|
||||
expect(records).toHaveLength(0);
|
||||
|
||||
// Query all records should return it (all: true).
|
||||
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
|
||||
records = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version }, true);
|
||||
expect(records).toBeDefined();
|
||||
expect(records).toHaveLength(1);
|
||||
});
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: cosmos/base/query/v1beta1/pagination.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as pb_1 from "google-protobuf";
|
||||
@ -37,7 +37,7 @@ export namespace cosmos.base.query.v1beta1 {
|
||||
}
|
||||
}
|
||||
get key() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array;
|
||||
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array()) as Uint8Array;
|
||||
}
|
||||
set key(value: Uint8Array) {
|
||||
pb_1.Message.setField(this, 1, value);
|
||||
@ -184,7 +184,7 @@ export namespace cosmos.base.query.v1beta1 {
|
||||
}
|
||||
}
|
||||
get next_key() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array;
|
||||
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array()) as Uint8Array;
|
||||
}
|
||||
set next_key(value: Uint8Array) {
|
||||
pb_1.Message.setField(this, 1, value);
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: cosmos/base/v1beta1/coin.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: gogoproto/gogo.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../google/protobuf/descriptor";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: google/api/annotations.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./http";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: google/api/http.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as pb_1 from "google-protobuf";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: google/protobuf/any.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../gogoproto/gogo";
|
||||
@ -32,7 +32,7 @@ export namespace google.protobuf {
|
||||
pb_1.Message.setField(this, 1, value);
|
||||
}
|
||||
get value() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array(0)) as Uint8Array;
|
||||
return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array()) as Uint8Array;
|
||||
}
|
||||
set value(value: Uint8Array) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: google/protobuf/descriptor.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as pb_1 from "google-protobuf";
|
||||
@ -3604,7 +3604,7 @@ export namespace google.protobuf {
|
||||
return pb_1.Message.getField(this, 6) != null;
|
||||
}
|
||||
get string_value() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 7, new Uint8Array(0)) as Uint8Array;
|
||||
return pb_1.Message.getFieldWithDefault(this, 7, new Uint8Array()) as Uint8Array;
|
||||
}
|
||||
set string_value(value: Uint8Array) {
|
||||
pb_1.Message.setField(this, 7, value);
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: google/protobuf/duration.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as pb_1 from "google-protobuf";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: google/protobuf/timestamp.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as pb_1 from "google-protobuf";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/auction/v1beta1/genesis.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/auction/v1beta1/query.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/auction/v1beta1/tx.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/auction/v1beta1/types.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/bond/v1beta1/bond.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/bond/v1beta1/genesis.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/bond/v1beta1/query.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/bond/v1beta1/tx.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/registry/v1beta1/genesis.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/registry/v1beta1/query.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./registry";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/registry/v1beta1/registry.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../google/protobuf/duration";
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.25.1
|
||||
* compiler version: 3.12.4
|
||||
* source: vulcanize/registry/v1beta1/tx.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||
|
@ -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/data/watcher.yml');
|
||||
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/website_registration_example.yml');
|
||||
|
||||
jest.setTimeout(40 * 1000);
|
||||
|
||||
@ -45,17 +45,17 @@ describe('Querying', () => {
|
||||
});
|
||||
|
||||
test('Query records by reference.', async () => {
|
||||
const { repo_registration_record_cid } = watcher.record;
|
||||
const records = await registry.queryRecords({ repo_registration_record_cid }, true);
|
||||
const { ref } = watcher.record.repo_reference;
|
||||
const records = await registry.queryRecords({ "repo_reference---/---": ref}, true);
|
||||
expect(records.length).toBeGreaterThanOrEqual(1);
|
||||
|
||||
const { attributes: { repo_registration_record_cid: record_repo_registration_record_cid } } = records[0];
|
||||
expect(repo_registration_record_cid).toBe(record_repo_registration_record_cid);
|
||||
const { attributes: { repo_reference: {ref: record_repo_registration_record_cid} } } = records[0];
|
||||
expect(ref).toBe(record_repo_registration_record_cid);
|
||||
});
|
||||
|
||||
test('Query records by attributes.', async () => {
|
||||
const { version, name } = watcher.record;
|
||||
const records = await registry.queryRecords({ version, name }, true);
|
||||
const records = await registry.queryRecords({ "version---": version, "name---": 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_registration_record_cid).toBeDefined();
|
||||
expect(record.attributes.repo_registration_record_cid).toHaveLength(46);
|
||||
expect(record.attributes.repo_reference["/"]).toBeDefined();
|
||||
expect(record.attributes.repo_reference["/"]).toHaveLength(46);
|
||||
});
|
||||
});
|
||||
|
9
src/testing/examples/binary_example.yml
Normal file
9
src/testing/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
src/testing/examples/chain_registration_example.yml
Normal file
13
src/testing/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
src/testing/examples/docker_image_example.yml
Normal file
8
src/testing/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
|
7
src/testing/examples/example1.yml
Normal file
7
src/testing/examples/example1.yml
Normal file
@ -0,0 +1,7 @@
|
||||
record:
|
||||
attr1: value1
|
||||
attr2: value2
|
||||
link1:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
link2:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
6
src/testing/examples/git_repo_example.yml
Normal file
6
src/testing/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.48
|
||||
type: GitRepository
|
8
src/testing/examples/js_package_example.yml
Normal file
8
src/testing/examples/js_package_example.yml
Normal file
@ -0,0 +1,8 @@
|
||||
record:
|
||||
repo_reference:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
js_package_ref:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
version: 1.0.0
|
||||
type: JSPackage
|
||||
name: test-JSPackage
|
9
src/testing/examples/responder_contract_example.yml
Normal file
9
src/testing/examples/responder_contract_example.yml
Normal file
@ -0,0 +1,9 @@
|
||||
record:
|
||||
service_provider_ref:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
auction_ref:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
watcher_ref:
|
||||
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.0
|
||||
type: ResponderContract
|
12
src/testing/examples/service_provider_example.yml
Normal file
12
src/testing/examples/service_provider_example.yml
Normal file
@ -0,0 +1,12 @@
|
||||
record:
|
||||
type: ServiceProviderRecord
|
||||
bond_id: madeUpBondID
|
||||
laconic_id: madeUpLaconicID
|
||||
version: 1.0.13
|
||||
x500:
|
||||
common_name: cerc-io
|
||||
organization_unit: xyz
|
||||
organization_name: abc
|
||||
state_name: california
|
||||
country: US
|
||||
locality_name: local
|
15
src/testing/examples/watcher_registration_example.yml
Normal file
15
src/testing/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.25
|
||||
type: WatcherRegistrationRecord
|
10
src/testing/examples/website_registration_example.yml
Normal file
10
src/testing/examples/website_registration_example.yml
Normal file
@ -0,0 +1,10 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://cerc.io'
|
||||
repo_reference:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_ref:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_ref:
|
||||
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.20
|
@ -24,18 +24,13 @@ export const getBaseConfig = async (path: string) => {
|
||||
* Provision a bond for record registration.
|
||||
*/
|
||||
export const provisionBondId = async (registry: Registry, privateKey: string, fee: Fee) => {
|
||||
// let bonds = await registry.queryBonds();
|
||||
// console.log("found bonds: " + bonds.length)
|
||||
// if (!bonds.length) {
|
||||
// await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
|
||||
// bonds = await registry.queryBonds();
|
||||
// console.log("created bond and got back: " + bonds.length)
|
||||
// }
|
||||
let bondId: string;
|
||||
bondId = await registry.getNextBondId(privateKey);
|
||||
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
|
||||
return bondId
|
||||
//return bonds[0].id;
|
||||
let bonds = await registry.queryBonds();
|
||||
if (!bonds.length) {
|
||||
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
|
||||
bonds = await registry.queryBonds();
|
||||
}
|
||||
|
||||
return bonds[0].id;
|
||||
};
|
||||
|
||||
export const getConfig = () => {
|
||||
|
160
src/types.ts
160
src/types.ts
@ -29,22 +29,156 @@ export class Record {
|
||||
}
|
||||
|
||||
get attributes() {
|
||||
let a = new any.google.protobuf.Any();
|
||||
|
||||
if (this._record.type) {
|
||||
const namespace: any = attributes.vulcanize.registry.v1beta1;
|
||||
if (!namespace[this._record.type]) {
|
||||
throw new Error(`Class not found: ${this._record.type}`);
|
||||
}
|
||||
var a = new any.google.protobuf.Any()
|
||||
|
||||
const value = namespace[this._record.type].fromObject(this._record);
|
||||
a = new any.google.protobuf.Any({
|
||||
type_url: `/vulcanize.registry.v1beta1.${this._record.type}`,
|
||||
value: value.serialize(),
|
||||
});
|
||||
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({ref:this._record.repo_reference["/"],}),
|
||||
build_artifact_ref: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.build_artifact_ref["/"]}),
|
||||
tls_cert_ref:new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.tls_cert_ref["/"]}),
|
||||
type: this._record.type,
|
||||
version:this._record.version,
|
||||
})
|
||||
a= new any.google.protobuf.Any({
|
||||
type_url: "/vulcanize.registry.v1beta1.WebsiteRegistrationRecord",
|
||||
value: webAttr.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({ref:this._record.hash_reference["/"]}),
|
||||
targeted_arch: this._record.targeted_arch,
|
||||
runtime_version: this._record.runtime_version,
|
||||
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref: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({ref:this._record.binary_reference["/"]}),
|
||||
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref: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({ref:this._record.metadata.chain_reference["/"]}),
|
||||
}),
|
||||
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.repo_reference["/"]}),
|
||||
wasm: new attributes.vulcanize.registry.v1beta1.WatcherRegistrationRecord.WASMBinary({
|
||||
hash_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref: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({ref:this._record.service_provider_ref["/"]}),
|
||||
auction_ref: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.auction_ref["/"]}),
|
||||
watcher_ref: new attributes.vulcanize.registry.v1beta1.HashReference({ref: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({ref:this._record.repo_reference["/"]}),
|
||||
js_package_ref: new attributes.vulcanize.registry.v1beta1.HashReference({ref: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({ref:this._record.genesis_hash["/"]}),
|
||||
})
|
||||
a= new any.google.protobuf.Any({
|
||||
type_url: "/vulcanize.registry.v1beta1.ChainRegistrationRecord",
|
||||
value: chainAttr.serialize()
|
||||
})
|
||||
};
|
||||
break;
|
||||
|
||||
default: {
|
||||
const err = new Error("Unsupported reocrd type");
|
||||
console.error(err);
|
||||
throw err;
|
||||
};
|
||||
}
|
||||
|
||||
return a;
|
||||
return a
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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/data/watcher.yml');
|
||||
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/git_repo_example.yml');
|
||||
|
||||
jest.setTimeout(90 * 1000);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user