Compare commits
5 Commits
5562d9f985
...
51d264cbfa
Author | SHA1 | Date | |
---|---|---|---|
51d264cbfa | |||
5d7a73b55e | |||
036905e7e7 | |||
7ae577072a | |||
ad03d1f8e8 |
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Dockerfile
|
||||||
|
node_modules
|
@ -21,34 +21,18 @@ RUN \
|
|||||||
&& npm config -g set prefix ${NPM_GLOBAL} \
|
&& npm config -g set prefix ${NPM_GLOBAL} \
|
||||||
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
|
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
|
||||||
# Install eslint
|
# Install eslint
|
||||||
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint lerna jest" \
|
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
||||||
&& npm cache clean --force > /dev/null 2>&1
|
&& 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 /
|
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 .
|
COPY entrypoint.sh .
|
||||||
ENTRYPOINT ["/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
|
CMD node --version
|
||||||
|
|
||||||
# Temp hack, clone the laconic-sdk repo here
|
WORKDIR /app/laconic-sdk
|
||||||
WORKDIR /app
|
|
||||||
|
COPY package*.json .
|
||||||
RUN yarn install
|
RUN yarn install
|
||||||
|
COPY . .
|
||||||
|
|
||||||
WORKDIR /app/laconic-sdk
|
WORKDIR /app/laconic-sdk
|
@ -67,17 +67,25 @@ message QueryParamsResponse {
|
|||||||
|
|
||||||
// QueryListRecordsRequest is request type for registry records list
|
// QueryListRecordsRequest is request type for registry records list
|
||||||
message QueryListRecordsRequest {
|
message QueryListRecordsRequest {
|
||||||
message ReferenceInput {
|
message LinkInput {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
}
|
}
|
||||||
|
message ArrayInput {
|
||||||
|
repeated ValueInput values = 1;
|
||||||
|
}
|
||||||
|
message MapInput {
|
||||||
|
map<string, ValueInput> values = 1;
|
||||||
|
}
|
||||||
message ValueInput {
|
message ValueInput {
|
||||||
string type = 1;
|
oneof value {
|
||||||
string string = 2;
|
string string = 1;
|
||||||
int64 int = 3;
|
int64 int = 2;
|
||||||
double float = 4;
|
double float = 3;
|
||||||
bool boolean = 5;
|
bool boolean = 4;
|
||||||
ReferenceInput reference = 6;
|
string link = 5;
|
||||||
repeated ValueInput values = 7;
|
ArrayInput array = 6;
|
||||||
|
MapInput map = 7;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
message KeyValueInput {
|
message KeyValueInput {
|
||||||
string key = 1;
|
string key = 1;
|
||||||
|
@ -180,9 +180,9 @@ export class Registry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish record.
|
* Publish record.
|
||||||
* @param transactionPrivateKey - private key in HEX to sign transaction.
|
* @param transactionPrivateKey - private key in HEX to sign transaction.
|
||||||
*/
|
*/
|
||||||
async setRecord(
|
async setRecord(
|
||||||
params: { privateKey: string, record: any, bondId: string },
|
params: { privateKey: string, record: any, bondId: string },
|
||||||
transactionPrivateKey: string,
|
transactionPrivateKey: string,
|
||||||
|
@ -18,12 +18,6 @@ const namingTests = () => {
|
|||||||
let watcher: any;
|
let watcher: any;
|
||||||
let watcherId: string;
|
let watcherId: string;
|
||||||
|
|
||||||
let authorityName: string;
|
|
||||||
let otherAuthorityName: string;
|
|
||||||
let otherPrivateKey: string;
|
|
||||||
|
|
||||||
let crn: string;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
||||||
@ -46,221 +40,271 @@ const namingTests = () => {
|
|||||||
watcherId = result.data.id;
|
watcherId = result.data.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Reserve authority.', async () => {
|
describe('Authority tests', () => {
|
||||||
authorityName = `laconic-${Date.now()}`;
|
test('Reserve authority.', async () => {
|
||||||
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
|
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('Lookup authority.', async () => {
|
describe('Naming tests', () => {
|
||||||
const [record] = await registry.lookupAuthorities([authorityName]);
|
let authorityName: string;
|
||||||
|
let otherAuthorityName: string;
|
||||||
|
let otherPrivateKey: string;
|
||||||
|
let otherAccount: Account;
|
||||||
|
|
||||||
expect(record).toBeDefined();
|
beforeAll(async () => {
|
||||||
expect(record.ownerAddress).not.toBe('');
|
authorityName = `laconic-${Date.now()}`;
|
||||||
expect(record.ownerPublicKey).not.toBe('');
|
|
||||||
expect(Number(record.height)).toBeGreaterThan(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Lookup non existing authority', async () => {
|
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
|
||||||
const [record] = await registry.lookupAuthorities(['does-not-exist']);
|
await registry.setAuthorityBond({ name: authorityName, bondId }, privateKey, fee);
|
||||||
|
|
||||||
expect(record.ownerAddress).toBe('');
|
// Create another account.
|
||||||
expect(record.ownerPublicKey).toBe('');
|
const mnenonic = Account.generateMnemonic();
|
||||||
expect(Number(record.height)).toBe(0);
|
otherAccount = await Account.generateFromMnemonic(mnenonic);
|
||||||
});
|
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount.formattedCosmosAddress }, privateKey, fee);
|
||||||
|
|
||||||
test('Reserve already reserved authority', async () => {
|
otherAuthorityName = `other-${Date.now()}`;
|
||||||
await expect(registry.reserveAuthority({ name: authorityName }, privateKey, fee)).rejects.toThrow('Name already reserved.');
|
otherPrivateKey = otherAccount.privateKey.toString('hex');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Reserve sub-authority.', async () => {
|
test('Set name', async () => {
|
||||||
const subAuthority = `echo.${authorityName}`;
|
const crn = `crn://${authorityName}/app/test1`;
|
||||||
await registry.reserveAuthority({ name: subAuthority }, privateKey, fee);
|
|
||||||
|
|
||||||
const [record] = await registry.lookupAuthorities([subAuthority]);
|
await registry.setName({ crn, cid: watcherId }, privateKey, fee);
|
||||||
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 () => {
|
// Query records should return it (some CRN points to it).
|
||||||
// Create another account, send tx to set public key on the account.
|
const records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
|
||||||
const mnenonic1 = Account.generateMnemonic();
|
expect(records).toBeDefined();
|
||||||
const otherAccount1 = await Account.generateFromMnemonic(mnenonic1);
|
expect(records).toHaveLength(1);
|
||||||
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount1.formattedCosmosAddress }, privateKey, fee);
|
|
||||||
|
|
||||||
const mnenonic2 = Account.generateMnemonic();
|
await registry.deleteName({ crn }, privateKey, fee);
|
||||||
const otherAccount2 = await Account.generateFromMnemonic(mnenonic2);
|
});
|
||||||
await registry.sendCoins({ denom: 'aphoton', amount: '10', destinationAddress: otherAccount2.formattedCosmosAddress }, otherAccount1.getPrivateKey(), fee);
|
|
||||||
|
|
||||||
const subAuthority = `halo.${authorityName}`;
|
describe('With name set', () => {
|
||||||
await registry.reserveAuthority({ name: subAuthority, owner: otherAccount1.formattedCosmosAddress }, privateKey, fee);
|
let crn: string;
|
||||||
|
|
||||||
const [record] = await registry.lookupAuthorities([subAuthority]);
|
beforeAll(async () => {
|
||||||
expect(record).toBeDefined();
|
crn = `crn://${authorityName}/app/test2`;
|
||||||
expect(record.ownerAddress).toBeDefined();
|
await registry.setName({ crn, cid: watcherId }, privateKey, fee);
|
||||||
expect(record.ownerAddress).toBe(otherAccount1.getCosmosAddress());
|
});
|
||||||
expect(record.ownerPublicKey).toBeDefined();
|
|
||||||
expect(Number(record.height)).toBeGreaterThan(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Set name for unbonded authority', async () => {
|
afterAll(async () => {
|
||||||
crn = `crn://${authorityName}/app/test`;
|
await registry.deleteName({ crn }, privateKey, fee);
|
||||||
assert(watcherId)
|
});
|
||||||
await expect(registry.setName({ crn, cid: watcherId }, privateKey, fee)).rejects.toThrow('Authority bond not found.');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Set authority bond', async () => {
|
test('Lookup name', async () => {
|
||||||
await registry.setAuthorityBond({ name: authorityName, bondId }, privateKey, fee);
|
const records = await registry.lookupNames([crn]);
|
||||||
});
|
expect(records).toBeDefined();
|
||||||
|
expect(records).toHaveLength(1);
|
||||||
|
|
||||||
test('Set name', async () => {
|
const [{ latest, history }] = records;
|
||||||
crn = `crn://${authorityName}/app/test`;
|
expect(latest).toBeDefined();
|
||||||
await registry.setName({ crn, cid: watcherId }, privateKey, fee);
|
expect(latest.id).toBeDefined();
|
||||||
|
expect(latest.id).toBe(watcherId);
|
||||||
|
expect(latest.height).toBeDefined();
|
||||||
|
expect(history).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
// Query records should return it (some CRN points to it).
|
test('Resolve name', async () => {
|
||||||
const records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
|
const records = await registry.resolveNames([crn]);
|
||||||
expect(records).toBeDefined();
|
expect(records).toBeDefined();
|
||||||
expect(records).toHaveLength(1);
|
expect(records).toHaveLength(1);
|
||||||
});
|
|
||||||
|
|
||||||
test('Lookup name', async () => {
|
const [{ attributes }] = records;
|
||||||
const records = await registry.lookupNames([crn]);
|
expect(attributes).toEqual(watcher.record);
|
||||||
expect(records).toBeDefined();
|
});
|
||||||
expect(records).toHaveLength(1);
|
|
||||||
|
|
||||||
const [{ latest, history }] = records;
|
test('Lookup name with history', async () => {
|
||||||
expect(latest).toBeDefined();
|
const updatedWatcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
|
||||||
expect(latest.id).toBeDefined();
|
const result = await registry.setRecord(
|
||||||
expect(latest.id).toBe(watcherId);
|
{
|
||||||
expect(latest.height).toBeDefined();
|
privateKey,
|
||||||
expect(history).toBeUndefined();
|
bondId,
|
||||||
});
|
record: updatedWatcher.record
|
||||||
|
},
|
||||||
|
privateKey,
|
||||||
|
fee
|
||||||
|
)
|
||||||
|
|
||||||
test('Resolve name', async () => {
|
const updatedWatcherId = result.data.id;
|
||||||
const records = await registry.resolveNames([crn]);
|
await registry.setName({ crn, cid: updatedWatcherId }, privateKey, fee);
|
||||||
expect(records).toBeDefined();
|
|
||||||
expect(records).toHaveLength(1);
|
|
||||||
|
|
||||||
const [{ attributes }] = records;
|
const records = await registry.lookupNames([crn], true);
|
||||||
expect(attributes).toEqual(watcher.record);
|
expect(records).toHaveLength(1);
|
||||||
});
|
|
||||||
|
|
||||||
test('Lookup name with history', async () => {
|
const [{ latest, history }] = records;
|
||||||
const updatedWatcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
|
expect(latest).toBeDefined();
|
||||||
const result = await registry.setRecord(
|
expect(latest.id).toBeDefined();
|
||||||
{
|
expect(latest.id).toBe(updatedWatcherId);
|
||||||
privateKey,
|
expect(latest.height).toBeDefined();
|
||||||
bondId,
|
expect(history).toBeDefined();
|
||||||
record: updatedWatcher.record
|
expect(history).toHaveLength(1);
|
||||||
},
|
|
||||||
privateKey,
|
|
||||||
fee
|
|
||||||
)
|
|
||||||
|
|
||||||
const updatedWatcherId = result.data.id;
|
const [oldRecord] = history;
|
||||||
await registry.setName({ crn, cid: updatedWatcherId }, privateKey, fee);
|
expect(oldRecord).toBeDefined();
|
||||||
|
expect(oldRecord.id).toBeDefined();
|
||||||
|
expect(oldRecord.id).toBe(watcherId);
|
||||||
|
expect(oldRecord.height).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
const records = await registry.lookupNames([crn], true);
|
test('Delete name', async () => {
|
||||||
expect(records).toHaveLength(1);
|
await registry.deleteName({ crn }, privateKey, fee);
|
||||||
|
|
||||||
const [{ latest, history }] = records;
|
let records = await registry.lookupNames([crn], true);
|
||||||
expect(latest).toBeDefined();
|
expect(records).toBeDefined();
|
||||||
expect(latest.id).toBeDefined();
|
expect(records).toHaveLength(1);
|
||||||
expect(latest.id).toBe(updatedWatcherId);
|
|
||||||
expect(latest.height).toBeDefined();
|
|
||||||
expect(history).toBeDefined();
|
|
||||||
expect(history).toHaveLength(1);
|
|
||||||
|
|
||||||
const [oldRecord] = history;
|
const [{ latest }] = records;
|
||||||
expect(oldRecord).toBeDefined();
|
expect(latest).toBeDefined();
|
||||||
expect(oldRecord.id).toBeDefined();
|
expect(latest.id).toBeDefined();
|
||||||
expect(oldRecord.id).toBe(watcherId);
|
expect(latest.id).toBe('');
|
||||||
expect(oldRecord.height).toBeDefined();
|
expect(latest.height).toBeDefined();
|
||||||
});
|
|
||||||
|
|
||||||
test('Set name without reserving authority', async () => {
|
// Query records should NOT return it (no CRN points to it).
|
||||||
await expect(registry.setName({ crn: 'crn://not-reserved/app/test', cid: watcherId }, privateKey, fee))
|
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
|
||||||
.rejects.toThrow('Name authority not found.');
|
expect(records).toBeDefined();
|
||||||
});
|
expect(records).toHaveLength(0);
|
||||||
|
|
||||||
test('Set name for non-owned authority', async () => {
|
// Query all records should return it (all: true).
|
||||||
// Create another account.
|
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
|
||||||
const mnenonic = Account.generateMnemonic();
|
expect(records).toBeDefined();
|
||||||
const otherAccount = await Account.generateFromMnemonic(mnenonic);
|
expect(records).toHaveLength(1);
|
||||||
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount.formattedCosmosAddress }, privateKey, fee);
|
});
|
||||||
|
|
||||||
// Other account reserves an authority.
|
test('Delete already deleted name', async () => {
|
||||||
otherAuthorityName = `other-${Date.now()}`;
|
await registry.deleteName({ crn }, privateKey, fee);
|
||||||
otherPrivateKey = otherAccount.privateKey.toString('hex');
|
await registry.deleteName({ crn }, privateKey, fee);
|
||||||
await registry.reserveAuthority({ name: otherAuthorityName }, otherPrivateKey, fee);
|
|
||||||
|
|
||||||
// Try setting name under other authority.
|
const records = await registry.lookupNames([crn], true);
|
||||||
await expect(registry.setName({ crn: `crn://${otherAuthorityName}/app/test`, cid: watcherId }, privateKey, fee)).rejects.toThrow('Access denied.');
|
expect(records).toBeDefined();
|
||||||
});
|
expect(records).toHaveLength(1);
|
||||||
|
|
||||||
test('Lookup non existing name', async () => {
|
const [{ latest }] = records;
|
||||||
const records = await registry.lookupNames(['crn://not-reserved/app/test']);
|
expect(latest).toBeDefined();
|
||||||
expect(records).toBeDefined();
|
expect(latest.id).toBeDefined();
|
||||||
expect(records).toHaveLength(1);
|
expect(latest.id).toBe('');
|
||||||
const [record] = records;
|
expect(latest.height).toBeDefined();
|
||||||
expect(record).toBeNull();
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Resolve non existing name', async () => {
|
test('Set name without reserving authority', async () => {
|
||||||
const records = await registry.resolveNames(['crn://not-reserved/app/test']);
|
await expect(registry.setName({ crn: 'crn://not-reserved/app/test', cid: watcherId }, privateKey, fee))
|
||||||
expect(records).toBeDefined();
|
.rejects.toThrow('Name authority not found.');
|
||||||
expect(records).toHaveLength(1);
|
});
|
||||||
const [record] = records;
|
|
||||||
expect(record).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Delete name', async () => {
|
test('Set name for non-owned authority', async () => {
|
||||||
await registry.deleteName({ crn }, privateKey, fee);
|
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount.formattedCosmosAddress }, privateKey, fee);
|
||||||
|
|
||||||
let records = await registry.lookupNames([crn], true);
|
// Other account reserves an authority.
|
||||||
expect(records).toBeDefined();
|
await registry.reserveAuthority({ name: otherAuthorityName }, otherPrivateKey, fee);
|
||||||
expect(records).toHaveLength(1);
|
|
||||||
|
|
||||||
const [{ latest }] = records;
|
// Try setting name under other authority.
|
||||||
expect(latest).toBeDefined();
|
await expect(registry.setName({ crn: `crn://${otherAuthorityName}/app/test`, cid: watcherId }, privateKey, fee)).rejects.toThrow('Access denied.');
|
||||||
expect(latest.id).toBeDefined();
|
});
|
||||||
expect(latest.id).toBe('');
|
|
||||||
expect(latest.height).toBeDefined();
|
|
||||||
|
|
||||||
// Query records should NOT return it (no CRN points to it).
|
test('Delete name for non-owned authority.', async () => {
|
||||||
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
|
const otherBondId = await registry.getNextBondId(otherPrivateKey);
|
||||||
expect(records).toBeDefined();
|
await registry.createBond({ denom: 'aphoton', amount: '10000' }, otherPrivateKey, fee);
|
||||||
expect(records).toHaveLength(0);
|
await registry.setAuthorityBond({ name: otherAuthorityName, bondId: otherBondId }, otherPrivateKey, fee);
|
||||||
|
await registry.setName({ crn: `crn://${otherAuthorityName}/app/test`, cid: watcherId }, otherPrivateKey, fee);
|
||||||
|
|
||||||
// Query all records should return it (all: true).
|
// Try deleting name under other authority.
|
||||||
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
|
await expect(registry.deleteName({ crn: `crn://${otherAuthorityName}/app/test` }, privateKey, fee)).rejects.toThrow('Access denied.');
|
||||||
expect(records).toBeDefined();
|
});
|
||||||
expect(records).toHaveLength(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Delete already deleted name', async () => {
|
test('Lookup non existing name', async () => {
|
||||||
await registry.deleteName({ crn }, privateKey, fee);
|
const records = await registry.lookupNames(['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);
|
test('Resolve non existing name', async () => {
|
||||||
expect(records).toBeDefined();
|
const records = await registry.resolveNames(['crn://not-reserved/app/test']);
|
||||||
expect(records).toHaveLength(1);
|
expect(records).toBeDefined();
|
||||||
|
expect(records).toHaveLength(1);
|
||||||
const [{ latest }] = records;
|
const [record] = records;
|
||||||
expect(latest).toBeDefined();
|
expect(record).toBeNull();
|
||||||
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 */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: cosmos/base/query/v1beta1/pagination.proto
|
* source: cosmos/base/query/v1beta1/pagination.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as pb_1 from "google-protobuf";
|
import * as pb_1 from "google-protobuf";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: cosmos/base/v1beta1/coin.proto
|
* source: cosmos/base/v1beta1/coin.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: gogoproto/gogo.proto
|
* source: gogoproto/gogo.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../google/protobuf/descriptor";
|
import * as dependency_1 from "./../google/protobuf/descriptor";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: google/api/annotations.proto
|
* source: google/api/annotations.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./http";
|
import * as dependency_1 from "./http";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: google/api/http.proto
|
* source: google/api/http.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as pb_1 from "google-protobuf";
|
import * as pb_1 from "google-protobuf";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: google/protobuf/descriptor.proto
|
* source: google/protobuf/descriptor.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as pb_1 from "google-protobuf";
|
import * as pb_1 from "google-protobuf";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: google/protobuf/duration.proto
|
* source: google/protobuf/duration.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as pb_1 from "google-protobuf";
|
import * as pb_1 from "google-protobuf";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: google/protobuf/timestamp.proto
|
* source: google/protobuf/timestamp.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as pb_1 from "google-protobuf";
|
import * as pb_1 from "google-protobuf";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/auction/v1beta1/genesis.proto
|
* source: vulcanize/auction/v1beta1/genesis.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/auction/v1beta1/query.proto
|
* source: vulcanize/auction/v1beta1/query.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/auction/v1beta1/tx.proto
|
* source: vulcanize/auction/v1beta1/tx.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/auction/v1beta1/types.proto
|
* source: vulcanize/auction/v1beta1/types.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/bond/v1beta1/bond.proto
|
* source: vulcanize/bond/v1beta1/bond.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/bond/v1beta1/genesis.proto
|
* source: vulcanize/bond/v1beta1/genesis.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/bond/v1beta1/query.proto
|
* source: vulcanize/bond/v1beta1/query.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/bond/v1beta1/tx.proto
|
* source: vulcanize/bond/v1beta1/tx.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/registry/v1beta1/genesis.proto
|
* source: vulcanize/registry/v1beta1/genesis.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/registry/v1beta1/query.proto
|
* source: vulcanize/registry/v1beta1/query.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./registry";
|
import * as dependency_1 from "./registry";
|
||||||
@ -239,7 +239,7 @@ export namespace vulcanize.registry.v1beta1 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
export namespace QueryListRecordsRequest {
|
export namespace QueryListRecordsRequest {
|
||||||
export class ReferenceInput extends pb_1.Message {
|
export class LinkInput extends pb_1.Message {
|
||||||
#one_of_decls: number[][] = [];
|
#one_of_decls: number[][] = [];
|
||||||
constructor(data?: any[] | {
|
constructor(data?: any[] | {
|
||||||
id?: string;
|
id?: string;
|
||||||
@ -260,8 +260,8 @@ export namespace vulcanize.registry.v1beta1 {
|
|||||||
}
|
}
|
||||||
static fromObject(data: {
|
static fromObject(data: {
|
||||||
id?: string;
|
id?: string;
|
||||||
}): ReferenceInput {
|
}): LinkInput {
|
||||||
const message = new ReferenceInput({});
|
const message = new LinkInput({});
|
||||||
if (data.id != null) {
|
if (data.id != null) {
|
||||||
message.id = data.id;
|
message.id = data.id;
|
||||||
}
|
}
|
||||||
@ -285,8 +285,8 @@ export namespace vulcanize.registry.v1beta1 {
|
|||||||
if (!w)
|
if (!w)
|
||||||
return writer.getResultBuffer();
|
return writer.getResultBuffer();
|
||||||
}
|
}
|
||||||
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ReferenceInput {
|
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): LinkInput {
|
||||||
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ReferenceInput();
|
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new LinkInput();
|
||||||
while (reader.nextField()) {
|
while (reader.nextField()) {
|
||||||
if (reader.isEndGroup())
|
if (reader.isEndGroup())
|
||||||
break;
|
break;
|
||||||
@ -302,27 +302,220 @@ export namespace vulcanize.registry.v1beta1 {
|
|||||||
serializeBinary(): Uint8Array {
|
serializeBinary(): Uint8Array {
|
||||||
return this.serialize();
|
return this.serialize();
|
||||||
}
|
}
|
||||||
static deserializeBinary(bytes: Uint8Array): ReferenceInput {
|
static deserializeBinary(bytes: Uint8Array): LinkInput {
|
||||||
return ReferenceInput.deserialize(bytes);
|
return LinkInput.deserialize(bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class ValueInput extends pb_1.Message {
|
export class ArrayInput extends pb_1.Message {
|
||||||
#one_of_decls: number[][] = [];
|
#one_of_decls: number[][] = [];
|
||||||
constructor(data?: any[] | {
|
constructor(data?: any[] | {
|
||||||
type?: string;
|
|
||||||
string?: string;
|
|
||||||
int?: number;
|
|
||||||
float?: number;
|
|
||||||
boolean?: boolean;
|
|
||||||
reference?: QueryListRecordsRequest.ReferenceInput;
|
|
||||||
values?: QueryListRecordsRequest.ValueInput[];
|
values?: QueryListRecordsRequest.ValueInput[];
|
||||||
}) {
|
}) {
|
||||||
super();
|
super();
|
||||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [7], this.#one_of_decls);
|
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], this.#one_of_decls);
|
||||||
if (!Array.isArray(data) && typeof data == "object") {
|
if (!Array.isArray(data) && typeof data == "object") {
|
||||||
if ("type" in data && data.type != undefined) {
|
if ("values" in data && data.values != undefined) {
|
||||||
this.type = data.type;
|
this.values = data.values;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get values() {
|
||||||
|
return pb_1.Message.getRepeatedWrapperField(this, QueryListRecordsRequest.ValueInput, 1) as QueryListRecordsRequest.ValueInput[];
|
||||||
|
}
|
||||||
|
set values(value: QueryListRecordsRequest.ValueInput[]) {
|
||||||
|
pb_1.Message.setRepeatedWrapperField(this, 1, value);
|
||||||
|
}
|
||||||
|
static fromObject(data: {
|
||||||
|
values?: ReturnType<typeof QueryListRecordsRequest.ValueInput.prototype.toObject>[];
|
||||||
|
}): ArrayInput {
|
||||||
|
const message = new ArrayInput({});
|
||||||
|
if (data.values != null) {
|
||||||
|
message.values = data.values.map(item => QueryListRecordsRequest.ValueInput.fromObject(item));
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
toObject() {
|
||||||
|
const data: {
|
||||||
|
values?: ReturnType<typeof QueryListRecordsRequest.ValueInput.prototype.toObject>[];
|
||||||
|
} = {};
|
||||||
|
if (this.values != null) {
|
||||||
|
data.values = this.values.map((item: QueryListRecordsRequest.ValueInput) => item.toObject());
|
||||||
|
}
|
||||||
|
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.values.length)
|
||||||
|
writer.writeRepeatedMessage(1, this.values, (item: QueryListRecordsRequest.ValueInput) => item.serialize(writer));
|
||||||
|
if (!w)
|
||||||
|
return writer.getResultBuffer();
|
||||||
|
}
|
||||||
|
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ArrayInput {
|
||||||
|
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ArrayInput();
|
||||||
|
while (reader.nextField()) {
|
||||||
|
if (reader.isEndGroup())
|
||||||
|
break;
|
||||||
|
switch (reader.getFieldNumber()) {
|
||||||
|
case 1:
|
||||||
|
reader.readMessage(message.values, () => pb_1.Message.addToRepeatedWrapperField(message, 1, QueryListRecordsRequest.ValueInput.deserialize(reader), QueryListRecordsRequest.ValueInput));
|
||||||
|
break;
|
||||||
|
default: reader.skipField();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
serializeBinary(): Uint8Array {
|
||||||
|
return this.serialize();
|
||||||
|
}
|
||||||
|
static deserializeBinary(bytes: Uint8Array): ArrayInput {
|
||||||
|
return ArrayInput.deserialize(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class MapInput extends pb_1.Message {
|
||||||
|
#one_of_decls: number[][] = [];
|
||||||
|
constructor(data?: any[] | {
|
||||||
|
values?: Map<string, QueryListRecordsRequest.ValueInput>;
|
||||||
|
}) {
|
||||||
|
super();
|
||||||
|
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||||
|
if (!Array.isArray(data) && typeof data == "object") {
|
||||||
|
if ("values" in data && data.values != undefined) {
|
||||||
|
this.values = data.values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!this.values)
|
||||||
|
this.values = new Map();
|
||||||
|
}
|
||||||
|
get values() {
|
||||||
|
return pb_1.Message.getField(this, 1) as any as Map<string, QueryListRecordsRequest.ValueInput>;
|
||||||
|
}
|
||||||
|
set values(value: Map<string, QueryListRecordsRequest.ValueInput>) {
|
||||||
|
pb_1.Message.setField(this, 1, value as any);
|
||||||
|
}
|
||||||
|
static fromObject(data: {
|
||||||
|
values?: {
|
||||||
|
[key: string]: ReturnType<typeof QueryListRecordsRequest.ValueInput.prototype.toObject>;
|
||||||
|
};
|
||||||
|
}): MapInput {
|
||||||
|
const message = new MapInput({});
|
||||||
|
if (typeof data.values == "object") {
|
||||||
|
message.values = new Map(Object.entries(data.values).map(([key, value]) => [key, QueryListRecordsRequest.ValueInput.fromObject(value)]));
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
toObject() {
|
||||||
|
const data: {
|
||||||
|
values?: {
|
||||||
|
[key: string]: ReturnType<typeof QueryListRecordsRequest.ValueInput.prototype.toObject>;
|
||||||
|
};
|
||||||
|
} = {};
|
||||||
|
if (this.values != null) {
|
||||||
|
data.values = (Object.fromEntries)((Array.from)(this.values).map(([key, value]) => [key, value.toObject()]));
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
serialize(): Uint8Array;
|
||||||
|
serialize(w: pb_1.BinaryWriter): void;
|
||||||
|
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
|
||||||
|
const writer = w || new pb_1.BinaryWriter();
|
||||||
|
for (const [key, value] of this.values) {
|
||||||
|
writer.writeMessage(1, this.values, () => {
|
||||||
|
writer.writeString(1, key);
|
||||||
|
writer.writeMessage(2, value, () => value.serialize(writer));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!w)
|
||||||
|
return writer.getResultBuffer();
|
||||||
|
}
|
||||||
|
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MapInput {
|
||||||
|
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MapInput();
|
||||||
|
while (reader.nextField()) {
|
||||||
|
if (reader.isEndGroup())
|
||||||
|
break;
|
||||||
|
switch (reader.getFieldNumber()) {
|
||||||
|
case 1:
|
||||||
|
reader.readMessage(message, () => pb_1.Map.deserializeBinary(message.values as any, reader, reader.readString, () => {
|
||||||
|
let value;
|
||||||
|
reader.readMessage(message, () => value = QueryListRecordsRequest.ValueInput.deserialize(reader));
|
||||||
|
return value;
|
||||||
|
}));
|
||||||
|
break;
|
||||||
|
default: reader.skipField();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
serializeBinary(): Uint8Array {
|
||||||
|
return this.serialize();
|
||||||
|
}
|
||||||
|
static deserializeBinary(bytes: Uint8Array): MapInput {
|
||||||
|
return MapInput.deserialize(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class ValueInput extends pb_1.Message {
|
||||||
|
#one_of_decls: number[][] = [[1, 2, 3, 4, 5, 6, 7]];
|
||||||
|
constructor(data?: any[] | ({} & (({
|
||||||
|
string?: string;
|
||||||
|
int?: never;
|
||||||
|
float?: never;
|
||||||
|
boolean?: never;
|
||||||
|
link?: never;
|
||||||
|
array?: never;
|
||||||
|
map?: never;
|
||||||
|
} | {
|
||||||
|
string?: never;
|
||||||
|
int?: number;
|
||||||
|
float?: never;
|
||||||
|
boolean?: never;
|
||||||
|
link?: never;
|
||||||
|
array?: never;
|
||||||
|
map?: never;
|
||||||
|
} | {
|
||||||
|
string?: never;
|
||||||
|
int?: never;
|
||||||
|
float?: number;
|
||||||
|
boolean?: never;
|
||||||
|
link?: never;
|
||||||
|
array?: never;
|
||||||
|
map?: never;
|
||||||
|
} | {
|
||||||
|
string?: never;
|
||||||
|
int?: never;
|
||||||
|
float?: never;
|
||||||
|
boolean?: boolean;
|
||||||
|
link?: never;
|
||||||
|
array?: never;
|
||||||
|
map?: never;
|
||||||
|
} | {
|
||||||
|
string?: never;
|
||||||
|
int?: never;
|
||||||
|
float?: never;
|
||||||
|
boolean?: never;
|
||||||
|
link?: string;
|
||||||
|
array?: never;
|
||||||
|
map?: never;
|
||||||
|
} | {
|
||||||
|
string?: never;
|
||||||
|
int?: never;
|
||||||
|
float?: never;
|
||||||
|
boolean?: never;
|
||||||
|
link?: never;
|
||||||
|
array?: QueryListRecordsRequest.ArrayInput;
|
||||||
|
map?: never;
|
||||||
|
} | {
|
||||||
|
string?: never;
|
||||||
|
int?: never;
|
||||||
|
float?: never;
|
||||||
|
boolean?: never;
|
||||||
|
link?: never;
|
||||||
|
array?: never;
|
||||||
|
map?: QueryListRecordsRequest.MapInput;
|
||||||
|
})))) {
|
||||||
|
super();
|
||||||
|
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||||
|
if (!Array.isArray(data) && typeof data == "object") {
|
||||||
if ("string" in data && data.string != undefined) {
|
if ("string" in data && data.string != undefined) {
|
||||||
this.string = data.string;
|
this.string = data.string;
|
||||||
}
|
}
|
||||||
@ -335,72 +528,105 @@ export namespace vulcanize.registry.v1beta1 {
|
|||||||
if ("boolean" in data && data.boolean != undefined) {
|
if ("boolean" in data && data.boolean != undefined) {
|
||||||
this.boolean = data.boolean;
|
this.boolean = data.boolean;
|
||||||
}
|
}
|
||||||
if ("reference" in data && data.reference != undefined) {
|
if ("link" in data && data.link != undefined) {
|
||||||
this.reference = data.reference;
|
this.link = data.link;
|
||||||
}
|
}
|
||||||
if ("values" in data && data.values != undefined) {
|
if ("array" in data && data.array != undefined) {
|
||||||
this.values = data.values;
|
this.array = data.array;
|
||||||
|
}
|
||||||
|
if ("map" in data && data.map != undefined) {
|
||||||
|
this.map = data.map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get type() {
|
get string() {
|
||||||
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
|
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
|
||||||
}
|
}
|
||||||
set type(value: string) {
|
|
||||||
pb_1.Message.setField(this, 1, value);
|
|
||||||
}
|
|
||||||
get string() {
|
|
||||||
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
|
|
||||||
}
|
|
||||||
set string(value: string) {
|
set string(value: string) {
|
||||||
pb_1.Message.setField(this, 2, value);
|
pb_1.Message.setOneofField(this, 1, this.#one_of_decls[0], value);
|
||||||
|
}
|
||||||
|
get has_string() {
|
||||||
|
return pb_1.Message.getField(this, 1) != null;
|
||||||
}
|
}
|
||||||
get int() {
|
get int() {
|
||||||
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
|
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
|
||||||
}
|
}
|
||||||
set int(value: number) {
|
set int(value: number) {
|
||||||
pb_1.Message.setField(this, 3, value);
|
pb_1.Message.setOneofField(this, 2, this.#one_of_decls[0], value);
|
||||||
|
}
|
||||||
|
get has_int() {
|
||||||
|
return pb_1.Message.getField(this, 2) != null;
|
||||||
}
|
}
|
||||||
get float() {
|
get float() {
|
||||||
return pb_1.Message.getFieldWithDefault(this, 4, 0) as number;
|
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
|
||||||
}
|
}
|
||||||
set float(value: number) {
|
set float(value: number) {
|
||||||
pb_1.Message.setField(this, 4, value);
|
pb_1.Message.setOneofField(this, 3, this.#one_of_decls[0], value);
|
||||||
|
}
|
||||||
|
get has_float() {
|
||||||
|
return pb_1.Message.getField(this, 3) != null;
|
||||||
}
|
}
|
||||||
get boolean() {
|
get boolean() {
|
||||||
return pb_1.Message.getFieldWithDefault(this, 5, false) as boolean;
|
return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean;
|
||||||
}
|
}
|
||||||
set boolean(value: boolean) {
|
set boolean(value: boolean) {
|
||||||
pb_1.Message.setField(this, 5, value);
|
pb_1.Message.setOneofField(this, 4, this.#one_of_decls[0], value);
|
||||||
}
|
}
|
||||||
get reference() {
|
get has_boolean() {
|
||||||
return pb_1.Message.getWrapperField(this, QueryListRecordsRequest.ReferenceInput, 6) as QueryListRecordsRequest.ReferenceInput;
|
return pb_1.Message.getField(this, 4) != null;
|
||||||
}
|
}
|
||||||
set reference(value: QueryListRecordsRequest.ReferenceInput) {
|
get link() {
|
||||||
pb_1.Message.setWrapperField(this, 6, value);
|
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
|
||||||
}
|
}
|
||||||
get has_reference() {
|
set link(value: string) {
|
||||||
|
pb_1.Message.setOneofField(this, 5, this.#one_of_decls[0], value);
|
||||||
|
}
|
||||||
|
get has_link() {
|
||||||
|
return pb_1.Message.getField(this, 5) != null;
|
||||||
|
}
|
||||||
|
get array() {
|
||||||
|
return pb_1.Message.getWrapperField(this, QueryListRecordsRequest.ArrayInput, 6) as QueryListRecordsRequest.ArrayInput;
|
||||||
|
}
|
||||||
|
set array(value: QueryListRecordsRequest.ArrayInput) {
|
||||||
|
pb_1.Message.setOneofWrapperField(this, 6, this.#one_of_decls[0], value);
|
||||||
|
}
|
||||||
|
get has_array() {
|
||||||
return pb_1.Message.getField(this, 6) != null;
|
return pb_1.Message.getField(this, 6) != null;
|
||||||
}
|
}
|
||||||
get values() {
|
get map() {
|
||||||
return pb_1.Message.getRepeatedWrapperField(this, QueryListRecordsRequest.ValueInput, 7) as QueryListRecordsRequest.ValueInput[];
|
return pb_1.Message.getWrapperField(this, QueryListRecordsRequest.MapInput, 7) as QueryListRecordsRequest.MapInput;
|
||||||
}
|
}
|
||||||
set values(value: QueryListRecordsRequest.ValueInput[]) {
|
set map(value: QueryListRecordsRequest.MapInput) {
|
||||||
pb_1.Message.setRepeatedWrapperField(this, 7, value);
|
pb_1.Message.setOneofWrapperField(this, 7, this.#one_of_decls[0], value);
|
||||||
|
}
|
||||||
|
get has_map() {
|
||||||
|
return pb_1.Message.getField(this, 7) != null;
|
||||||
|
}
|
||||||
|
get value() {
|
||||||
|
const cases: {
|
||||||
|
[index: number]: "none" | "string" | "int" | "float" | "boolean" | "link" | "array" | "map";
|
||||||
|
} = {
|
||||||
|
0: "none",
|
||||||
|
1: "string",
|
||||||
|
2: "int",
|
||||||
|
3: "float",
|
||||||
|
4: "boolean",
|
||||||
|
5: "link",
|
||||||
|
6: "array",
|
||||||
|
7: "map"
|
||||||
|
};
|
||||||
|
return cases[pb_1.Message.computeOneofCase(this, [1, 2, 3, 4, 5, 6, 7])];
|
||||||
}
|
}
|
||||||
static fromObject(data: {
|
static fromObject(data: {
|
||||||
type?: string;
|
|
||||||
string?: string;
|
string?: string;
|
||||||
int?: number;
|
int?: number;
|
||||||
float?: number;
|
float?: number;
|
||||||
boolean?: boolean;
|
boolean?: boolean;
|
||||||
reference?: ReturnType<typeof QueryListRecordsRequest.ReferenceInput.prototype.toObject>;
|
link?: string;
|
||||||
values?: ReturnType<typeof QueryListRecordsRequest.ValueInput.prototype.toObject>[];
|
array?: ReturnType<typeof QueryListRecordsRequest.ArrayInput.prototype.toObject>;
|
||||||
|
map?: ReturnType<typeof QueryListRecordsRequest.MapInput.prototype.toObject>;
|
||||||
}): ValueInput {
|
}): ValueInput {
|
||||||
const message = new ValueInput({});
|
const message = new ValueInput({});
|
||||||
if (data.type != null) {
|
|
||||||
message.type = data.type;
|
|
||||||
}
|
|
||||||
if (data.string != null) {
|
if (data.string != null) {
|
||||||
message.string = data.string;
|
message.string = data.string;
|
||||||
}
|
}
|
||||||
@ -413,27 +639,27 @@ export namespace vulcanize.registry.v1beta1 {
|
|||||||
if (data.boolean != null) {
|
if (data.boolean != null) {
|
||||||
message.boolean = data.boolean;
|
message.boolean = data.boolean;
|
||||||
}
|
}
|
||||||
if (data.reference != null) {
|
if (data.link != null) {
|
||||||
message.reference = QueryListRecordsRequest.ReferenceInput.fromObject(data.reference);
|
message.link = data.link;
|
||||||
}
|
}
|
||||||
if (data.values != null) {
|
if (data.array != null) {
|
||||||
message.values = data.values.map(item => QueryListRecordsRequest.ValueInput.fromObject(item));
|
message.array = QueryListRecordsRequest.ArrayInput.fromObject(data.array);
|
||||||
|
}
|
||||||
|
if (data.map != null) {
|
||||||
|
message.map = QueryListRecordsRequest.MapInput.fromObject(data.map);
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
toObject() {
|
toObject() {
|
||||||
const data: {
|
const data: {
|
||||||
type?: string;
|
|
||||||
string?: string;
|
string?: string;
|
||||||
int?: number;
|
int?: number;
|
||||||
float?: number;
|
float?: number;
|
||||||
boolean?: boolean;
|
boolean?: boolean;
|
||||||
reference?: ReturnType<typeof QueryListRecordsRequest.ReferenceInput.prototype.toObject>;
|
link?: string;
|
||||||
values?: ReturnType<typeof QueryListRecordsRequest.ValueInput.prototype.toObject>[];
|
array?: ReturnType<typeof QueryListRecordsRequest.ArrayInput.prototype.toObject>;
|
||||||
|
map?: ReturnType<typeof QueryListRecordsRequest.MapInput.prototype.toObject>;
|
||||||
} = {};
|
} = {};
|
||||||
if (this.type != null) {
|
|
||||||
data.type = this.type;
|
|
||||||
}
|
|
||||||
if (this.string != null) {
|
if (this.string != null) {
|
||||||
data.string = this.string;
|
data.string = this.string;
|
||||||
}
|
}
|
||||||
@ -446,11 +672,14 @@ export namespace vulcanize.registry.v1beta1 {
|
|||||||
if (this.boolean != null) {
|
if (this.boolean != null) {
|
||||||
data.boolean = this.boolean;
|
data.boolean = this.boolean;
|
||||||
}
|
}
|
||||||
if (this.reference != null) {
|
if (this.link != null) {
|
||||||
data.reference = this.reference.toObject();
|
data.link = this.link;
|
||||||
}
|
}
|
||||||
if (this.values != null) {
|
if (this.array != null) {
|
||||||
data.values = this.values.map((item: QueryListRecordsRequest.ValueInput) => item.toObject());
|
data.array = this.array.toObject();
|
||||||
|
}
|
||||||
|
if (this.map != null) {
|
||||||
|
data.map = this.map.toObject();
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -458,20 +687,20 @@ export namespace vulcanize.registry.v1beta1 {
|
|||||||
serialize(w: pb_1.BinaryWriter): void;
|
serialize(w: pb_1.BinaryWriter): void;
|
||||||
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
|
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
|
||||||
const writer = w || new pb_1.BinaryWriter();
|
const writer = w || new pb_1.BinaryWriter();
|
||||||
if (this.type.length)
|
if (this.has_string)
|
||||||
writer.writeString(1, this.type);
|
writer.writeString(1, this.string);
|
||||||
if (this.string.length)
|
if (this.has_int)
|
||||||
writer.writeString(2, this.string);
|
writer.writeInt64(2, this.int);
|
||||||
if (this.int != 0)
|
if (this.has_float)
|
||||||
writer.writeInt64(3, this.int);
|
writer.writeDouble(3, this.float);
|
||||||
if (this.float != 0)
|
if (this.has_boolean)
|
||||||
writer.writeDouble(4, this.float);
|
writer.writeBool(4, this.boolean);
|
||||||
if (this.boolean != false)
|
if (this.has_link)
|
||||||
writer.writeBool(5, this.boolean);
|
writer.writeString(5, this.link);
|
||||||
if (this.has_reference)
|
if (this.has_array)
|
||||||
writer.writeMessage(6, this.reference, () => this.reference.serialize(writer));
|
writer.writeMessage(6, this.array, () => this.array.serialize(writer));
|
||||||
if (this.values.length)
|
if (this.has_map)
|
||||||
writer.writeRepeatedMessage(7, this.values, (item: QueryListRecordsRequest.ValueInput) => item.serialize(writer));
|
writer.writeMessage(7, this.map, () => this.map.serialize(writer));
|
||||||
if (!w)
|
if (!w)
|
||||||
return writer.getResultBuffer();
|
return writer.getResultBuffer();
|
||||||
}
|
}
|
||||||
@ -482,25 +711,25 @@ export namespace vulcanize.registry.v1beta1 {
|
|||||||
break;
|
break;
|
||||||
switch (reader.getFieldNumber()) {
|
switch (reader.getFieldNumber()) {
|
||||||
case 1:
|
case 1:
|
||||||
message.type = reader.readString();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
message.string = reader.readString();
|
message.string = reader.readString();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 2:
|
||||||
message.int = reader.readInt64();
|
message.int = reader.readInt64();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 3:
|
||||||
message.float = reader.readDouble();
|
message.float = reader.readDouble();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 4:
|
||||||
message.boolean = reader.readBool();
|
message.boolean = reader.readBool();
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
message.link = reader.readString();
|
||||||
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
reader.readMessage(message.reference, () => message.reference = QueryListRecordsRequest.ReferenceInput.deserialize(reader));
|
reader.readMessage(message.array, () => message.array = QueryListRecordsRequest.ArrayInput.deserialize(reader));
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
reader.readMessage(message.values, () => pb_1.Message.addToRepeatedWrapperField(message, 7, QueryListRecordsRequest.ValueInput.deserialize(reader), QueryListRecordsRequest.ValueInput));
|
reader.readMessage(message.map, () => message.map = QueryListRecordsRequest.MapInput.deserialize(reader));
|
||||||
break;
|
break;
|
||||||
default: reader.skipField();
|
default: reader.skipField();
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/registry/v1beta1/registry.proto
|
* source: vulcanize/registry/v1beta1/registry.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../google/protobuf/duration";
|
import * as dependency_1 from "./../../../google/protobuf/duration";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||||
* compiler version: 3.12.4
|
* compiler version: 4.24.4
|
||||||
* source: vulcanize/registry/v1beta1/tx.proto
|
* source: vulcanize/registry/v1beta1/tx.proto
|
||||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||||
import * as dependency_1 from "./../../../gogoproto/gogo";
|
import * as dependency_1 from "./../../../gogoproto/gogo";
|
||||||
|
@ -10,15 +10,14 @@ const attributeField = `
|
|||||||
attributes {
|
attributes {
|
||||||
key
|
key
|
||||||
value {
|
value {
|
||||||
null
|
... on BooleanValue { bool: value }
|
||||||
int
|
... on IntValue { int: value }
|
||||||
float
|
... on FloatValue { float: value }
|
||||||
string
|
... on StringValue { string: value }
|
||||||
boolean
|
... on BytesValue { bytes: value }
|
||||||
json
|
... on LinkValue { link: value }
|
||||||
reference {
|
... on ArrayValue { array: value { __typename } }
|
||||||
id
|
... on MapValue { map: value { key mapping: value { __typename } } }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@ -50,7 +50,7 @@ describe('Querying', () => {
|
|||||||
expect(records.length).toBeGreaterThanOrEqual(1);
|
expect(records.length).toBeGreaterThanOrEqual(1);
|
||||||
|
|
||||||
const { attributes: { repo_registration_record_cid: record_repo_registration_record_cid } } = records[0];
|
const { attributes: { repo_registration_record_cid: record_repo_registration_record_cid } } = records[0];
|
||||||
expect(repo_registration_record_cid).toBe(record_repo_registration_record_cid);
|
expect(repo_registration_record_cid).toStrictEqual(record_repo_registration_record_cid);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Query records by attributes.', async () => {
|
test('Query records by attributes.', async () => {
|
||||||
@ -75,6 +75,7 @@ describe('Querying', () => {
|
|||||||
expect(record.id).toBe(watcher.id);
|
expect(record.id).toBe(watcher.id);
|
||||||
// temp fix
|
// temp fix
|
||||||
expect(record.attributes.repo_registration_record_cid).toBeDefined();
|
expect(record.attributes.repo_registration_record_cid).toBeDefined();
|
||||||
expect(record.attributes.repo_registration_record_cid).toHaveLength(46);
|
expect(record.attributes.repo_registration_record_cid).toHaveProperty("/");
|
||||||
|
expect(record.attributes.repo_registration_record_cid["/"]).toHaveLength(46);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
record:
|
record:
|
||||||
type: WebsiteRegistrationRecord
|
type: WebsiteRegistrationRecord
|
||||||
url: 'https://cerc.io'
|
url: 'https://cerc.io'
|
||||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
repo_registration_record_cid:
|
||||||
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||||
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
build_artifact_cid:
|
||||||
|
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||||
|
tls_cert_cid:
|
||||||
|
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||||
version: 1.0.23
|
version: 1.0.23
|
||||||
|
87
src/util.ts
87
src/util.ts
@ -10,21 +10,21 @@ export class Util {
|
|||||||
/**
|
/**
|
||||||
* Sorts JSON object.
|
* Sorts JSON object.
|
||||||
*/
|
*/
|
||||||
static sortJSON(object: any) {
|
static sortJSON(obj: any) {
|
||||||
if (object instanceof Array) {
|
if (obj instanceof Array) {
|
||||||
for (let i = 0; i < object.length; i++) {
|
for (let i = 0; i < obj.length; i++) {
|
||||||
object[i] = Util.sortJSON(object[i]);
|
obj[i] = Util.sortJSON(obj[i]);
|
||||||
}
|
}
|
||||||
return object;
|
return obj;
|
||||||
}
|
}
|
||||||
if (typeof object !== 'object' || object === null) return object;
|
if (typeof obj !== 'object' || obj === null) return obj;
|
||||||
|
|
||||||
let keys = Object.keys(object);
|
let keys = Object.keys(obj);
|
||||||
keys = keys.sort();
|
keys = keys.sort();
|
||||||
const newObject: {[key: string]: any} = {};
|
const newObject: {[key: string]: any} = {};
|
||||||
|
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
newObject[keys[i]] = Util.sortJSON(object[keys[i]]);
|
newObject[keys[i]] = Util.sortJSON(obj[keys[i]]);
|
||||||
}
|
}
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
@ -32,31 +32,40 @@ export class Util {
|
|||||||
/**
|
/**
|
||||||
* Marshal object into gql 'attributes' variable.
|
* Marshal object into gql 'attributes' variable.
|
||||||
*/
|
*/
|
||||||
static toGQLAttributes(object: any) {
|
static toGQLAttributes(obj: any) {
|
||||||
const vars: any[] = [];
|
const vars: any[] = [];
|
||||||
|
Object.keys(obj).forEach(key => {
|
||||||
Object.keys(object).forEach(key => {
|
vars.push({ key, value: this.toGQLValue(obj[key]) });
|
||||||
let type: string = typeof object[key];
|
|
||||||
if (object[key] === null) {
|
|
||||||
vars.push({ key, value: { 'null': true } });
|
|
||||||
} else if (type === 'number') {
|
|
||||||
type = (object[key] % 1 === 0) ? 'int' : 'float';
|
|
||||||
vars.push({ key, value: { [type]: object[key] } });
|
|
||||||
} else if (type === 'string') {
|
|
||||||
vars.push({ key, value: { 'string': object[key] } });
|
|
||||||
} else if (type === 'boolean') {
|
|
||||||
vars.push({ key, value: { 'boolean': object[key] } });
|
|
||||||
} else if (type === 'object') {
|
|
||||||
const nestedObject = object[key];
|
|
||||||
if (nestedObject['/'] !== undefined) {
|
|
||||||
vars.push({ key, value: { 'reference': { id: nestedObject['/'] } } });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return vars;
|
return vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static toGQLValue(obj: any) {
|
||||||
|
if (obj === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let type: string = typeof obj;
|
||||||
|
switch (type) {
|
||||||
|
case 'number':
|
||||||
|
type = (obj % 1 === 0) ? 'int' : 'float';
|
||||||
|
return { [type]: obj };
|
||||||
|
case 'string':
|
||||||
|
return { 'string': obj };
|
||||||
|
case 'boolean':
|
||||||
|
return { 'boolean': obj };
|
||||||
|
case 'object':
|
||||||
|
if (obj['/'] !== undefined) {
|
||||||
|
return { 'link': obj['/'] };
|
||||||
|
}
|
||||||
|
if (obj instanceof Array) {
|
||||||
|
return { 'array': obj };
|
||||||
|
}
|
||||||
|
return { 'map': obj };
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown object type '${type}': ${obj}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unmarshal attributes array to object.
|
* Unmarshal attributes array to object.
|
||||||
*/
|
*/
|
||||||
@ -64,24 +73,20 @@ export class Util {
|
|||||||
const res: {[key: string]: any} = {};
|
const res: {[key: string]: any} = {};
|
||||||
|
|
||||||
attributes.forEach(attr => {
|
attributes.forEach(attr => {
|
||||||
if (attr.value.null) {
|
res[attr.key] = this.fromGQLValue(attr.value);
|
||||||
res[attr.key] = null;
|
|
||||||
} else if (attr.value.json) {
|
|
||||||
res[attr.key] = JSON.parse(attr.value.json);
|
|
||||||
} else if (attr.value.reference) {
|
|
||||||
// Convert GQL reference to IPLD style link.
|
|
||||||
const ref = attr.value.reference;
|
|
||||||
res[attr.key] = { '/': ref.id };
|
|
||||||
} else {
|
|
||||||
const { values, null: n, ...types } = attr.value;
|
|
||||||
const value = Object.values(types).find(v => v !== null);
|
|
||||||
res[attr.key] = value;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static fromGQLValue(obj: any) {
|
||||||
|
const present = Object.keys(obj).find(k => obj[k] !== null);
|
||||||
|
if (present === undefined) {
|
||||||
|
throw new Error('Object has no non-null values');
|
||||||
|
}
|
||||||
|
return obj[present];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get record content ID.
|
* Get record content ID.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user