From a70fc6ab71178de2c31611cd75e5ccb444ae5cb8 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Tue, 29 Oct 2024 17:51:50 +0530 Subject: [PATCH 1/5] Display deployer base domain in overview tab --- packages/backend/src/database.ts | 1 + packages/backend/src/schema.gql | 1 + packages/frontend/src/pages/components/modals.tsx | 1 + .../src/pages/org-slug/projects/id/Overview.tsx | 10 +++++----- packages/frontend/src/stories/MockStoriesData.ts | 2 ++ packages/gql-client/src/queries.ts | 3 +++ packages/gql-client/src/types.ts | 1 + 7 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/database.ts b/packages/backend/src/database.ts index bae1769c..71b2323b 100644 --- a/packages/backend/src/database.ts +++ b/packages/backend/src/database.ts @@ -140,6 +140,7 @@ export class Database { ) .leftJoinAndSelect('deployments.createdBy', 'user') .leftJoinAndSelect('deployments.domain', 'domain') + .leftJoinAndSelect('deployments.deployer', 'deployer') .leftJoinAndSelect('project.owner', 'owner') .leftJoinAndSelect('project.deployers', 'deployers') .leftJoinAndSelect('project.organization', 'organization') diff --git a/packages/backend/src/schema.gql b/packages/backend/src/schema.gql index b8a292a6..ff51098a 100644 --- a/packages/backend/src/schema.gql +++ b/packages/backend/src/schema.gql @@ -143,6 +143,7 @@ type Deployer { paymentAddress: String createdAt: String! updatedAt: String! + baseDomain: String } type AuthResult { diff --git a/packages/frontend/src/pages/components/modals.tsx b/packages/frontend/src/pages/components/modals.tsx index cf734d31..35688b26 100644 --- a/packages/frontend/src/pages/components/modals.tsx +++ b/packages/frontend/src/pages/components/modals.tsx @@ -41,6 +41,7 @@ const deployment: Deployment = { deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu', deployerLrn: 'lrn://example/deployers/webapp-deployer-api.example.com', minimumPayment: '1000alnt', + baseDomain: 'pwa.wireitin.com' }, status: DeploymentStatus.Ready, createdBy: { diff --git a/packages/frontend/src/pages/org-slug/projects/id/Overview.tsx b/packages/frontend/src/pages/org-slug/projects/id/Overview.tsx index 9346deb0..8e840bb3 100644 --- a/packages/frontend/src/pages/org-slug/projects/id/Overview.tsx +++ b/packages/frontend/src/pages/org-slug/projects/id/Overview.tsx @@ -129,16 +129,16 @@ const OverviewTabPanel = () => { {project.name} - {project.baseDomains && - project.baseDomains.length > 0 && - project.baseDomains.map((baseDomain, index) => ( + {project.deployments && + project.deployments.length > 0 && + project.deployments.map((deployment, index) => (

- {baseDomain} + {deployment.deployer.baseDomain}

))} diff --git a/packages/frontend/src/stories/MockStoriesData.ts b/packages/frontend/src/stories/MockStoriesData.ts index d6dbb544..f4ffca20 100644 --- a/packages/frontend/src/stories/MockStoriesData.ts +++ b/packages/frontend/src/stories/MockStoriesData.ts @@ -107,6 +107,7 @@ export const deployment0: Deployment = { deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu', deployerLrn: 'lrn://deployer.apps.snowballtools.com ', minimumPayment: '1000alnt', + baseDomain: 'pwa.wireitin.com' }, applicationDeploymentRequestId: 'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize', @@ -134,6 +135,7 @@ export const project: Project = { deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu', deployerLrn: 'lrn://deployer.apps.snowballtools.com ', minimumPayment: '1000alnt', + baseDomain: 'pwa.wireitin.com' }, ], paymentAddress: '0x657868687686rb4787987br8497298r79284797487', diff --git a/packages/gql-client/src/queries.ts b/packages/gql-client/src/queries.ts index 467e0583..48760dbd 100644 --- a/packages/gql-client/src/queries.ts +++ b/packages/gql-client/src/queries.ts @@ -57,6 +57,9 @@ query ($projectId: String!) { commitHash createdAt environment + deployer { + baseDomain + } domain { status branch diff --git a/packages/gql-client/src/types.ts b/packages/gql-client/src/types.ts index b4685706..3c690fc6 100644 --- a/packages/gql-client/src/types.ts +++ b/packages/gql-client/src/types.ts @@ -119,6 +119,7 @@ export type Deployer = { deployerLrn: string; deployerId: string; deployerApiUrl: string; + baseDomain: string; minimumPayment: string | null; } -- 2.45.2 From 15eb505af4632e7d1417f7991b49037c4ccff182 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Tue, 29 Oct 2024 18:37:08 +0530 Subject: [PATCH 2/5] Add default value for env variables array --- .../src/components/projects/create/Configure.tsx | 11 +++++++++++ .../project/overview/Activity/AuctionCard.tsx | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/components/projects/create/Configure.tsx b/packages/frontend/src/components/projects/create/Configure.tsx index f4cd0092..c4a2eb45 100644 --- a/packages/frontend/src/components/projects/create/Configure.tsx +++ b/packages/frontend/src/components/projects/create/Configure.tsx @@ -70,6 +70,7 @@ const Configure = () => { maxPrice: DEFAULT_MAX_PRICE, lrn: '', numProviders: 1, + variables: [] }, }); @@ -173,6 +174,7 @@ const Configure = () => { const handleFormSubmit = useCallback( async (createFormData: FieldValues) => { + try { const deployerLrn = createFormData.lrn; const deployer = deployers.find( (deployer) => deployer.deployerLrn === deployerLrn, @@ -268,6 +270,15 @@ const Configure = () => { `/${orgSlug}/projects/create/deploy?projectId=${projectId}`, ); } + } catch (error) { + console.error(error) + toast({ + id: 'error-deploying-app', + title: 'Error deploying app', + variant: 'error', + onDismiss: dismiss, + }); + } }, [client, createProject, dismiss, toast], ); diff --git a/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx b/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx index d7ca2be4..6927c2d8 100644 --- a/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx +++ b/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx @@ -134,7 +134,7 @@ export const AuctionCard = ({ project }: { project: Project }) => { size="xs" type={fundsStatus ? 'positive' : 'emphasized'} > - {fundsStatus ? 'RELEASED' : 'LOCKED'} + {fundsStatus ? 'RELEASED' : 'WAITING'} -- 2.45.2 From fa1ba6150a07bfecaa86c1a179f3aa701a372dac Mon Sep 17 00:00:00 2001 From: Neeraj Date: Tue, 29 Oct 2024 18:41:21 +0530 Subject: [PATCH 3/5] Add example base domains --- packages/frontend/src/pages/components/modals.tsx | 2 +- packages/frontend/src/stories/MockStoriesData.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/pages/components/modals.tsx b/packages/frontend/src/pages/components/modals.tsx index 35688b26..58582a35 100644 --- a/packages/frontend/src/pages/components/modals.tsx +++ b/packages/frontend/src/pages/components/modals.tsx @@ -41,7 +41,7 @@ const deployment: Deployment = { deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu', deployerLrn: 'lrn://example/deployers/webapp-deployer-api.example.com', minimumPayment: '1000alnt', - baseDomain: 'pwa.wireitin.com' + baseDomain: 'pwa.example.com' }, status: DeploymentStatus.Ready, createdBy: { diff --git a/packages/frontend/src/stories/MockStoriesData.ts b/packages/frontend/src/stories/MockStoriesData.ts index f4ffca20..bdce7ee9 100644 --- a/packages/frontend/src/stories/MockStoriesData.ts +++ b/packages/frontend/src/stories/MockStoriesData.ts @@ -107,7 +107,7 @@ export const deployment0: Deployment = { deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu', deployerLrn: 'lrn://deployer.apps.snowballtools.com ', minimumPayment: '1000alnt', - baseDomain: 'pwa.wireitin.com' + baseDomain: 'pwa.example.com' }, applicationDeploymentRequestId: 'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize', @@ -135,7 +135,7 @@ export const project: Project = { deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu', deployerLrn: 'lrn://deployer.apps.snowballtools.com ', minimumPayment: '1000alnt', - baseDomain: 'pwa.wireitin.com' + baseDomain: 'pwa.example.com' }, ], paymentAddress: '0x657868687686rb4787987br8497298r79284797487', -- 2.45.2 From 97354f35a1f3e0a75d1af11fb03e39bd3d7e3637 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 29 Oct 2024 18:56:45 +0530 Subject: [PATCH 4/5] Poll for project details for auction details --- .../project/overview/Activity/AuctionCard.tsx | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx b/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx index 6927c2d8..5e93a1d4 100644 --- a/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx +++ b/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx @@ -42,31 +42,31 @@ export const AuctionCard = ({ project }: { project: Project }) => { ); - const checkAuctionStatus = useCallback(async () => { - const result = await client.getAuctionData(project.auctionId); - setAuctionStatus(result.status); - setAuctionDetails(result); - setDeployers(project.deployers); - setFundsStatus(project.fundsReleased); - }, []); + const checkAuctionStatus = useCallback(async () => { + const result = await client.getAuctionData(project.auctionId); + setAuctionStatus(result.status); + setAuctionDetails(result); + }, [project.auctionId, project.deployers, project.fundsReleased]); - useEffect(() => { - if (auctionStatus !== 'completed') { - checkAuctionStatus(); - const intervalId = setInterval(checkAuctionStatus, WAIT_DURATION); - return () => clearInterval(intervalId); - } + const fetchUpdatedProject = useCallback(async () => { + const updatedProject = await client.getProject(project.id); + setDeployers(updatedProject.project!.deployers!); + setFundsStatus(updatedProject.project!.fundsReleased!); + }, [project.id]); - if (auctionStatus === 'completed') { - const fetchUpdatedProject = async () => { - // Wait for 5 secs since the project is not immediately updated with deployer LRNs - await new Promise((resolve) => setTimeout(resolve, WAIT_DURATION)); - const updatedProject = await client.getProject(project.id); - setDeployers(updatedProject.project?.deployers || []); - }; - fetchUpdatedProject(); - } - }, [auctionStatus, client]); + const fetchData = useCallback(async () => { + await Promise.all([checkAuctionStatus(), fetchUpdatedProject()]); + }, [checkAuctionStatus, fetchUpdatedProject]); + + useEffect(() => { + fetchData(); + + const timerId = setInterval(() => { + fetchData(); + }, WAIT_DURATION); + + return () => clearInterval(timerId); + }, [fetchData]); const renderAuctionStatus = useCallback( () => ( -- 2.45.2 From eb9c14dce38e4be925065eb8d3c41ca5d039c8ef Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Tue, 29 Oct 2024 19:19:33 +0530 Subject: [PATCH 5/5] Update wallet connect meta data while signing in --- .../components/projects/create/Configure.tsx | 202 +++++++++--------- .../frontend/src/context/Web3Provider.tsx | 4 +- .../frontend/src/pages/components/modals.tsx | 2 +- .../frontend/src/stories/MockStoriesData.ts | 4 +- 4 files changed, 107 insertions(+), 105 deletions(-) diff --git a/packages/frontend/src/components/projects/create/Configure.tsx b/packages/frontend/src/components/projects/create/Configure.tsx index c4a2eb45..9dca4915 100644 --- a/packages/frontend/src/components/projects/create/Configure.tsx +++ b/packages/frontend/src/components/projects/create/Configure.tsx @@ -70,7 +70,7 @@ const Configure = () => { maxPrice: DEFAULT_MAX_PRICE, lrn: '', numProviders: 1, - variables: [] + variables: [], }, }); @@ -175,110 +175,110 @@ const Configure = () => { const handleFormSubmit = useCallback( async (createFormData: FieldValues) => { try { - 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({ - id: 'no-payment-required', - title: 'No payment required. Deploying app...', - variant: 'info', - onDismiss: dismiss, - }); - - txHash = ''; - senderAddress = ''; - } else { - if (!selectedAccount) return; - - senderAddress = selectedAccount.split(':')[2]; - - if (createFormData.option === 'LRN') { - amount = deployer?.minimumPayment!; - } else { - amount = ( - createFormData.numProviders * createFormData.maxPrice - ).toString(); - } - - const amountToBePaid = amount.replace(/\D/g, '').toString(); - - const txHashResponse = await cosmosSendTokensHandler( - selectedAccount, - amountToBePaid, + const deployerLrn = createFormData.lrn; + const deployer = deployers.find( + (deployer) => deployer.deployerLrn === deployerLrn, ); - if (!txHashResponse) { - console.error('Tx not successful'); - return; + let amount: string; + let senderAddress: string; + let txHash: string; + if (createFormData.option === 'LRN' && !deployer?.minimumPayment) { + toast({ + id: 'no-payment-required', + title: 'No payment required. Deploying app...', + variant: 'info', + onDismiss: dismiss, + }); + + txHash = ''; + senderAddress = ''; + } else { + if (!selectedAccount) return; + + senderAddress = selectedAccount.split(':')[2]; + + if (createFormData.option === 'LRN') { + amount = deployer?.minimumPayment!; + } else { + amount = ( + createFormData.numProviders * createFormData.maxPrice + ).toString(); + } + + const amountToBePaid = amount.replace(/\D/g, '').toString(); + + const txHashResponse = await cosmosSendTokensHandler( + selectedAccount, + amountToBePaid, + ); + + if (!txHashResponse) { + console.error('Tx not successful'); + return; + } + + txHash = txHashResponse; + + const isTxHashValid = await verifyTx( + senderAddress, + txHash, + amountToBePaid.toString(), + ); + + if (isTxHashValid === false) { + console.error('Invalid Tx hash', txHash); + return; + } } - txHash = txHashResponse; + const environmentVariables = createFormData.variables.map( + (variable: any) => { + return { + key: variable.key, + value: variable.value, + environments: Object.entries(createFormData.environment) + .filter(([, value]) => value === true) + .map(([key]) => key.charAt(0).toUpperCase() + key.slice(1)), + }; + }, + ); - const isTxHashValid = await verifyTx( + const projectId = await createProject( + createFormData, + environmentVariables, senderAddress, txHash, - amountToBePaid.toString(), ); - if (isTxHashValid === false) { - console.error('Invalid Tx hash', txHash); - return; + await client.getEnvironmentVariables(projectId); + + if (templateId) { + createFormData.option === 'Auction' + ? navigate( + `/${orgSlug}/projects/create/success/${projectId}?isAuction=true`, + ) + : navigate( + `/${orgSlug}/projects/create/template/deploy?projectId=${projectId}&templateId=${templateId}`, + ); + } else { + createFormData.option === 'Auction' + ? navigate( + `/${orgSlug}/projects/create/success/${projectId}?isAuction=true`, + ) + : navigate( + `/${orgSlug}/projects/create/deploy?projectId=${projectId}`, + ); } + } catch (error) { + console.error(error); + toast({ + id: 'error-deploying-app', + title: 'Error deploying app', + variant: 'error', + onDismiss: dismiss, + }); } - - const environmentVariables = createFormData.variables.map( - (variable: any) => { - return { - key: variable.key, - value: variable.value, - environments: Object.entries(createFormData.environment) - .filter(([, value]) => value === true) - .map(([key]) => key.charAt(0).toUpperCase() + key.slice(1)), - }; - }, - ); - - const projectId = await createProject( - createFormData, - environmentVariables, - senderAddress, - txHash, - ); - - await client.getEnvironmentVariables(projectId); - - if (templateId) { - createFormData.option === 'Auction' - ? navigate( - `/${orgSlug}/projects/create/success/${projectId}?isAuction=true`, - ) - : navigate( - `/${orgSlug}/projects/create/template/deploy?projectId=${projectId}&templateId=${templateId}`, - ); - } else { - createFormData.option === 'Auction' - ? navigate( - `/${orgSlug}/projects/create/success/${projectId}?isAuction=true`, - ) - : navigate( - `/${orgSlug}/projects/create/deploy?projectId=${projectId}`, - ); - } - } catch (error) { - console.error(error) - toast({ - id: 'error-deploying-app', - title: 'Error deploying app', - variant: 'error', - onDismiss: dismiss, - }); - } }, [client, createProject, dismiss, toast], ); @@ -292,10 +292,13 @@ const Configure = () => { setSelectedAccount(account); }, []); - const onDeployerChange = useCallback((selectedLrn: string) => { - const deployer = deployers.find((d) => d.deployerLrn === selectedLrn); - setSelectedDeployer(deployer); - }, [deployers]); + const onDeployerChange = useCallback( + (selectedLrn: string) => { + const deployer = deployers.find((d) => d.deployerLrn === selectedLrn); + setSelectedDeployer(deployer); + }, + [deployers], + ); const cosmosSendTokensHandler = useCallback( async (selectedAccount: string, amount: string) => { @@ -507,8 +510,7 @@ const Configure = () => { - {selectedOption === 'LRN' && - !selectedDeployer?.minimumPayment ? ( + {selectedOption === 'LRN' && !selectedDeployer?.minimumPayment ? (