Compare commits

..
Author SHA1 Message Date
telackey 27443c3cac v0.1.7 (#45)
Reviewed-on: cerc-io/laconic-sdk#45
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-11-21 22:31:06 +00:00
telackey b5fce86d48 Add new record types ApplicationRecord, WebAppDeploymentRecord, GeneralRecord (#44)
See also: cerc-io/laconicd#113

![image](/attachments/db05bbb6-86ca-4fbb-a8a4-fcd06501b1b1)

```
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\""];
  string repository     = 8 [(gogoproto.moretags) = "json:\"repository\" yaml:\"repository\""];
  string repository_tag = 9 [(gogoproto.moretags) = "json:\"repositoryTag\" yaml:\"repositoryTag\""];
  string app_version    = 10 [(gogoproto.moretags) = "json:\"appVersion\" yaml:\"appVersion\""];
  string app_type       = 11 [(gogoproto.moretags) = "json:\"appType\" yaml:\"appType\""];
  string meta           = 20 [(gogoproto.moretags) = "json:\"meta\" yaml:\"meta\""];
  repeated string tags  = 21 [(gogoproto.moretags) = "json:\"tags\" yaml:\"tags\""];
}

message WebAppDeploymentRecord {
  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:\"\" yaml:\"name\""];
  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\""];
```

```
❯ cat general.yml
record:
  type: GeneralRecord
  name: my-generic-record
  version: 0.0.1
  value: "anything-goes-here"
  category: filter-by-this
  tags:
    - a
    - b
    - c
  meta:
    foo: bar
    bar:
      baz: boz

❯ bin/laconic cns record publish --filename general.yml --bond-id ba774084e25af5b29be126dda0bb910d93dea3634713a438ac257da5bbdc631c
{
  "id": "bafyreigt3he52eia5g4i5pnst4dfcuwwgjdoul6xmcke2obz5os4xwoo3q"
}

❯ bin/laconic cns record get --id bafyreigt3he52eia5g4i5pnst4dfcuwwgjdoul6xmcke2obz5os4xwoo3q
[
  {
    "id": "bafyreigt3he52eia5g4i5pnst4dfcuwwgjdoul6xmcke2obz5os4xwoo3q",
    "names": null,
    "owners": [
      "9A66500A9AA574CAAB4EDB26F7333590BF452CE0"
    ],
    "bondId": "ba774084e25af5b29be126dda0bb910d93dea3634713a438ac257da5bbdc631c",
    "createTime": "2023-11-17T23:11:27Z",
    "expiryTime": "2024-11-16T23:11:27Z",
    "attributes": {
      "meta": "{\"foo\":\"bar\",\"bar\":{\"baz\":\"boz\"}}",
      "tags": [
        "a",
        "b",
        "c"
      ],
      "type": "GeneralRecord",
      "name": "my-generic-record",
      "version": "0.0.1",
      "category": "filter-by-this",
      "value": "anything-goes-here"
    }
  }
]
```

> Note: The repeated items are preserved as lists, but the object/map ends up encoded as a string.  It would be nice to avoid this.

Reviewed-on: cerc-io/laconic-sdk#44
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-11-20 22:01:19 +00:00
31 changed files with 1229 additions and 361 deletions
-2
View File
@@ -1,2 +0,0 @@
Dockerfile
node_modules
+21 -5
View File
@@ -21,18 +21,34 @@ RUN \
&& npm config -g set prefix ${NPM_GLOBAL} \
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
# Install eslint
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint lerna jest" \
&& npm cache clean --force > /dev/null 2>&1
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
# [Optional] Uncomment if you want to install more global node modules
# RUN su node -c "npm install -g <your-package-list-here>"
WORKDIR /
RUN mkdir node_modules && mkdir proto && mkdir scripts && mkdir src
COPY node_modules ./node_modules/
COPY proto . ./proto/
COPY scripts ./scripts/
COPY src ./src/
COPY entrypoint.sh .
ENTRYPOINT ["/entrypoint.sh"]
# Placeholder CMD : generally this will be overridden at run time like :
# docker run -it -v /home/builder/cerc/laconic-sdk:/workspace cerc/builder-js sh -c 'cd /workspace && yarn && yarn build'
CMD node --version
WORKDIR /app/laconic-sdk
COPY package*.json .
# Temp hack, clone the laconic-sdk repo here
WORKDIR /app
RUN yarn install
COPY . .
WORKDIR /app/laconic-sdk
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-sdk",
"version": "0.1.6",
"version": "0.1.7",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:cerc-io/laconic-sdk.git",
@@ -14,7 +14,7 @@
"dotenv": "^16.0.0",
"google-protobuf": "^3.21.0",
"jest": "29.0.0",
"protoc-gen-ts": "^0.8.5",
"protoc-gen-ts": "^0.8.7",
"ts-jest": "^29.0.2",
"typescript": "^4.6.2"
},
@@ -30,4 +30,45 @@ message WebsiteRegistrationRecord {
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 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\""];
string repository = 8 [(gogoproto.moretags) = "json:\"repository\" yaml:\"repository\""];
string repository_tag = 9 [(gogoproto.moretags) = "json:\"repositoryTag\" yaml:\"repositoryTag\""];
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 WebAppDeploymentRecord {
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 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\""];
}
+68 -84
View File
@@ -12,10 +12,20 @@ jest.setTimeout(90 * 1000);
const bondTests = () => {
let registry: Registry;
let watcher: any;
let version1: string;
let version2: string;
let bondId1: string;
let bondId2: string;
let bondOwner: string;
const publishNewWatcherVersion = async (bondId: string) => {
let watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
await registry.setRecord({ privateKey, record: watcher.record, bondId }, privateKey, fee);
return watcher;
return watcher.record.version;
};
beforeAll(async () => {
@@ -23,119 +33,93 @@ const bondTests = () => {
});
test('Create bond.', async () => {
let bondId = await registry.getNextBondId(privateKey);
expect(bondId).toBeDefined();
bondId1 = await registry.getNextBondId(privateKey);
expect(bondId1).toBeDefined();
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
})
test('Get bond by ID.', async () => {
const [bond] = await registry.getBondsByIds([bondId1]);
expect(bond).toBeDefined();
expect(bond.id).toBe(bondId1);
expect(bond.balance).toHaveLength(1);
expect(bond.balance[0]).toEqual({ type: 'aphoton', quantity: '1000000000' });
bondOwner = bond.owner;
});
describe('With bond created', () => {
let bond1: any
test('Query bonds.', async () => {
const bonds = await registry.queryBonds();
expect(bonds).toBeDefined();
const bond = bonds.filter((bond: any) => bond.id === bondId1);
expect(bond).toBeDefined();
});
beforeAll(async () => {
let bondId1 = await registry.getNextBondId(privateKey);
expect(bondId1).toBeDefined();
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
test('Query bonds by owner.', async () => {
const bonds = await registry.queryBonds({ owner: bondOwner });
expect(bonds).toBeDefined();
const bond = bonds.filter((bond: any) => bond.id === bondId1);
expect(bond).toBeDefined();
});
[bond1] = await registry.getBondsByIds([bondId1]);
expect(bond1).toBeDefined();
expect(bond1.id).toEqual(bondId1);
});
test('Refill bond.', async () => {
await registry.refillBond({ id: bondId1, denom: 'aphoton', amount: '500' }, privateKey, fee);
test('Get bond by ID.', async () => {
const [bond] = await registry.getBondsByIds([bond1.id]);
expect(bond).toBeDefined();
expect(bond.id).toBe(bond1.id);
expect(bond.balance).toHaveLength(1);
expect(bond.balance[0]).toEqual({ type: 'aphoton', quantity: '1000000000' });
});
const [bond] = await registry.getBondsByIds([bondId1]);
expect(bond).toBeDefined();
expect(bond.id).toBe(bondId1);
expect(bond.balance).toHaveLength(1);
expect(bond.balance[0]).toEqual({ type: 'aphoton', quantity: '1000000500' });
});
test('Query bonds.', async () => {
const bonds = await registry.queryBonds();
expect(bonds).toBeDefined();
const bond = bonds.filter((bond: any) => bond.id === bond1.id);
expect(bond).toBeDefined();
});
test('Withdraw bond.', async () => {
await registry.withdrawBond({ id: bondId1, denom: 'aphoton', amount: '500' }, privateKey, fee);
test('Query bonds by owner.', async () => {
const bonds = await registry.queryBonds({ owner: bond1.owner });
expect(bonds).toBeDefined();
const bond = bonds.filter((bond: any) => bond.id === bond1.id);
expect(bond).toBeDefined();
});
const [bond] = await registry.getBondsByIds([bondId1]);
expect(bond).toBeDefined();
expect(bond.id).toBe(bondId1);
expect(bond.balance).toHaveLength(1);
expect(bond.balance[0]).toEqual({ type: 'aphoton', quantity: '1000000000' });
});
test('Refill bond.', async () => {
await registry.refillBond({ id: bond1.id, denom: 'aphoton', amount: '500' }, privateKey, fee);
const [bond] = await registry.getBondsByIds([bond1.id]);
expect(bond).toBeDefined();
expect(bond.id).toBe(bond1.id);
expect(bond.balance).toHaveLength(1);
expect(bond.balance[0]).toEqual({ type: 'aphoton', quantity: '1000000500' });
});
test('Withdraw bond.', async () => {
await registry.withdrawBond({ id: bond1.id, denom: 'aphoton', amount: '500' }, privateKey, fee);
const [bond] = await registry.getBondsByIds([bond1.id]);
expect(bond).toBeDefined();
expect(bond.id).toBe(bond1.id);
expect(bond.balance).toHaveLength(1);
expect(bond.balance[0]).toEqual({ type: 'aphoton', quantity: '1000000000' });
});
test('Cancel bond.', async () => {
await registry.cancelBond({ id: bond1.id }, privateKey, fee);
const [bond] = await registry.getBondsByIds([bond1.id]);
expect(bond.id).toBe("");
expect(bond.owner).toBe("");
expect(bond.balance).toHaveLength(0);
});
test('Cancel bond.', async () => {
await registry.cancelBond({ id: bondId1 }, privateKey, fee);
const [bond] = await registry.getBondsByIds([bondId1]);
expect(bond.id).toBe("");
expect(bond.owner).toBe("");
expect(bond.balance).toHaveLength(0);
});
test('Associate/Dissociate bond.', async () => {
let bondId1: string;
bondId1 = await registry.getNextBondId(privateKey);
expect(bondId1).toBeDefined();
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
// Create a new record.
let watcher = await publishNewWatcherVersion(bondId1);
let query = { type: watcher.record.type, url: watcher.record.url, version: watcher.record.version };
let [record1] = await registry.queryRecords(query, true);
version1 = await publishNewWatcherVersion(bondId1);
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(query, 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(query, true);
[record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(record1.bondId).toBe(bondId1);
});
test('Reassociate/Dissociate records.', async () => {
let bondId1: string;
let bondId2: string;
bondId1 = await registry.getNextBondId(privateKey);
expect(bondId1).toBeDefined();
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
// Create a new record version.
let watcher = await publishNewWatcherVersion(bondId1);
let queryv1 = { type: watcher.record.type, url: watcher.record.url, version: watcher.record.version };
let queryv2 = { type: watcher.record.type, url: watcher.record.url, version: watcher.record.version };
version2 = await publishNewWatcherVersion(bondId1);
// Check version1, version2 as associated with bondId1.
let records;
records = await registry.queryRecords(queryv1, 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(queryv2, 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.
@@ -147,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(queryv1, 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(queryv2, 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(queryv1, 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(queryv2, true);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true);
expect(records[0].bondId).toBe('');
});
};
+3 -3
View File
@@ -180,9 +180,9 @@ export class Registry {
}
/**
* Publish record.
* @param transactionPrivateKey - private key in HEX to sign transaction.
*/
* Publish record.
* @param transactionPrivateKey - private key in HEX to sign transaction.
*/
async setRecord(
params: { privateKey: string, record: any, bondId: string },
transactionPrivateKey: string,
+183 -227
View File
@@ -18,6 +18,12 @@ const namingTests = () => {
let watcher: any;
let watcherId: string;
let authorityName: string;
let otherAuthorityName: string;
let otherPrivateKey: string;
let crn: string;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
@@ -40,271 +46,221 @@ const namingTests = () => {
watcherId = result.data.id;
});
describe('Authority tests', () => {
test('Reserve authority.', async () => {
const authorityName = `laconic-${Date.now()}`;
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
});
describe('With authority reserved', () => {
let authorityName: string;
let crn: string;
beforeAll(async () => {
authorityName = `laconic-${Date.now()}`;
crn = `crn://${authorityName}/app/test`;
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
})
test('Lookup authority.', async () => {
const [record] = await registry.lookupAuthorities([authorityName]);
expect(record).toBeDefined();
expect(record.ownerAddress).not.toBe('');
expect(record.ownerPublicKey).not.toBe('');
expect(Number(record.height)).toBeGreaterThan(0);
});
test('Lookup non existing authority', async () => {
const [record] = await registry.lookupAuthorities(['does-not-exist']);
expect(record.ownerAddress).toBe('');
expect(record.ownerPublicKey).toBe('');
expect(Number(record.height)).toBe(0);
});
test('Reserve already reserved authority', async () => {
await expect(registry.reserveAuthority({ name: authorityName }, privateKey, fee)).
rejects.toThrow('Name already reserved.');
});
test('Reserve sub-authority.', async () => {
const subAuthority = `echo.${authorityName}`;
await registry.reserveAuthority({ name: subAuthority }, privateKey, fee);
const [record] = await registry.lookupAuthorities([subAuthority]);
expect(record).toBeDefined();
expect(record.ownerAddress).not.toBe('');
expect(record.ownerPublicKey).not.toBe('');
expect(Number(record.height)).toBeGreaterThan(0);
});
test('Reserve sub-authority with different owner.', async () => {
// Create another account, send tx to set public key on the account.
const mnenonic1 = Account.generateMnemonic();
const otherAccount1 = await Account.generateFromMnemonic(mnenonic1);
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount1.formattedCosmosAddress }, privateKey, fee);
const mnenonic2 = Account.generateMnemonic();
const otherAccount2 = await Account.generateFromMnemonic(mnenonic2);
await registry.sendCoins({ denom: 'aphoton', amount: '10', destinationAddress: otherAccount2.formattedCosmosAddress }, otherAccount1.getPrivateKey(), fee);
const subAuthority = `halo.${authorityName}`;
await registry.reserveAuthority({ name: subAuthority, owner: otherAccount1.formattedCosmosAddress }, privateKey, fee);
const [record] = await registry.lookupAuthorities([subAuthority]);
expect(record).toBeDefined();
expect(record.ownerAddress).toBeDefined();
expect(record.ownerAddress).toBe(otherAccount1.getCosmosAddress());
expect(record.ownerPublicKey).toBeDefined();
expect(Number(record.height)).toBeGreaterThan(0);
});
test('Set name for unbonded authority', async () => {
assert(watcherId)
await expect(registry.setName({ crn, cid: watcherId }, privateKey, fee)).
rejects.toThrow('Authority bond not found.');
});
test('Set authority bond', async () => {
await registry.setAuthorityBond({ name: authorityName, bondId }, privateKey, fee);
});
});
test('Reserve authority.', async () => {
authorityName = `laconic-${Date.now()}`;
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
});
describe('Naming tests', () => {
let authorityName: string;
let otherAuthorityName: string;
let otherPrivateKey: string;
let otherAccount: Account;
test('Lookup authority.', async () => {
const [record] = await registry.lookupAuthorities([authorityName]);
beforeAll(async () => {
authorityName = `laconic-${Date.now()}`;
expect(record).toBeDefined();
expect(record.ownerAddress).not.toBe('');
expect(record.ownerPublicKey).not.toBe('');
expect(Number(record.height)).toBeGreaterThan(0);
});
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
await registry.setAuthorityBond({ name: authorityName, bondId }, privateKey, fee);
test('Lookup non existing authority', async () => {
const [record] = await registry.lookupAuthorities(['does-not-exist']);
// Create another account.
const mnenonic = Account.generateMnemonic();
otherAccount = await Account.generateFromMnemonic(mnenonic);
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount.formattedCosmosAddress }, privateKey, fee);
expect(record.ownerAddress).toBe('');
expect(record.ownerPublicKey).toBe('');
expect(Number(record.height)).toBe(0);
});
otherAuthorityName = `other-${Date.now()}`;
otherPrivateKey = otherAccount.privateKey.toString('hex');
});
test('Reserve already reserved authority', async () => {
await expect(registry.reserveAuthority({ name: authorityName }, privateKey, fee)).rejects.toThrow('Name already reserved.');
});
test('Set name', async () => {
const crn = `crn://${authorityName}/app/test1`;
test('Reserve sub-authority.', async () => {
const subAuthority = `echo.${authorityName}`;
await registry.reserveAuthority({ name: subAuthority }, privateKey, fee);
await registry.setName({ crn, cid: watcherId }, privateKey, fee);
const [record] = await registry.lookupAuthorities([subAuthority]);
expect(record).toBeDefined();
expect(record.ownerAddress).not.toBe('');
expect(record.ownerPublicKey).not.toBe('');
expect(Number(record.height)).toBeGreaterThan(0);
});
// Query records should return it (some CRN points to it).
const records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
expect(records).toBeDefined();
expect(records).toHaveLength(1);
test('Reserve sub-authority with different owner.', async () => {
// Create another account, send tx to set public key on the account.
const mnenonic1 = Account.generateMnemonic();
const otherAccount1 = await Account.generateFromMnemonic(mnenonic1);
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount1.formattedCosmosAddress }, privateKey, fee);
await registry.deleteName({ crn }, privateKey, fee);
});
const mnenonic2 = Account.generateMnemonic();
const otherAccount2 = await Account.generateFromMnemonic(mnenonic2);
await registry.sendCoins({ denom: 'aphoton', amount: '10', destinationAddress: otherAccount2.formattedCosmosAddress }, otherAccount1.getPrivateKey(), fee);
describe('With name set', () => {
let crn: string;
const subAuthority = `halo.${authorityName}`;
await registry.reserveAuthority({ name: subAuthority, owner: otherAccount1.formattedCosmosAddress }, privateKey, fee);
beforeAll(async () => {
crn = `crn://${authorityName}/app/test2`;
await registry.setName({ crn, cid: watcherId }, privateKey, fee);
});
const [record] = await registry.lookupAuthorities([subAuthority]);
expect(record).toBeDefined();
expect(record.ownerAddress).toBeDefined();
expect(record.ownerAddress).toBe(otherAccount1.getCosmosAddress());
expect(record.ownerPublicKey).toBeDefined();
expect(Number(record.height)).toBeGreaterThan(0);
});
afterAll(async () => {
await registry.deleteName({ crn }, privateKey, fee);
});
test('Set name for unbonded authority', async () => {
crn = `crn://${authorityName}/app/test`;
assert(watcherId)
await expect(registry.setName({ crn, cid: watcherId }, privateKey, fee)).rejects.toThrow('Authority bond not found.');
});
test('Lookup name', async () => {
const records = await registry.lookupNames([crn]);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
test('Set authority bond', async () => {
await registry.setAuthorityBond({ name: authorityName, bondId }, privateKey, fee);
});
const [{ latest, history }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe(watcherId);
expect(latest.height).toBeDefined();
expect(history).toBeUndefined();
});
test('Set name', async () => {
crn = `crn://${authorityName}/app/test`;
await registry.setName({ crn, cid: watcherId }, privateKey, fee);
test('Resolve name', async () => {
const records = await registry.resolveNames([crn]);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
// Query records should return it (some CRN points to it).
const records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
expect(records).toBeDefined();
expect(records).toHaveLength(1);
});
const [{ attributes }] = records;
expect(attributes).toEqual(watcher.record);
});
test('Lookup name', async () => {
const records = await registry.lookupNames([crn]);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
test('Lookup name with history', async () => {
const updatedWatcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
const result = await registry.setRecord(
{
privateKey,
bondId,
record: updatedWatcher.record
},
privateKey,
fee
)
const [{ latest, history }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe(watcherId);
expect(latest.height).toBeDefined();
expect(history).toBeUndefined();
});
const updatedWatcherId = result.data.id;
await registry.setName({ crn, cid: updatedWatcherId }, privateKey, fee);
test('Resolve name', async () => {
const records = await registry.resolveNames([crn]);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const records = await registry.lookupNames([crn], true);
expect(records).toHaveLength(1);
const [{ attributes }] = records;
expect(attributes).toEqual(watcher.record);
});
const [{ latest, history }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe(updatedWatcherId);
expect(latest.height).toBeDefined();
expect(history).toBeDefined();
expect(history).toHaveLength(1);
test('Lookup name with history', async () => {
const updatedWatcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
const result = await registry.setRecord(
{
privateKey,
bondId,
record: updatedWatcher.record
},
privateKey,
fee
)
const [oldRecord] = history;
expect(oldRecord).toBeDefined();
expect(oldRecord.id).toBeDefined();
expect(oldRecord.id).toBe(watcherId);
expect(oldRecord.height).toBeDefined();
});
const updatedWatcherId = result.data.id;
await registry.setName({ crn, cid: updatedWatcherId }, privateKey, fee);
test('Delete name', async () => {
await registry.deleteName({ crn }, privateKey, fee);
const records = await registry.lookupNames([crn], true);
expect(records).toHaveLength(1);
let records = await registry.lookupNames([crn], true);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [{ latest, history }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe(updatedWatcherId);
expect(latest.height).toBeDefined();
expect(history).toBeDefined();
expect(history).toHaveLength(1);
const [{ latest }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe('');
expect(latest.height).toBeDefined();
const [oldRecord] = history;
expect(oldRecord).toBeDefined();
expect(oldRecord.id).toBeDefined();
expect(oldRecord.id).toBe(watcherId);
expect(oldRecord.height).toBeDefined();
});
// Query records should NOT return it (no CRN points to it).
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
expect(records).toBeDefined();
expect(records).toHaveLength(0);
test('Set name without reserving authority', async () => {
await expect(registry.setName({ crn: 'crn://not-reserved/app/test', cid: watcherId }, privateKey, fee))
.rejects.toThrow('Name authority not found.');
});
// Query all records should return it (all: true).
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
});
test('Set name for non-owned authority', async () => {
// Create another account.
const mnenonic = Account.generateMnemonic();
const otherAccount = await Account.generateFromMnemonic(mnenonic);
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount.formattedCosmosAddress }, privateKey, fee);
test('Delete already deleted name', async () => {
await registry.deleteName({ crn }, privateKey, fee);
await registry.deleteName({ crn }, privateKey, fee);
// Other account reserves an authority.
otherAuthorityName = `other-${Date.now()}`;
otherPrivateKey = otherAccount.privateKey.toString('hex');
await registry.reserveAuthority({ name: otherAuthorityName }, otherPrivateKey, fee);
const records = await registry.lookupNames([crn], true);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
// Try setting name under other authority.
await expect(registry.setName({ crn: `crn://${otherAuthorityName}/app/test`, cid: watcherId }, privateKey, fee)).rejects.toThrow('Access denied.');
});
const [{ latest }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe('');
expect(latest.height).toBeDefined();
});
});
test('Lookup non existing name', async () => {
const records = await registry.lookupNames(['crn://not-reserved/app/test']);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [record] = records;
expect(record).toBeNull();
});
test('Set name without reserving authority', async () => {
await expect(registry.setName({ crn: 'crn://not-reserved/app/test', cid: watcherId }, privateKey, fee))
.rejects.toThrow('Name authority not found.');
});
test('Resolve non existing name', async () => {
const records = await registry.resolveNames(['crn://not-reserved/app/test']);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [record] = records;
expect(record).toBeNull();
});
test('Set name for non-owned authority', async () => {
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount.formattedCosmosAddress }, privateKey, fee);
test('Delete name', async () => {
await registry.deleteName({ crn }, privateKey, fee);
// Other account reserves an authority.
await registry.reserveAuthority({ name: otherAuthorityName }, otherPrivateKey, fee);
let records = await registry.lookupNames([crn], true);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
// Try setting name under other authority.
await expect(registry.setName({ crn: `crn://${otherAuthorityName}/app/test`, cid: watcherId }, privateKey, fee)).rejects.toThrow('Access denied.');
});
const [{ latest }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe('');
expect(latest.height).toBeDefined();
test('Delete name for non-owned authority.', async () => {
const otherBondId = await registry.getNextBondId(otherPrivateKey);
await registry.createBond({ denom: 'aphoton', amount: '10000' }, otherPrivateKey, fee);
await registry.setAuthorityBond({ name: otherAuthorityName, bondId: otherBondId }, otherPrivateKey, fee);
await registry.setName({ crn: `crn://${otherAuthorityName}/app/test`, cid: watcherId }, otherPrivateKey, fee);
// Query records should NOT return it (no CRN points to it).
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
expect(records).toBeDefined();
expect(records).toHaveLength(0);
// Try deleting name under other authority.
await expect(registry.deleteName({ crn: `crn://${otherAuthorityName}/app/test` }, privateKey, fee)).rejects.toThrow('Access denied.');
});
// Query all records should return it (all: true).
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
});
test('Lookup non existing name', async () => {
const records = await registry.lookupNames(['crn://not-reserved/app/test']);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [record] = records;
expect(record).toBeNull();
});
test('Delete already deleted name', async () => {
await registry.deleteName({ crn }, privateKey, fee);
test('Resolve non existing name', async () => {
const records = await registry.resolveNames(['crn://not-reserved/app/test']);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [record] = records;
expect(record).toBeNull();
});
const records = await registry.lookupNames([crn], true);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [{ latest }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe('');
expect(latest.height).toBeDefined();
});
test('Delete name for non-owned authority.', async () => {
const otherBondId = await registry.getNextBondId(otherPrivateKey);
await registry.createBond({ denom: 'aphoton', amount: '10000' }, otherPrivateKey, fee);
await registry.setAuthorityBond({ name: otherAuthorityName, bondId: otherBondId }, otherPrivateKey, fee);
await registry.setName({ crn: `crn://${otherAuthorityName}/app/test`, cid: watcherId }, otherPrivateKey, fee);
// Try deleting name under other authority.
await expect(registry.deleteName({ crn: `crn://${otherAuthorityName}/app/test` }, privateKey, fee)).rejects.toThrow('Access denied.');
});
};
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* 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()) as Uint8Array;
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) 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()) as Uint8Array;
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array;
}
set next_key(value: Uint8Array) {
pb_1.Message.setField(this, 1, value);
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: cosmos/base/v1beta1/coin.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: gogoproto/gogo.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../google/protobuf/descriptor";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: google/api/annotations.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./http";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: google/api/http.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf";
+2 -2
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* 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()) as Uint8Array;
return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array(0)) as Uint8Array;
}
set value(value: Uint8Array) {
pb_1.Message.setField(this, 2, value);
+2 -2
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* 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()) as Uint8Array;
return pb_1.Message.getFieldWithDefault(this, 7, new Uint8Array(0)) as Uint8Array;
}
set string_value(value: Uint8Array) {
pb_1.Message.setField(this, 7, value);
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: google/protobuf/duration.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* 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: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/auction/v1beta1/genesis.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/auction/v1beta1/query.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/auction/v1beta1/tx.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/auction/v1beta1/types.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/bond/v1beta1/bond.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/bond/v1beta1/genesis.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/bond/v1beta1/query.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/bond/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: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/registry/v1beta1/attributes.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
@@ -534,4 +534,872 @@ export namespace vulcanize.registry.v1beta1 {
return WebsiteRegistrationRecord.deserialize(bytes);
}
}
export class ApplicationRecord extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
type?: string;
name?: string;
description?: string;
version?: string;
homepage?: string;
license?: string;
author?: string;
repository?: string;
repository_tag?: string;
app_version?: string;
app_type?: string;
engines?: string;
os?: string[];
cpu?: string[];
meta?: string;
tags?: string[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [13, 14, 21], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("type" in data && data.type != undefined) {
this.type = data.type;
}
if ("name" in data && data.name != undefined) {
this.name = data.name;
}
if ("description" in data && data.description != undefined) {
this.description = data.description;
}
if ("version" in data && data.version != undefined) {
this.version = data.version;
}
if ("homepage" in data && data.homepage != undefined) {
this.homepage = data.homepage;
}
if ("license" in data && data.license != undefined) {
this.license = data.license;
}
if ("author" in data && data.author != undefined) {
this.author = data.author;
}
if ("repository" in data && data.repository != undefined) {
this.repository = data.repository;
}
if ("repository_tag" in data && data.repository_tag != undefined) {
this.repository_tag = data.repository_tag;
}
if ("app_version" in data && data.app_version != undefined) {
this.app_version = data.app_version;
}
if ("app_type" in data && data.app_type != undefined) {
this.app_type = data.app_type;
}
if ("engines" in data && data.engines != undefined) {
this.engines = data.engines;
}
if ("os" in data && data.os != undefined) {
this.os = data.os;
}
if ("cpu" in data && data.cpu != undefined) {
this.cpu = data.cpu;
}
if ("meta" in data && data.meta != undefined) {
this.meta = data.meta;
}
if ("tags" in data && data.tags != undefined) {
this.tags = data.tags;
}
}
}
get type() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set type(value: string) {
pb_1.Message.setField(this, 1, value);
}
get name() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set name(value: string) {
pb_1.Message.setField(this, 2, value);
}
get description() {
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
}
set description(value: string) {
pb_1.Message.setField(this, 3, value);
}
get version() {
return pb_1.Message.getFieldWithDefault(this, 4, "") as string;
}
set version(value: string) {
pb_1.Message.setField(this, 4, value);
}
get homepage() {
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
}
set homepage(value: string) {
pb_1.Message.setField(this, 5, value);
}
get license() {
return pb_1.Message.getFieldWithDefault(this, 6, "") as string;
}
set license(value: string) {
pb_1.Message.setField(this, 6, value);
}
get author() {
return pb_1.Message.getFieldWithDefault(this, 7, "") as string;
}
set author(value: string) {
pb_1.Message.setField(this, 7, value);
}
get repository() {
return pb_1.Message.getFieldWithDefault(this, 8, "") as string;
}
set repository(value: string) {
pb_1.Message.setField(this, 8, value);
}
get repository_tag() {
return pb_1.Message.getFieldWithDefault(this, 9, "") as string;
}
set repository_tag(value: string) {
pb_1.Message.setField(this, 9, value);
}
get app_version() {
return pb_1.Message.getFieldWithDefault(this, 10, "") as string;
}
set app_version(value: string) {
pb_1.Message.setField(this, 10, value);
}
get app_type() {
return pb_1.Message.getFieldWithDefault(this, 11, "") as string;
}
set app_type(value: string) {
pb_1.Message.setField(this, 11, value);
}
get engines() {
return pb_1.Message.getFieldWithDefault(this, 12, "") as string;
}
set engines(value: string) {
pb_1.Message.setField(this, 12, value);
}
get os() {
return pb_1.Message.getFieldWithDefault(this, 13, []) as string[];
}
set os(value: string[]) {
pb_1.Message.setField(this, 13, value);
}
get cpu() {
return pb_1.Message.getFieldWithDefault(this, 14, []) as string[];
}
set cpu(value: string[]) {
pb_1.Message.setField(this, 14, value);
}
get meta() {
return pb_1.Message.getFieldWithDefault(this, 20, "") as string;
}
set meta(value: string) {
pb_1.Message.setField(this, 20, value);
}
get tags() {
return pb_1.Message.getFieldWithDefault(this, 21, []) as string[];
}
set tags(value: string[]) {
pb_1.Message.setField(this, 21, value);
}
static fromObject(data: {
type?: string;
name?: string;
description?: string;
version?: string;
homepage?: string;
license?: string;
author?: string;
repository?: string;
repository_tag?: string;
app_version?: string;
app_type?: string;
engines?: string;
os?: string[];
cpu?: string[];
meta?: string;
tags?: string[];
}): ApplicationRecord {
const message = new ApplicationRecord({});
if (data.type != null) {
message.type = data.type;
}
if (data.name != null) {
message.name = data.name;
}
if (data.description != null) {
message.description = data.description;
}
if (data.version != null) {
message.version = data.version;
}
if (data.homepage != null) {
message.homepage = data.homepage;
}
if (data.license != null) {
message.license = data.license;
}
if (data.author != null) {
message.author = data.author;
}
if (data.repository != null) {
message.repository = data.repository;
}
if (data.repository_tag != null) {
message.repository_tag = data.repository_tag;
}
if (data.app_version != null) {
message.app_version = data.app_version;
}
if (data.app_type != null) {
message.app_type = data.app_type;
}
if (data.engines != null) {
message.engines = data.engines;
}
if (data.os != null) {
message.os = data.os;
}
if (data.cpu != null) {
message.cpu = data.cpu;
}
if (data.meta != null) {
message.meta = data.meta;
}
if (data.tags != null) {
message.tags = data.tags;
}
return message;
}
toObject() {
const data: {
type?: string;
name?: string;
description?: string;
version?: string;
homepage?: string;
license?: string;
author?: string;
repository?: string;
repository_tag?: string;
app_version?: string;
app_type?: string;
engines?: string;
os?: string[];
cpu?: string[];
meta?: string;
tags?: string[];
} = {};
if (this.type != null) {
data.type = this.type;
}
if (this.name != null) {
data.name = this.name;
}
if (this.description != null) {
data.description = this.description;
}
if (this.version != null) {
data.version = this.version;
}
if (this.homepage != null) {
data.homepage = this.homepage;
}
if (this.license != null) {
data.license = this.license;
}
if (this.author != null) {
data.author = this.author;
}
if (this.repository != null) {
data.repository = this.repository;
}
if (this.repository_tag != null) {
data.repository_tag = this.repository_tag;
}
if (this.app_version != null) {
data.app_version = this.app_version;
}
if (this.app_type != null) {
data.app_type = this.app_type;
}
if (this.engines != null) {
data.engines = this.engines;
}
if (this.os != null) {
data.os = this.os;
}
if (this.cpu != null) {
data.cpu = this.cpu;
}
if (this.meta != null) {
data.meta = this.meta;
}
if (this.tags != null) {
data.tags = this.tags;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.type.length)
writer.writeString(1, this.type);
if (this.name.length)
writer.writeString(2, this.name);
if (this.description.length)
writer.writeString(3, this.description);
if (this.version.length)
writer.writeString(4, this.version);
if (this.homepage.length)
writer.writeString(5, this.homepage);
if (this.license.length)
writer.writeString(6, this.license);
if (this.author.length)
writer.writeString(7, this.author);
if (this.repository.length)
writer.writeString(8, this.repository);
if (this.repository_tag.length)
writer.writeString(9, this.repository_tag);
if (this.app_version.length)
writer.writeString(10, this.app_version);
if (this.app_type.length)
writer.writeString(11, this.app_type);
if (this.engines.length)
writer.writeString(12, this.engines);
if (this.os.length)
writer.writeRepeatedString(13, this.os);
if (this.cpu.length)
writer.writeRepeatedString(14, this.cpu);
if (this.meta.length)
writer.writeString(20, this.meta);
if (this.tags.length)
writer.writeRepeatedString(21, this.tags);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ApplicationRecord {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ApplicationRecord();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.type = reader.readString();
break;
case 2:
message.name = reader.readString();
break;
case 3:
message.description = reader.readString();
break;
case 4:
message.version = reader.readString();
break;
case 5:
message.homepage = reader.readString();
break;
case 6:
message.license = reader.readString();
break;
case 7:
message.author = reader.readString();
break;
case 8:
message.repository = reader.readString();
break;
case 9:
message.repository_tag = reader.readString();
break;
case 10:
message.app_version = reader.readString();
break;
case 11:
message.app_type = reader.readString();
break;
case 12:
message.engines = reader.readString();
break;
case 13:
pb_1.Message.addToRepeatedField(message, 13, reader.readString());
break;
case 14:
pb_1.Message.addToRepeatedField(message, 14, reader.readString());
break;
case 20:
message.meta = reader.readString();
break;
case 21:
pb_1.Message.addToRepeatedField(message, 21, reader.readString());
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): ApplicationRecord {
return ApplicationRecord.deserialize(bytes);
}
}
export class WebAppDeploymentRecord extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
type?: string;
name?: string;
description?: string;
version?: string;
application?: string;
url?: string;
meta?: string;
tags?: string[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [21], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("type" in data && data.type != undefined) {
this.type = data.type;
}
if ("name" in data && data.name != undefined) {
this.name = data.name;
}
if ("description" in data && data.description != undefined) {
this.description = data.description;
}
if ("version" in data && data.version != undefined) {
this.version = data.version;
}
if ("application" in data && data.application != undefined) {
this.application = data.application;
}
if ("url" in data && data.url != undefined) {
this.url = data.url;
}
if ("meta" in data && data.meta != undefined) {
this.meta = data.meta;
}
if ("tags" in data && data.tags != undefined) {
this.tags = data.tags;
}
}
}
get type() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set type(value: string) {
pb_1.Message.setField(this, 1, value);
}
get name() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set name(value: string) {
pb_1.Message.setField(this, 2, value);
}
get description() {
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
}
set description(value: string) {
pb_1.Message.setField(this, 3, value);
}
get version() {
return pb_1.Message.getFieldWithDefault(this, 4, "") as string;
}
set version(value: string) {
pb_1.Message.setField(this, 4, value);
}
get application() {
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
}
set application(value: string) {
pb_1.Message.setField(this, 5, value);
}
get url() {
return pb_1.Message.getFieldWithDefault(this, 6, "") as string;
}
set url(value: string) {
pb_1.Message.setField(this, 6, value);
}
get meta() {
return pb_1.Message.getFieldWithDefault(this, 20, "") as string;
}
set meta(value: string) {
pb_1.Message.setField(this, 20, value);
}
get tags() {
return pb_1.Message.getFieldWithDefault(this, 21, []) as string[];
}
set tags(value: string[]) {
pb_1.Message.setField(this, 21, value);
}
static fromObject(data: {
type?: string;
name?: string;
description?: string;
version?: string;
application?: string;
url?: string;
meta?: string;
tags?: string[];
}): WebAppDeploymentRecord {
const message = new WebAppDeploymentRecord({});
if (data.type != null) {
message.type = data.type;
}
if (data.name != null) {
message.name = data.name;
}
if (data.description != null) {
message.description = data.description;
}
if (data.version != null) {
message.version = data.version;
}
if (data.application != null) {
message.application = data.application;
}
if (data.url != null) {
message.url = data.url;
}
if (data.meta != null) {
message.meta = data.meta;
}
if (data.tags != null) {
message.tags = data.tags;
}
return message;
}
toObject() {
const data: {
type?: string;
name?: string;
description?: string;
version?: string;
application?: string;
url?: string;
meta?: string;
tags?: string[];
} = {};
if (this.type != null) {
data.type = this.type;
}
if (this.name != null) {
data.name = this.name;
}
if (this.description != null) {
data.description = this.description;
}
if (this.version != null) {
data.version = this.version;
}
if (this.application != null) {
data.application = this.application;
}
if (this.url != null) {
data.url = this.url;
}
if (this.meta != null) {
data.meta = this.meta;
}
if (this.tags != null) {
data.tags = this.tags;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.type.length)
writer.writeString(1, this.type);
if (this.name.length)
writer.writeString(2, this.name);
if (this.description.length)
writer.writeString(3, this.description);
if (this.version.length)
writer.writeString(4, this.version);
if (this.application.length)
writer.writeString(5, this.application);
if (this.url.length)
writer.writeString(6, this.url);
if (this.meta.length)
writer.writeString(20, this.meta);
if (this.tags.length)
writer.writeRepeatedString(21, this.tags);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): WebAppDeploymentRecord {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new WebAppDeploymentRecord();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.type = reader.readString();
break;
case 2:
message.name = reader.readString();
break;
case 3:
message.description = reader.readString();
break;
case 4:
message.version = reader.readString();
break;
case 5:
message.application = reader.readString();
break;
case 6:
message.url = reader.readString();
break;
case 20:
message.meta = reader.readString();
break;
case 21:
pb_1.Message.addToRepeatedField(message, 21, reader.readString());
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): WebAppDeploymentRecord {
return WebAppDeploymentRecord.deserialize(bytes);
}
}
export class GeneralRecord extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
type?: string;
name?: string;
description?: string;
version?: string;
category?: string;
value?: string;
meta?: string;
tags?: string[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [21], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("type" in data && data.type != undefined) {
this.type = data.type;
}
if ("name" in data && data.name != undefined) {
this.name = data.name;
}
if ("description" in data && data.description != undefined) {
this.description = data.description;
}
if ("version" in data && data.version != undefined) {
this.version = data.version;
}
if ("category" in data && data.category != undefined) {
this.category = data.category;
}
if ("value" in data && data.value != undefined) {
this.value = data.value;
}
if ("meta" in data && data.meta != undefined) {
this.meta = data.meta;
}
if ("tags" in data && data.tags != undefined) {
this.tags = data.tags;
}
}
}
get type() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set type(value: string) {
pb_1.Message.setField(this, 1, value);
}
get name() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set name(value: string) {
pb_1.Message.setField(this, 2, value);
}
get description() {
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
}
set description(value: string) {
pb_1.Message.setField(this, 3, value);
}
get version() {
return pb_1.Message.getFieldWithDefault(this, 4, "") as string;
}
set version(value: string) {
pb_1.Message.setField(this, 4, value);
}
get category() {
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
}
set category(value: string) {
pb_1.Message.setField(this, 5, value);
}
get value() {
return pb_1.Message.getFieldWithDefault(this, 6, "") as string;
}
set value(value: string) {
pb_1.Message.setField(this, 6, value);
}
get meta() {
return pb_1.Message.getFieldWithDefault(this, 20, "") as string;
}
set meta(value: string) {
pb_1.Message.setField(this, 20, value);
}
get tags() {
return pb_1.Message.getFieldWithDefault(this, 21, []) as string[];
}
set tags(value: string[]) {
pb_1.Message.setField(this, 21, value);
}
static fromObject(data: {
type?: string;
name?: string;
description?: string;
version?: string;
category?: string;
value?: string;
meta?: string;
tags?: string[];
}): GeneralRecord {
const message = new GeneralRecord({});
if (data.type != null) {
message.type = data.type;
}
if (data.name != null) {
message.name = data.name;
}
if (data.description != null) {
message.description = data.description;
}
if (data.version != null) {
message.version = data.version;
}
if (data.category != null) {
message.category = data.category;
}
if (data.value != null) {
message.value = data.value;
}
if (data.meta != null) {
message.meta = data.meta;
}
if (data.tags != null) {
message.tags = data.tags;
}
return message;
}
toObject() {
const data: {
type?: string;
name?: string;
description?: string;
version?: string;
category?: string;
value?: string;
meta?: string;
tags?: string[];
} = {};
if (this.type != null) {
data.type = this.type;
}
if (this.name != null) {
data.name = this.name;
}
if (this.description != null) {
data.description = this.description;
}
if (this.version != null) {
data.version = this.version;
}
if (this.category != null) {
data.category = this.category;
}
if (this.value != null) {
data.value = this.value;
}
if (this.meta != null) {
data.meta = this.meta;
}
if (this.tags != null) {
data.tags = this.tags;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.type.length)
writer.writeString(1, this.type);
if (this.name.length)
writer.writeString(2, this.name);
if (this.description.length)
writer.writeString(3, this.description);
if (this.version.length)
writer.writeString(4, this.version);
if (this.category.length)
writer.writeString(5, this.category);
if (this.value.length)
writer.writeString(6, this.value);
if (this.meta.length)
writer.writeString(20, this.meta);
if (this.tags.length)
writer.writeRepeatedString(21, this.tags);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GeneralRecord {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GeneralRecord();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.type = reader.readString();
break;
case 2:
message.name = reader.readString();
break;
case 3:
message.description = reader.readString();
break;
case 4:
message.version = reader.readString();
break;
case 5:
message.category = reader.readString();
break;
case 6:
message.value = reader.readString();
break;
case 20:
message.meta = reader.readString();
break;
case 21:
pb_1.Message.addToRepeatedField(message, 21, reader.readString());
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): GeneralRecord {
return GeneralRecord.deserialize(bytes);
}
}
}
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* 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: 3.12.4
* compiler version: 4.25.1
* 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: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/registry/v1beta1/registry.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../google/protobuf/duration";
+1 -1
View File
@@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* compiler version: 4.25.1
* source: vulcanize/registry/v1beta1/tx.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
+13 -8
View File
@@ -29,17 +29,22 @@ export class Record {
}
get attributes() {
let a = new any.google.protobuf.Any();
var 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}`);
}
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: attr.serialize()
})
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(),
});
}
return a
return a;
}
/**
+4 -4
View File
@@ -3086,10 +3086,10 @@ protobufjs@~6.11.2:
"@types/node" ">=13.7.0"
long "^4.0.0"
protoc-gen-ts@^0.8.5:
version "0.8.5"
resolved "https://registry.yarnpkg.com/protoc-gen-ts/-/protoc-gen-ts-0.8.5.tgz#5c277ff90b6b38f52313b1b0ad69e6c825305b29"
integrity sha512-LHZ+w/+DqmdgnhPtShgqtPtdv+hJ9bAXEIqNU0kkY2bPcCVIEWz5seOv20FCw6gbKorriTGP8xgz2RsIcrRvVw==
protoc-gen-ts@^0.8.7:
version "0.8.7"
resolved "https://registry.yarnpkg.com/protoc-gen-ts/-/protoc-gen-ts-0.8.7.tgz#63e4d9af2ad30b753acf6f739323d01fc9f80b52"
integrity sha512-jr4VJey2J9LVYCV7EVyVe53g1VMw28cCmYJhBe5e3YX5wiyiDwgxWxeDf9oTqAe4P1bN/YGAkW2jhlH8LohwiQ==
randombytes@^2.0.1, randombytes@^2.1.0:
version "2.1.0"