Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ebebaf4b6 | ||
|
|
6055da62c7 |
@@ -16,6 +16,7 @@ enum RecordType {
|
||||
StackRecord = 'StackRecord',
|
||||
SubgraphRecord = 'SubgraphRecord',
|
||||
WatcherRecord = 'WatcherRecord',
|
||||
DockerImageRecord = 'DockerImageRecord'
|
||||
}
|
||||
|
||||
const recordTypeToRecordField = new Map<string, string>([
|
||||
@@ -188,6 +189,46 @@ async function publishRecord (userKey: string, bondId: string, fee: StdFee, reco
|
||||
record.repository = repoRecordId;
|
||||
}
|
||||
|
||||
// For stack records, check for attributes
|
||||
if (record.type === RecordType.StackRecord) {
|
||||
const watcherName = record.meta?.watcher;
|
||||
const dockerImages = record.docker_images;
|
||||
|
||||
// If .docker_images present, check for image records
|
||||
if (Array.isArray(dockerImages) && dockerImages.length > 0) {
|
||||
const dockerImageRecordsIdPromises = dockerImages.map(async (dockerImage) => {
|
||||
// Find the required docker image record
|
||||
const queryResult = await registry.queryRecords({ type: RecordType.DockerImageRecord, name: dockerImage }, true);
|
||||
if (queryResult.length === 0) {
|
||||
throw new Error(`Record not found, type: ${RecordType.DockerImageRecord}, name: ${dockerImage}`);
|
||||
}
|
||||
|
||||
// Assume the first query result
|
||||
const dockerImageRecordId = queryResult[0].id;
|
||||
|
||||
// Replace watcher name with the watcher record id
|
||||
return dockerImageRecordId;
|
||||
});
|
||||
|
||||
record.docker_images = await Promise.all(dockerImageRecordsIdPromises);
|
||||
}
|
||||
|
||||
// If .meta.watcher present, check for watcher record
|
||||
if (watcherName) {
|
||||
// Find the required watcher record
|
||||
const queryResult = await registry.queryRecords({ type: RecordType.WatcherRecord, name: watcherName }, true);
|
||||
if (queryResult.length === 0) {
|
||||
throw new Error(`Record not found, type: ${RecordType.WatcherRecord}, name: ${watcherName}`);
|
||||
}
|
||||
|
||||
// Assume the first query result
|
||||
const watcherRecordId = queryResult[0].id;
|
||||
|
||||
// Replace watcher name with the watcher record id
|
||||
record.meta.watcher = watcherRecordId;
|
||||
}
|
||||
}
|
||||
|
||||
return registry.setRecord({ privateKey: userKey, record, bondId }, userKey, fee);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cerc-io/laconic-registry-cli",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"main": "index.js",
|
||||
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
|
||||
"author": "",
|
||||
|
||||
@@ -18,7 +18,9 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(chainId, 'Invalid registry Chain ID.');
|
||||
|
||||
if (!address && privateKey) {
|
||||
address = new Account(Buffer.from(privateKey, 'hex')).address;
|
||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||
await account.init();
|
||||
address = account.address;
|
||||
}
|
||||
|
||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
|
||||
Reference in New Issue
Block a user