Check request Id for updating deployment data

This commit is contained in:
IshaVenikar 2024-10-08 16:58:59 +05:30 committed by Nabarun
parent 8ae1aec468
commit 1374a28fe6
4 changed files with 27 additions and 12 deletions

View File

@ -6,7 +6,6 @@ import { DeepPartial } from 'typeorm';
import { Octokit } from 'octokit';
import { Registry as LaconicRegistry, getGasPrice, parseGasAndFees } from '@cerc-io/registry-sdk';
import { Auction } from '@cerc-io/registry-sdk/dist/proto/cerc/auction/v1/auction';
import { RegistryConfig } from './config';
import {
@ -15,7 +14,7 @@ import {
ApplicationDeploymentRequest,
ApplicationDeploymentRemovalRequest
} from './entity/Deployment';
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionData, PackageJSON } from './types';
import { AppDeploymentRecord, AppDeploymentRemovalRecord, Auction, AuctionData, PackageJSON } from './types';
import { getConfig, sleep } from './utils';
const log = debug('snowball:registry');
@ -195,7 +194,7 @@ export class Registry {
})
).data.html_url;
// TODO: Set environment variables for each deployment (environment variables can`t be set in application record)
// TODO: Set environment variables for each deployment (environment variables can't be set in application record)
const { applicationRecordId } =
await this.createApplicationRecord({
appName: repo,
@ -221,7 +220,6 @@ export class Registry {
const auctionConfig = config.auction;
const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees);
const auctionResult = await this.registry.createProviderAuction(
{
commitFee: auctionConfig.commitFee,
@ -472,7 +470,6 @@ export class Registry {
}
async getRecordsByName(name: string): Promise<any> {
return this.registry.resolveNames([name]);
}

View File

@ -194,7 +194,7 @@ export class Service {
const recordToDeploymentsMap = deployments.reduce(
(acc: { [key: string]: Deployment }, deployment) => {
acc[deployment.applicationRecordId] = deployment;
acc[deployment.applicationDeploymentRequestId!] = deployment;
return acc;
},
{},
@ -202,7 +202,7 @@ export class Service {
// Update deployment data for ApplicationDeploymentRecords
const deploymentUpdatePromises = records.map(async (record) => {
const deployment = recordToDeploymentsMap[record.attributes.application];
const deployment = recordToDeploymentsMap[record.attributes.request];
await this.db.updateDeploymentById(deployment.id, {
applicationDeploymentRecordId: record.id,
@ -282,11 +282,11 @@ export class Service {
const completedAuctionIds = await this.registry.getCompletedAuctionIds(auctionIds);
if (completedAuctionIds) {
const auctionProjects = projects.filter((project) =>
const projectsToBedeployed = projects.filter((project) =>
completedAuctionIds.includes(project.auctionId!)
);
for (const project of auctionProjects) {
for (const project of projectsToBedeployed) {
await this.createDeploymentFromAuction(project);
}
}
@ -688,12 +688,12 @@ export class Service {
async createDeploymentFromAuction(
project: DeepPartial<Project>,
) {
const deployerLrns = await this.registry.getAuctionWinners(project!.auctionId!);
// Update project with deployer LRNs
const deployerLrns = await this.registry.getAuctionWinners(project!.auctionId!);
await this.db.updateProjectById(project.id!, {
deployerLrn: deployerLrns
})
const octokit = await this.getOctokit(project.ownerId!);
const [owner, repo] = project.repository!.split('/');

View File

@ -70,6 +70,25 @@ export interface AddProjectFromTemplateInput {
isPrivate: boolean;
}
export interface Auction {
id: string;
kind: string;
status: string;
ownerAddress: string;
createTime?: Date;
commitsEndTime?: Date;
revealsEndTime?: Date;
commitFee?: string;
revealFee?: string;
minimumBid?: string;
winnerAddresses: string[];
winningBids: string[];
winningPrice?: string;
maxPrice?: string;
numProviders: number;
fundsReleased: boolean;
}
export interface AuctionData {
maxPrice: string,
numProviders: number,

View File

@ -1,4 +1,3 @@
import assert from 'assert';
import fs from 'fs-extra';
import path from 'path';
import toml from 'toml';