From 5fe04dd6919ae816f3cf3ddd7ceb372f63b57b44 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 8 Oct 2024 16:58:59 +0530 Subject: [PATCH] Check request Id for updating deployment data --- packages/backend/src/registry.ts | 7 ++----- packages/backend/src/service.ts | 12 ++++++------ packages/backend/src/types.ts | 19 +++++++++++++++++++ packages/backend/src/utils.ts | 1 - 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index ac53f170..be2d6c6d 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -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 { - return this.registry.resolveNames([name]); } diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index e8dd2f6c..266e6106 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -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, ) { - 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('/'); diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts index 5f368c0b..ab12b8be 100644 --- a/packages/backend/src/types.ts +++ b/packages/backend/src/types.ts @@ -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, diff --git a/packages/backend/src/utils.ts b/packages/backend/src/utils.ts index f8314c87..83ceb533 100644 --- a/packages/backend/src/utils.ts +++ b/packages/backend/src/utils.ts @@ -1,4 +1,3 @@ -import assert from 'assert'; import fs from 'fs-extra'; import path from 'path'; import toml from 'toml';