From 2a011a99cd41e899568c7e6e64ee4da9a079ceef Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Mon, 7 Oct 2024 14:21:40 +0530 Subject: [PATCH] Pass auction data when adding project --- .../backend/environments/local.toml.example | 2 +- packages/backend/src/registry.ts | 10 ++++++---- .../components/projects/create/Configure.tsx | 20 +++++++++++-------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/backend/environments/local.toml.example b/packages/backend/environments/local.toml.example index 5d392f39..a18bd357 100644 --- a/packages/backend/environments/local.toml.example +++ b/packages/backend/environments/local.toml.example @@ -38,7 +38,7 @@ [registryConfig.fee] gas = "" fees = "" - gasPrice = "1" + gasPrice = "1alnt" [auction] commitFee = "1000" diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index 77d76d3e..671daec9 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -5,7 +5,7 @@ import { DateTime } from 'luxon'; import { DeepPartial } from 'typeorm'; import { Octokit } from 'octokit'; -import { Registry as LaconicRegistry, parseGasAndFees } from '@cerc-io/registry-sdk'; +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'; @@ -35,12 +35,13 @@ export class Registry { constructor (registryConfig: RegistryConfig) { this.registryConfig = registryConfig; - // const gasPrice = Util.getGasPrice(registryConfig.fee.gasPrice); + + const gasPrice = getGasPrice(registryConfig.fee.gasPrice); + this.registry = new LaconicRegistry( registryConfig.gqlEndpoint, registryConfig.restEndpoint, - // Pass gasPrice - { chainId: registryConfig.chainId } + { chainId: registryConfig.chainId, gasPrice } ); } @@ -218,6 +219,7 @@ export class Registry { const config = await getConfig(); const auctionConfig = config.auction; + const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees); const auctionResult = await this.registry.createProviderAuction( diff --git a/packages/frontend/src/components/projects/create/Configure.tsx b/packages/frontend/src/components/projects/create/Configure.tsx index 2a7c8e03..8fa2e049 100644 --- a/packages/frontend/src/components/projects/create/Configure.tsx +++ b/packages/frontend/src/components/projects/create/Configure.tsx @@ -1,6 +1,7 @@ import { useCallback, useState } from 'react'; import { useForm, Controller, SubmitHandler } from 'react-hook-form'; import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'; +import { AuctionData } from 'gql-client'; import { Heading } from '../../shared/Heading'; import { Button } from '../../shared/Button'; @@ -13,7 +14,7 @@ type ConfigureFormValues = { option: string; lrn?: string; numProviders?: number; - maxPrice?: number; + maxPrice?: string; }; const Configure = () => { @@ -46,20 +47,23 @@ const Configure = () => { isPrivate }; - let configData: any; + let lrn: string | undefined; + let auctionData: AuctionData | undefined; + if (data.option === 'LRN') { - configData = data.lrn; + lrn = data.lrn; } else if (data.option === 'Auction') { - configData = { - numProviders: data.numProviders, - maxPrice: data.maxPrice - } + auctionData = { + numProviders: Number(data.numProviders!), + maxPrice: (data.maxPrice!).toString() + }; } const { addProjectFromTemplate } = await client.addProjectFromTemplate( orgSlug, projectData, - configData + lrn, + auctionData ); navigate(`/${orgSlug}/projects/create/template/deploy?projectId=${addProjectFromTemplate.id}&templateId=${templateId}`);