From 827213c9e7653ef0eccb98558620db19cd013d38 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Mon, 28 Oct 2024 19:06:35 +0530 Subject: [PATCH 01/10] Pass payment in deployment requests --- packages/backend/src/entity/Deployment.ts | 1 + packages/backend/src/registry.ts | 2 ++ packages/backend/src/service.ts | 11 ++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/entity/Deployment.ts b/packages/backend/src/entity/Deployment.ts index 5efb28b4..cf0889e8 100644 --- a/packages/backend/src/entity/Deployment.ts +++ b/packages/backend/src/entity/Deployment.ts @@ -38,6 +38,7 @@ export interface ApplicationDeploymentRequest { auction?: string; config: string; meta: string; + payment: string; } export interface ApplicationDeploymentRemovalRequest { diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index 9f3b314c..3e35d779 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -248,6 +248,7 @@ export class Registry { lrn: string, environmentVariables: { [key: string]: string }, dns: string, + payment: string }): Promise<{ applicationDeploymentRequestId: string; applicationDeploymentRequestData: ApplicationDeploymentRequest; @@ -267,6 +268,7 @@ export class Registry { name: `${applicationRecord.attributes.name}@${applicationRecord.attributes.app_version}`, application: `${lrn}@${applicationRecord.attributes.app_version}`, dns: data.dns, + payment: data.payment, // https://git.vdb.to/cerc-io/laconic-registry-cli/commit/129019105dfb93bebcea02fde0ed64d0f8e5983b config: JSON.stringify({ diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index e697b663..b5c57cf5 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -648,7 +648,8 @@ export class Service { repository: repoUrl, environmentVariables: environmentVariablesObj, dns: `${newDeployment.project.name}`, - lrn: deployer!.deployerLrn! + lrn: deployer!.deployerLrn!, + payment: data.project.txHash! }); } @@ -660,6 +661,7 @@ export class Service { lrn: deployer!.deployerLrn!, environmentVariables: environmentVariablesObj, dns: `${newDeployment.project.name}-${newDeployment.id}`, + payment: data.project.txHash! }); await this.db.updateDeploymentById(newDeployment.id, { @@ -725,6 +727,7 @@ export class Service { dns: `${newDeployment.project.name}`, auctionId: project.auctionId!, lrn: deployerLrn, + payment: project.txHash! }); } @@ -738,6 +741,7 @@ export class Service { lrn: deployerLrn, environmentVariables: environmentVariablesObj, dns: `${newDeployment.project.name}-${newDeployment.id}`, + payment: project.txHash! }); await this.db.updateDeploymentById(newDeployment.id, { @@ -1342,12 +1346,13 @@ export class Service { } const auction = await this.getAuctionData(project.auctionId); + const maxPrice = Number(auction.maxPrice.quantity) * auction.numProviders; let amountToBeReturned; if (winningDeployersPresent) { - amountToBeReturned = auction.winnerPrice * auction.numProviders; + amountToBeReturned = maxPrice - auction.winnerAddresses.length * Number(auction.winnerPrice.quantity); } else { - amountToBeReturned = auction.maxPrice * auction.numProviders; + amountToBeReturned = maxPrice; } await this.laconicRegistry.sendTokensToAccount( -- 2.45.2 From e675bec1c7cf1b6ec7be0a83350d5a082179d5f7 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 29 Oct 2024 10:33:05 +0530 Subject: [PATCH 02/10] Update configure step UI --- .../src/components/projects/create/Configure.tsx | 14 ++++++++------ packages/gql-client/src/client.ts | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/frontend/src/components/projects/create/Configure.tsx b/packages/frontend/src/components/projects/create/Configure.tsx index 711b448b..e56e7d1d 100644 --- a/packages/frontend/src/components/projects/create/Configure.tsx +++ b/packages/frontend/src/components/projects/create/Configure.tsx @@ -173,17 +173,13 @@ const Configure = () => { const handleFormSubmit = useCallback( async (createFormData: FieldValues) => { - if (!selectedAccount) { - return; - } - - const senderAddress = selectedAccount; const deployerLrn = createFormData.lrn; const deployer = deployers.find( (deployer) => deployer.deployerLrn === deployerLrn, ); let amount: string; + let senderAddress: string; let txHash: string; if (createFormData.option === 'LRN' && !deployer?.minimumPayment) { toast({ @@ -194,7 +190,12 @@ const Configure = () => { }); txHash = ''; + senderAddress = ''; } else { + if (!selectedAccount) return; + + senderAddress = selectedAccount.split(':')[2]; + if (createFormData.option === 'LRN') { amount = deployer?.minimumPayment!; } else { @@ -222,6 +223,7 @@ const Configure = () => { txHash, amount.toString(), ); + if (isTxHashValid === false) { console.error('Invalid Tx hash', txHash); return; @@ -243,7 +245,7 @@ const Configure = () => { const projectId = await createProject( createFormData, environmentVariables, - senderAddress.split(':')[2], + senderAddress, txHash, ); diff --git a/packages/gql-client/src/client.ts b/packages/gql-client/src/client.ts index 201f9fcb..c915dde9 100644 --- a/packages/gql-client/src/client.ts +++ b/packages/gql-client/src/client.ts @@ -442,7 +442,7 @@ export class GQLClient { } async verifyTx(txHash: string, amount: string, senderAddress: string): Promise { - const { data: verifyTx } = await this.client.query({ + const { data } = await this.client.query({ query: queries.verifyTx, variables: { txHash, @@ -451,6 +451,6 @@ export class GQLClient { } }); - return verifyTx; + return data.verifyTx; } } -- 2.45.2 From 89aa75ff16be66522f53de7d99691349fb25c82d Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 29 Oct 2024 12:09:09 +0530 Subject: [PATCH 03/10] Transfer funds from snowball to deployer on project creation --- packages/backend/src/entity/Deployer.ts | 3 + packages/backend/src/entity/Deployment.ts | 9 +-- packages/backend/src/entity/Project.ts | 8 ++- packages/backend/src/registry.ts | 42 +++++++----- packages/backend/src/service.ts | 79 ++++++++++++++++------- 5 files changed, 93 insertions(+), 48 deletions(-) diff --git a/packages/backend/src/entity/Deployer.ts b/packages/backend/src/entity/Deployer.ts index 4328a122..b894d98f 100644 --- a/packages/backend/src/entity/Deployer.ts +++ b/packages/backend/src/entity/Deployer.ts @@ -18,6 +18,9 @@ export class Deployer { @Column('varchar', { nullable: true }) minimumPayment!: string | null; + @Column('varchar', { nullable: true }) + deployerAddress!: string | null; + @ManyToMany(() => Project, (project) => project.deployers) projects!: Project[]; } diff --git a/packages/backend/src/entity/Deployment.ts b/packages/backend/src/entity/Deployment.ts index cf0889e8..5c772b32 100644 --- a/packages/backend/src/entity/Deployment.ts +++ b/packages/backend/src/entity/Deployment.ts @@ -38,20 +38,17 @@ export interface ApplicationDeploymentRequest { auction?: string; config: string; meta: string; - payment: string; + payment?: string; } export interface ApplicationDeploymentRemovalRequest { type: string; version: string; deployment: string; + auction?: string; + payment?: string; } -export interface ApplicationDeploymentRemovalRequest { - type: string; - version: string; - deployment: string; -} export interface ApplicationRecord { type: string; diff --git a/packages/backend/src/entity/Project.ts b/packages/backend/src/entity/Project.ts index aa622dd7..a27b0f06 100644 --- a/packages/backend/src/entity/Project.ts +++ b/packages/backend/src/entity/Project.ts @@ -52,6 +52,10 @@ export class Project { @Column('varchar', { nullable: true }) auctionId!: string | null; + // Tx hash for sending coins from snowball to deployer + @Column('varchar', { nullable: true }) + txHash!: string | null; + @ManyToMany(() => Deployer, (deployer) => (deployer.projects)) @JoinTable() deployers!: Deployer[] @@ -66,12 +70,10 @@ export class Project { @Column('varchar', { nullable: true }) framework!: string | null; + // Address of the user who created the project i.e. requested deployments @Column('varchar') paymentAddress!: string; - @Column('varchar') - txHash!: string; - @Column({ type: 'simple-array' }) diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index 3e35d779..d19d83f4 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -5,8 +5,8 @@ import { Octokit } from 'octokit'; import { inc as semverInc } from 'semver'; import { DeepPartial } from 'typeorm'; -import { Account, Registry as LaconicRegistry, getGasPrice, parseGasAndFees } from '@cerc-io/registry-sdk'; -import { IndexedTx } from '@cosmjs/stargate'; +import { Account, DEFAULT_GAS_ESTIMATION_MULTIPLIER, Registry as LaconicRegistry, getGasPrice, parseGasAndFees } from '@cerc-io/registry-sdk'; +import { DeliverTxResponse, IndexedTx } from '@cosmjs/stargate'; import { RegistryConfig } from './config'; import { @@ -248,7 +248,7 @@ export class Registry { lrn: string, environmentVariables: { [key: string]: string }, dns: string, - payment: string + payment?: string | null }): Promise<{ applicationDeploymentRequestId: string; applicationDeploymentRequestData: ApplicationDeploymentRequest; @@ -268,7 +268,6 @@ export class Registry { name: `${applicationRecord.attributes.name}@${applicationRecord.attributes.app_version}`, application: `${lrn}@${applicationRecord.attributes.app_version}`, dns: data.dns, - payment: data.payment, // https://git.vdb.to/cerc-io/laconic-registry-cli/commit/129019105dfb93bebcea02fde0ed64d0f8e5983b config: JSON.stringify({ @@ -283,6 +282,7 @@ export class Registry { }), deployer: data.lrn, ...(data.auctionId && { auction: data.auctionId }), + ...(data.payment && { payment: data.payment }), }; await sleep(SLEEP_DURATION); @@ -430,6 +430,8 @@ export class Registry { async createApplicationDeploymentRemovalRequest(data: { deploymentId: string; deployerLrn: string; + auctionId?: string | null; + payment?: string | null; }): Promise<{ applicationDeploymentRemovalRequestId: string; applicationDeploymentRemovalRequestData: ApplicationDeploymentRemovalRequest; @@ -438,7 +440,9 @@ export class Registry { type: APP_DEPLOYMENT_REMOVAL_REQUEST_TYPE, version: '1.0.0', deployment: data.deploymentId, - deployer: data.deployerLrn + deployer: data.deployerLrn, + ...(data.auctionId && { auction: data.auctionId }), + ...(data.payment && { payment: data.payment }), }; const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees); @@ -486,19 +490,23 @@ export class Registry { return this.registry.getAuctionsByIds([auctionId]); } - async sendTokensToAccount(receiverAddress: string, amount: string): Promise { + async sendTokensToAccount(receiverAddress: string, amount: string): Promise { const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees); - await registryTransactionWithRetry(() => - this.registry.sendCoins( - { - amount, - denom: 'alnt', - destinationAddress: receiverAddress - }, - this.registryConfig.privateKey, - fee - ) - ); + const account = await this.getAccount(); + const laconicClient = await this.registry.getLaconicClient(account); + const txResponse: DeliverTxResponse = + await registryTransactionWithRetry(() => + laconicClient.sendTokens(account.address, receiverAddress, + [ + { + denom: 'alnt', + amount + } + ], + fee || DEFAULT_GAS_ESTIMATION_MULTIPLIER) + ); + + return txResponse; } async getAccount(): Promise { diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index b5c57cf5..f2c3afb3 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -649,7 +649,7 @@ export class Service { environmentVariables: environmentVariablesObj, dns: `${newDeployment.project.name}`, lrn: deployer!.deployerLrn!, - payment: data.project.txHash! + payment: data.project.txHash }); } @@ -661,7 +661,7 @@ export class Service { lrn: deployer!.deployerLrn!, environmentVariables: environmentVariablesObj, dns: `${newDeployment.project.name}-${newDeployment.id}`, - payment: data.project.txHash! + payment: data.project.txHash }); await this.db.updateDeploymentById(newDeployment.id, { @@ -727,7 +727,7 @@ export class Service { dns: `${newDeployment.project.name}`, auctionId: project.auctionId!, lrn: deployerLrn, - payment: project.txHash! + payment: project.txHash }); } @@ -741,7 +741,7 @@ export class Service { lrn: deployerLrn, environmentVariables: environmentVariablesObj, dns: `${newDeployment.project.name}-${newDeployment.id}`, - payment: project.txHash! + payment: project.txHash }); await this.db.updateDeploymentById(newDeployment.id, { @@ -890,21 +890,50 @@ export class Service { per_page: 1, }); - // Create deployment with prod branch and latest commit - const deploymentData = { - project, - branch: project.prodBranch, - environment: Environment.Production, - domain: null, - commitHash: latestCommit.sha, - commitMessage: latestCommit.commit.message, - }; - if (auctionParams) { + // Create deployment with prod branch and latest commit + const deploymentData = { + project, + branch: project.prodBranch, + environment: Environment.Production, + domain: null, + commitHash: latestCommit.sha, + commitMessage: latestCommit.commit.message, + }; const { applicationDeploymentAuctionId } = await this.laconicRegistry.createApplicationDeploymentAuction(repo, octokit, auctionParams!, deploymentData); await this.updateProject(project.id, { auctionId: applicationDeploymentAuctionId }); } else { - const newDeployment = await this.createDeployment(user.id, octokit, deploymentData, lrn); + const deployer = await this.db.getDeployerByLRN(lrn!); + + if (!deployer) { + log('Invalid deployer LRN'); + return; + } + + if (deployer.minimumPayment && project.txHash) { + const txResponse = await this.laconicRegistry.sendTokensToAccount( + deployer?.deployerAddress!, + deployer?.minimumPayment + ); + + const txHash = txResponse.transactionHash; + if (txHash) { + await this.updateProject(project.id, { txHash }); + log('Funds transferrend to deployer'); + } + } + + const deploymentData = { + project, + branch: project.prodBranch, + environment: Environment.Production, + domain: null, + commitHash: latestCommit.sha, + commitMessage: latestCommit.commit.message, + deployer + }; + + const newDeployment = await this.createDeployment(user.id, octokit, deploymentData); // Update project with deployer await this.updateProjectWithDeployer(newDeployment.projectId, newDeployment.deployer); } @@ -1145,14 +1174,18 @@ export class Service { await this.laconicRegistry.createApplicationDeploymentRemovalRequest({ deploymentId: latestRecord.id, - deployerLrn: deployment.deployer.deployerLrn + deployerLrn: deployment.deployer.deployerLrn, + auctionId: deployment.project.auctionId, + payment: deployment.project.txHash }); } const result = await this.laconicRegistry.createApplicationDeploymentRemovalRequest({ deploymentId: deployment.applicationDeploymentRecordId, - deployerLrn: deployment.deployer.deployerLrn + deployerLrn: deployment.deployer.deployerLrn, + auctionId: deployment.project.auctionId, + payment: deployment.project.txHash }); await this.db.updateDeploymentById(deployment.id, { @@ -1346,13 +1379,13 @@ export class Service { } const auction = await this.getAuctionData(project.auctionId); - const maxPrice = Number(auction.maxPrice.quantity) * auction.numProviders; + const totalAuctionPrice = Number(auction.maxPrice.quantity) * auction.numProviders; let amountToBeReturned; if (winningDeployersPresent) { - amountToBeReturned = maxPrice - auction.winnerAddresses.length * Number(auction.winnerPrice.quantity); + amountToBeReturned = totalAuctionPrice - auction.winnerAddresses.length * Number(auction.winnerPrice.quantity); } else { - amountToBeReturned = maxPrice; + amountToBeReturned = totalAuctionPrice; } await this.laconicRegistry.sendTokensToAccount( @@ -1389,7 +1422,8 @@ export class Service { const deployerId = record.id; const deployerLrn = record.names[0]; const deployerApiUrl = record.attributes.apiUrl; - const minimumPayment = record.attributes.minimumPayment + const minimumPayment = record.attributes.minimumPayment; + const deployerAddress = record.attributes.paymentAddress; const baseDomain = deployerApiUrl.substring(deployerApiUrl.indexOf('.') + 1); const deployerData = { @@ -1397,7 +1431,8 @@ export class Service { deployerId, deployerApiUrl, baseDomain, - minimumPayment + minimumPayment, + deployerAddress }; // TODO: Update deployers table in a separate job -- 2.45.2 From 5d7fe68351fddc91fa335da9675fc518e00f07ec Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 29 Oct 2024 12:21:35 +0530 Subject: [PATCH 04/10] Don't pass payment in deployment requests with auction flow --- packages/backend/src/registry.ts | 2 +- packages/backend/src/service.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index d19d83f4..d0a03e41 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -244,7 +244,7 @@ export class Registry { deployment: Deployment, appName: string, repository: string, - auctionId?: string, + auctionId?: string | null, lrn: string, environmentVariables: { [key: string]: string }, dns: string, diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index f2c3afb3..1e9ec653 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -649,7 +649,8 @@ export class Service { environmentVariables: environmentVariablesObj, dns: `${newDeployment.project.name}`, lrn: deployer!.deployerLrn!, - payment: data.project.txHash + payment: data.project.txHash, + auctionId: data.project.auctionId }); } @@ -661,7 +662,8 @@ export class Service { lrn: deployer!.deployerLrn!, environmentVariables: environmentVariablesObj, dns: `${newDeployment.project.name}-${newDeployment.id}`, - payment: data.project.txHash + payment: data.project.txHash, + auctionId: data.project.auctionId }); await this.db.updateDeploymentById(newDeployment.id, { @@ -727,7 +729,6 @@ export class Service { dns: `${newDeployment.project.name}`, auctionId: project.auctionId!, lrn: deployerLrn, - payment: project.txHash }); } @@ -741,7 +742,6 @@ export class Service { lrn: deployerLrn, environmentVariables: environmentVariablesObj, dns: `${newDeployment.project.name}-${newDeployment.id}`, - payment: project.txHash }); await this.db.updateDeploymentById(newDeployment.id, { -- 2.45.2 From c4ca9517c088ec365b40e2b818978ef272a160ff Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 29 Oct 2024 12:24:29 +0530 Subject: [PATCH 05/10] Change field name in deployer entity --- packages/backend/src/entity/Deployer.ts | 2 +- packages/backend/src/service.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/entity/Deployer.ts b/packages/backend/src/entity/Deployer.ts index b894d98f..b2612c54 100644 --- a/packages/backend/src/entity/Deployer.ts +++ b/packages/backend/src/entity/Deployer.ts @@ -19,7 +19,7 @@ export class Deployer { minimumPayment!: string | null; @Column('varchar', { nullable: true }) - deployerAddress!: string | null; + paymentAddress!: string | null; @ManyToMany(() => Project, (project) => project.deployers) projects!: Project[]; diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 1e9ec653..c831442e 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -912,7 +912,7 @@ export class Service { if (deployer.minimumPayment && project.txHash) { const txResponse = await this.laconicRegistry.sendTokensToAccount( - deployer?.deployerAddress!, + deployer?.paymentAddress!, deployer?.minimumPayment ); @@ -1423,7 +1423,7 @@ export class Service { const deployerLrn = record.names[0]; const deployerApiUrl = record.attributes.apiUrl; const minimumPayment = record.attributes.minimumPayment; - const deployerAddress = record.attributes.paymentAddress; + const paymentAddress = record.attributes.paymentAddress; const baseDomain = deployerApiUrl.substring(deployerApiUrl.indexOf('.') + 1); const deployerData = { @@ -1432,7 +1432,7 @@ export class Service { deployerApiUrl, baseDomain, minimumPayment, - deployerAddress + paymentAddress }; // TODO: Update deployers table in a separate job -- 2.45.2 From b3f5d35cac4a281f9c122b516fc9cee3ea0db1e8 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 29 Oct 2024 12:35:16 +0530 Subject: [PATCH 06/10] Update project with new tx hash --- packages/backend/src/service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index c831442e..44e369c9 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -919,6 +919,7 @@ export class Service { const txHash = txResponse.transactionHash; if (txHash) { await this.updateProject(project.id, { txHash }); + project.txHash = txHash; log('Funds transferrend to deployer'); } } -- 2.45.2 From 6e1464d4daa5745cdb9d8cc5eea1032baeae3d7a Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 29 Oct 2024 12:44:30 +0530 Subject: [PATCH 07/10] Fix deployer type --- packages/backend/src/entity/Deployer.ts | 2 +- packages/backend/src/schema.gql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/entity/Deployer.ts b/packages/backend/src/entity/Deployer.ts index b2612c54..d9e1b600 100644 --- a/packages/backend/src/entity/Deployer.ts +++ b/packages/backend/src/entity/Deployer.ts @@ -19,7 +19,7 @@ export class Deployer { minimumPayment!: string | null; @Column('varchar', { nullable: true }) - paymentAddress!: string | null; + paymentAddress!: string | null; @ManyToMany(() => Project, (project) => project.deployers) projects!: Project[]; diff --git a/packages/backend/src/schema.gql b/packages/backend/src/schema.gql index 3f7a615d..b8a292a6 100644 --- a/packages/backend/src/schema.gql +++ b/packages/backend/src/schema.gql @@ -140,6 +140,7 @@ type Deployer { deployerId: String! deployerApiUrl: String! minimumPayment: String + paymentAddress: String createdAt: String! updatedAt: String! } -- 2.45.2 From 781b6673194a5378a7f7e7fb79461bcbd44c34db Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 29 Oct 2024 13:58:22 +0530 Subject: [PATCH 08/10] Check names in deployer lrn --- packages/backend/src/registry.ts | 6 +++++- packages/backend/src/service.ts | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index d0a03e41..9b5d913b 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -324,7 +324,11 @@ export class Registry { paymentAddress: auctionWinner, }); - for (const record of records) { + const newRecords = records.filter(record => { + record.names !== null + }) + + for (const record of newRecords) { if (record.id) { deployerRecords.push(record); break; diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 44e369c9..98f19476 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -911,9 +911,11 @@ export class Service { } if (deployer.minimumPayment && project.txHash) { + const amountToBePaid = deployer?.minimumPayment.replace(/\D/g, '').toString(); + const txResponse = await this.laconicRegistry.sendTokensToAccount( deployer?.paymentAddress!, - deployer?.minimumPayment + amountToBePaid ); const txHash = txResponse.transactionHash; -- 2.45.2 From c6162cd036a65f72d3176b8041910b3c36cb14e0 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 29 Oct 2024 14:11:58 +0530 Subject: [PATCH 09/10] Check records with names not null --- packages/backend/src/registry.ts | 4 +--- .../frontend/src/components/projects/create/Configure.tsx | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index 9b5d913b..03ef08aa 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -324,9 +324,7 @@ export class Registry { paymentAddress: auctionWinner, }); - const newRecords = records.filter(record => { - record.names !== null - }) + const newRecords = records.filter(record => record.names !== null); for (const record of newRecords) { if (record.id) { diff --git a/packages/frontend/src/components/projects/create/Configure.tsx b/packages/frontend/src/components/projects/create/Configure.tsx index e56e7d1d..f4cd0092 100644 --- a/packages/frontend/src/components/projects/create/Configure.tsx +++ b/packages/frontend/src/components/projects/create/Configure.tsx @@ -221,7 +221,7 @@ const Configure = () => { const isTxHashValid = await verifyTx( senderAddress, txHash, - amount.toString(), + amountToBePaid.toString(), ); if (isTxHashValid === false) { -- 2.45.2 From 5b7f638caf7258ab3a46410f1bfc4793058537d0 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 29 Oct 2024 14:34:08 +0530 Subject: [PATCH 10/10] Add check for amount to be returned --- packages/backend/src/registry.ts | 4 +++- packages/backend/src/service.ts | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index 03ef08aa..43d9c988 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -324,7 +324,9 @@ export class Registry { paymentAddress: auctionWinner, }); - const newRecords = records.filter(record => record.names !== null); + const newRecords = records.filter(record => { + return record.names !== null && record.names.length > 0; + }); for (const record of newRecords) { if (record.id) { diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 98f19476..b142ad67 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -1391,10 +1391,12 @@ export class Service { amountToBeReturned = totalAuctionPrice; } - await this.laconicRegistry.sendTokensToAccount( - project.paymentAddress, - amountToBeReturned.toString() - ); + if (amountToBeReturned !== 0) { + await this.laconicRegistry.sendTokensToAccount( + project.paymentAddress, + amountToBeReturned.toString() + ); + } } async getDeployers(): Promise { -- 2.45.2