Compare commits
8 Commits
custom-dom
...
main
Author | SHA1 | Date | |
---|---|---|---|
095cf0df34 | |||
dd1d747b60 | |||
cda6ebec30 | |||
05dd75a38c | |||
|
fbfe2a47d6 | ||
c33a4e5574 | |||
6c79ed37fa | |||
a51765dae5 |
@ -47,11 +47,11 @@ jobs:
|
|||||||
cat > packages/deployer/config.yml <<EOF
|
cat > packages/deployer/config.yml <<EOF
|
||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
rpcEndpoint: https://laconicd-sapo.laconic.com
|
rpcEndpoint: https://laconicd-mainnet-1.laconic.com
|
||||||
gqlEndpoint: https://laconicd-sapo.laconic.com/api
|
gqlEndpoint: https://laconicd-mainnet-1.laconic.com/api
|
||||||
userKey: $REGISTRY_USER_KEY
|
userKey: $REGISTRY_USER_KEY
|
||||||
bondId: $REGISTRY_BOND_ID
|
bondId: $REGISTRY_BOND_ID
|
||||||
chainId: laconic-testnet-2
|
chainId: laconic-mainnet
|
||||||
gasPrice: 0.001alnt
|
gasPrice: 0.001alnt
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@ VITE_GITHUB_CLIENT_ID = 'LACONIC_HOSTED_CONFIG_github_clientid'
|
|||||||
VITE_GITHUB_PWA_TEMPLATE_REPO = 'LACONIC_HOSTED_CONFIG_github_pwa_templaterepo'
|
VITE_GITHUB_PWA_TEMPLATE_REPO = 'LACONIC_HOSTED_CONFIG_github_pwa_templaterepo'
|
||||||
VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO = 'LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo'
|
VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO = 'LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo'
|
||||||
VITE_GITHUB_NEXT_APP_TEMPLATE_REPO = 'LACONIC_HOSTED_CONFIG_github_next_app_templaterepo'
|
VITE_GITHUB_NEXT_APP_TEMPLATE_REPO = 'LACONIC_HOSTED_CONFIG_github_next_app_templaterepo'
|
||||||
VITE_WALLET_CONNECT_ID = 'LACONIC_HOSTED_CONFIG_wallet_connect_id'
|
|
||||||
VITE_LACONICD_CHAIN_ID = 'LACONIC_HOSTED_CONFIG_laconicd_chain_id'
|
|
||||||
VITE_WALLET_IFRAME_URL = 'LACONIC_HOSTED_CONFIG_wallet_iframe_url'
|
VITE_WALLET_IFRAME_URL = 'LACONIC_HOSTED_CONFIG_wallet_iframe_url'
|
||||||
VITE_LIT_RELAY_API_KEY = 'LACONIC_HOSTED_CONFIG_lit_relay_api_key'
|
VITE_LIT_RELAY_API_KEY = 'LACONIC_HOSTED_CONFIG_lit_relay_api_key'
|
||||||
VITE_BUGSNAG_API_KEY = 'LACONIC_HOSTED_CONFIG_bugsnag_api_key'
|
VITE_BUGSNAG_API_KEY = 'LACONIC_HOSTED_CONFIG_bugsnag_api_key'
|
||||||
|
@ -14,5 +14,6 @@
|
|||||||
"prepare": "husky install",
|
"prepare": "husky install",
|
||||||
"build": "lerna run build --stream",
|
"build": "lerna run build --stream",
|
||||||
"lint": "lerna run lint --stream"
|
"lint": "lerna run lint --stream"
|
||||||
}
|
},
|
||||||
|
"packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import {
|
|||||||
FindOneOptions,
|
FindOneOptions,
|
||||||
FindOptionsWhere,
|
FindOptionsWhere,
|
||||||
IsNull,
|
IsNull,
|
||||||
Not
|
Not,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
@ -16,14 +16,15 @@ import { lowercase, numbers } from 'nanoid-dictionary';
|
|||||||
import { DatabaseConfig } from './config';
|
import { DatabaseConfig } from './config';
|
||||||
import { User } from './entity/User';
|
import { User } from './entity/User';
|
||||||
import { Organization } from './entity/Organization';
|
import { Organization } from './entity/Organization';
|
||||||
import { Project } from './entity/Project';
|
import { AuctionStatus, Project } from './entity/Project';
|
||||||
import { Deployment } from './entity/Deployment';
|
import { Deployment, DeploymentStatus } from './entity/Deployment';
|
||||||
import { ProjectMember } from './entity/ProjectMember';
|
import { ProjectMember } from './entity/ProjectMember';
|
||||||
import { EnvironmentVariable } from './entity/EnvironmentVariable';
|
import { EnvironmentVariable } from './entity/EnvironmentVariable';
|
||||||
import { Domain } from './entity/Domain';
|
import { Domain } from './entity/Domain';
|
||||||
import { getEntities, loadAndSaveData } from './utils';
|
import { getEntities, loadAndSaveData } from './utils';
|
||||||
import { UserOrganization } from './entity/UserOrganization';
|
import { UserOrganization } from './entity/UserOrganization';
|
||||||
import { Deployer } from './entity/Deployer';
|
import { Deployer } from './entity/Deployer';
|
||||||
|
import { DNSRecordAttributes } from './types';
|
||||||
|
|
||||||
const ORGANIZATION_DATA_PATH = '../test/fixtures/organizations.json';
|
const ORGANIZATION_DATA_PATH = '../test/fixtures/organizations.json';
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ export class Database {
|
|||||||
database: dbPath,
|
database: dbPath,
|
||||||
entities: [path.join(__dirname, '/entity/*')],
|
entities: [path.join(__dirname, '/entity/*')],
|
||||||
synchronize: true,
|
synchronize: true,
|
||||||
logging: false
|
logging: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,21 +54,24 @@ export class Database {
|
|||||||
|
|
||||||
// Load an organization if none exist
|
// Load an organization if none exist
|
||||||
if (!organizations.length) {
|
if (!organizations.length) {
|
||||||
const orgEntities = await getEntities(path.resolve(__dirname, ORGANIZATION_DATA_PATH));
|
const orgEntities = await getEntities(
|
||||||
organizations = await loadAndSaveData(Organization, this.dataSource, [orgEntities[0]]);
|
path.resolve(__dirname, ORGANIZATION_DATA_PATH),
|
||||||
|
);
|
||||||
|
organizations = await loadAndSaveData(Organization, this.dataSource, [
|
||||||
|
orgEntities[0],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hotfix for updating old DB data
|
// Hotfix for updating old DB data
|
||||||
if (organizations[0].slug === 'snowball-tools-1') {
|
if (organizations[0].slug === 'snowball-tools-1') {
|
||||||
const [orgEntity] = await getEntities(path.resolve(__dirname, ORGANIZATION_DATA_PATH));
|
const [orgEntity] = await getEntities(
|
||||||
|
path.resolve(__dirname, ORGANIZATION_DATA_PATH),
|
||||||
|
);
|
||||||
|
|
||||||
await this.updateOrganization(
|
await this.updateOrganization(organizations[0].id, {
|
||||||
organizations[0].id,
|
|
||||||
{
|
|
||||||
slug: orgEntity.slug as string,
|
slug: orgEntity.slug as string,
|
||||||
name: orgEntity.name as string
|
name: orgEntity.name as string,
|
||||||
}
|
});
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +98,7 @@ export class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getOrganizations(
|
async getOrganizations(
|
||||||
options: FindManyOptions<Organization>
|
options: FindManyOptions<Organization>,
|
||||||
): Promise<Organization[]> {
|
): Promise<Organization[]> {
|
||||||
const organizationRepository = this.dataSource.getRepository(Organization);
|
const organizationRepository = this.dataSource.getRepository(Organization);
|
||||||
const organizations = await organizationRepository.find(options);
|
const organizations = await organizationRepository.find(options);
|
||||||
@ -103,7 +107,7 @@ export class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getOrganization(
|
async getOrganization(
|
||||||
options: FindOneOptions<Organization>
|
options: FindOneOptions<Organization>,
|
||||||
): Promise<Organization | null> {
|
): Promise<Organization | null> {
|
||||||
const organizationRepository = this.dataSource.getRepository(Organization);
|
const organizationRepository = this.dataSource.getRepository(Organization);
|
||||||
const organization = await organizationRepository.findOne(options);
|
const organization = await organizationRepository.findOne(options);
|
||||||
@ -118,25 +122,34 @@ export class Database {
|
|||||||
where: {
|
where: {
|
||||||
userOrganizations: {
|
userOrganizations: {
|
||||||
member: {
|
member: {
|
||||||
id: userId
|
id: userId,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return userOrgs;
|
return userOrgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
async addUserOrganization(data: DeepPartial<UserOrganization>): Promise<UserOrganization> {
|
async addUserOrganization(
|
||||||
const userOrganizationRepository = this.dataSource.getRepository(UserOrganization);
|
data: DeepPartial<UserOrganization>,
|
||||||
|
): Promise<UserOrganization> {
|
||||||
|
const userOrganizationRepository =
|
||||||
|
this.dataSource.getRepository(UserOrganization);
|
||||||
const newUserOrganization = await userOrganizationRepository.save(data);
|
const newUserOrganization = await userOrganizationRepository.save(data);
|
||||||
|
|
||||||
return newUserOrganization;
|
return newUserOrganization;
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateOrganization(organizationId: string, data: DeepPartial<Organization>): Promise<boolean> {
|
async updateOrganization(
|
||||||
|
organizationId: string,
|
||||||
|
data: DeepPartial<Organization>,
|
||||||
|
): Promise<boolean> {
|
||||||
const organizationRepository = this.dataSource.getRepository(Organization);
|
const organizationRepository = this.dataSource.getRepository(Organization);
|
||||||
const updateResult = await organizationRepository.update({ id: organizationId }, data);
|
const updateResult = await organizationRepository.update(
|
||||||
|
{ id: organizationId },
|
||||||
|
data,
|
||||||
|
);
|
||||||
assert(updateResult.affected);
|
assert(updateResult.affected);
|
||||||
|
|
||||||
return updateResult.affected > 0;
|
return updateResult.affected > 0;
|
||||||
@ -157,16 +170,15 @@ export class Database {
|
|||||||
.leftJoinAndSelect(
|
.leftJoinAndSelect(
|
||||||
'project.deployments',
|
'project.deployments',
|
||||||
'deployments',
|
'deployments',
|
||||||
'deployments.isCurrent = true'
|
'deployments.isCurrent = true AND deployments.isCanonical = true',
|
||||||
)
|
)
|
||||||
.leftJoinAndSelect('deployments.createdBy', 'user')
|
.leftJoinAndSelect('deployments.createdBy', 'user')
|
||||||
.leftJoinAndSelect('deployments.domain', 'domain')
|
|
||||||
.leftJoinAndSelect('deployments.deployer', 'deployer')
|
.leftJoinAndSelect('deployments.deployer', 'deployer')
|
||||||
.leftJoinAndSelect('project.owner', 'owner')
|
.leftJoinAndSelect('project.owner', 'owner')
|
||||||
.leftJoinAndSelect('project.deployers', 'deployers')
|
.leftJoinAndSelect('project.deployers', 'deployers')
|
||||||
.leftJoinAndSelect('project.organization', 'organization')
|
.leftJoinAndSelect('project.organization', 'organization')
|
||||||
.where('project.id = :projectId', {
|
.where('project.id = :projectId', {
|
||||||
projectId
|
projectId,
|
||||||
})
|
})
|
||||||
.getOne();
|
.getOne();
|
||||||
|
|
||||||
@ -174,26 +186,28 @@ export class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async allProjectsWithoutDeployments(): Promise<Project[]> {
|
async allProjectsWithoutDeployments(): Promise<Project[]> {
|
||||||
|
// Fetch all projects with auction not completed and wihout any deployments
|
||||||
const allProjects = await this.getProjects({
|
const allProjects = await this.getProjects({
|
||||||
where: {
|
where: {
|
||||||
auctionId: Not(IsNull()),
|
auctionId: Not(IsNull()),
|
||||||
|
auctionStatus: Not(AuctionStatus.Completed),
|
||||||
},
|
},
|
||||||
relations: ['deployments'],
|
relations: ['deployments'],
|
||||||
withDeleted: true,
|
withDeleted: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const projects = allProjects.filter(project => {
|
const activeProjectsWithoutDeployments = allProjects.filter((project) => {
|
||||||
if (project.deletedAt !== null) return false;
|
if (project.deletedAt !== null) return false;
|
||||||
|
|
||||||
return project.deployments.length === 0;
|
return project.deployments.length === 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
return projects;
|
return activeProjectsWithoutDeployments;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProjectsInOrganization(
|
async getProjectsInOrganization(
|
||||||
userId: string,
|
userId: string,
|
||||||
organizationSlug: string
|
organizationSlug: string,
|
||||||
): Promise<Project[]> {
|
): Promise<Project[]> {
|
||||||
const projectRepository = this.dataSource.getRepository(Project);
|
const projectRepository = this.dataSource.getRepository(Project);
|
||||||
|
|
||||||
@ -202,17 +216,16 @@ export class Database {
|
|||||||
.leftJoinAndSelect(
|
.leftJoinAndSelect(
|
||||||
'project.deployments',
|
'project.deployments',
|
||||||
'deployments',
|
'deployments',
|
||||||
'deployments.isCurrent = true'
|
'deployments.isCurrent = true AND deployments.isCanonical = true',
|
||||||
)
|
)
|
||||||
.leftJoinAndSelect('deployments.domain', 'domain')
|
|
||||||
.leftJoin('project.projectMembers', 'projectMembers')
|
.leftJoin('project.projectMembers', 'projectMembers')
|
||||||
.leftJoin('project.organization', 'organization')
|
.leftJoin('project.organization', 'organization')
|
||||||
.where(
|
.where(
|
||||||
'(project.ownerId = :userId OR projectMembers.userId = :userId) AND organization.slug = :organizationSlug',
|
'(project.ownerId = :userId OR projectMembers.userId = :userId) AND organization.slug = :organizationSlug',
|
||||||
{
|
{
|
||||||
userId,
|
userId,
|
||||||
organizationSlug
|
organizationSlug,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
@ -223,7 +236,7 @@ export class Database {
|
|||||||
* Get deployments with specified filter
|
* Get deployments with specified filter
|
||||||
*/
|
*/
|
||||||
async getDeployments(
|
async getDeployments(
|
||||||
options: FindManyOptions<Deployment>
|
options: FindManyOptions<Deployment>,
|
||||||
): Promise<Deployment[]> {
|
): Promise<Deployment[]> {
|
||||||
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
||||||
const deployments = await deploymentRepository.find(options);
|
const deployments = await deploymentRepository.find(options);
|
||||||
@ -235,23 +248,43 @@ export class Database {
|
|||||||
return this.getDeployments({
|
return this.getDeployments({
|
||||||
relations: {
|
relations: {
|
||||||
project: true,
|
project: true,
|
||||||
domain: true,
|
|
||||||
createdBy: true,
|
createdBy: true,
|
||||||
deployer: true,
|
deployer: true,
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
project: {
|
project: {
|
||||||
id: projectId
|
id: projectId,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
createdAt: 'DESC'
|
createdAt: 'DESC',
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getNonCanonicalDeploymentsByProjectId(
|
||||||
|
projectId: string,
|
||||||
|
): Promise<Deployment[]> {
|
||||||
|
return this.getDeployments({
|
||||||
|
relations: {
|
||||||
|
project: true,
|
||||||
|
createdBy: true,
|
||||||
|
deployer: true,
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
project: {
|
||||||
|
id: projectId,
|
||||||
|
},
|
||||||
|
isCanonical: false,
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
createdAt: 'DESC',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDeployment(
|
async getDeployment(
|
||||||
options: FindOneOptions<Deployment>
|
options: FindOneOptions<Deployment>,
|
||||||
): Promise<Deployment | null> {
|
): Promise<Deployment | null> {
|
||||||
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
||||||
const deployment = await deploymentRepository.findOne(options);
|
const deployment = await deploymentRepository.findOne(options);
|
||||||
@ -273,7 +306,7 @@ export class Database {
|
|||||||
|
|
||||||
const updatedData = {
|
const updatedData = {
|
||||||
...data,
|
...data,
|
||||||
id
|
id,
|
||||||
};
|
};
|
||||||
const deployment = await deploymentRepository.save(updatedData);
|
const deployment = await deploymentRepository.save(updatedData);
|
||||||
|
|
||||||
@ -281,7 +314,7 @@ export class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getProjectMembersByProjectId(
|
async getProjectMembersByProjectId(
|
||||||
projectId: string
|
projectId: string,
|
||||||
): Promise<ProjectMember[]> {
|
): Promise<ProjectMember[]> {
|
||||||
const projectMemberRepository =
|
const projectMemberRepository =
|
||||||
this.dataSource.getRepository(ProjectMember);
|
this.dataSource.getRepository(ProjectMember);
|
||||||
@ -289,13 +322,13 @@ export class Database {
|
|||||||
const projectMembers = await projectMemberRepository.find({
|
const projectMembers = await projectMemberRepository.find({
|
||||||
relations: {
|
relations: {
|
||||||
project: true,
|
project: true,
|
||||||
member: true
|
member: true,
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
project: {
|
project: {
|
||||||
id: projectId
|
id: projectId,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return projectMembers;
|
return projectMembers;
|
||||||
@ -303,7 +336,7 @@ export class Database {
|
|||||||
|
|
||||||
async getEnvironmentVariablesByProjectId(
|
async getEnvironmentVariablesByProjectId(
|
||||||
projectId: string,
|
projectId: string,
|
||||||
filter?: FindOptionsWhere<EnvironmentVariable>
|
filter?: FindOptionsWhere<EnvironmentVariable>,
|
||||||
): Promise<EnvironmentVariable[]> {
|
): Promise<EnvironmentVariable[]> {
|
||||||
const environmentVariableRepository =
|
const environmentVariableRepository =
|
||||||
this.dataSource.getRepository(EnvironmentVariable);
|
this.dataSource.getRepository(EnvironmentVariable);
|
||||||
@ -311,10 +344,10 @@ export class Database {
|
|||||||
const environmentVariables = await environmentVariableRepository.find({
|
const environmentVariables = await environmentVariableRepository.find({
|
||||||
where: {
|
where: {
|
||||||
project: {
|
project: {
|
||||||
id: projectId
|
id: projectId,
|
||||||
|
},
|
||||||
|
...filter,
|
||||||
},
|
},
|
||||||
...filter
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return environmentVariables;
|
return environmentVariables;
|
||||||
@ -325,7 +358,7 @@ export class Database {
|
|||||||
this.dataSource.getRepository(ProjectMember);
|
this.dataSource.getRepository(ProjectMember);
|
||||||
|
|
||||||
const deleteResult = await projectMemberRepository.delete({
|
const deleteResult = await projectMemberRepository.delete({
|
||||||
id: projectMemberId
|
id: projectMemberId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (deleteResult.affected) {
|
if (deleteResult.affected) {
|
||||||
@ -337,20 +370,20 @@ export class Database {
|
|||||||
|
|
||||||
async updateProjectMemberById(
|
async updateProjectMemberById(
|
||||||
projectMemberId: string,
|
projectMemberId: string,
|
||||||
data: DeepPartial<ProjectMember>
|
data: DeepPartial<ProjectMember>,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const projectMemberRepository =
|
const projectMemberRepository =
|
||||||
this.dataSource.getRepository(ProjectMember);
|
this.dataSource.getRepository(ProjectMember);
|
||||||
const updateResult = await projectMemberRepository.update(
|
const updateResult = await projectMemberRepository.update(
|
||||||
{ id: projectMemberId },
|
{ id: projectMemberId },
|
||||||
data
|
data,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Boolean(updateResult.affected);
|
return Boolean(updateResult.affected);
|
||||||
}
|
}
|
||||||
|
|
||||||
async addProjectMember(
|
async addProjectMember(
|
||||||
data: DeepPartial<ProjectMember>
|
data: DeepPartial<ProjectMember>,
|
||||||
): Promise<ProjectMember> {
|
): Promise<ProjectMember> {
|
||||||
const projectMemberRepository =
|
const projectMemberRepository =
|
||||||
this.dataSource.getRepository(ProjectMember);
|
this.dataSource.getRepository(ProjectMember);
|
||||||
@ -360,7 +393,7 @@ export class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async addEnvironmentVariables(
|
async addEnvironmentVariables(
|
||||||
data: DeepPartial<EnvironmentVariable>[]
|
data: DeepPartial<EnvironmentVariable>[],
|
||||||
): Promise<EnvironmentVariable[]> {
|
): Promise<EnvironmentVariable[]> {
|
||||||
const environmentVariableRepository =
|
const environmentVariableRepository =
|
||||||
this.dataSource.getRepository(EnvironmentVariable);
|
this.dataSource.getRepository(EnvironmentVariable);
|
||||||
@ -372,25 +405,25 @@ export class Database {
|
|||||||
|
|
||||||
async updateEnvironmentVariable(
|
async updateEnvironmentVariable(
|
||||||
environmentVariableId: string,
|
environmentVariableId: string,
|
||||||
data: DeepPartial<EnvironmentVariable>
|
data: DeepPartial<EnvironmentVariable>,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const environmentVariableRepository =
|
const environmentVariableRepository =
|
||||||
this.dataSource.getRepository(EnvironmentVariable);
|
this.dataSource.getRepository(EnvironmentVariable);
|
||||||
const updateResult = await environmentVariableRepository.update(
|
const updateResult = await environmentVariableRepository.update(
|
||||||
{ id: environmentVariableId },
|
{ id: environmentVariableId },
|
||||||
data
|
data,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Boolean(updateResult.affected);
|
return Boolean(updateResult.affected);
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteEnvironmentVariable(
|
async deleteEnvironmentVariable(
|
||||||
environmentVariableId: string
|
environmentVariableId: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const environmentVariableRepository =
|
const environmentVariableRepository =
|
||||||
this.dataSource.getRepository(EnvironmentVariable);
|
this.dataSource.getRepository(EnvironmentVariable);
|
||||||
const deleteResult = await environmentVariableRepository.delete({
|
const deleteResult = await environmentVariableRepository.delete({
|
||||||
id: environmentVariableId
|
id: environmentVariableId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (deleteResult.affected) {
|
if (deleteResult.affected) {
|
||||||
@ -407,13 +440,13 @@ export class Database {
|
|||||||
const projectMemberWithProject = await projectMemberRepository.find({
|
const projectMemberWithProject = await projectMemberRepository.find({
|
||||||
relations: {
|
relations: {
|
||||||
project: {
|
project: {
|
||||||
owner: true
|
owner: true,
|
||||||
},
|
},
|
||||||
member: true
|
member: true,
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
id: projectMemberId
|
id: projectMemberId,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (projectMemberWithProject.length === 0) {
|
if (projectMemberWithProject.length === 0) {
|
||||||
@ -425,7 +458,7 @@ export class Database {
|
|||||||
|
|
||||||
async getProjectsBySearchText(
|
async getProjectsBySearchText(
|
||||||
userId: string,
|
userId: string,
|
||||||
searchText: string
|
searchText: string,
|
||||||
): Promise<Project[]> {
|
): Promise<Project[]> {
|
||||||
const projectRepository = this.dataSource.getRepository(Project);
|
const projectRepository = this.dataSource.getRepository(Project);
|
||||||
|
|
||||||
@ -437,8 +470,8 @@ export class Database {
|
|||||||
'(project.owner = :userId OR projectMembers.member.id = :userId) AND project.name LIKE :searchText',
|
'(project.owner = :userId OR projectMembers.member.id = :userId) AND project.name LIKE :searchText',
|
||||||
{
|
{
|
||||||
userId,
|
userId,
|
||||||
searchText: `%${searchText}%`
|
searchText: `%${searchText}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
@ -447,14 +480,14 @@ export class Database {
|
|||||||
|
|
||||||
async updateDeploymentById(
|
async updateDeploymentById(
|
||||||
deploymentId: string,
|
deploymentId: string,
|
||||||
data: DeepPartial<Deployment>
|
data: DeepPartial<Deployment>,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
return this.updateDeployment({ id: deploymentId }, data);
|
return this.updateDeployment({ id: deploymentId }, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateDeployment(
|
async updateDeployment(
|
||||||
criteria: FindOptionsWhere<Deployment>,
|
criteria: FindOptionsWhere<Deployment>,
|
||||||
data: DeepPartial<Deployment>
|
data: DeepPartial<Deployment>,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
||||||
const updateResult = await deploymentRepository.update(criteria, data);
|
const updateResult = await deploymentRepository.update(criteria, data);
|
||||||
@ -464,7 +497,7 @@ export class Database {
|
|||||||
|
|
||||||
async updateDeploymentsByProjectIds(
|
async updateDeploymentsByProjectIds(
|
||||||
projectIds: string[],
|
projectIds: string[],
|
||||||
data: DeepPartial<Deployment>
|
data: DeepPartial<Deployment>,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
||||||
|
|
||||||
@ -482,8 +515,8 @@ export class Database {
|
|||||||
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
||||||
const deployment = await deploymentRepository.findOneOrFail({
|
const deployment = await deploymentRepository.findOneOrFail({
|
||||||
where: {
|
where: {
|
||||||
id: deploymentId
|
id: deploymentId,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteResult = await deploymentRepository.softRemove(deployment);
|
const deleteResult = await deploymentRepository.softRemove(deployment);
|
||||||
@ -491,7 +524,11 @@ export class Database {
|
|||||||
return Boolean(deleteResult);
|
return Boolean(deleteResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
async addProject(user: User, organizationId: string, data: DeepPartial<Project>): Promise<Project> {
|
async addProject(
|
||||||
|
user: User,
|
||||||
|
organizationId: string,
|
||||||
|
data: DeepPartial<Project>,
|
||||||
|
): Promise<Project> {
|
||||||
const projectRepository = this.dataSource.getRepository(Project);
|
const projectRepository = this.dataSource.getRepository(Project);
|
||||||
|
|
||||||
// TODO: Check if organization exists
|
// TODO: Check if organization exists
|
||||||
@ -504,7 +541,7 @@ export class Database {
|
|||||||
newProject.owner = user;
|
newProject.owner = user;
|
||||||
|
|
||||||
newProject.organization = Object.assign(new Organization(), {
|
newProject.organization = Object.assign(new Organization(), {
|
||||||
id: organizationId
|
id: organizationId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return projectRepository.save(newProject);
|
return projectRepository.save(newProject);
|
||||||
@ -518,12 +555,12 @@ export class Database {
|
|||||||
|
|
||||||
async updateProjectById(
|
async updateProjectById(
|
||||||
projectId: string,
|
projectId: string,
|
||||||
data: DeepPartial<Project>
|
data: DeepPartial<Project>,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const projectRepository = this.dataSource.getRepository(Project);
|
const projectRepository = this.dataSource.getRepository(Project);
|
||||||
const updateResult = await projectRepository.update(
|
const updateResult = await projectRepository.update(
|
||||||
{ id: projectId },
|
{ id: projectId },
|
||||||
data
|
data,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Boolean(updateResult.affected);
|
return Boolean(updateResult.affected);
|
||||||
@ -533,11 +570,11 @@ export class Database {
|
|||||||
const projectRepository = this.dataSource.getRepository(Project);
|
const projectRepository = this.dataSource.getRepository(Project);
|
||||||
const project = await projectRepository.findOneOrFail({
|
const project = await projectRepository.findOneOrFail({
|
||||||
where: {
|
where: {
|
||||||
id: projectId
|
id: projectId,
|
||||||
},
|
},
|
||||||
relations: {
|
relations: {
|
||||||
projectMembers: true
|
projectMembers: true,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteResult = await projectRepository.softRemove(project);
|
const deleteResult = await projectRepository.softRemove(project);
|
||||||
@ -573,7 +610,7 @@ export class Database {
|
|||||||
|
|
||||||
async updateDomainById(
|
async updateDomainById(
|
||||||
domainId: string,
|
domainId: string,
|
||||||
data: DeepPartial<Domain>
|
data: DeepPartial<Domain>,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const domainRepository = this.dataSource.getRepository(Domain);
|
const domainRepository = this.dataSource.getRepository(Domain);
|
||||||
const updateResult = await domainRepository.update({ id: domainId }, data);
|
const updateResult = await domainRepository.update({ id: domainId }, data);
|
||||||
@ -583,25 +620,66 @@ export class Database {
|
|||||||
|
|
||||||
async getDomainsByProjectId(
|
async getDomainsByProjectId(
|
||||||
projectId: string,
|
projectId: string,
|
||||||
filter?: FindOptionsWhere<Domain>
|
filter?: FindOptionsWhere<Domain>,
|
||||||
): Promise<Domain[]> {
|
): Promise<Domain[]> {
|
||||||
const domainRepository = this.dataSource.getRepository(Domain);
|
const domainRepository = this.dataSource.getRepository(Domain);
|
||||||
|
|
||||||
const domains = await domainRepository.find({
|
const domains = await domainRepository.find({
|
||||||
relations: {
|
relations: {
|
||||||
redirectTo: true
|
redirectTo: true,
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
project: {
|
project: {
|
||||||
id: projectId
|
id: projectId,
|
||||||
|
},
|
||||||
|
...filter,
|
||||||
},
|
},
|
||||||
...filter
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return domains;
|
return domains;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getOldestDomainByProjectId(projectId: string): Promise<Domain | null> {
|
||||||
|
const domainRepository = this.dataSource.getRepository(Domain);
|
||||||
|
|
||||||
|
const domain = await domainRepository.findOne({
|
||||||
|
where: {
|
||||||
|
project: {
|
||||||
|
id: projectId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
createdAt: 'ASC',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getLatestDNSRecordByProjectId(
|
||||||
|
projectId: string,
|
||||||
|
): Promise<DNSRecordAttributes | null> {
|
||||||
|
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
||||||
|
|
||||||
|
const deployment = await deploymentRepository.findOne({
|
||||||
|
where: {
|
||||||
|
project: {
|
||||||
|
id: projectId,
|
||||||
|
},
|
||||||
|
status: DeploymentStatus.Ready,
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
createdAt: 'DESC',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (deployment === null) {
|
||||||
|
throw new Error(`No deployment found for project ${projectId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return deployment.dnsRecordData;
|
||||||
|
}
|
||||||
|
|
||||||
async addDeployer(data: DeepPartial<Deployer>): Promise<Deployer> {
|
async addDeployer(data: DeepPartial<Deployer>): Promise<Deployer> {
|
||||||
const deployerRepository = this.dataSource.getRepository(Deployer);
|
const deployerRepository = this.dataSource.getRepository(Deployer);
|
||||||
const newDomain = await deployerRepository.save(data);
|
const newDomain = await deployerRepository.save(data);
|
||||||
@ -617,7 +695,9 @@ export class Database {
|
|||||||
|
|
||||||
async getDeployerByLRN(deployerLrn: string): Promise<Deployer | null> {
|
async getDeployerByLRN(deployerLrn: string): Promise<Deployer | null> {
|
||||||
const deployerRepository = this.dataSource.getRepository(Deployer);
|
const deployerRepository = this.dataSource.getRepository(Deployer);
|
||||||
const deployer = await deployerRepository.findOne({ where: { deployerLrn } });
|
const deployer = await deployerRepository.findOne({
|
||||||
|
where: { deployerLrn },
|
||||||
|
});
|
||||||
|
|
||||||
return deployer;
|
return deployer;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import { Project } from './Project';
|
|||||||
import { Domain } from './Domain';
|
import { Domain } from './Domain';
|
||||||
import { User } from './User';
|
import { User } from './User';
|
||||||
import { Deployer } from './Deployer';
|
import { Deployer } from './Deployer';
|
||||||
import { AppDeploymentRecordAttributes, AppDeploymentRemovalRecordAttributes } from '../types';
|
import { AppDeploymentRecordAttributes, AppDeploymentRemovalRecordAttributes, DNSRecordAttributes } from '../types';
|
||||||
|
|
||||||
export enum Environment {
|
export enum Environment {
|
||||||
Production = 'Production',
|
Production = 'Production',
|
||||||
@ -39,6 +39,7 @@ export interface ApplicationDeploymentRequest {
|
|||||||
config: string;
|
config: string;
|
||||||
meta: string;
|
meta: string;
|
||||||
payment?: string;
|
payment?: string;
|
||||||
|
dns?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApplicationDeploymentRemovalRequest {
|
export interface ApplicationDeploymentRemovalRequest {
|
||||||
@ -77,13 +78,6 @@ export class Deployment {
|
|||||||
@JoinColumn({ name: 'projectId' })
|
@JoinColumn({ name: 'projectId' })
|
||||||
project!: Project;
|
project!: Project;
|
||||||
|
|
||||||
@Column({ nullable: true })
|
|
||||||
domainId!: string | null;
|
|
||||||
|
|
||||||
@OneToOne(() => Domain)
|
|
||||||
@JoinColumn({ name: 'domainId' })
|
|
||||||
domain!: Domain | null;
|
|
||||||
|
|
||||||
@Column('varchar')
|
@Column('varchar')
|
||||||
branch!: string;
|
branch!: string;
|
||||||
|
|
||||||
@ -126,6 +120,9 @@ export class Deployment {
|
|||||||
@Column('simple-json', { nullable: true })
|
@Column('simple-json', { nullable: true })
|
||||||
applicationDeploymentRemovalRecordData!: AppDeploymentRemovalRecordAttributes | null;
|
applicationDeploymentRemovalRecordData!: AppDeploymentRemovalRecordAttributes | null;
|
||||||
|
|
||||||
|
@Column('simple-json', { nullable: true })
|
||||||
|
dnsRecordData!: DNSRecordAttributes | null;
|
||||||
|
|
||||||
@ManyToOne(() => Deployer)
|
@ManyToOne(() => Deployer)
|
||||||
@JoinColumn({ name: 'deployerLrn' })
|
@JoinColumn({ name: 'deployerLrn' })
|
||||||
deployer!: Deployer;
|
deployer!: Deployer;
|
||||||
@ -138,6 +135,9 @@ export class Deployment {
|
|||||||
@Column('boolean', { default: false })
|
@Column('boolean', { default: false })
|
||||||
isCurrent!: boolean;
|
isCurrent!: boolean;
|
||||||
|
|
||||||
|
@Column('boolean', { default: false })
|
||||||
|
isCanonical!: boolean;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
enum: DeploymentStatus
|
enum: DeploymentStatus
|
||||||
})
|
})
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
OneToMany,
|
OneToMany,
|
||||||
DeleteDateColumn,
|
DeleteDateColumn,
|
||||||
JoinTable,
|
JoinTable,
|
||||||
ManyToMany
|
ManyToMany,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
import { User } from './User';
|
import { User } from './User';
|
||||||
@ -18,6 +18,12 @@ import { ProjectMember } from './ProjectMember';
|
|||||||
import { Deployment } from './Deployment';
|
import { Deployment } from './Deployment';
|
||||||
import { Deployer } from './Deployer';
|
import { Deployer } from './Deployer';
|
||||||
|
|
||||||
|
export enum AuctionStatus {
|
||||||
|
Commit = 'commit',
|
||||||
|
Reveal = 'reveal',
|
||||||
|
Completed = 'completed',
|
||||||
|
}
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Project {
|
export class Project {
|
||||||
@PrimaryGeneratedColumn('uuid')
|
@PrimaryGeneratedColumn('uuid')
|
||||||
@ -49,16 +55,23 @@ export class Project {
|
|||||||
@Column('text', { default: '' })
|
@Column('text', { default: '' })
|
||||||
description!: string;
|
description!: string;
|
||||||
|
|
||||||
@Column('varchar', { nullable: true })
|
|
||||||
auctionId!: string | null;
|
|
||||||
|
|
||||||
// Tx hash for sending coins from snowball to deployer
|
// Tx hash for sending coins from snowball to deployer
|
||||||
@Column('varchar', { nullable: true })
|
@Column('varchar', { nullable: true })
|
||||||
txHash!: string | null;
|
txHash!: string | null;
|
||||||
|
|
||||||
@ManyToMany(() => Deployer, (deployer) => (deployer.projects))
|
@ManyToMany(() => Deployer, (deployer) => deployer.projects)
|
||||||
@JoinTable()
|
@JoinTable()
|
||||||
deployers!: Deployer[]
|
deployers!: Deployer[];
|
||||||
|
|
||||||
|
@Column('varchar', { nullable: true })
|
||||||
|
auctionId!: string | null;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
enum: AuctionStatus,
|
||||||
|
// TODO: Remove later after all projects auction status have been set
|
||||||
|
default: AuctionStatus.Completed,
|
||||||
|
})
|
||||||
|
auctionStatus!: AuctionStatus;
|
||||||
|
|
||||||
@Column('boolean', { default: false, nullable: true })
|
@Column('boolean', { default: false, nullable: true })
|
||||||
fundsReleased!: boolean;
|
fundsReleased!: boolean;
|
||||||
|
@ -6,7 +6,13 @@ import { inc as semverInc } from 'semver';
|
|||||||
import { DeepPartial } from 'typeorm';
|
import { DeepPartial } from 'typeorm';
|
||||||
import * as openpgp from 'openpgp';
|
import * as openpgp from 'openpgp';
|
||||||
|
|
||||||
import { Account, DEFAULT_GAS_ESTIMATION_MULTIPLIER, Registry as LaconicRegistry, getGasPrice, parseGasAndFees } from '@cerc-io/registry-sdk';
|
import {
|
||||||
|
Account,
|
||||||
|
DEFAULT_GAS_ESTIMATION_MULTIPLIER,
|
||||||
|
Registry as LaconicRegistry,
|
||||||
|
getGasPrice,
|
||||||
|
parseGasAndFees,
|
||||||
|
} from '@cerc-io/registry-sdk';
|
||||||
import { DeliverTxResponse, IndexedTx } from '@cosmjs/stargate';
|
import { DeliverTxResponse, IndexedTx } from '@cosmjs/stargate';
|
||||||
|
|
||||||
import { RegistryConfig } from './config';
|
import { RegistryConfig } from './config';
|
||||||
@ -14,20 +20,33 @@ import {
|
|||||||
ApplicationRecord,
|
ApplicationRecord,
|
||||||
Deployment,
|
Deployment,
|
||||||
ApplicationDeploymentRequest,
|
ApplicationDeploymentRequest,
|
||||||
ApplicationDeploymentRemovalRequest
|
ApplicationDeploymentRemovalRequest,
|
||||||
} from './entity/Deployment';
|
} from './entity/Deployment';
|
||||||
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams, DeployerRecord } from './types';
|
import {
|
||||||
import { getConfig, getRepoDetails, registryTransactionWithRetry, sleep } from './utils';
|
AppDeploymentRecord,
|
||||||
|
AppDeploymentRemovalRecord,
|
||||||
|
AuctionParams,
|
||||||
|
DeployerRecord,
|
||||||
|
RegistryRecord,
|
||||||
|
} from './types';
|
||||||
|
import {
|
||||||
|
getConfig,
|
||||||
|
getRepoDetails,
|
||||||
|
registryTransactionWithRetry,
|
||||||
|
sleep,
|
||||||
|
} from './utils';
|
||||||
|
import { MsgCreateAuctionResponse } from '@cerc-io/registry-sdk/dist/proto/cerc/auction/v1/tx';
|
||||||
|
|
||||||
const log = debug('snowball:registry');
|
const log = debug('snowball:registry');
|
||||||
|
|
||||||
const APP_RECORD_TYPE = 'ApplicationRecord';
|
const APP_RECORD_TYPE = 'ApplicationRecord';
|
||||||
const APP_DEPLOYMENT_AUCTION_RECORD_TYPE = 'ApplicationDeploymentAuction';
|
const APP_DEPLOYMENT_AUCTION_RECORD_TYPE = 'ApplicationDeploymentAuction';
|
||||||
const APP_DEPLOYMENT_REQUEST_TYPE = 'ApplicationDeploymentRequest';
|
const APP_DEPLOYMENT_REQUEST_TYPE = 'ApplicationDeploymentRequest';
|
||||||
const APP_DEPLOYMENT_REMOVAL_REQUEST_TYPE = 'ApplicationDeploymentRemovalRequest';
|
const APP_DEPLOYMENT_REMOVAL_REQUEST_TYPE =
|
||||||
|
'ApplicationDeploymentRemovalRequest';
|
||||||
const APP_DEPLOYMENT_RECORD_TYPE = 'ApplicationDeploymentRecord';
|
const APP_DEPLOYMENT_RECORD_TYPE = 'ApplicationDeploymentRecord';
|
||||||
const APP_DEPLOYMENT_REMOVAL_RECORD_TYPE = 'ApplicationDeploymentRemovalRecord';
|
const APP_DEPLOYMENT_REMOVAL_RECORD_TYPE = 'ApplicationDeploymentRemovalRecord';
|
||||||
const WEBAPP_DEPLOYER_RECORD_TYPE = 'WebappDeployer'
|
const WEBAPP_DEPLOYER_RECORD_TYPE = 'WebappDeployer';
|
||||||
const SLEEP_DURATION = 1000;
|
const SLEEP_DURATION = 1000;
|
||||||
|
|
||||||
// TODO: Move registry code to registry-sdk/watcher-ts
|
// TODO: Move registry code to registry-sdk/watcher-ts
|
||||||
@ -43,7 +62,7 @@ export class Registry {
|
|||||||
this.registry = new LaconicRegistry(
|
this.registry = new LaconicRegistry(
|
||||||
registryConfig.gqlEndpoint,
|
registryConfig.gqlEndpoint,
|
||||||
registryConfig.restEndpoint,
|
registryConfig.restEndpoint,
|
||||||
{ chainId: registryConfig.chainId, gasPrice }
|
{ chainId: registryConfig.chainId, gasPrice },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +72,7 @@ export class Registry {
|
|||||||
commitHash,
|
commitHash,
|
||||||
appType,
|
appType,
|
||||||
}: {
|
}: {
|
||||||
octokit: Octokit
|
octokit: Octokit;
|
||||||
repository: string;
|
repository: string;
|
||||||
commitHash: string;
|
commitHash: string;
|
||||||
appType: string;
|
appType: string;
|
||||||
@ -61,29 +80,33 @@ export class Registry {
|
|||||||
applicationRecordId: string;
|
applicationRecordId: string;
|
||||||
applicationRecordData: ApplicationRecord;
|
applicationRecordData: ApplicationRecord;
|
||||||
}> {
|
}> {
|
||||||
const { repo, repoUrl, packageJSON } = await getRepoDetails(octokit, repository, commitHash)
|
const { repo, repoUrl, packageJSON } = await getRepoDetails(
|
||||||
|
octokit,
|
||||||
|
repository,
|
||||||
|
commitHash,
|
||||||
|
);
|
||||||
// Use registry-sdk to publish record
|
// Use registry-sdk to publish record
|
||||||
// Reference: https://git.vdb.to/cerc-io/test-progressive-web-app/src/branch/main/scripts/publish-app-record.sh
|
// Reference: https://git.vdb.to/cerc-io/test-progressive-web-app/src/branch/main/scripts/publish-app-record.sh
|
||||||
// Fetch previous records
|
// Fetch previous records
|
||||||
const records = await this.registry.queryRecords(
|
const records = await this.registry.queryRecords(
|
||||||
{
|
{
|
||||||
type: APP_RECORD_TYPE,
|
type: APP_RECORD_TYPE,
|
||||||
name: packageJSON.name
|
name: packageJSON.name,
|
||||||
},
|
},
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get next version of record
|
// Get next version of record
|
||||||
const bondRecords = records.filter(
|
const bondRecords = records.filter(
|
||||||
(record: any) => record.bondId === this.registryConfig.bondId
|
(record: any) => record.bondId === this.registryConfig.bondId,
|
||||||
);
|
);
|
||||||
const [latestBondRecord] = bondRecords.sort(
|
const [latestBondRecord] = bondRecords.sort(
|
||||||
(a: any, b: any) =>
|
(a: any, b: any) =>
|
||||||
new Date(b.createTime).getTime() - new Date(a.createTime).getTime()
|
new Date(b.createTime).getTime() - new Date(a.createTime).getTime(),
|
||||||
);
|
);
|
||||||
const nextVersion = semverInc(
|
const nextVersion = semverInc(
|
||||||
latestBondRecord?.attributes.version ?? '0.0.0',
|
latestBondRecord?.attributes.version ?? '0.0.0',
|
||||||
'patch'
|
'patch',
|
||||||
);
|
);
|
||||||
|
|
||||||
assert(nextVersion, 'Application record version not valid');
|
assert(nextVersion, 'Application record version not valid');
|
||||||
@ -103,24 +126,12 @@ export class Registry {
|
|||||||
author:
|
author:
|
||||||
typeof packageJSON.author === 'object'
|
typeof packageJSON.author === 'object'
|
||||||
? JSON.stringify(packageJSON.author)
|
? JSON.stringify(packageJSON.author)
|
||||||
: packageJSON.author
|
: packageJSON.author,
|
||||||
}),
|
}),
|
||||||
...(packageJSON.version && { app_version: packageJSON.version })
|
...(packageJSON.version && { app_version: packageJSON.version }),
|
||||||
};
|
};
|
||||||
|
|
||||||
const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees);
|
const result = await this.publishRecord(applicationRecord);
|
||||||
|
|
||||||
const result = await registryTransactionWithRetry(() =>
|
|
||||||
this.registry.setRecord(
|
|
||||||
{
|
|
||||||
privateKey: this.registryConfig.privateKey,
|
|
||||||
record: applicationRecord,
|
|
||||||
bondId: this.registryConfig.bondId
|
|
||||||
},
|
|
||||||
this.registryConfig.privateKey,
|
|
||||||
fee
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
log(`Published application record ${result.id}`);
|
log(`Published application record ${result.id}`);
|
||||||
log('Application record data:', applicationRecord);
|
log('Application record data:', applicationRecord);
|
||||||
@ -129,16 +140,9 @@ export class Registry {
|
|||||||
const lrn = this.getLrn(repo);
|
const lrn = this.getLrn(repo);
|
||||||
log(`Setting name: ${lrn} for record ID: ${result.id}`);
|
log(`Setting name: ${lrn} for record ID: ${result.id}`);
|
||||||
|
|
||||||
await sleep(SLEEP_DURATION);
|
const fee = parseGasAndFees(
|
||||||
await registryTransactionWithRetry(() =>
|
this.registryConfig.fee.gas,
|
||||||
this.registry.setName(
|
this.registryConfig.fee.fees,
|
||||||
{
|
|
||||||
cid: result.id,
|
|
||||||
lrn
|
|
||||||
},
|
|
||||||
this.registryConfig.privateKey,
|
|
||||||
fee
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await sleep(SLEEP_DURATION);
|
await sleep(SLEEP_DURATION);
|
||||||
@ -146,11 +150,11 @@ export class Registry {
|
|||||||
this.registry.setName(
|
this.registry.setName(
|
||||||
{
|
{
|
||||||
cid: result.id,
|
cid: result.id,
|
||||||
lrn: `${lrn}@${applicationRecord.app_version}`
|
lrn,
|
||||||
},
|
},
|
||||||
this.registryConfig.privateKey,
|
this.registryConfig.privateKey,
|
||||||
fee
|
fee,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
await sleep(SLEEP_DURATION);
|
await sleep(SLEEP_DURATION);
|
||||||
@ -158,16 +162,28 @@ export class Registry {
|
|||||||
this.registry.setName(
|
this.registry.setName(
|
||||||
{
|
{
|
||||||
cid: result.id,
|
cid: result.id,
|
||||||
lrn: `${lrn}@${applicationRecord.repository_ref}`
|
lrn: `${lrn}@${applicationRecord.app_version}`,
|
||||||
},
|
},
|
||||||
this.registryConfig.privateKey,
|
this.registryConfig.privateKey,
|
||||||
fee
|
fee,
|
||||||
)
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await sleep(SLEEP_DURATION);
|
||||||
|
await registryTransactionWithRetry(() =>
|
||||||
|
this.registry.setName(
|
||||||
|
{
|
||||||
|
cid: result.id,
|
||||||
|
lrn: `${lrn}@${applicationRecord.repository_ref}`,
|
||||||
|
},
|
||||||
|
this.registryConfig.privateKey,
|
||||||
|
fee,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
applicationRecordId: result.id,
|
applicationRecordId: result.id,
|
||||||
applicationRecordData: applicationRecord
|
applicationRecordData: applicationRecord,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +193,7 @@ export class Registry {
|
|||||||
auctionParams: AuctionParams,
|
auctionParams: AuctionParams,
|
||||||
data: DeepPartial<Deployment>,
|
data: DeepPartial<Deployment>,
|
||||||
): Promise<{
|
): Promise<{
|
||||||
applicationDeploymentAuctionId: string;
|
applicationDeploymentAuction: MsgCreateAuctionResponse['auction'];
|
||||||
}> {
|
}> {
|
||||||
assert(data.project?.repository, 'Project repository not found');
|
assert(data.project?.repository, 'Project repository not found');
|
||||||
|
|
||||||
@ -192,8 +208,11 @@ export class Registry {
|
|||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
const auctionConfig = config.auction;
|
const auctionConfig = config.auction;
|
||||||
|
|
||||||
const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees);
|
const fee = parseGasAndFees(
|
||||||
const auctionResult = await registryTransactionWithRetry(() =>
|
this.registryConfig.fee.gas,
|
||||||
|
this.registryConfig.fee.fees,
|
||||||
|
);
|
||||||
|
const auctionResult = (await registryTransactionWithRetry(() =>
|
||||||
this.registry.createProviderAuction(
|
this.registry.createProviderAuction(
|
||||||
{
|
{
|
||||||
commitFee: auctionConfig.commitFee,
|
commitFee: auctionConfig.commitFee,
|
||||||
@ -205,9 +224,9 @@ export class Registry {
|
|||||||
numProviders: auctionParams.numProviders,
|
numProviders: auctionParams.numProviders,
|
||||||
},
|
},
|
||||||
this.registryConfig.privateKey,
|
this.registryConfig.privateKey,
|
||||||
fee
|
fee,
|
||||||
)
|
),
|
||||||
);
|
)) as MsgCreateAuctionResponse;
|
||||||
|
|
||||||
if (!auctionResult.auction) {
|
if (!auctionResult.auction) {
|
||||||
throw new Error('Error creating auction');
|
throw new Error('Error creating auction');
|
||||||
@ -220,39 +239,29 @@ export class Registry {
|
|||||||
type: APP_DEPLOYMENT_AUCTION_RECORD_TYPE,
|
type: APP_DEPLOYMENT_AUCTION_RECORD_TYPE,
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = await registryTransactionWithRetry(() =>
|
const result = await this.publishRecord(applicationDeploymentAuction);
|
||||||
this.registry.setRecord(
|
|
||||||
{
|
|
||||||
privateKey: this.registryConfig.privateKey,
|
|
||||||
record: applicationDeploymentAuction,
|
|
||||||
bondId: this.registryConfig.bondId
|
|
||||||
},
|
|
||||||
this.registryConfig.privateKey,
|
|
||||||
fee
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
log(`Application deployment auction created: ${auctionResult.auction.id}`);
|
log(`Application deployment auction created: ${auctionResult.auction.id}`);
|
||||||
log(`Application deployment auction record published: ${result.id}`);
|
log(`Application deployment auction record published: ${result.id}`);
|
||||||
log('Application deployment auction data:', applicationDeploymentAuction);
|
log('Application deployment auction data:', applicationDeploymentAuction);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
applicationDeploymentAuctionId: auctionResult.auction.id,
|
applicationDeploymentAuction: auctionResult.auction!,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async createApplicationDeploymentRequest(data: {
|
async createApplicationDeploymentRequest(data: {
|
||||||
deployment: Deployment,
|
deployment: Deployment;
|
||||||
appName: string,
|
appName: string;
|
||||||
repository: string,
|
repository: string;
|
||||||
auctionId?: string | null,
|
auctionId?: string | null;
|
||||||
lrn: string,
|
lrn: string;
|
||||||
apiUrl: string,
|
apiUrl: string;
|
||||||
environmentVariables: { [key: string]: string },
|
environmentVariables: { [key: string]: string };
|
||||||
dns: string,
|
dns: string;
|
||||||
requesterAddress: string,
|
requesterAddress: string;
|
||||||
publicKey: string,
|
publicKey: string;
|
||||||
payment?: string | null
|
payment?: string | null;
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
applicationDeploymentRequestId: string;
|
applicationDeploymentRequestId: string;
|
||||||
applicationDeploymentRequestData: ApplicationDeploymentRequest;
|
applicationDeploymentRequestData: ApplicationDeploymentRequest;
|
||||||
@ -265,12 +274,15 @@ export class Registry {
|
|||||||
throw new Error(`No record found for ${lrn}`);
|
throw new Error(`No record found for ${lrn}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const hash = await this.generateConfigHash(
|
let hash;
|
||||||
|
if (Object.keys(data.environmentVariables).length !== 0) {
|
||||||
|
hash = await this.generateConfigHash(
|
||||||
data.environmentVariables,
|
data.environmentVariables,
|
||||||
data.requesterAddress,
|
data.requesterAddress,
|
||||||
data.publicKey,
|
data.publicKey,
|
||||||
data.apiUrl,
|
data.apiUrl,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Create record of type ApplicationDeploymentRequest and publish
|
// Create record of type ApplicationDeploymentRequest and publish
|
||||||
const applicationDeploymentRequest = {
|
const applicationDeploymentRequest = {
|
||||||
@ -281,15 +293,13 @@ export class Registry {
|
|||||||
dns: data.dns,
|
dns: data.dns,
|
||||||
|
|
||||||
// https://git.vdb.to/cerc-io/laconic-registry-cli/commit/129019105dfb93bebcea02fde0ed64d0f8e5983b
|
// https://git.vdb.to/cerc-io/laconic-registry-cli/commit/129019105dfb93bebcea02fde0ed64d0f8e5983b
|
||||||
config: JSON.stringify({
|
config: JSON.stringify(hash ? { ref: hash } : {}),
|
||||||
ref: hash,
|
|
||||||
}),
|
|
||||||
meta: JSON.stringify({
|
meta: JSON.stringify({
|
||||||
note: `Added by Snowball @ ${DateTime.utc().toFormat(
|
note: `Added by Snowball @ ${DateTime.utc().toFormat(
|
||||||
"EEE LLL dd HH:mm:ss 'UTC' yyyy"
|
"EEE LLL dd HH:mm:ss 'UTC' yyyy",
|
||||||
)}`,
|
)}`,
|
||||||
repository: data.repository,
|
repository: data.repository,
|
||||||
repository_ref: data.deployment.commitHash
|
repository_ref: data.deployment.commitHash,
|
||||||
}),
|
}),
|
||||||
deployer: data.lrn,
|
deployer: data.lrn,
|
||||||
...(data.auctionId && { auction: data.auctionId }),
|
...(data.auctionId && { auction: data.auctionId }),
|
||||||
@ -298,31 +308,19 @@ export class Registry {
|
|||||||
|
|
||||||
await sleep(SLEEP_DURATION);
|
await sleep(SLEEP_DURATION);
|
||||||
|
|
||||||
const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees);
|
const result = await this.publishRecord(applicationDeploymentRequest);
|
||||||
|
|
||||||
const result = await registryTransactionWithRetry(() =>
|
|
||||||
this.registry.setRecord(
|
|
||||||
{
|
|
||||||
privateKey: this.registryConfig.privateKey,
|
|
||||||
record: applicationDeploymentRequest,
|
|
||||||
bondId: this.registryConfig.bondId
|
|
||||||
},
|
|
||||||
this.registryConfig.privateKey,
|
|
||||||
fee
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
log(`Application deployment request record published: ${result.id}`);
|
log(`Application deployment request record published: ${result.id}`);
|
||||||
log('Application deployment request data:', applicationDeploymentRequest);
|
log('Application deployment request data:', applicationDeploymentRequest);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
applicationDeploymentRequestId: result.id,
|
applicationDeploymentRequestId: result.id,
|
||||||
applicationDeploymentRequestData: applicationDeploymentRequest
|
applicationDeploymentRequestData: applicationDeploymentRequest,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAuctionWinningDeployerRecords(
|
async getAuctionWinningDeployerRecords(
|
||||||
auctionId: string
|
auctionId: string,
|
||||||
): Promise<DeployerRecord[]> {
|
): Promise<DeployerRecord[]> {
|
||||||
const records = await this.registry.getAuctionsByIds([auctionId]);
|
const records = await this.registry.getAuctionsByIds([auctionId]);
|
||||||
const auctionResult = records[0];
|
const auctionResult = records[0];
|
||||||
@ -335,7 +333,7 @@ export class Registry {
|
|||||||
paymentAddress: auctionWinner,
|
paymentAddress: auctionWinner,
|
||||||
});
|
});
|
||||||
|
|
||||||
const newRecords = records.filter(record => {
|
const newRecords = records.filter((record) => {
|
||||||
return record.names !== null && record.names.length > 0;
|
return record.names !== null && record.names.length > 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -350,18 +348,19 @@ export class Registry {
|
|||||||
return deployerRecords;
|
return deployerRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
async releaseDeployerFunds(
|
async releaseDeployerFunds(auctionId: string): Promise<any> {
|
||||||
auctionId: string
|
const fee = parseGasAndFees(
|
||||||
): Promise<any> {
|
this.registryConfig.fee.gas,
|
||||||
const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees);
|
this.registryConfig.fee.fees,
|
||||||
|
);
|
||||||
const auction = await registryTransactionWithRetry(() =>
|
const auction = await registryTransactionWithRetry(() =>
|
||||||
this.registry.releaseFunds(
|
this.registry.releaseFunds(
|
||||||
{
|
{
|
||||||
auctionId
|
auctionId,
|
||||||
},
|
},
|
||||||
this.registryConfig.privateKey,
|
this.registryConfig.privateKey,
|
||||||
fee
|
fee,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return auction;
|
return auction;
|
||||||
@ -371,50 +370,54 @@ export class Registry {
|
|||||||
* Fetch ApplicationDeploymentRecords for deployments
|
* Fetch ApplicationDeploymentRecords for deployments
|
||||||
*/
|
*/
|
||||||
async getDeploymentRecords(
|
async getDeploymentRecords(
|
||||||
deployments: Deployment[]
|
deployments: Deployment[],
|
||||||
): Promise<AppDeploymentRecord[]> {
|
): Promise<AppDeploymentRecord[]> {
|
||||||
// Fetch ApplicationDeploymentRecords for corresponding ApplicationRecord set in deployments
|
// Fetch ApplicationDeploymentRecords for corresponding ApplicationRecord set in deployments
|
||||||
// TODO: Implement Laconicd GQL query to filter records by multiple values for an attribute
|
// TODO: Implement Laconicd GQL query to filter records by multiple values for an attribute
|
||||||
const records = await this.registry.queryRecords(
|
const records = await this.registry.queryRecords(
|
||||||
{
|
{
|
||||||
type: APP_DEPLOYMENT_RECORD_TYPE
|
type: APP_DEPLOYMENT_RECORD_TYPE,
|
||||||
},
|
},
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Filter records with ApplicationDeploymentRequestId ID and Deployment specific URL
|
// Filter records with ApplicationDeploymentRequestId ID
|
||||||
return records.filter((record: AppDeploymentRecord) =>
|
return records.filter((record: AppDeploymentRecord) =>
|
||||||
deployments.some(
|
deployments.some(
|
||||||
(deployment) =>
|
(deployment) =>
|
||||||
deployment.applicationDeploymentRequestId === record.attributes.request &&
|
deployment.applicationDeploymentRequestId ===
|
||||||
record.attributes.url.includes(deployment.id)
|
record.attributes.request,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch WebappDeployer Records by filter
|
* Fetch WebappDeployer Records by filter
|
||||||
*/
|
*/
|
||||||
async getDeployerRecordsByFilter(filter: { [key: string]: any }): Promise<DeployerRecord[]> {
|
async getDeployerRecordsByFilter(filter: {
|
||||||
|
[key: string]: any;
|
||||||
|
}): Promise<DeployerRecord[]> {
|
||||||
return this.registry.queryRecords(
|
return this.registry.queryRecords(
|
||||||
{
|
{
|
||||||
type: WEBAPP_DEPLOYER_RECORD_TYPE,
|
type: WEBAPP_DEPLOYER_RECORD_TYPE,
|
||||||
...filter
|
...filter,
|
||||||
},
|
},
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch ApplicationDeploymentRecords by filter
|
* Fetch ApplicationDeploymentRecords by filter
|
||||||
*/
|
*/
|
||||||
async getDeploymentRecordsByFilter(filter: { [key: string]: any }): Promise<AppDeploymentRecord[]> {
|
async getDeploymentRecordsByFilter(filter: {
|
||||||
|
[key: string]: any;
|
||||||
|
}): Promise<AppDeploymentRecord[]> {
|
||||||
return this.registry.queryRecords(
|
return this.registry.queryRecords(
|
||||||
{
|
{
|
||||||
type: APP_DEPLOYMENT_RECORD_TYPE,
|
type: APP_DEPLOYMENT_RECORD_TYPE,
|
||||||
...filter
|
...filter,
|
||||||
},
|
},
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,26 +425,36 @@ export class Registry {
|
|||||||
* Fetch ApplicationDeploymentRemovalRecords for deployments
|
* Fetch ApplicationDeploymentRemovalRecords for deployments
|
||||||
*/
|
*/
|
||||||
async getDeploymentRemovalRecords(
|
async getDeploymentRemovalRecords(
|
||||||
deployments: Deployment[]
|
deployments: Deployment[],
|
||||||
): Promise<AppDeploymentRemovalRecord[]> {
|
): Promise<AppDeploymentRemovalRecord[]> {
|
||||||
// Fetch ApplicationDeploymentRemovalRecords for corresponding ApplicationDeploymentRecord set in deployments
|
// Fetch ApplicationDeploymentRemovalRecords for corresponding ApplicationDeploymentRecord set in deployments
|
||||||
const records = await this.registry.queryRecords(
|
const records = await this.registry.queryRecords(
|
||||||
{
|
{
|
||||||
type: APP_DEPLOYMENT_REMOVAL_RECORD_TYPE
|
type: APP_DEPLOYMENT_REMOVAL_RECORD_TYPE,
|
||||||
},
|
},
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Filter records with ApplicationDeploymentRecord and ApplicationDeploymentRemovalRequest IDs
|
// Filter records with ApplicationDeploymentRecord and ApplicationDeploymentRemovalRequest IDs
|
||||||
return records.filter((record: AppDeploymentRemovalRecord) =>
|
return records.filter((record: AppDeploymentRemovalRecord) =>
|
||||||
deployments.some(
|
deployments.some(
|
||||||
(deployment) =>
|
(deployment) =>
|
||||||
deployment.applicationDeploymentRemovalRequestId === record.attributes.request &&
|
deployment.applicationDeploymentRemovalRequestId ===
|
||||||
deployment.applicationDeploymentRecordId === record.attributes.deployment
|
record.attributes.request &&
|
||||||
)
|
deployment.applicationDeploymentRecordId ===
|
||||||
|
record.attributes.deployment,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch record by Id
|
||||||
|
*/
|
||||||
|
async getRecordById(id: string): Promise<RegistryRecord | null> {
|
||||||
|
const [record] = await this.registry.getRecordsByIds([id]);
|
||||||
|
return record ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
async createApplicationDeploymentRemovalRequest(data: {
|
async createApplicationDeploymentRemovalRequest(data: {
|
||||||
deploymentId: string;
|
deploymentId: string;
|
||||||
deployerLrn: string;
|
deployerLrn: string;
|
||||||
@ -460,26 +473,22 @@ export class Registry {
|
|||||||
...(data.payment && { payment: data.payment }),
|
...(data.payment && { payment: data.payment }),
|
||||||
};
|
};
|
||||||
|
|
||||||
const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees);
|
const result = await this.publishRecord(
|
||||||
|
applicationDeploymentRemovalRequest,
|
||||||
const result = await registryTransactionWithRetry(() =>
|
|
||||||
this.registry.setRecord(
|
|
||||||
{
|
|
||||||
privateKey: this.registryConfig.privateKey,
|
|
||||||
record: applicationDeploymentRemovalRequest,
|
|
||||||
bondId: this.registryConfig.bondId
|
|
||||||
},
|
|
||||||
this.registryConfig.privateKey,
|
|
||||||
fee
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
log(`Application deployment removal request record published: ${result.id}`);
|
log(
|
||||||
log('Application deployment removal request data:', applicationDeploymentRemovalRequest);
|
`Application deployment removal request record published: ${result.id}`,
|
||||||
|
);
|
||||||
|
log(
|
||||||
|
'Application deployment removal request data:',
|
||||||
|
applicationDeploymentRemovalRequest,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
applicationDeploymentRemovalRequestId: result.id,
|
applicationDeploymentRemovalRequestId: result.id,
|
||||||
applicationDeploymentRemovalRequestData: applicationDeploymentRemovalRequest
|
applicationDeploymentRemovalRequestData:
|
||||||
|
applicationDeploymentRemovalRequest,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,12 +500,36 @@ export class Registry {
|
|||||||
const auctions = await this.registry.getAuctionsByIds(auctionIds);
|
const auctions = await this.registry.getAuctionsByIds(auctionIds);
|
||||||
|
|
||||||
const completedAuctions = auctions
|
const completedAuctions = auctions
|
||||||
.filter((auction: { id: string, status: string }) => auction.status === 'completed')
|
.filter(
|
||||||
.map((auction: { id: string, status: string }) => auction.id);
|
(auction: { id: string; status: string }) =>
|
||||||
|
auction.status === 'completed',
|
||||||
|
)
|
||||||
|
.map((auction: { id: string; status: string }) => auction.id);
|
||||||
|
|
||||||
return completedAuctions;
|
return completedAuctions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async publishRecord(recordData: any): Promise<any> {
|
||||||
|
const fee = parseGasAndFees(
|
||||||
|
this.registryConfig.fee.gas,
|
||||||
|
this.registryConfig.fee.fees,
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = await registryTransactionWithRetry(() =>
|
||||||
|
this.registry.setRecord(
|
||||||
|
{
|
||||||
|
privateKey: this.registryConfig.privateKey,
|
||||||
|
record: recordData,
|
||||||
|
bondId: this.registryConfig.bondId,
|
||||||
|
},
|
||||||
|
this.registryConfig.privateKey,
|
||||||
|
fee,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
async getRecordsByName(name: string): Promise<any> {
|
async getRecordsByName(name: string): Promise<any> {
|
||||||
return this.registry.resolveNames([name]);
|
return this.registry.resolveNames([name]);
|
||||||
}
|
}
|
||||||
@ -505,27 +538,38 @@ export class Registry {
|
|||||||
return this.registry.getAuctionsByIds([auctionId]);
|
return this.registry.getAuctionsByIds([auctionId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendTokensToAccount(receiverAddress: string, amount: string): Promise<DeliverTxResponse> {
|
async sendTokensToAccount(
|
||||||
const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees);
|
receiverAddress: string,
|
||||||
|
amount: string,
|
||||||
|
): Promise<DeliverTxResponse> {
|
||||||
|
const fee = parseGasAndFees(
|
||||||
|
this.registryConfig.fee.gas,
|
||||||
|
this.registryConfig.fee.fees,
|
||||||
|
);
|
||||||
const account = await this.getAccount();
|
const account = await this.getAccount();
|
||||||
const laconicClient = await this.registry.getLaconicClient(account);
|
const laconicClient = await this.registry.getLaconicClient(account);
|
||||||
const txResponse: DeliverTxResponse =
|
const txResponse: DeliverTxResponse = await registryTransactionWithRetry(
|
||||||
await registryTransactionWithRetry(() =>
|
() =>
|
||||||
laconicClient.sendTokens(account.address, receiverAddress,
|
laconicClient.sendTokens(
|
||||||
|
account.address,
|
||||||
|
receiverAddress,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
denom: 'alnt',
|
denom: 'alnt',
|
||||||
amount
|
amount,
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
fee || DEFAULT_GAS_ESTIMATION_MULTIPLIER)
|
fee || DEFAULT_GAS_ESTIMATION_MULTIPLIER,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return txResponse;
|
return txResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAccount(): Promise<Account> {
|
async getAccount(): Promise<Account> {
|
||||||
const account = new Account(Buffer.from(this.registryConfig.privateKey, 'hex'));
|
const account = new Account(
|
||||||
|
Buffer.from(this.registryConfig.privateKey, 'hex'),
|
||||||
|
);
|
||||||
await account.init();
|
await account.init();
|
||||||
|
|
||||||
return account;
|
return account;
|
||||||
|
@ -38,7 +38,7 @@ export const createResolvers = async (service: Service): Promise<any> => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
deployments: async (_: any, { projectId }: { projectId: string }) => {
|
deployments: async (_: any, { projectId }: { projectId: string }) => {
|
||||||
return service.getDeploymentsByProjectId(projectId);
|
return service.getNonCanonicalDeploymentsByProjectId(projectId);
|
||||||
},
|
},
|
||||||
|
|
||||||
environmentVariables: async (
|
environmentVariables: async (
|
||||||
@ -95,6 +95,13 @@ export const createResolvers = async (service: Service): Promise<any> => {
|
|||||||
) => {
|
) => {
|
||||||
return service.verifyTx(txHash, amount, senderAddress);
|
return service.verifyTx(txHash, amount, senderAddress);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
latestDNSRecord: async (
|
||||||
|
_: any,
|
||||||
|
{ projectId }: { projectId: string },
|
||||||
|
) => {
|
||||||
|
return service.getLatestDNSRecordByProjectId(projectId);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Return error in GQL response
|
// TODO: Return error in GQL response
|
||||||
|
@ -94,13 +94,4 @@ router.get('/session', (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/logout', (req, res) => {
|
|
||||||
req.session.destroy((err) => {
|
|
||||||
if (err) {
|
|
||||||
return res.send({ success: false });
|
|
||||||
}
|
|
||||||
res.send({ success: true });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
@ -100,7 +100,6 @@ type ProjectMember {
|
|||||||
|
|
||||||
type Deployment {
|
type Deployment {
|
||||||
id: String!
|
id: String!
|
||||||
domain: Domain
|
|
||||||
branch: String!
|
branch: String!
|
||||||
commitHash: String!
|
commitHash: String!
|
||||||
commitMessage: String!
|
commitMessage: String!
|
||||||
@ -108,6 +107,7 @@ type Deployment {
|
|||||||
environment: Environment!
|
environment: Environment!
|
||||||
deployer: Deployer
|
deployer: Deployer
|
||||||
applicationDeploymentRequestId: String
|
applicationDeploymentRequestId: String
|
||||||
|
applicationDeploymentRecordData: AppDeploymentRecordAttributes
|
||||||
isCurrent: Boolean!
|
isCurrent: Boolean!
|
||||||
baseDomain: String
|
baseDomain: String
|
||||||
status: DeploymentStatus!
|
status: DeploymentStatus!
|
||||||
@ -249,6 +249,27 @@ type Auction {
|
|||||||
bids: [Bid!]!
|
bids: [Bid!]!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DNSRecordAttributes {
|
||||||
|
name: String
|
||||||
|
value: String
|
||||||
|
request: String
|
||||||
|
resourceType: String
|
||||||
|
version: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type AppDeploymentRecordAttributes {
|
||||||
|
application: String
|
||||||
|
auction: String
|
||||||
|
deployer: String
|
||||||
|
dns: String
|
||||||
|
meta: String
|
||||||
|
name: String
|
||||||
|
request: String
|
||||||
|
type: String
|
||||||
|
url: String
|
||||||
|
version: String
|
||||||
|
}
|
||||||
|
|
||||||
input AuctionParams {
|
input AuctionParams {
|
||||||
maxPrice: String,
|
maxPrice: String,
|
||||||
numProviders: Int,
|
numProviders: Int,
|
||||||
@ -265,6 +286,7 @@ type Query {
|
|||||||
projectMembers(projectId: String!): [ProjectMember!]
|
projectMembers(projectId: String!): [ProjectMember!]
|
||||||
searchProjects(searchText: String!): [Project!]
|
searchProjects(searchText: String!): [Project!]
|
||||||
getAuctionData(auctionId: String!): Auction!
|
getAuctionData(auctionId: String!): Auction!
|
||||||
|
latestDNSRecord(projectId: String!): DNSRecordAttributes
|
||||||
domains(projectId: String!, filter: FilterDomainsInput): [Domain]
|
domains(projectId: String!, filter: FilterDomainsInput): [Domain]
|
||||||
deployers: [Deployer]
|
deployers: [Deployer]
|
||||||
address: String!
|
address: String!
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,22 @@ export interface AppDeploymentRecordAttributes {
|
|||||||
version: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DNSRecordAttributes {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
request: string;
|
||||||
|
resourceType: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegistryDNSRecordAttributes {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
request: string;
|
||||||
|
resource_type: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AppDeploymentRemovalRecordAttributes {
|
export interface AppDeploymentRemovalRecordAttributes {
|
||||||
deployment: string;
|
deployment: string;
|
||||||
request: string;
|
request: string;
|
||||||
@ -47,7 +63,7 @@ export interface AppDeploymentRemovalRecordAttributes {
|
|||||||
version: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RegistryRecord {
|
export interface RegistryRecord {
|
||||||
id: string;
|
id: string;
|
||||||
names: string[] | null;
|
names: string[] | null;
|
||||||
owners: string[];
|
owners: string[];
|
||||||
@ -64,6 +80,10 @@ export interface AppDeploymentRemovalRecord extends RegistryRecord {
|
|||||||
attributes: AppDeploymentRemovalRecordAttributes;
|
attributes: AppDeploymentRemovalRecordAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DNSRecord extends RegistryRecord {
|
||||||
|
attributes: RegistryDNSRecordAttributes
|
||||||
|
}
|
||||||
|
|
||||||
export interface AddProjectFromTemplateInput {
|
export interface AddProjectFromTemplateInput {
|
||||||
templateOwner: string;
|
templateOwner: string;
|
||||||
templateRepo: string;
|
templateRepo: string;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
rpcEndpoint: https://laconicd-sapo.laconic.com
|
rpcEndpoint: https://laconicd-mainnet-1.laconic.com
|
||||||
gqlEndpoint: https://laconicd-sapo.laconic.com/api
|
gqlEndpoint: https://laconicd-mainnet-1.laconic.com/api
|
||||||
userKey:
|
userKey:
|
||||||
bondId:
|
bondId:
|
||||||
chainId: laconic-testnet-2
|
chainId: laconic-mainnet
|
||||||
gasPrice: 0.001alnt
|
gasPrice: 0.001alnt
|
||||||
|
@ -133,8 +133,6 @@ record:
|
|||||||
LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: laconic-templates/test-progressive-web-app
|
LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: laconic-templates/test-progressive-web-app
|
||||||
LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: laconic-templates/image-upload-pwa-example
|
LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: laconic-templates/image-upload-pwa-example
|
||||||
LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: laconic-templates/starter.nextjs-react-tailwind
|
LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: laconic-templates/starter.nextjs-react-tailwind
|
||||||
LACONIC_HOSTED_CONFIG_wallet_connect_id: 63cad7ba97391f63652161f484670e15
|
|
||||||
LACONIC_HOSTED_CONFIG_laconicd_chain_id: laconic-testnet-2
|
|
||||||
LACONIC_HOSTED_CONFIG_wallet_iframe_url: https://wallet.laconic.com
|
LACONIC_HOSTED_CONFIG_wallet_iframe_url: https://wallet.laconic.com
|
||||||
meta:
|
meta:
|
||||||
note: Added @ $CURRENT_DATE_TIME
|
note: Added @ $CURRENT_DATE_TIME
|
||||||
|
@ -127,7 +127,6 @@ record:
|
|||||||
LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: laconic-templates/test-progressive-web-app
|
LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: laconic-templates/test-progressive-web-app
|
||||||
LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: laconic-templates/image-upload-pwa-example
|
LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: laconic-templates/image-upload-pwa-example
|
||||||
LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: laconic-templates/starter.nextjs-react-tailwind
|
LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: laconic-templates/starter.nextjs-react-tailwind
|
||||||
LACONIC_HOSTED_CONFIG_wallet_connect_id: 63cad7ba97391f63652161f484670e15
|
|
||||||
LACONIC_HOSTED_CONFIG_laconicd_chain_id: laconic-testnet-2
|
LACONIC_HOSTED_CONFIG_laconicd_chain_id: laconic-testnet-2
|
||||||
meta:
|
meta:
|
||||||
note: Added by Snowball @ $CURRENT_DATE_TIME
|
note: Added by Snowball @ $CURRENT_DATE_TIME
|
||||||
|
@ -5,8 +5,6 @@ VITE_GITHUB_PWA_TEMPLATE_REPO="snowball-tools/test-progressive-web-app"
|
|||||||
VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO="snowball-tools/image-upload-pwa-example"
|
VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO="snowball-tools/image-upload-pwa-example"
|
||||||
VITE_GITHUB_NEXT_APP_TEMPLATE_REPO="snowball-tools/starter.nextjs-react-tailwind"
|
VITE_GITHUB_NEXT_APP_TEMPLATE_REPO="snowball-tools/starter.nextjs-react-tailwind"
|
||||||
|
|
||||||
VITE_WALLET_CONNECT_ID=
|
|
||||||
|
|
||||||
VITE_LIT_RELAY_API_KEY=
|
VITE_LIT_RELAY_API_KEY=
|
||||||
|
|
||||||
VITE_BUGSNAG_API_KEY=
|
VITE_BUGSNAG_API_KEY=
|
||||||
@ -14,5 +12,4 @@ VITE_BUGSNAG_API_KEY=
|
|||||||
VITE_PASSKEY_WALLET_RPID=
|
VITE_PASSKEY_WALLET_RPID=
|
||||||
VITE_TURNKEY_API_BASE_URL=
|
VITE_TURNKEY_API_BASE_URL=
|
||||||
|
|
||||||
VITE_LACONICD_CHAIN_ID=
|
|
||||||
VITE_WALLET_IFRAME_URL=
|
VITE_WALLET_IFRAME_URL=
|
||||||
|
@ -41,13 +41,12 @@
|
|||||||
"@turnkey/http": "^2.10.0",
|
"@turnkey/http": "^2.10.0",
|
||||||
"@turnkey/sdk-react": "^0.1.0",
|
"@turnkey/sdk-react": "^0.1.0",
|
||||||
"@turnkey/webauthn-stamper": "^0.5.0",
|
"@turnkey/webauthn-stamper": "^0.5.0",
|
||||||
"@walletconnect/ethereum-provider": "^2.16.1",
|
|
||||||
"@web3modal/siwe": "4.0.5",
|
"@web3modal/siwe": "4.0.5",
|
||||||
"@web3modal/wagmi": "4.0.5",
|
|
||||||
"assert": "^2.1.0",
|
"assert": "^2.1.0",
|
||||||
"axios": "^1.6.7",
|
"axios": "^1.6.7",
|
||||||
"clsx": "^2.1.0",
|
"clsx": "^2.1.0",
|
||||||
"date-fns": "^3.3.1",
|
"date-fns": "^3.3.1",
|
||||||
|
"ethers": "^5.6.2",
|
||||||
"downshift": "^8.3.2",
|
"downshift": "^8.3.2",
|
||||||
"framer-motion": "^11.0.8",
|
"framer-motion": "^11.0.8",
|
||||||
"gql-client": "^1.0.0",
|
"gql-client": "^1.0.0",
|
||||||
@ -69,7 +68,6 @@
|
|||||||
"usehooks-ts": "^2.15.1",
|
"usehooks-ts": "^2.15.1",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^9.0.1",
|
||||||
"viem": "^2.7.11",
|
"viem": "^2.7.11",
|
||||||
"wagmi": "2.5.7",
|
|
||||||
"web-vitals": "^2.1.4"
|
"web-vitals": "^2.1.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
BIN
packages/frontend/public/android-chrome-192x192.png
Normal file
BIN
packages/frontend/public/android-chrome-192x192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
11
packages/frontend/public/network.json
Normal file
11
packages/frontend/public/network.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"chainId": "laconic-mainnet",
|
||||||
|
"networkName": "laconicd mainnet",
|
||||||
|
"namespace": "cosmos",
|
||||||
|
"rpcUrl": "https://laconicd-mainnet-1.laconic.com",
|
||||||
|
"blockExplorerUrl": "",
|
||||||
|
"nativeDenom": "alnt",
|
||||||
|
"addressPrefix": "laconic",
|
||||||
|
"coinType": 118,
|
||||||
|
"gasPrice": 0.001
|
||||||
|
}
|
@ -11,8 +11,8 @@ import ProjectSearchLayout from './layouts/ProjectSearch';
|
|||||||
import Index from './pages';
|
import Index from './pages';
|
||||||
import AuthPage from './pages/AuthPage';
|
import AuthPage from './pages/AuthPage';
|
||||||
import { DashboardLayout } from './pages/org-slug/layout';
|
import { DashboardLayout } from './pages/org-slug/layout';
|
||||||
import Web3Provider from 'context/Web3Provider';
|
|
||||||
import { BASE_URL } from 'utils/constants';
|
import { BASE_URL } from 'utils/constants';
|
||||||
|
import BuyPrepaidService from './pages/BuyPrepaidService';
|
||||||
|
|
||||||
const router = createBrowserRouter([
|
const router = createBrowserRouter([
|
||||||
{
|
{
|
||||||
@ -50,6 +50,10 @@ const router = createBrowserRouter([
|
|||||||
path: '/login',
|
path: '/login',
|
||||||
element: <AuthPage />,
|
element: <AuthPage />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/buy-prepaid-service',
|
||||||
|
element: <BuyPrepaidService />,
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
@ -75,9 +79,7 @@ function App() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Web3Provider>
|
|
||||||
<RouterProvider router={router} />
|
<RouterProvider router={router} />
|
||||||
</Web3Provider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,11 @@ import {
|
|||||||
MenuItem,
|
MenuItem,
|
||||||
MenuList,
|
MenuList,
|
||||||
} from '@snowballtools/material-tailwind-react-fork';
|
} from '@snowballtools/material-tailwind-react-fork';
|
||||||
import { ComponentPropsWithoutRef, MouseEvent, useCallback } from 'react';
|
import {
|
||||||
|
ComponentPropsWithoutRef,
|
||||||
|
MouseEvent,
|
||||||
|
useCallback,
|
||||||
|
} from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Project } from 'gql-client';
|
import { Project } from 'gql-client';
|
||||||
import { Avatar } from 'components/shared/Avatar';
|
import { Avatar } from 'components/shared/Avatar';
|
||||||
@ -83,7 +87,7 @@ export const ProjectCard = ({
|
|||||||
<p className={theme.title()}>{project.name}</p>
|
<p className={theme.title()}>{project.name}</p>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<p className={theme.description()}>
|
<p className={theme.description()}>
|
||||||
{project.deployments[0]?.domain?.name ?? 'No domain'}
|
{project.deployments[0]?.applicationDeploymentRecordData?.url ?? 'No domain'}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{/* Icons */}
|
{/* Icons */}
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
import {
|
|
||||||
Select,
|
|
||||||
Option,
|
|
||||||
Spinner,
|
|
||||||
} from '@snowballtools/material-tailwind-react-fork';
|
|
||||||
|
|
||||||
const AccountsDropdown = ({
|
|
||||||
accounts,
|
|
||||||
isDataReceived,
|
|
||||||
onAccountChange,
|
|
||||||
}: {
|
|
||||||
accounts: string[];
|
|
||||||
isDataReceived: boolean;
|
|
||||||
onAccountChange: (selectedAccount: string) => void;
|
|
||||||
}) => {
|
|
||||||
return (
|
|
||||||
<div className="p-6 bg-slate-100 dark:bg-overlay3 rounded-lg mb-6 shadow-md">
|
|
||||||
{isDataReceived ? (
|
|
||||||
!accounts.length ? (
|
|
||||||
<div className="text-center">
|
|
||||||
<p className="text-gray-700 dark:text-gray-300 mb-4">
|
|
||||||
No accounts found. Please visit{' '}
|
|
||||||
<a
|
|
||||||
href="https://store.laconic.com"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="text-blue-600 underline dark:text-blue-400"
|
|
||||||
>
|
|
||||||
store.laconic.com
|
|
||||||
</a>{' '}
|
|
||||||
to create a wallet.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div>
|
|
||||||
<Select
|
|
||||||
label="Select Account"
|
|
||||||
defaultValue={accounts[0]}
|
|
||||||
onChange={(value) => value && onAccountChange(value)}
|
|
||||||
className="dark:bg-overlay2 dark:text-foreground"
|
|
||||||
aria-label="Wallet Account Selector"
|
|
||||||
>
|
|
||||||
{accounts.map((account, index) => (
|
|
||||||
<Option key={index} value={account}>
|
|
||||||
{account}
|
|
||||||
</Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
<div className="flex items-center justify-center h-12">
|
|
||||||
<Spinner className="h-6 w-6" />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AccountsDropdown;
|
|
@ -3,27 +3,38 @@ import { useCallback, useEffect } from 'react';
|
|||||||
import { Box, Modal } from '@mui/material';
|
import { Box, Modal } from '@mui/material';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
VITE_LACONICD_CHAIN_ID,
|
|
||||||
VITE_WALLET_IFRAME_URL,
|
VITE_WALLET_IFRAME_URL,
|
||||||
} from 'utils/constants';
|
} from 'utils/constants';
|
||||||
|
import { REQUEST_WALLET_ACCOUNTS, WALLET_ACCOUNTS_DATA } from '../../../constants';
|
||||||
|
import { useAddNetwork } from '../../../hooks/useAddNetwork';
|
||||||
|
|
||||||
const IFrameModal = ({
|
const ApproveTransactionModal = ({
|
||||||
setAccounts,
|
setAccount,
|
||||||
setIsDataReceived,
|
setIsDataReceived,
|
||||||
isVisible,
|
isVisible,
|
||||||
}: {
|
}: {
|
||||||
setAccounts: (accounts: string[]) => void;
|
setAccount: (account: string) => void;
|
||||||
setIsDataReceived: (isReceived: boolean) => void;
|
setIsDataReceived: (isReceived: boolean) => void;
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
|
const { setIframe, isNetworkAvailable, networkData } = useAddNetwork();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleMessage = (event: MessageEvent) => {
|
const handleMessage = (event: MessageEvent) => {
|
||||||
if (event.origin !== VITE_WALLET_IFRAME_URL) return;
|
if (event.origin !== VITE_WALLET_IFRAME_URL) return;
|
||||||
|
|
||||||
|
if (event.data.type === WALLET_ACCOUNTS_DATA) {
|
||||||
setIsDataReceived(true);
|
setIsDataReceived(true);
|
||||||
if (event.data.type === 'WALLET_ACCOUNTS_DATA') {
|
|
||||||
setAccounts(event.data.data);
|
if (event.data.data.length === 0) {
|
||||||
} else if (event.data.type === 'ERROR') {
|
console.error(`Accounts not present for chainId: ${networkData?.chainId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setAccount(event.data.data[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.data.type === 'ERROR') {
|
||||||
console.error('Error from wallet:', event.data.message);
|
console.error('Error from wallet:', event.data.message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -33,9 +44,14 @@ const IFrameModal = ({
|
|||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('message', handleMessage);
|
window.removeEventListener('message', handleMessage);
|
||||||
};
|
};
|
||||||
}, []);
|
}, [networkData]);
|
||||||
|
|
||||||
const getDataFromWallet = useCallback(() => {
|
const getDataFromWallet = useCallback(() => {
|
||||||
|
if (!networkData) {
|
||||||
|
console.error('networkData should not be empty');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const iframe = document.getElementById('walletIframe') as HTMLIFrameElement;
|
const iframe = document.getElementById('walletIframe') as HTMLIFrameElement;
|
||||||
|
|
||||||
if (!iframe.contentWindow) {
|
if (!iframe.contentWindow) {
|
||||||
@ -45,12 +61,18 @@ const IFrameModal = ({
|
|||||||
|
|
||||||
iframe.contentWindow.postMessage(
|
iframe.contentWindow.postMessage(
|
||||||
{
|
{
|
||||||
type: 'REQUEST_WALLET_ACCOUNTS',
|
type: REQUEST_WALLET_ACCOUNTS,
|
||||||
chainId: VITE_LACONICD_CHAIN_ID,
|
chainId: networkData.chainId,
|
||||||
},
|
},
|
||||||
VITE_WALLET_IFRAME_URL,
|
VITE_WALLET_IFRAME_URL,
|
||||||
);
|
);
|
||||||
}, []);
|
}, [networkData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isNetworkAvailable) {
|
||||||
|
getDataFromWallet();
|
||||||
|
}
|
||||||
|
}, [isNetworkAvailable, getDataFromWallet])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={isVisible} disableEscapeKeyDown keepMounted>
|
<Modal open={isVisible} disableEscapeKeyDown keepMounted>
|
||||||
@ -72,7 +94,7 @@ const IFrameModal = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<iframe
|
<iframe
|
||||||
onLoad={getDataFromWallet}
|
onLoad={(event) => setIframe(event.target as HTMLIFrameElement)}
|
||||||
id="walletIframe"
|
id="walletIframe"
|
||||||
src={`${VITE_WALLET_IFRAME_URL}/wallet-embed`}
|
src={`${VITE_WALLET_IFRAME_URL}/wallet-embed`}
|
||||||
width="100%"
|
width="100%"
|
||||||
@ -85,4 +107,4 @@ const IFrameModal = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default IFrameModal;
|
export default ApproveTransactionModal;
|
@ -0,0 +1,67 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
|
import { Modal } from '@mui/material';
|
||||||
|
|
||||||
|
import { VITE_WALLET_IFRAME_URL } from 'utils/constants';
|
||||||
|
import useCheckBalance from '../../../hooks/useCheckBalance';
|
||||||
|
import { useAddNetwork } from '../../../hooks/useAddNetwork';
|
||||||
|
|
||||||
|
const CHECK_BALANCE_INTERVAL = 5000;
|
||||||
|
const IFRAME_ID = 'checkBalanceIframe';
|
||||||
|
|
||||||
|
const CheckBalanceIframe = ({
|
||||||
|
onBalanceChange,
|
||||||
|
isPollingEnabled,
|
||||||
|
amount,
|
||||||
|
}: {
|
||||||
|
onBalanceChange: (value: boolean | undefined) => void;
|
||||||
|
isPollingEnabled: boolean;
|
||||||
|
amount: string;
|
||||||
|
}) => {
|
||||||
|
const { isBalanceSufficient, checkBalance } = useCheckBalance(
|
||||||
|
amount,
|
||||||
|
IFRAME_ID,
|
||||||
|
);
|
||||||
|
|
||||||
|
const { isNetworkAvailable, setIframe } = useAddNetwork();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isNetworkAvailable || isBalanceSufficient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkBalance();
|
||||||
|
|
||||||
|
if (!isPollingEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
checkBalance();
|
||||||
|
}, CHECK_BALANCE_INTERVAL);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearInterval(interval);
|
||||||
|
};
|
||||||
|
}, [isBalanceSufficient, isPollingEnabled, checkBalance, isNetworkAvailable]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onBalanceChange(isBalanceSufficient);
|
||||||
|
}, [isBalanceSufficient]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal open={false} disableEscapeKeyDown keepMounted>
|
||||||
|
<iframe
|
||||||
|
onLoad={(event) => setIframe(event.target as HTMLIFrameElement)}
|
||||||
|
id={IFRAME_ID}
|
||||||
|
src={VITE_WALLET_IFRAME_URL}
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
sandbox="allow-scripts allow-same-origin"
|
||||||
|
className="border rounded-md shadow-sm"
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CheckBalanceIframe;
|
@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useState, useEffect } from 'react';
|
import { useCallback, useState, useEffect, useMemo } from 'react';
|
||||||
import { useForm, Controller } from 'react-hook-form';
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { FormProvider, FieldValues } from 'react-hook-form';
|
import { FormProvider, FieldValues } from 'react-hook-form';
|
||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
@ -8,6 +8,7 @@ import {
|
|||||||
AuctionParams,
|
AuctionParams,
|
||||||
Deployer,
|
Deployer,
|
||||||
} from 'gql-client';
|
} from 'gql-client';
|
||||||
|
import { BigNumber } from 'ethers';
|
||||||
|
|
||||||
import { Select, MenuItem, FormControl, FormHelperText } from '@mui/material';
|
import { Select, MenuItem, FormControl, FormHelperText } from '@mui/material';
|
||||||
|
|
||||||
@ -20,19 +21,19 @@ import { Button } from '../../shared/Button';
|
|||||||
import { Input } from 'components/shared/Input';
|
import { Input } from 'components/shared/Input';
|
||||||
import { useToast } from 'components/shared/Toast';
|
import { useToast } from 'components/shared/Toast';
|
||||||
import { useGQLClient } from '../../../context/GQLClientContext';
|
import { useGQLClient } from '../../../context/GQLClientContext';
|
||||||
import IFrameModal from './IFrameModal';
|
import ApproveTransactionModal from './ApproveTransactionModal';
|
||||||
import EnvironmentVariablesForm from 'pages/org-slug/projects/id/settings/EnvironmentVariablesForm';
|
import EnvironmentVariablesForm from 'pages/org-slug/projects/id/settings/EnvironmentVariablesForm';
|
||||||
import { EnvironmentVariablesFormValues } from 'types/types';
|
import { EnvironmentVariablesFormValues } from 'types/types';
|
||||||
import {
|
import {
|
||||||
VITE_LACONICD_CHAIN_ID,
|
|
||||||
VITE_WALLET_IFRAME_URL,
|
VITE_WALLET_IFRAME_URL,
|
||||||
} from 'utils/constants';
|
} from 'utils/constants';
|
||||||
import AccountsDropdown from './AccountsDropdown';
|
import CheckBalanceIframe from './CheckBalanceIframe';
|
||||||
|
import { useAddNetwork } from '../../../hooks/useAddNetwork';
|
||||||
|
|
||||||
type ConfigureDeploymentFormValues = {
|
type ConfigureDeploymentFormValues = {
|
||||||
option: string;
|
option: string;
|
||||||
lrn?: string;
|
lrn?: string;
|
||||||
numProviders?: number;
|
numProviders?: string;
|
||||||
maxPrice?: string;
|
maxPrice?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,12 +47,13 @@ const Configure = () => {
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [deployers, setDeployers] = useState<Deployer[]>([]);
|
const [deployers, setDeployers] = useState<Deployer[]>([]);
|
||||||
const [selectedAccount, setSelectedAccount] = useState<string>();
|
const [selectedAccount, setSelectedAccount] = useState<string>();
|
||||||
const [accounts, setAccounts] = useState<string[]>([]);
|
|
||||||
const [selectedDeployer, setSelectedDeployer] = useState<Deployer>();
|
const [selectedDeployer, setSelectedDeployer] = useState<Deployer>();
|
||||||
const [isPaymentLoading, setIsPaymentLoading] = useState(false);
|
const [isPaymentLoading, setIsPaymentLoading] = useState(false);
|
||||||
const [isPaymentDone, setIsPaymentDone] = useState(false);
|
const [isPaymentDone, setIsPaymentDone] = useState(false);
|
||||||
const [isFrameVisible, setIsFrameVisible] = useState(false);
|
const [isFrameVisible, setIsFrameVisible] = useState(false);
|
||||||
const [isAccountsDataReceived, setIsAccountsDataReceived] = useState(false);
|
const [isAccountsDataReceived, setIsAccountsDataReceived] = useState(false);
|
||||||
|
const [balanceMessage, setBalanceMessage] = useState<string>();
|
||||||
|
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>();
|
||||||
|
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const templateId = searchParams.get('templateId');
|
const templateId = searchParams.get('templateId');
|
||||||
@ -69,22 +71,47 @@ const Configure = () => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { toast, dismiss } = useToast();
|
const { toast, dismiss } = useToast();
|
||||||
const client = useGQLClient();
|
const client = useGQLClient();
|
||||||
|
const { networkData } = useAddNetwork()
|
||||||
|
|
||||||
const methods = useForm<ConfigureFormValues>({
|
const methods = useForm<ConfigureFormValues>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
option: 'Auction',
|
option: 'Auction',
|
||||||
maxPrice: DEFAULT_MAX_PRICE,
|
maxPrice: DEFAULT_MAX_PRICE,
|
||||||
lrn: '',
|
lrn: '',
|
||||||
numProviders: 1,
|
numProviders: '1',
|
||||||
variables: [],
|
variables: [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectedOption = methods.watch('option');
|
const selectedOption = methods.watch('option');
|
||||||
|
const selectedNumProviders = methods.watch('numProviders') ?? '1';
|
||||||
|
const selectedMaxPrice = methods.watch('maxPrice') ?? DEFAULT_MAX_PRICE;
|
||||||
|
|
||||||
const isTabletView = useMediaQuery('(min-width: 720px)'); // md:
|
const isTabletView = useMediaQuery('(min-width: 720px)'); // md:
|
||||||
const buttonSize = isTabletView ? { size: 'lg' as const } : {};
|
const buttonSize = isTabletView ? { size: 'lg' as const } : {};
|
||||||
|
|
||||||
|
const amountToBePaid = useMemo(() => {
|
||||||
|
let amount: string;
|
||||||
|
|
||||||
|
if (selectedOption === 'LRN') {
|
||||||
|
amount = selectedDeployer?.minimumPayment?.replace(/\D/g, '') ?? '0';
|
||||||
|
} else {
|
||||||
|
if (!selectedNumProviders || !selectedMaxPrice) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const bigMaxPrice = BigNumber.from(selectedMaxPrice);
|
||||||
|
amount = bigMaxPrice.mul(selectedNumProviders).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return amount;
|
||||||
|
}, [
|
||||||
|
selectedOption,
|
||||||
|
selectedDeployer?.minimumPayment,
|
||||||
|
selectedMaxPrice,
|
||||||
|
selectedNumProviders,
|
||||||
|
]);
|
||||||
|
|
||||||
const createProject = async (
|
const createProject = async (
|
||||||
data: FieldValues,
|
data: FieldValues,
|
||||||
envVariables: AddEnvironmentVariableInput[],
|
envVariables: AddEnvironmentVariableInput[],
|
||||||
@ -186,7 +213,6 @@ const Configure = () => {
|
|||||||
(deployer) => deployer.deployerLrn === deployerLrn,
|
(deployer) => deployer.deployerLrn === deployerLrn,
|
||||||
);
|
);
|
||||||
|
|
||||||
let amount: string;
|
|
||||||
let senderAddress: string;
|
let senderAddress: string;
|
||||||
let txHash: string | null = null;
|
let txHash: string | null = null;
|
||||||
if (createFormData.option === 'LRN' && !deployer?.minimumPayment) {
|
if (createFormData.option === 'LRN' && !deployer?.minimumPayment) {
|
||||||
@ -204,16 +230,6 @@ const Configure = () => {
|
|||||||
|
|
||||||
senderAddress = selectedAccount;
|
senderAddress = selectedAccount;
|
||||||
|
|
||||||
if (createFormData.option === 'LRN') {
|
|
||||||
amount = deployer?.minimumPayment!;
|
|
||||||
} else {
|
|
||||||
amount = (
|
|
||||||
createFormData.numProviders * createFormData.maxPrice
|
|
||||||
).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
const amountToBePaid = amount.replace(/\D/g, '').toString();
|
|
||||||
|
|
||||||
txHash = await cosmosSendTokensHandler(senderAddress, amountToBePaid);
|
txHash = await cosmosSendTokensHandler(senderAddress, amountToBePaid);
|
||||||
|
|
||||||
if (!txHash) {
|
if (!txHash) {
|
||||||
@ -303,7 +319,7 @@ const Configure = () => {
|
|||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[client, createProject, dismiss, toast],
|
[client, createProject, dismiss, toast, amountToBePaid],
|
||||||
);
|
);
|
||||||
|
|
||||||
const fetchDeployers = useCallback(async () => {
|
const fetchDeployers = useCallback(async () => {
|
||||||
@ -311,10 +327,6 @@ const Configure = () => {
|
|||||||
setDeployers(res.deployers);
|
setDeployers(res.deployers);
|
||||||
}, [client]);
|
}, [client]);
|
||||||
|
|
||||||
const onAccountChange = useCallback((account: string) => {
|
|
||||||
setSelectedAccount(account);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const onDeployerChange = useCallback(
|
const onDeployerChange = useCallback(
|
||||||
(selectedLrn: string) => {
|
(selectedLrn: string) => {
|
||||||
const deployer = deployers.find((d) => d.deployerLrn === selectedLrn);
|
const deployer = deployers.find((d) => d.deployerLrn === selectedLrn);
|
||||||
@ -340,12 +352,20 @@ const Configure = () => {
|
|||||||
await requestTx(senderAddress, snowballAddress, amount);
|
await requestTx(senderAddress, snowballAddress, amount);
|
||||||
|
|
||||||
const txHash = await new Promise<string | null>((resolve, reject) => {
|
const txHash = await new Promise<string | null>((resolve, reject) => {
|
||||||
|
// Call cleanup method only if appropriate event type is recieved
|
||||||
|
const cleanup = () => {
|
||||||
|
setIsFrameVisible(false);
|
||||||
|
window.removeEventListener('message', handleTxStatus);
|
||||||
|
};
|
||||||
|
|
||||||
const handleTxStatus = async (event: MessageEvent) => {
|
const handleTxStatus = async (event: MessageEvent) => {
|
||||||
if (event.origin !== VITE_WALLET_IFRAME_URL) return;
|
if (event.origin !== VITE_WALLET_IFRAME_URL) return;
|
||||||
|
|
||||||
if (event.data.type === 'TRANSACTION_RESPONSE') {
|
if (event.data.type === 'TRANSACTION_RESPONSE') {
|
||||||
const txResponse = event.data.data;
|
const txResponse = event.data.data;
|
||||||
resolve(txResponse);
|
resolve(txResponse);
|
||||||
|
|
||||||
|
cleanup();
|
||||||
} else if (event.data.type === 'ERROR') {
|
} else if (event.data.type === 'ERROR') {
|
||||||
console.error('Error from wallet:', event.data.message);
|
console.error('Error from wallet:', event.data.message);
|
||||||
reject(new Error('Transaction failed'));
|
reject(new Error('Transaction failed'));
|
||||||
@ -355,10 +375,9 @@ const Configure = () => {
|
|||||||
variant: 'error',
|
variant: 'error',
|
||||||
onDismiss: dismiss,
|
onDismiss: dismiss,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
setIsFrameVisible(false);
|
|
||||||
|
|
||||||
window.removeEventListener('message', handleTxStatus);
|
cleanup();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('message', handleTxStatus);
|
window.addEventListener('message', handleTxStatus);
|
||||||
@ -403,7 +422,7 @@ const Configure = () => {
|
|||||||
iframe.contentWindow.postMessage(
|
iframe.contentWindow.postMessage(
|
||||||
{
|
{
|
||||||
type: 'REQUEST_TX',
|
type: 'REQUEST_TX',
|
||||||
chainId: VITE_LACONICD_CHAIN_ID,
|
chainId: networkData?.chainId,
|
||||||
fromAddress: sender,
|
fromAddress: sender,
|
||||||
toAddress: recipient,
|
toAddress: recipient,
|
||||||
amount,
|
amount,
|
||||||
@ -418,6 +437,12 @@ const Configure = () => {
|
|||||||
fetchDeployers();
|
fetchDeployers();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isBalanceSufficient) {
|
||||||
|
setBalanceMessage(undefined);
|
||||||
|
}
|
||||||
|
}, [isBalanceSufficient]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-7 px-4 py-6">
|
<div className="space-y-7 px-4 py-6">
|
||||||
<div className="flex justify-between mb-6">
|
<div className="flex justify-between mb-6">
|
||||||
@ -534,6 +559,7 @@ const Configure = () => {
|
|||||||
type="number"
|
type="number"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => onChange(e)}
|
onChange={(e) => onChange(e)}
|
||||||
|
min={1}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@ -547,7 +573,7 @@ const Configure = () => {
|
|||||||
control={methods.control}
|
control={methods.control}
|
||||||
rules={{ required: true }}
|
rules={{ required: true }}
|
||||||
render={({ field: { value, onChange } }) => (
|
render={({ field: { value, onChange } }) => (
|
||||||
<Input type="number" value={value} onChange={onChange} />
|
<Input type="number" value={value} onChange={onChange} min={1} />
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -566,7 +592,7 @@ const Configure = () => {
|
|||||||
<Button
|
<Button
|
||||||
{...buttonSize}
|
{...buttonSize}
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={isLoading || !selectedDeployer || !selectedAccount}
|
disabled={isLoading || !selectedDeployer}
|
||||||
rightIcon={
|
rightIcon={
|
||||||
isLoading ? (
|
isLoading ? (
|
||||||
<LoadingIcon className="animate-spin" />
|
<LoadingIcon className="animate-spin" />
|
||||||
@ -579,20 +605,18 @@ const Configure = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<div className="flex gap-4">
|
||||||
<AccountsDropdown
|
|
||||||
accounts={accounts}
|
|
||||||
onAccountChange={onAccountChange}
|
|
||||||
isDataReceived={isAccountsDataReceived}
|
|
||||||
/>
|
|
||||||
{accounts.length > 0 && (
|
|
||||||
<div>
|
|
||||||
<Button
|
<Button
|
||||||
{...buttonSize}
|
{...buttonSize}
|
||||||
type="submit"
|
type="submit"
|
||||||
shape="default"
|
shape="default"
|
||||||
disabled={
|
disabled={
|
||||||
isLoading || isPaymentLoading || !selectedAccount
|
isLoading ||
|
||||||
|
isPaymentLoading ||
|
||||||
|
!selectedAccount ||
|
||||||
|
!isBalanceSufficient ||
|
||||||
|
amountToBePaid === '' ||
|
||||||
|
selectedNumProviders === ''
|
||||||
}
|
}
|
||||||
rightIcon={
|
rightIcon={
|
||||||
isLoading || isPaymentLoading ? (
|
isLoading || isPaymentLoading ? (
|
||||||
@ -610,18 +634,54 @@ const Configure = () => {
|
|||||||
? 'Deploying'
|
? 'Deploying'
|
||||||
: 'Deploy'}
|
: 'Deploy'}
|
||||||
</Button>
|
</Button>
|
||||||
|
{isAccountsDataReceived && isBalanceSufficient !== undefined ? (
|
||||||
|
!selectedAccount || !isBalanceSufficient ? (
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<Button
|
||||||
|
{...buttonSize}
|
||||||
|
shape="default"
|
||||||
|
onClick={(e: any) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setBalanceMessage('Waiting for payment');
|
||||||
|
window.open(
|
||||||
|
'https://store.laconic.com',
|
||||||
|
'_blank',
|
||||||
|
'noopener,noreferrer',
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Buy prepaid service
|
||||||
|
</Button>
|
||||||
|
<p className="text-gray-700 dark:text-gray-300">
|
||||||
|
{balanceMessage !== undefined ? (
|
||||||
|
<div className="flex items-center gap-2 text-white">
|
||||||
|
<LoadingIcon className="animate-spin w-5 h-5" />
|
||||||
|
<p>{balanceMessage}</p>
|
||||||
</div>
|
</div>
|
||||||
|
) : !selectedAccount ? (
|
||||||
|
'No accounts found. Create a wallet.'
|
||||||
|
) : (
|
||||||
|
'Insufficient funds.'
|
||||||
)}
|
)}
|
||||||
</>
|
</p>
|
||||||
|
</div>
|
||||||
|
) : null
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</form>
|
</form>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
|
|
||||||
<IFrameModal
|
<ApproveTransactionModal
|
||||||
setAccounts={setAccounts}
|
setAccount={setSelectedAccount}
|
||||||
setIsDataReceived={setIsAccountsDataReceived}
|
setIsDataReceived={setIsAccountsDataReceived}
|
||||||
isVisible={isFrameVisible}
|
isVisible={isFrameVisible}
|
||||||
/>
|
/>
|
||||||
|
<CheckBalanceIframe
|
||||||
|
onBalanceChange={setIsBalanceSufficient}
|
||||||
|
amount={amountToBePaid}
|
||||||
|
isPollingEnabled={true}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
import { CopyBlock, atomOneLight } from 'react-code-blocks';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
|
|
||||||
import { Modal } from 'components/shared/Modal';
|
|
||||||
import { Button } from 'components/shared/Button';
|
|
||||||
|
|
||||||
interface AssignDomainProps {
|
|
||||||
open: boolean;
|
|
||||||
handleOpen: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const AssignDomainDialog = ({ open, handleOpen }: AssignDomainProps) => {
|
|
||||||
return (
|
|
||||||
<Modal open={open} onOpenChange={handleOpen}>
|
|
||||||
<Modal.Content>
|
|
||||||
<Modal.Header>Assign Domain</Modal.Header>
|
|
||||||
<Modal.Body>
|
|
||||||
In order to assign a domain to your production deployments, configure
|
|
||||||
it in the{' '}
|
|
||||||
{/* TODO: Fix selection of project settings tab on navigation to domains */}
|
|
||||||
<Link to="../settings/domains" className="text-light-blue-800 inline">
|
|
||||||
project settings{' '}
|
|
||||||
</Link>
|
|
||||||
(recommended). If you want to assign to this specific deployment,
|
|
||||||
however, you can do so using our command-line interface:
|
|
||||||
{/* https://github.com/rajinwonderland/react-code-blocks/issues/138 */}
|
|
||||||
<CopyBlock
|
|
||||||
text="snowball alias <deployment> <domain>"
|
|
||||||
language=""
|
|
||||||
showLineNumbers={false}
|
|
||||||
theme={atomOneLight}
|
|
||||||
/>
|
|
||||||
</Modal.Body>
|
|
||||||
<Modal.Footer className="flex justify-start">
|
|
||||||
<Button onClick={handleOpen}>Okay</Button>
|
|
||||||
</Modal.Footer>
|
|
||||||
</Modal.Content>
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AssignDomainDialog;
|
|
@ -10,7 +10,6 @@ import {
|
|||||||
import { Deployment, Domain, Environment, Project } from 'gql-client';
|
import { Deployment, Domain, Environment, Project } from 'gql-client';
|
||||||
import { Button } from 'components/shared/Button';
|
import { Button } from 'components/shared/Button';
|
||||||
import {
|
import {
|
||||||
GlobeIcon,
|
|
||||||
HorizontalDotIcon,
|
HorizontalDotIcon,
|
||||||
LinkIcon,
|
LinkIcon,
|
||||||
RefreshIcon,
|
RefreshIcon,
|
||||||
@ -18,7 +17,6 @@ import {
|
|||||||
UndoIcon,
|
UndoIcon,
|
||||||
CrossCircleIcon,
|
CrossCircleIcon,
|
||||||
} from 'components/shared/CustomIcon';
|
} from 'components/shared/CustomIcon';
|
||||||
import AssignDomainDialog from './AssignDomainDialog';
|
|
||||||
import { useGQLClient } from 'context/GQLClientContext';
|
import { useGQLClient } from 'context/GQLClientContext';
|
||||||
import { cn } from 'utils/classnames';
|
import { cn } from 'utils/classnames';
|
||||||
import { ChangeStateToProductionDialog } from 'components/projects/Dialog/ChangeStateToProductionDialog';
|
import { ChangeStateToProductionDialog } from 'components/projects/Dialog/ChangeStateToProductionDialog';
|
||||||
@ -49,8 +47,8 @@ export const DeploymentMenu = ({
|
|||||||
const [redeployToProduction, setRedeployToProduction] = useState(false);
|
const [redeployToProduction, setRedeployToProduction] = useState(false);
|
||||||
const [deleteDeploymentDialog, setDeleteDeploymentDialog] = useState(false);
|
const [deleteDeploymentDialog, setDeleteDeploymentDialog] = useState(false);
|
||||||
const [isConfirmDeleteLoading, setIsConfirmDeleteLoading] = useState(false);
|
const [isConfirmDeleteLoading, setIsConfirmDeleteLoading] = useState(false);
|
||||||
|
const [isConfirmUpdateLoading, setIsConfirmUpdateLoading] = useState(false);
|
||||||
const [rollbackDeployment, setRollbackDeployment] = useState(false);
|
const [rollbackDeployment, setRollbackDeployment] = useState(false);
|
||||||
const [assignDomainDialog, setAssignDomainDialog] = useState(false);
|
|
||||||
const [isConfirmButtonLoading, setConfirmButtonLoadingLoading] =
|
const [isConfirmButtonLoading, setConfirmButtonLoadingLoading] =
|
||||||
useState(false);
|
useState(false);
|
||||||
|
|
||||||
@ -58,6 +56,8 @@ export const DeploymentMenu = ({
|
|||||||
const isUpdated = await client.updateDeploymentToProd(deployment.id);
|
const isUpdated = await client.updateDeploymentToProd(deployment.id);
|
||||||
if (isUpdated.updateDeploymentToProd) {
|
if (isUpdated.updateDeploymentToProd) {
|
||||||
await onUpdate();
|
await onUpdate();
|
||||||
|
setIsConfirmUpdateLoading(false);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
id: 'deployment_changed_to_production',
|
id: 'deployment_changed_to_production',
|
||||||
title: 'Deployment changed to production',
|
title: 'Deployment changed to production',
|
||||||
@ -102,6 +102,8 @@ export const DeploymentMenu = ({
|
|||||||
);
|
);
|
||||||
if (isRollbacked.rollbackDeployment) {
|
if (isRollbacked.rollbackDeployment) {
|
||||||
await onUpdate();
|
await onUpdate();
|
||||||
|
setIsConfirmUpdateLoading(false);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
id: 'deployment_rolled_back',
|
id: 'deployment_rolled_back',
|
||||||
title: 'Deployment rolled back',
|
title: 'Deployment rolled back',
|
||||||
@ -173,12 +175,6 @@ export const DeploymentMenu = ({
|
|||||||
<LinkIcon /> Visit
|
<LinkIcon /> Visit
|
||||||
</a>
|
</a>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
|
||||||
className="hover:bg-base-bg-emphasized flex items-center gap-3"
|
|
||||||
onClick={() => setAssignDomainDialog(!assignDomainDialog)}
|
|
||||||
>
|
|
||||||
<GlobeIcon /> Assign domain
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
className="hover:bg-base-bg-emphasized flex items-center gap-3"
|
className="hover:bg-base-bg-emphasized flex items-center gap-3"
|
||||||
onClick={() => setChangeToProduction(!changeToProduction)}
|
onClick={() => setChangeToProduction(!changeToProduction)}
|
||||||
@ -226,9 +222,11 @@ export const DeploymentMenu = ({
|
|||||||
handleCancel={() => setChangeToProduction((preVal) => !preVal)}
|
handleCancel={() => setChangeToProduction((preVal) => !preVal)}
|
||||||
open={changeToProduction}
|
open={changeToProduction}
|
||||||
handleConfirm={async () => {
|
handleConfirm={async () => {
|
||||||
|
setIsConfirmUpdateLoading(true);
|
||||||
await updateDeployment();
|
await updateDeployment();
|
||||||
setChangeToProduction((preVal) => !preVal);
|
setChangeToProduction((preVal) => !preVal);
|
||||||
}}
|
}}
|
||||||
|
isConfirmButtonLoading={isConfirmUpdateLoading}
|
||||||
deployment={deployment}
|
deployment={deployment}
|
||||||
domains={prodBranchDomains}
|
domains={prodBranchDomains}
|
||||||
/>
|
/>
|
||||||
@ -243,7 +241,7 @@ export const DeploymentMenu = ({
|
|||||||
setRedeployToProduction((preVal) => !preVal);
|
setRedeployToProduction((preVal) => !preVal);
|
||||||
}}
|
}}
|
||||||
deployment={deployment}
|
deployment={deployment}
|
||||||
domains={deployment.domain ? [deployment.domain] : []}
|
domains={prodBranchDomains}
|
||||||
isConfirmButtonLoading={isConfirmButtonLoading}
|
isConfirmButtonLoading={isConfirmButtonLoading}
|
||||||
/>
|
/>
|
||||||
{Boolean(currentDeployment) && (
|
{Boolean(currentDeployment) && (
|
||||||
@ -253,18 +251,16 @@ export const DeploymentMenu = ({
|
|||||||
open={rollbackDeployment}
|
open={rollbackDeployment}
|
||||||
confirmButtonTitle="Rollback"
|
confirmButtonTitle="Rollback"
|
||||||
handleConfirm={async () => {
|
handleConfirm={async () => {
|
||||||
|
setIsConfirmUpdateLoading(true);
|
||||||
await rollbackDeploymentHandler();
|
await rollbackDeploymentHandler();
|
||||||
setRollbackDeployment((preVal) => !preVal);
|
setRollbackDeployment((preVal) => !preVal);
|
||||||
}}
|
}}
|
||||||
deployment={currentDeployment}
|
deployment={currentDeployment}
|
||||||
newDeployment={deployment}
|
newDeployment={deployment}
|
||||||
domains={currentDeployment.domain ? [currentDeployment.domain] : []}
|
domains={prodBranchDomains}
|
||||||
|
isConfirmButtonLoading={isConfirmUpdateLoading}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<AssignDomainDialog
|
|
||||||
open={assignDomainDialog}
|
|
||||||
handleOpen={() => setAssignDomainDialog(!assignDomainDialog)}
|
|
||||||
/>
|
|
||||||
<DeleteDeploymentDialog
|
<DeleteDeploymentDialog
|
||||||
open={deleteDeploymentDialog}
|
open={deleteDeploymentDialog}
|
||||||
handleConfirm={async () => {
|
handleConfirm={async () => {
|
||||||
|
@ -43,6 +43,11 @@ export const AuctionCard = ({ project }: { project: Project }) => {
|
|||||||
|
|
||||||
const checkAuctionStatus = useCallback(async () => {
|
const checkAuctionStatus = useCallback(async () => {
|
||||||
const result = await client.getAuctionData(project.auctionId);
|
const result = await client.getAuctionData(project.auctionId);
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
setAuctionStatus(result.status);
|
setAuctionStatus(result.status);
|
||||||
setAuctionDetails(result);
|
setAuctionDetails(result);
|
||||||
}, [project.auctionId, project.deployers, project.fundsReleased]);
|
}, [project.auctionId, project.deployers, project.fundsReleased]);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Domain, DomainStatus, Project } from 'gql-client';
|
import { DNSRecordAttributes, Domain, DomainStatus, Project } from 'gql-client';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Typography,
|
Typography,
|
||||||
@ -14,22 +14,27 @@ import EditDomainDialog from './EditDomainDialog';
|
|||||||
import { useGQLClient } from 'context/GQLClientContext';
|
import { useGQLClient } from 'context/GQLClientContext';
|
||||||
import { DeleteDomainDialog } from 'components/projects/Dialog/DeleteDomainDialog';
|
import { DeleteDomainDialog } from 'components/projects/Dialog/DeleteDomainDialog';
|
||||||
import { useToast } from 'components/shared/Toast';
|
import { useToast } from 'components/shared/Toast';
|
||||||
import { Tag } from 'components/shared/Tag';
|
import { GearIcon } from 'components/shared/CustomIcon';
|
||||||
import {
|
|
||||||
CheckIcon,
|
|
||||||
CrossIcon,
|
|
||||||
GearIcon,
|
|
||||||
LoadingIcon,
|
|
||||||
} from 'components/shared/CustomIcon';
|
|
||||||
import { Heading } from 'components/shared/Heading';
|
import { Heading } from 'components/shared/Heading';
|
||||||
import { Button } from 'components/shared/Button';
|
import { Button } from 'components/shared/Button';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
enum RefreshStatus {
|
// NOTE: Commented code for verify domain functionality
|
||||||
IDLE,
|
// import { Tag } from 'components/shared/Tag';
|
||||||
CHECKING,
|
// import {
|
||||||
CHECK_SUCCESS,
|
// CheckIcon,
|
||||||
CHECK_FAIL,
|
// CrossIcon,
|
||||||
}
|
// LoadingIcon,
|
||||||
|
// } from 'components/shared/CustomIcon';
|
||||||
|
|
||||||
|
// enum RefreshStatus {
|
||||||
|
// IDLE,
|
||||||
|
// CHECKING,
|
||||||
|
// CHECK_SUCCESS,
|
||||||
|
// CHECK_FAIL,
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const CHECK_FAIL_TIMEOUT = 5000; // In milliseconds
|
||||||
|
|
||||||
interface DomainCardProps {
|
interface DomainCardProps {
|
||||||
domains: Domain[];
|
domains: Domain[];
|
||||||
@ -39,14 +44,6 @@ interface DomainCardProps {
|
|||||||
onUpdate: () => Promise<void>;
|
onUpdate: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CHECK_FAIL_TIMEOUT = 5000; // In milliseconds
|
|
||||||
|
|
||||||
// TODO: Get domain record
|
|
||||||
const DOMAIN_RECORD = {
|
|
||||||
type: 'A',
|
|
||||||
name: '@',
|
|
||||||
value: '56.49.19.21',
|
|
||||||
};
|
|
||||||
|
|
||||||
const DomainCard = ({
|
const DomainCard = ({
|
||||||
domains,
|
domains,
|
||||||
@ -56,9 +53,11 @@ const DomainCard = ({
|
|||||||
onUpdate,
|
onUpdate,
|
||||||
}: DomainCardProps) => {
|
}: DomainCardProps) => {
|
||||||
const { toast, dismiss } = useToast();
|
const { toast, dismiss } = useToast();
|
||||||
const [refreshStatus, SetRefreshStatus] = useState(RefreshStatus.IDLE);
|
const { id } = useParams();
|
||||||
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
||||||
const [editDialogOpen, setEditDialogOpen] = useState(false);
|
const [editDialogOpen, setEditDialogOpen] = useState(false);
|
||||||
|
const [dnsRecord, setDnsRecord] = useState<DNSRecordAttributes | null>(null);
|
||||||
|
// const [refreshStatus, SetRefreshStatus] = useState(RefreshStatus.IDLE);
|
||||||
|
|
||||||
const client = useGQLClient();
|
const client = useGQLClient();
|
||||||
|
|
||||||
@ -83,13 +82,33 @@ const DomainCard = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchDNSData = async () => {
|
||||||
|
if (id === undefined) {
|
||||||
|
toast({
|
||||||
|
id: 'domain_cannot_find_project',
|
||||||
|
title: 'Cannot find project',
|
||||||
|
variant: 'error',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dnsRecordResponse = await client.getLatestDNSRecordByProjectId(id);
|
||||||
|
|
||||||
|
setDnsRecord(dnsRecordResponse.latestDNSRecord);
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchDNSData();
|
||||||
|
}, [id, client]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex justify-between py-3">
|
<div className="flex justify-between py-3">
|
||||||
<div className="flex justify-start gap-1">
|
<div className="flex justify-start gap-1">
|
||||||
<Heading as="h6" className="flex-col">
|
<Heading as="h6" className="flex-col">
|
||||||
{domain.name}{' '}
|
{domain.name}{' '}
|
||||||
<Tag
|
{/* <Tag
|
||||||
type={
|
type={
|
||||||
domain.status === DomainStatus.Live ? 'positive' : 'negative'
|
domain.status === DomainStatus.Live ? 'positive' : 'negative'
|
||||||
}
|
}
|
||||||
@ -102,12 +121,12 @@ const DomainCard = ({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{domain.status}
|
{domain.status}
|
||||||
</Tag>
|
</Tag> */}
|
||||||
</Heading>
|
</Heading>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-start gap-1">
|
<div className="flex justify-start gap-1">
|
||||||
<i
|
{/* <i
|
||||||
id="refresh"
|
id="refresh"
|
||||||
className="cursor-pointer"
|
className="cursor-pointer"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@ -122,7 +141,7 @@ const DomainCard = ({
|
|||||||
) : (
|
) : (
|
||||||
'L'
|
'L'
|
||||||
)}
|
)}
|
||||||
</i>
|
</i> */}
|
||||||
<Menu placement="bottom-end">
|
<Menu placement="bottom-end">
|
||||||
<MenuHandler>
|
<MenuHandler>
|
||||||
<Button iconOnly>
|
<Button iconOnly>
|
||||||
@ -163,11 +182,11 @@ const DomainCard = ({
|
|||||||
<Typography variant="small">Production</Typography>
|
<Typography variant="small">Production</Typography>
|
||||||
{domain.status === DomainStatus.Pending && (
|
{domain.status === DomainStatus.Pending && (
|
||||||
<Card className="bg-slate-100 p-4 text-sm">
|
<Card className="bg-slate-100 p-4 text-sm">
|
||||||
{refreshStatus === RefreshStatus.IDLE ? (
|
{/* {refreshStatus === RefreshStatus.IDLE ? ( */}
|
||||||
<Heading>
|
<Heading>
|
||||||
^ Add these records to your domain and refresh to check
|
^ Add these records to your domain {/* and refresh to check */}
|
||||||
</Heading>
|
</Heading>
|
||||||
) : refreshStatus === RefreshStatus.CHECKING ? (
|
{/* ) : refreshStatus === RefreshStatus.CHECKING ? (
|
||||||
<Heading className="text-blue-500">
|
<Heading className="text-blue-500">
|
||||||
^ Checking records for {domain.name}
|
^ Checking records for {domain.name}
|
||||||
</Heading>
|
</Heading>
|
||||||
@ -178,7 +197,7 @@ const DomainCard = ({
|
|||||||
hours. Please ensure you added the correct records and refresh.
|
hours. Please ensure you added the correct records and refresh.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@ -189,11 +208,15 @@ const DomainCard = ({
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{dnsRecord ? (
|
||||||
<tr>
|
<tr>
|
||||||
<td>{DOMAIN_RECORD.type}</td>
|
<td>{dnsRecord.resourceType}</td>
|
||||||
<td>{DOMAIN_RECORD.name}</td>
|
<td>@</td>
|
||||||
<td>{DOMAIN_RECORD.value}</td>
|
<td>{dnsRecord.value ?? 'Not Configured'}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
) : (
|
||||||
|
<p className={'text-red-500'}>DNS record data not available</p>
|
||||||
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</Card>
|
</Card>
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
import { useCallback, useEffect, useMemo } from 'react';
|
import {
|
||||||
import { Controller, useForm, SubmitHandler } from 'react-hook-form';
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
} from 'react';
|
||||||
|
import {
|
||||||
|
useForm,
|
||||||
|
SubmitHandler,
|
||||||
|
} from 'react-hook-form';
|
||||||
import { Domain } from 'gql-client';
|
import { Domain } from 'gql-client';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Typography,
|
Typography,
|
||||||
Select,
|
|
||||||
Option,
|
|
||||||
} from '@snowballtools/material-tailwind-react-fork';
|
} from '@snowballtools/material-tailwind-react-fork';
|
||||||
|
|
||||||
import { useGQLClient } from 'context/GQLClientContext';
|
import { useGQLClient } from 'context/GQLClientContext';
|
||||||
@ -14,7 +18,15 @@ import { Button } from 'components/shared/Button';
|
|||||||
import { Input } from 'components/shared/Input';
|
import { Input } from 'components/shared/Input';
|
||||||
import { useToast } from 'components/shared/Toast';
|
import { useToast } from 'components/shared/Toast';
|
||||||
|
|
||||||
const DEFAULT_REDIRECT_OPTIONS = ['none'];
|
// NOTE: Commented code for redirect domain functionality
|
||||||
|
// import {
|
||||||
|
// Select,
|
||||||
|
// Option,
|
||||||
|
// } from '@snowballtools/material-tailwind-react-fork';
|
||||||
|
// import { Controller } from 'react-hook-form';
|
||||||
|
// import { useMemo } from 'react';
|
||||||
|
|
||||||
|
// const DEFAULT_REDIRECT_OPTIONS = ['none'];
|
||||||
|
|
||||||
interface EditDomainDialogProp {
|
interface EditDomainDialogProp {
|
||||||
domains: Domain[];
|
domains: Domain[];
|
||||||
@ -28,7 +40,7 @@ interface EditDomainDialogProp {
|
|||||||
type EditDomainValues = {
|
type EditDomainValues = {
|
||||||
name: string;
|
name: string;
|
||||||
branch: string;
|
branch: string;
|
||||||
redirectedTo: string;
|
// redirectedTo: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const EditDomainDialog = ({
|
const EditDomainDialog = ({
|
||||||
@ -42,58 +54,58 @@ const EditDomainDialog = ({
|
|||||||
const client = useGQLClient();
|
const client = useGQLClient();
|
||||||
const { toast, dismiss } = useToast();
|
const { toast, dismiss } = useToast();
|
||||||
|
|
||||||
const getRedirectUrl = (domain: Domain) => {
|
// const getRedirectUrl = (domain: Domain) => {
|
||||||
const redirectDomain = domain.redirectTo;
|
// const redirectDomain = domain.redirectTo;
|
||||||
|
|
||||||
if (redirectDomain !== null) {
|
// if (redirectDomain !== null) {
|
||||||
return redirectDomain?.name;
|
// return redirectDomain?.name;
|
||||||
} else {
|
// } else {
|
||||||
return 'none';
|
// return 'none';
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
const redirectOptions = useMemo(() => {
|
// const redirectOptions = useMemo(() => {
|
||||||
const domainNames = domains
|
// const domainNames = domains
|
||||||
.filter((domainData) => domainData.id !== domain.id)
|
// .filter((domainData) => domainData.id !== domain.id)
|
||||||
.map((domain) => domain.name);
|
// .map((domain) => domain.name);
|
||||||
return ['none', ...domainNames];
|
// return ['none', ...domainNames];
|
||||||
}, [domain, domains]);
|
// }, [domain, domains]);
|
||||||
|
|
||||||
const domainRedirectedFrom = useMemo(() => {
|
// const domainRedirectedFrom = useMemo(() => {
|
||||||
return domains.find(
|
// return domains.find(
|
||||||
(domainData) => domainData.redirectTo?.id === domain.id,
|
// (domainData) => domainData.redirectTo?.id === domain.id,
|
||||||
);
|
// );
|
||||||
}, [domains, domain]);
|
// }, [domains, domain]);
|
||||||
|
|
||||||
const isDisableDropdown = useMemo(() => {
|
// const isDisableDropdown = useMemo(() => {
|
||||||
return domainRedirectedFrom !== undefined;
|
// return domainRedirectedFrom !== undefined;
|
||||||
}, [domain, domains]);
|
// }, [domain, domains]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
register,
|
register,
|
||||||
control,
|
// control,
|
||||||
watch,
|
// watch,
|
||||||
reset,
|
reset,
|
||||||
formState: { isValid, isDirty },
|
formState: { isValid, isDirty },
|
||||||
} = useForm({
|
} = useForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: domain.name,
|
name: domain.name,
|
||||||
branch: domain.branch,
|
branch: domain.branch,
|
||||||
redirectedTo: getRedirectUrl(domain),
|
// redirectedTo: getRedirectUrl(domain),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateDomainHandler: SubmitHandler<EditDomainValues> = useCallback(
|
const updateDomainHandler: SubmitHandler<EditDomainValues> = useCallback(
|
||||||
async (data) => {
|
async (data) => {
|
||||||
const domainRedirectTo = domains.find(
|
// const domainRedirectTo = domains.find(
|
||||||
(domainData) => data.redirectedTo === domainData.name,
|
// (domainData) => data.redirectedTo === domainData.name,
|
||||||
);
|
// );
|
||||||
|
|
||||||
const updates = {
|
const updates = {
|
||||||
name: data.name ? data.name : domain.name,
|
name: data.name ? data.name : domain.name,
|
||||||
branch: data.branch ? data.branch : domain.branch,
|
branch: data.branch ? data.branch : domain.branch,
|
||||||
redirectToId: domainRedirectTo ? domainRedirectTo.id : null,
|
// redirectToId: domainRedirectTo ? domainRedirectTo.id : null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { updateDomain } = await client.updateDomain(domain.id, updates);
|
const { updateDomain } = await client.updateDomain(domain.id, updates);
|
||||||
@ -125,7 +137,7 @@ const EditDomainDialog = ({
|
|||||||
reset({
|
reset({
|
||||||
name: domain.name,
|
name: domain.name,
|
||||||
branch: domain.branch,
|
branch: domain.branch,
|
||||||
redirectedTo: getRedirectUrl(domain),
|
// redirectedTo: getRedirectUrl(domain),
|
||||||
});
|
});
|
||||||
}, [domain]);
|
}, [domain]);
|
||||||
|
|
||||||
@ -137,7 +149,7 @@ const EditDomainDialog = ({
|
|||||||
<Modal.Body className="flex flex-col gap-2">
|
<Modal.Body className="flex flex-col gap-2">
|
||||||
<Typography variant="small">Domain name</Typography>
|
<Typography variant="small">Domain name</Typography>
|
||||||
<Input {...register('name')} />
|
<Input {...register('name')} />
|
||||||
<Typography variant="small">Redirect to</Typography>
|
{/* <Typography variant="small">Redirect to</Typography>
|
||||||
<Controller
|
<Controller
|
||||||
name="redirectedTo"
|
name="redirectedTo"
|
||||||
control={control}
|
control={control}
|
||||||
@ -161,7 +173,7 @@ const EditDomainDialog = ({
|
|||||||
further.
|
further.
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)} */}
|
||||||
<Typography variant="small">Git branch</Typography>
|
<Typography variant="small">Git branch</Typography>
|
||||||
<Input
|
<Input
|
||||||
{...register('branch', {
|
{...register('branch', {
|
||||||
@ -169,8 +181,8 @@ const EditDomainDialog = ({
|
|||||||
Boolean(branches.length) ? branches.includes(value) : true,
|
Boolean(branches.length) ? branches.includes(value) : true,
|
||||||
})}
|
})}
|
||||||
disabled={
|
disabled={
|
||||||
!Boolean(branches.length) ||
|
!Boolean(branches.length)
|
||||||
watch('redirectedTo') !== DEFAULT_REDIRECT_OPTIONS[0]
|
// || watch('redirectedTo') !== DEFAULT_REDIRECT_OPTIONS[0]
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{!isValid && (
|
{!isValid && (
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
|
|
||||||
import { Heading } from 'components/shared/Heading';
|
import { Heading } from 'components/shared/Heading';
|
||||||
import { InlineNotification } from 'components/shared/InlineNotification';
|
|
||||||
import { Input } from 'components/shared/Input';
|
import { Input } from 'components/shared/Input';
|
||||||
import { Button } from 'components/shared/Button';
|
import { Button } from 'components/shared/Button';
|
||||||
import { Radio } from 'components/shared/Radio';
|
|
||||||
|
// NOTE: Commented code for redirect domain functionality
|
||||||
|
// import { useEffect, useState } from 'react';
|
||||||
|
// import { InlineNotification } from 'components/shared/InlineNotification';
|
||||||
|
// import { Radio } from 'components/shared/Radio';
|
||||||
|
|
||||||
interface SetupDomainFormValues {
|
interface SetupDomainFormValues {
|
||||||
domainName: string;
|
domainName: string;
|
||||||
@ -18,47 +20,45 @@ const SetupDomain = () => {
|
|||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { isValid },
|
formState: { isValid },
|
||||||
watch,
|
// watch,
|
||||||
setValue,
|
// setValue,
|
||||||
} = useForm<SetupDomainFormValues>({
|
} = useForm<SetupDomainFormValues>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
domainName: '',
|
domainName: '',
|
||||||
isWWW: 'false',
|
// isWWW: 'false',
|
||||||
},
|
},
|
||||||
mode: 'onChange',
|
mode: 'onChange',
|
||||||
});
|
});
|
||||||
|
|
||||||
const [domainStr, setDomainStr] = useState<string>('');
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const isWWWRadioOptions = [
|
// const [domainStr, setDomainStr] = useState<string>('');
|
||||||
{ label: domainStr, value: 'false' },
|
// const isWWWRadioOptions = [
|
||||||
{ label: `www.${domainStr}`, value: 'true' },
|
// { label: domainStr, value: 'false' },
|
||||||
];
|
// { label: `www.${domainStr}`, value: 'true' },
|
||||||
|
// ];
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
const subscription = watch((value, { name }) => {
|
// const subscription = watch((value, { name }) => {
|
||||||
if (name === 'domainName' && value.domainName) {
|
// if (name === 'domainName' && value.domainName) {
|
||||||
const domainArr = value.domainName.split('www.');
|
// const domainArr = value.domainName.split('www.');
|
||||||
const cleanedDomain =
|
// const cleanedDomain =
|
||||||
domainArr.length > 1 ? domainArr[1] : domainArr[0];
|
// domainArr.length > 1 ? domainArr[1] : domainArr[0];
|
||||||
setDomainStr(cleanedDomain);
|
// setDomainStr(cleanedDomain);
|
||||||
|
|
||||||
setValue(
|
// setValue(
|
||||||
'isWWW',
|
// 'isWWW',
|
||||||
value.domainName.startsWith('www.') ? 'true' : 'false',
|
// value.domainName.startsWith('www.') ? 'true' : 'false',
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
return () => subscription.unsubscribe();
|
// return () => subscription.unsubscribe();
|
||||||
}, [watch, setValue]);
|
// }, [watch, setValue]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form
|
<form
|
||||||
onSubmit={handleSubmit(() => {
|
onSubmit={handleSubmit((e) => {
|
||||||
watch('isWWW') === 'true'
|
navigate(`config?name=${e.domainName}`)
|
||||||
? navigate(`config?name=www.${domainStr}`)
|
|
||||||
: navigate(`config?name=${domainStr}`);
|
|
||||||
})}
|
})}
|
||||||
className="flex flex-col gap-6 w-full"
|
className="flex flex-col gap-6 w-full"
|
||||||
>
|
>
|
||||||
@ -67,7 +67,7 @@ const SetupDomain = () => {
|
|||||||
Setup domain name
|
Setup domain name
|
||||||
</Heading>
|
</Heading>
|
||||||
<p className="text-slate-500 text-sm font-normal leading-tight">
|
<p className="text-slate-500 text-sm font-normal leading-tight">
|
||||||
Add your domain and setup redirects
|
Add your domain {/* and setup redirects */}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ const SetupDomain = () => {
|
|||||||
label="Domain name"
|
label="Domain name"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{isValid && (
|
{/* {isValid && (
|
||||||
<div className="self-stretch flex flex-col gap-4">
|
<div className="self-stretch flex flex-col gap-4">
|
||||||
<Heading className="text-sky-950 text-lg font-medium leading-normal">
|
<Heading className="text-sky-950 text-lg font-medium leading-normal">
|
||||||
Primary domain
|
Primary domain
|
||||||
@ -99,7 +99,7 @@ const SetupDomain = () => {
|
|||||||
}. Redirect preferences can be changed later`}
|
}. Redirect preferences can be changed later`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
<div className="self-stretch">
|
<div className="self-stretch">
|
||||||
<Button disabled={!isValid} type="submit" shape="default">
|
<Button disabled={!isValid} type="submit" shape="default">
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { User } from 'gql-client';
|
import { User } from 'gql-client';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { useDisconnect } from 'wagmi';
|
|
||||||
|
|
||||||
import { useGQLClient } from 'context/GQLClientContext';
|
import { useGQLClient } from 'context/GQLClientContext';
|
||||||
import {
|
import {
|
||||||
GlobeIcon,
|
|
||||||
LifeBuoyIcon,
|
LifeBuoyIcon,
|
||||||
LogoutIcon,
|
|
||||||
QuestionMarkRoundIcon,
|
QuestionMarkRoundIcon,
|
||||||
} from 'components/shared/CustomIcon';
|
} from 'components/shared/CustomIcon';
|
||||||
import { Tabs } from 'components/shared/Tabs';
|
import { Tabs } from 'components/shared/Tabs';
|
||||||
@ -16,10 +13,9 @@ import { Logo } from 'components/Logo';
|
|||||||
import { Avatar } from 'components/shared/Avatar';
|
import { Avatar } from 'components/shared/Avatar';
|
||||||
import { formatAddress } from 'utils/format';
|
import { formatAddress } from 'utils/format';
|
||||||
import { getInitials } from 'utils/geInitials';
|
import { getInitials } from 'utils/geInitials';
|
||||||
import { Button } from 'components/shared/Button';
|
|
||||||
import { cn } from 'utils/classnames';
|
import { cn } from 'utils/classnames';
|
||||||
import { useMediaQuery } from 'usehooks-ts';
|
import { useMediaQuery } from 'usehooks-ts';
|
||||||
import { BASE_URL } from 'utils/constants';
|
import { SHOPIFY_APP_URL } from '../../../constants';
|
||||||
|
|
||||||
interface SidebarProps {
|
interface SidebarProps {
|
||||||
mobileOpen?: boolean;
|
mobileOpen?: boolean;
|
||||||
@ -27,12 +23,10 @@ interface SidebarProps {
|
|||||||
|
|
||||||
export const Sidebar = ({ mobileOpen }: SidebarProps) => {
|
export const Sidebar = ({ mobileOpen }: SidebarProps) => {
|
||||||
const { orgSlug } = useParams();
|
const { orgSlug } = useParams();
|
||||||
const navigate = useNavigate();
|
|
||||||
const client = useGQLClient();
|
const client = useGQLClient();
|
||||||
const isDesktop = useMediaQuery('(min-width: 960px)');
|
const isDesktop = useMediaQuery('(min-width: 960px)');
|
||||||
|
|
||||||
const [user, setUser] = useState<User>();
|
const [user, setUser] = useState<User>();
|
||||||
const { disconnect } = useDisconnect();
|
|
||||||
|
|
||||||
const fetchUser = useCallback(async () => {
|
const fetchUser = useCallback(async () => {
|
||||||
const { user } = await client.getUser();
|
const { user } = await client.getUser();
|
||||||
@ -43,16 +37,6 @@ export const Sidebar = ({ mobileOpen }: SidebarProps) => {
|
|||||||
fetchUser();
|
fetchUser();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleLogOut = useCallback(async () => {
|
|
||||||
await fetch(`${BASE_URL}/auth/logout`, {
|
|
||||||
method: 'POST',
|
|
||||||
credentials: 'include',
|
|
||||||
});
|
|
||||||
localStorage.clear();
|
|
||||||
disconnect();
|
|
||||||
navigate('/login');
|
|
||||||
}, [disconnect, navigate]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.nav
|
<motion.nav
|
||||||
initial={{ x: -320 }}
|
initial={{ x: -320 }}
|
||||||
@ -82,19 +66,10 @@ export const Sidebar = ({ mobileOpen }: SidebarProps) => {
|
|||||||
<Tabs defaultValue="Projects" orientation="vertical">
|
<Tabs defaultValue="Projects" orientation="vertical">
|
||||||
{/* // TODO: use proper link buttons */}
|
{/* // TODO: use proper link buttons */}
|
||||||
<Tabs.List>
|
<Tabs.List>
|
||||||
<Tabs.Trigger
|
|
||||||
icon={<GlobeIcon />}
|
|
||||||
value=""
|
|
||||||
className="hidden lg:flex"
|
|
||||||
>
|
|
||||||
<a className="cursor-pointer font-mono" onClick={handleLogOut}>
|
|
||||||
LOG OUT
|
|
||||||
</a>
|
|
||||||
</Tabs.Trigger>
|
|
||||||
<Tabs.Trigger icon={<QuestionMarkRoundIcon />} value="">
|
<Tabs.Trigger icon={<QuestionMarkRoundIcon />} value="">
|
||||||
<a
|
<a
|
||||||
className="cursor-pointer font-mono"
|
className="cursor-pointer font-mono"
|
||||||
href="https://store.laconic.com/pages/instruction-faq"
|
href={`${SHOPIFY_APP_URL}/pages/instruction-faq`}
|
||||||
>
|
>
|
||||||
DOCUMENTATION
|
DOCUMENTATION
|
||||||
</a>
|
</a>
|
||||||
@ -125,14 +100,6 @@ export const Sidebar = ({ mobileOpen }: SidebarProps) => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Button
|
|
||||||
iconOnly
|
|
||||||
variant="ghost"
|
|
||||||
className="text-elements-low-em"
|
|
||||||
onClick={handleLogOut}
|
|
||||||
>
|
|
||||||
<LogoutIcon />
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</motion.nav>
|
</motion.nav>
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,155 @@
|
|||||||
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
import { generateNonce, SiweMessage } from 'siwe';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { Box, Modal } from '@mui/material';
|
||||||
|
|
||||||
|
import { BASE_URL, VITE_WALLET_IFRAME_URL } from 'utils/constants';
|
||||||
|
import { REQUEST_CREATE_OR_GET_ACCOUNTS, WALLET_ACCOUNTS_DATA } from '../../../constants';
|
||||||
|
|
||||||
|
const axiosInstance = axios.create({
|
||||||
|
baseURL: BASE_URL,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
},
|
||||||
|
withCredentials: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const AutoSignInIFrameModal = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const [accountAddress, setAccountAddress] = useState();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleSignInResponse = async (event: MessageEvent) => {
|
||||||
|
if (event.origin !== VITE_WALLET_IFRAME_URL) return;
|
||||||
|
|
||||||
|
if (event.data.type === 'SIGN_IN_RESPONSE') {
|
||||||
|
try {
|
||||||
|
const { success } = (
|
||||||
|
await axiosInstance.post('/auth/validate', {
|
||||||
|
message: event.data.data.message,
|
||||||
|
signature: event.data.data.signature,
|
||||||
|
})
|
||||||
|
).data;
|
||||||
|
|
||||||
|
if (success === true) {
|
||||||
|
navigate('/');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error signing in:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('message', handleSignInResponse);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('message', handleSignInResponse);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const initiateAutoSignIn = async () => {
|
||||||
|
if (!accountAddress) return;
|
||||||
|
|
||||||
|
const iframe = document.getElementById(
|
||||||
|
'autoSignInFrame',
|
||||||
|
) as HTMLIFrameElement;
|
||||||
|
|
||||||
|
if (!iframe.contentWindow) {
|
||||||
|
console.error('Iframe not found or not loaded');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = new SiweMessage({
|
||||||
|
version: '1',
|
||||||
|
domain: window.location.host,
|
||||||
|
uri: window.location.origin,
|
||||||
|
chainId: 1,
|
||||||
|
address: accountAddress,
|
||||||
|
nonce: generateNonce(),
|
||||||
|
// Human-readable ASCII assertion that the user will sign, and it must not contain `\n`.
|
||||||
|
statement: 'Sign in With Ethereum.',
|
||||||
|
}).prepareMessage();
|
||||||
|
|
||||||
|
iframe.contentWindow.postMessage(
|
||||||
|
{
|
||||||
|
type: 'AUTO_SIGN_IN',
|
||||||
|
chainId: '1',
|
||||||
|
message,
|
||||||
|
},
|
||||||
|
VITE_WALLET_IFRAME_URL,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
initiateAutoSignIn();
|
||||||
|
}, [accountAddress]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleAccountsDataResponse = async (event: MessageEvent) => {
|
||||||
|
if (event.origin !== VITE_WALLET_IFRAME_URL) return;
|
||||||
|
|
||||||
|
if (event.data.type === WALLET_ACCOUNTS_DATA) {
|
||||||
|
setAccountAddress(event.data.data[0]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('message', handleAccountsDataResponse);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('message', handleAccountsDataResponse);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const getAddressFromWallet = useCallback(() => {
|
||||||
|
const iframe = document.getElementById(
|
||||||
|
'autoSignInFrame',
|
||||||
|
) as HTMLIFrameElement;
|
||||||
|
|
||||||
|
if (!iframe.contentWindow) {
|
||||||
|
console.error('Iframe not found or not loaded');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe.contentWindow.postMessage(
|
||||||
|
{
|
||||||
|
type: REQUEST_CREATE_OR_GET_ACCOUNTS,
|
||||||
|
chainId: '1',
|
||||||
|
},
|
||||||
|
VITE_WALLET_IFRAME_URL,
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal open={true} disableEscapeKeyDown keepMounted>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: '50%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
width: '90%',
|
||||||
|
maxWidth: '1200px',
|
||||||
|
height: '600px',
|
||||||
|
maxHeight: '80vh',
|
||||||
|
overflow: 'auto',
|
||||||
|
outline: 'none',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<iframe
|
||||||
|
onLoad={getAddressFromWallet}
|
||||||
|
id="autoSignInFrame"
|
||||||
|
src={`${VITE_WALLET_IFRAME_URL}/auto-sign-in`}
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
sandbox="allow-scripts allow-same-origin"
|
||||||
|
></iframe>
|
||||||
|
</Box>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AutoSignInIFrameModal;
|
@ -1,3 +1,16 @@
|
|||||||
export const SHORT_COMMIT_HASH_LENGTH = 8;
|
export const SHORT_COMMIT_HASH_LENGTH = 8;
|
||||||
|
|
||||||
export const SERVER_GQL_PATH = 'graphql';
|
export const SERVER_GQL_PATH = 'graphql';
|
||||||
|
|
||||||
|
export const SHOPIFY_APP_URL = 'https://store.laconic.com';
|
||||||
|
|
||||||
|
// iframe request types
|
||||||
|
export const REQUEST_CREATE_OR_GET_ACCOUNTS = 'REQUEST_CREATE_OR_GET_ACCOUNTS';
|
||||||
|
export const REQUEST_ADD_NETWORK = 'REQUEST_ADD_NETWORK';
|
||||||
|
export const REQUEST_WALLET_ACCOUNTS = 'REQUEST_WALLET_ACCOUNTS';
|
||||||
|
|
||||||
|
// iframe response types
|
||||||
|
export const WALLET_ACCOUNTS_DATA = 'WALLET_ACCOUNTS_DATA';
|
||||||
|
export const NETWORK_ADDED_RESPONSE = "NETWORK_ADDED_RESPONSE";
|
||||||
|
export const NETWORK_ALREADY_EXISTS_RESPONSE = "NETWORK_ALREADY_EXISTS_RESPONSE";
|
||||||
|
export const NETWORK_ADD_FAILED_RESPONSE = "NETWORK_ADD_FAILED_RESPONSE";
|
||||||
|
@ -1,116 +0,0 @@
|
|||||||
import { ReactNode } from 'react';
|
|
||||||
import assert from 'assert';
|
|
||||||
import { SiweMessage, generateNonce } from 'siwe';
|
|
||||||
import { WagmiProvider } from 'wagmi';
|
|
||||||
import { mainnet } from 'wagmi/chains';
|
|
||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
import { createWeb3Modal } from '@web3modal/wagmi/react';
|
|
||||||
import { defaultWagmiConfig } from '@web3modal/wagmi/react/config';
|
|
||||||
import { createSIWEConfig } from '@web3modal/siwe';
|
|
||||||
import type {
|
|
||||||
SIWECreateMessageArgs,
|
|
||||||
SIWEVerifyMessageArgs,
|
|
||||||
} from '@web3modal/core';
|
|
||||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
||||||
|
|
||||||
import { VITE_WALLET_CONNECT_ID, BASE_URL } from 'utils/constants';
|
|
||||||
|
|
||||||
if (!VITE_WALLET_CONNECT_ID) {
|
|
||||||
throw new Error('Error: VITE_WALLET_CONNECT_ID env config is not set');
|
|
||||||
}
|
|
||||||
assert(BASE_URL, 'VITE_SERVER_URL is not set in env');
|
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
|
||||||
const axiosInstance = axios.create({
|
|
||||||
baseURL: BASE_URL,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
},
|
|
||||||
withCredentials: true,
|
|
||||||
});
|
|
||||||
const metadata = {
|
|
||||||
name: 'Deploy App Auth',
|
|
||||||
description: '',
|
|
||||||
url: window.location.origin,
|
|
||||||
icons: ['https://avatars.githubusercontent.com/u/37784886'],
|
|
||||||
};
|
|
||||||
const chains = [mainnet] as const;
|
|
||||||
const config = defaultWagmiConfig({
|
|
||||||
chains,
|
|
||||||
projectId: VITE_WALLET_CONNECT_ID,
|
|
||||||
metadata,
|
|
||||||
});
|
|
||||||
const siweConfig = createSIWEConfig({
|
|
||||||
createMessage: ({ nonce, address, chainId }: SIWECreateMessageArgs) =>
|
|
||||||
new SiweMessage({
|
|
||||||
version: '1',
|
|
||||||
domain: window.location.host,
|
|
||||||
uri: window.location.origin,
|
|
||||||
address,
|
|
||||||
chainId,
|
|
||||||
nonce,
|
|
||||||
// Human-readable ASCII assertion that the user will sign, and it must not contain `\n`.
|
|
||||||
statement: 'Sign in With Ethereum.',
|
|
||||||
}).prepareMessage(),
|
|
||||||
getNonce: async () => {
|
|
||||||
return generateNonce();
|
|
||||||
},
|
|
||||||
getSession: async () => {
|
|
||||||
try {
|
|
||||||
const session = (await axiosInstance.get('/auth/session')).data;
|
|
||||||
const { address, chainId } = session;
|
|
||||||
return { address, chainId };
|
|
||||||
} catch (err) {
|
|
||||||
if (window.location.pathname !== '/login') {
|
|
||||||
window.location.href = '/login';
|
|
||||||
}
|
|
||||||
throw new Error('Failed to get session!');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
verifyMessage: async ({ message, signature }: SIWEVerifyMessageArgs) => {
|
|
||||||
try {
|
|
||||||
const { success } = (
|
|
||||||
await axiosInstance.post('/auth/validate', {
|
|
||||||
message,
|
|
||||||
signature,
|
|
||||||
})
|
|
||||||
).data;
|
|
||||||
return success;
|
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
signOut: async () => {
|
|
||||||
try {
|
|
||||||
const { success } = (await axiosInstance.post('/auth/logout')).data;
|
|
||||||
return success;
|
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onSignOut: () => {
|
|
||||||
window.location.href = '/login';
|
|
||||||
},
|
|
||||||
onSignIn: () => {
|
|
||||||
window.location.href = '/';
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
createWeb3Modal({
|
|
||||||
siweConfig,
|
|
||||||
wagmiConfig: config,
|
|
||||||
projectId: VITE_WALLET_CONNECT_ID,
|
|
||||||
});
|
|
||||||
export default function Web3ModalProvider({
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<WagmiProvider config={config}>
|
|
||||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
||||||
</WagmiProvider>
|
|
||||||
);
|
|
||||||
}
|
|
92
packages/frontend/src/hooks/useAddNetwork.ts
Normal file
92
packages/frontend/src/hooks/useAddNetwork.ts
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
import { VITE_WALLET_IFRAME_URL } from 'utils/constants';
|
||||||
|
import { NETWORK_ADD_FAILED_RESPONSE, NETWORK_ADDED_RESPONSE, NETWORK_ALREADY_EXISTS_RESPONSE, REQUEST_ADD_NETWORK } from '../constants';
|
||||||
|
|
||||||
|
interface NetworkData {
|
||||||
|
chainId: string;
|
||||||
|
namespace: string;
|
||||||
|
networkName: string;
|
||||||
|
rpcUrl: string;
|
||||||
|
coinType: string;
|
||||||
|
addressPrefix?: string;
|
||||||
|
blockExplorerUrl?: string;
|
||||||
|
nativeDenom?: string;
|
||||||
|
gasPrice?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useAddNetwork = () => {
|
||||||
|
const [networkData, setNetworkData] = useState<NetworkData | null>(null);
|
||||||
|
const [iframe, setIframe] = useState<HTMLIFrameElement | null>(null);
|
||||||
|
const [isNetworkAvailable, setIsNetworkAvailable] = useState(false);
|
||||||
|
|
||||||
|
// useEffect to add network in embedded wallet
|
||||||
|
useEffect(() => {
|
||||||
|
if (!networkData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!iframe?.contentWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe.contentWindow.postMessage(
|
||||||
|
{
|
||||||
|
type: REQUEST_ADD_NETWORK,
|
||||||
|
chainId: networkData.chainId,
|
||||||
|
networkData,
|
||||||
|
},
|
||||||
|
VITE_WALLET_IFRAME_URL,
|
||||||
|
);
|
||||||
|
}, [networkData, iframe]);
|
||||||
|
|
||||||
|
// useEffect to listen for network add reponses
|
||||||
|
useEffect(() => {
|
||||||
|
const handleMessage = (event: MessageEvent) => {
|
||||||
|
if (event.origin !== VITE_WALLET_IFRAME_URL) return;
|
||||||
|
|
||||||
|
switch (event.data.type) {
|
||||||
|
case NETWORK_ADDED_RESPONSE:
|
||||||
|
case NETWORK_ALREADY_EXISTS_RESPONSE:
|
||||||
|
// Once network is available, set state
|
||||||
|
setIsNetworkAvailable(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NETWORK_ADD_FAILED_RESPONSE:
|
||||||
|
setIsNetworkAvailable(false);
|
||||||
|
console.error("Network could not be added:", event.data.message);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('message', handleMessage);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('message', handleMessage);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadNetworkData = async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetch('/network.json');
|
||||||
|
const json = await res.json();
|
||||||
|
|
||||||
|
setNetworkData(json);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to load network data:', err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
loadNetworkData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
networkData,
|
||||||
|
isNetworkAvailable,
|
||||||
|
iframe,
|
||||||
|
setIframe
|
||||||
|
};
|
||||||
|
};
|
50
packages/frontend/src/hooks/useCheckBalance.tsx
Normal file
50
packages/frontend/src/hooks/useCheckBalance.tsx
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import { useState, useEffect, useCallback } from 'react';
|
||||||
|
|
||||||
|
import { useAddNetwork } from './useAddNetwork';
|
||||||
|
|
||||||
|
const useCheckBalance = (amount: string, iframeId: string) => {
|
||||||
|
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>();
|
||||||
|
|
||||||
|
const { networkData } = useAddNetwork()
|
||||||
|
|
||||||
|
const checkBalance = useCallback(() => {
|
||||||
|
if (!networkData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const iframe = document.getElementById(iframeId) as HTMLIFrameElement;
|
||||||
|
|
||||||
|
if (!iframe || !iframe.contentWindow) {
|
||||||
|
console.error(`Iframe with ID "${iframeId}" not found or not loaded`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe.contentWindow.postMessage(
|
||||||
|
{
|
||||||
|
type: 'CHECK_BALANCE',
|
||||||
|
chainId: networkData.chainId,
|
||||||
|
amount,
|
||||||
|
},
|
||||||
|
import.meta.env.VITE_WALLET_IFRAME_URL
|
||||||
|
);
|
||||||
|
}, [iframeId, amount, networkData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleMessage = (event: MessageEvent) => {
|
||||||
|
if (event.origin !== import.meta.env.VITE_WALLET_IFRAME_URL) return;
|
||||||
|
|
||||||
|
if (event.data.type !== 'IS_SUFFICIENT') return;
|
||||||
|
|
||||||
|
setIsBalanceSufficient(event.data.data);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('message', handleMessage);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('message', handleMessage);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return { isBalanceSufficient, checkBalance };
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useCheckBalance;
|
@ -14,7 +14,6 @@ import { SERVER_GQL_PATH } from './constants';
|
|||||||
import { Toaster } from 'components/shared/Toast';
|
import { Toaster } from 'components/shared/Toast';
|
||||||
import { LogErrorBoundary } from 'utils/log-error';
|
import { LogErrorBoundary } from 'utils/log-error';
|
||||||
import { BASE_URL } from 'utils/constants';
|
import { BASE_URL } from 'utils/constants';
|
||||||
import Web3ModalProvider from './context/Web3Provider';
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
console.log(`v-0.0.9`);
|
console.log(`v-0.0.9`);
|
||||||
@ -32,12 +31,10 @@ root.render(
|
|||||||
<LogErrorBoundary>
|
<LogErrorBoundary>
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
<Web3ModalProvider>
|
|
||||||
<GQLClientProvider client={gqlClient}>
|
<GQLClientProvider client={gqlClient}>
|
||||||
<App />
|
<App />
|
||||||
<Toaster />
|
<Toaster />
|
||||||
</GQLClientProvider>
|
</GQLClientProvider>
|
||||||
</Web3ModalProvider>
|
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</React.StrictMode>
|
</React.StrictMode>
|
||||||
</LogErrorBoundary>,
|
</LogErrorBoundary>,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Login } from './auth/Login';
|
import AutoSignInIFrameModal from 'components/shared/auth/AutoSignInIFrameModal';
|
||||||
|
|
||||||
const AuthPage = () => {
|
const AuthPage = () => {
|
||||||
return (
|
return (
|
||||||
@ -13,9 +13,7 @@ const AuthPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="pb-12 relative z-10 flex-1 flex-center">
|
<div className="pb-12 relative z-10 flex-1 flex-center">
|
||||||
<div className="max-w-[520px] w-full dark:bg-overlay bg-white rounded-xl shadow">
|
<AutoSignInIFrameModal />
|
||||||
<Login />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
38
packages/frontend/src/pages/BuyPrepaidService.tsx
Normal file
38
packages/frontend/src/pages/BuyPrepaidService.tsx
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { useMediaQuery } from 'usehooks-ts';
|
||||||
|
|
||||||
|
import { Button } from 'components/shared';
|
||||||
|
import CheckBalanceIframe from 'components/projects/create/CheckBalanceIframe';
|
||||||
|
import { SHOPIFY_APP_URL } from '../constants';
|
||||||
|
|
||||||
|
const BuyPrepaidService = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>();
|
||||||
|
|
||||||
|
const isTabletView = useMediaQuery('(min-width: 720px)'); // md:
|
||||||
|
const buttonSize = isTabletView ? { size: 'lg' as const } : {};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isBalanceSufficient === true) {
|
||||||
|
navigate('/');
|
||||||
|
}
|
||||||
|
}, [isBalanceSufficient]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="dark:bg-background flex flex-col min-h-screen">
|
||||||
|
<div className="pb-12 relative z-10 flex-1 flex-center">
|
||||||
|
<Button {...buttonSize} shape={'default'}>
|
||||||
|
<a href={SHOPIFY_APP_URL} target="_blank">
|
||||||
|
Buy prepaid service
|
||||||
|
</a>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<CheckBalanceIframe onBalanceChange={setIsBalanceSufficient} isPollingEnabled={true} amount='1'/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BuyPrepaidService;
|
@ -9,12 +9,6 @@ export const Login = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<WavyBorder className="self-stretch" variant="stroke" />
|
<WavyBorder className="self-stretch" variant="stroke" />
|
||||||
|
|
||||||
<div className="self-stretch p-4 xs:p-6 flex-col justify-center items-center gap-8 flex">
|
|
||||||
<div className="self-stretch flex-col justify-center items-center gap-3 flex">
|
|
||||||
<w3m-button />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,7 @@ import { DeleteVariableDialog } from 'components/projects/Dialog/DeleteVariableD
|
|||||||
import { DeleteDomainDialog } from 'components/projects/Dialog/DeleteDomainDialog';
|
import { DeleteDomainDialog } from 'components/projects/Dialog/DeleteDomainDialog';
|
||||||
import { CancelDeploymentDialog } from 'components/projects/Dialog/CancelDeploymentDialog';
|
import { CancelDeploymentDialog } from 'components/projects/Dialog/CancelDeploymentDialog';
|
||||||
import {
|
import {
|
||||||
|
AppDeploymentRecordAttributes,
|
||||||
Deployment,
|
Deployment,
|
||||||
DeploymentStatus,
|
DeploymentStatus,
|
||||||
Domain,
|
Domain,
|
||||||
@ -20,15 +21,6 @@ import { ChangeStateToProductionDialog } from 'components/projects/Dialog/Change
|
|||||||
|
|
||||||
const deployment: Deployment = {
|
const deployment: Deployment = {
|
||||||
id: '1',
|
id: '1',
|
||||||
domain: {
|
|
||||||
id: 'domain1',
|
|
||||||
branch: 'main',
|
|
||||||
name: 'example.com',
|
|
||||||
status: DomainStatus.Live,
|
|
||||||
redirectTo: null,
|
|
||||||
createdAt: '1677609600', // 2023-02-25T12:00:00Z
|
|
||||||
updatedAt: '1677613200', // 2023-02-25T13:00:00Z
|
|
||||||
},
|
|
||||||
branch: 'main',
|
branch: 'main',
|
||||||
commitHash: 'a1b2c3d',
|
commitHash: 'a1b2c3d',
|
||||||
commitMessage:
|
commitMessage:
|
||||||
@ -57,6 +49,7 @@ const deployment: Deployment = {
|
|||||||
updatedAt: '1677680400', // 2023-03-01T13:00:00Z
|
updatedAt: '1677680400', // 2023-03-01T13:00:00Z
|
||||||
applicationDeploymentRequestId:
|
applicationDeploymentRequestId:
|
||||||
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
||||||
|
applicationDeploymentRecordData: {} as AppDeploymentRecordAttributes,
|
||||||
};
|
};
|
||||||
|
|
||||||
const domains: Domain[] = [
|
const domains: Domain[] = [
|
||||||
@ -252,7 +245,7 @@ const ModalsPage: React.FC = () => {
|
|||||||
setRedeployToProduction((preVal) => !preVal)
|
setRedeployToProduction((preVal) => !preVal)
|
||||||
}
|
}
|
||||||
deployment={deployment}
|
deployment={deployment}
|
||||||
domains={deployment.domain ? [deployment.domain] : []}
|
domains={domains}
|
||||||
/>
|
/>
|
||||||
{/* Rollback to this deployment */}
|
{/* Rollback to this deployment */}
|
||||||
<Button onClick={() => setRollbackDeployment(true)}>
|
<Button onClick={() => setRollbackDeployment(true)}>
|
||||||
@ -268,7 +261,7 @@ const ModalsPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
deployment={deployment}
|
deployment={deployment}
|
||||||
newDeployment={deployment}
|
newDeployment={deployment}
|
||||||
domains={deployment.domain ? [deployment.domain] : []}
|
domains={domains}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { Link, useParams } from 'react-router-dom';
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { ProjectCard } from 'components/projects/ProjectCard';
|
import { ProjectCard } from 'components/projects/ProjectCard';
|
||||||
import { Heading, Badge, Button } from 'components/shared';
|
import { Heading, Badge, Button } from 'components/shared';
|
||||||
import { PlusIcon } from 'components/shared/CustomIcon';
|
import { PlusIcon } from 'components/shared/CustomIcon';
|
||||||
import { useGQLClient } from 'context/GQLClientContext';
|
import { useGQLClient } from 'context/GQLClientContext';
|
||||||
import { Project } from 'gql-client';
|
import { Project } from 'gql-client';
|
||||||
|
import CheckBalanceIframe from 'components/projects/create/CheckBalanceIframe';
|
||||||
|
|
||||||
const Projects = () => {
|
const Projects = () => {
|
||||||
|
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>();
|
||||||
|
const [projects, setProjects] = useState<Project[]>([]);
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
const client = useGQLClient();
|
const client = useGQLClient();
|
||||||
const { orgSlug } = useParams();
|
const { orgSlug } = useParams();
|
||||||
const [projects, setProjects] = useState<Project[]>([]);
|
|
||||||
|
|
||||||
const fetchProjects = useCallback(async () => {
|
const fetchProjects = useCallback(async () => {
|
||||||
const { projectsInOrganization } = await client.getProjectsInOrganization(
|
const { projectsInOrganization } = await client.getProjectsInOrganization(
|
||||||
@ -23,6 +27,12 @@ const Projects = () => {
|
|||||||
fetchProjects();
|
fetchProjects();
|
||||||
}, [orgSlug]);
|
}, [orgSlug]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isBalanceSufficient === false) {
|
||||||
|
navigate('/buy-prepaid-service');
|
||||||
|
}
|
||||||
|
}, [isBalanceSufficient]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="px-4 md:px-6 py-6 flex flex-col gap-6">
|
<section className="px-4 md:px-6 py-6 flex flex-col gap-6">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
@ -49,6 +59,8 @@ const Projects = () => {
|
|||||||
return <ProjectCard project={project} key={key} />;
|
return <ProjectCard project={project} key={key} />;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<CheckBalanceIframe onBalanceChange={setIsBalanceSufficient} isPollingEnabled={false} amount='1' />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,39 +1,54 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Link, useNavigate, useOutletContext } from 'react-router-dom';
|
import {
|
||||||
|
Link,
|
||||||
|
useOutletContext,
|
||||||
|
} from 'react-router-dom';
|
||||||
import { RequestError } from 'octokit';
|
import { RequestError } from 'octokit';
|
||||||
|
|
||||||
import { useOctokit } from 'context/OctokitContext';
|
import {
|
||||||
import { GitCommitWithBranch, OutletContextType } from '../../../../types';
|
Heading,
|
||||||
import { useGQLClient } from 'context/GQLClientContext';
|
Avatar,
|
||||||
import { Button, Heading, Avatar, Tag } from 'components/shared';
|
} from 'components/shared';
|
||||||
import { getInitials } from 'utils/geInitials';
|
|
||||||
import {
|
import {
|
||||||
BranchStrokeIcon,
|
BranchStrokeIcon,
|
||||||
CheckRoundFilledIcon,
|
|
||||||
ClockIcon,
|
|
||||||
CursorBoxIcon,
|
CursorBoxIcon,
|
||||||
GithubStrokeIcon,
|
GithubStrokeIcon,
|
||||||
GlobeIcon,
|
|
||||||
LinkIcon,
|
LinkIcon,
|
||||||
CalendarDaysIcon,
|
CalendarDaysIcon,
|
||||||
} from 'components/shared/CustomIcon';
|
} from 'components/shared/CustomIcon';
|
||||||
|
import { useOctokit } from 'context/OctokitContext';
|
||||||
|
import { GitCommitWithBranch, OutletContextType } from '../../../../types';
|
||||||
|
import { getInitials } from 'utils/geInitials';
|
||||||
import { Activity } from 'components/projects/project/overview/Activity';
|
import { Activity } from 'components/projects/project/overview/Activity';
|
||||||
import { OverviewInfo } from 'components/projects/project/overview/OverviewInfo';
|
import { OverviewInfo } from 'components/projects/project/overview/OverviewInfo';
|
||||||
import { relativeTimeMs } from 'utils/time';
|
import { relativeTimeMs } from 'utils/time';
|
||||||
import { Domain, DomainStatus } from 'gql-client';
|
|
||||||
import { AuctionCard } from 'components/projects/project/overview/Activity/AuctionCard';
|
import { AuctionCard } from 'components/projects/project/overview/Activity/AuctionCard';
|
||||||
|
|
||||||
|
// NOTE: Commented code for verify domain functionality
|
||||||
|
// import { useGQLClient } from 'context/GQLClientContext';
|
||||||
|
// import { Domain, DomainStatus } from 'gql-client';
|
||||||
|
// import {
|
||||||
|
// CheckRoundFilledIcon,
|
||||||
|
// ClockIcon,
|
||||||
|
// GlobeIcon,
|
||||||
|
// } from 'components/shared/CustomIcon';
|
||||||
|
// import {
|
||||||
|
// Button,
|
||||||
|
// Tag,
|
||||||
|
// } from 'components/shared';
|
||||||
|
// import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
const COMMITS_PER_PAGE = 4;
|
const COMMITS_PER_PAGE = 4;
|
||||||
const PROJECT_UPDATE_WAIT_MS = 5000;
|
const PROJECT_UPDATE_WAIT_MS = 5000;
|
||||||
|
|
||||||
const OverviewTabPanel = () => {
|
const OverviewTabPanel = () => {
|
||||||
const { octokit } = useOctokit();
|
const { octokit } = useOctokit();
|
||||||
const navigate = useNavigate();
|
// const navigate = useNavigate();
|
||||||
const [activities, setActivities] = useState<GitCommitWithBranch[]>([]);
|
const [activities, setActivities] = useState<GitCommitWithBranch[]>([]);
|
||||||
const [fetchingActivities, setFetchingActivities] = useState(true);
|
const [fetchingActivities, setFetchingActivities] = useState(true);
|
||||||
const [liveDomain, setLiveDomain] = useState<Domain>();
|
// const [liveDomain, setLiveDomain] = useState<Domain>();
|
||||||
|
|
||||||
const client = useGQLClient();
|
// const client = useGQLClient();
|
||||||
const { project, onUpdate } = useOutletContext<OutletContextType>();
|
const { project, onUpdate } = useOutletContext<OutletContextType>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -107,22 +122,22 @@ const OverviewTabPanel = () => {
|
|||||||
return () => clearInterval(timerId);
|
return () => clearInterval(timerId);
|
||||||
}, [onUpdate]);
|
}, [onUpdate]);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
const fetchLiveProdDomain = async () => {
|
// const fetchLiveProdDomain = async () => {
|
||||||
const { domains } = await client.getDomains(project.id, {
|
// const { domains } = await client.getDomains(project.id, {
|
||||||
branch: project.prodBranch,
|
// branch: project.prodBranch,
|
||||||
status: DomainStatus.Live,
|
// status: DomainStatus.Live,
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (domains.length === 0) {
|
// if (domains.length === 0) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
setLiveDomain(domains[0]);
|
// setLiveDomain(domains[0]);
|
||||||
};
|
// };
|
||||||
|
|
||||||
fetchLiveProdDomain();
|
// fetchLiveProdDomain();
|
||||||
}, [project]);
|
// }, [project]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-5 gap-6 md:gap-[72px]">
|
<div className="grid grid-cols-5 gap-6 md:gap-[72px]">
|
||||||
@ -141,19 +156,16 @@ const OverviewTabPanel = () => {
|
|||||||
{project.deployments &&
|
{project.deployments &&
|
||||||
project.deployments.length > 0 &&
|
project.deployments.length > 0 &&
|
||||||
project.deployments.map((deployment, index) => (
|
project.deployments.map((deployment, index) => (
|
||||||
<p>
|
<p
|
||||||
<a
|
|
||||||
key={index}
|
key={index}
|
||||||
href={`https://${project.name.toLowerCase()}.${deployment.deployer.baseDomain}`}
|
|
||||||
className="text-sm text-elements-low-em dark:text-foreground tracking-tight truncate"
|
className="text-sm text-elements-low-em dark:text-foreground tracking-tight truncate"
|
||||||
>
|
>
|
||||||
{deployment.deployer.baseDomain}
|
{deployment.deployer.baseDomain}
|
||||||
</a>
|
|
||||||
</p>
|
</p>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<OverviewInfo label="Domain" icon={<GlobeIcon />}>
|
{/* <OverviewInfo label="Domain" icon={<GlobeIcon />}>
|
||||||
{liveDomain ? (
|
{liveDomain ? (
|
||||||
<Tag type="positive" size="xs" leftIcon={<CheckRoundFilledIcon />}>
|
<Tag type="positive" size="xs" leftIcon={<CheckRoundFilledIcon />}>
|
||||||
Connected
|
Connected
|
||||||
@ -174,7 +186,7 @@ const OverviewTabPanel = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</OverviewInfo>
|
</OverviewInfo> */}
|
||||||
{project.deployments.length !== 0 ? (
|
{project.deployments.length !== 0 ? (
|
||||||
<>
|
<>
|
||||||
{/* SOURCE */}
|
{/* SOURCE */}
|
||||||
@ -192,12 +204,10 @@ const OverviewTabPanel = () => {
|
|||||||
{project.deployments &&
|
{project.deployments &&
|
||||||
project.deployments.length > 0 &&
|
project.deployments.length > 0 &&
|
||||||
project.deployments.map((deployment) => (
|
project.deployments.map((deployment) => (
|
||||||
<div className="flex gap-2 items-center">
|
<div key={deployment.id} className="flex gap-2 items-center">
|
||||||
<Link
|
<Link to={deployment.applicationDeploymentRecordData.url}>
|
||||||
to={`https://${project.name.toLowerCase()}.${deployment.deployer.baseDomain}`}
|
|
||||||
>
|
|
||||||
<span className="text-controls-primary dark:text-foreground group hover:border-controls-primary transition-colors border-b border-b-transparent flex gap-2 items-center text-sm tracking-tight">
|
<span className="text-controls-primary dark:text-foreground group hover:border-controls-primary transition-colors border-b border-b-transparent flex gap-2 items-center text-sm tracking-tight">
|
||||||
{`https://${project.name.toLowerCase()}.${deployment.deployer.baseDomain}`}
|
{deployment.applicationDeploymentRecordData.url}
|
||||||
<LinkIcon className="group-hover:rotate-45 transition-transform" />
|
<LinkIcon className="group-hover:rotate-45 transition-transform" />
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -60,7 +60,8 @@ const Domains = () => {
|
|||||||
return (
|
return (
|
||||||
<ProjectSettingContainer
|
<ProjectSettingContainer
|
||||||
headingText="Domains"
|
headingText="Domains"
|
||||||
button={
|
{...(!project.auctionId && {
|
||||||
|
button: (
|
||||||
<Button
|
<Button
|
||||||
as="a"
|
as="a"
|
||||||
href="add"
|
href="add"
|
||||||
@ -70,9 +71,15 @@ const Domains = () => {
|
|||||||
>
|
>
|
||||||
Add domain
|
Add domain
|
||||||
</Button>
|
</Button>
|
||||||
}
|
),
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
{domains.map((domain) => {
|
{project.auctionId ? (
|
||||||
|
<p className="text-gray-500">
|
||||||
|
Custom domains not supported for auction driven deployments.
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
domains.map((domain) => {
|
||||||
return (
|
return (
|
||||||
<DomainCard
|
<DomainCard
|
||||||
domains={domains}
|
domains={domains}
|
||||||
@ -84,7 +91,8 @@ const Domains = () => {
|
|||||||
onUpdate={fetchDomains}
|
onUpdate={fetchDomains}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})
|
||||||
|
)}
|
||||||
</ProjectSettingContainer>
|
</ProjectSettingContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,8 @@ import { InlineNotification } from 'components/shared/InlineNotification';
|
|||||||
import { ArrowRightCircleIcon } from 'components/shared/CustomIcon';
|
import { ArrowRightCircleIcon } from 'components/shared/CustomIcon';
|
||||||
import { ProjectSettingContainer } from 'components/projects/project/settings/ProjectSettingContainer';
|
import { ProjectSettingContainer } from 'components/projects/project/settings/ProjectSettingContainer';
|
||||||
import { useToast } from 'components/shared/Toast';
|
import { useToast } from 'components/shared/Toast';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { DNSRecordAttributes } from 'gql-client';
|
||||||
|
|
||||||
const Config = () => {
|
const Config = () => {
|
||||||
const { id, orgSlug } = useParams();
|
const { id, orgSlug } = useParams();
|
||||||
@ -16,6 +18,8 @@ const Config = () => {
|
|||||||
const primaryDomainName = searchParams.get('name');
|
const primaryDomainName = searchParams.get('name');
|
||||||
const { toast, dismiss } = useToast();
|
const { toast, dismiss } = useToast();
|
||||||
|
|
||||||
|
const [dnsRecord, setDnsRecord] = useState<DNSRecordAttributes | null>(null);
|
||||||
|
|
||||||
const handleSubmitDomain = async () => {
|
const handleSubmitDomain = async () => {
|
||||||
if (primaryDomainName === null) {
|
if (primaryDomainName === null) {
|
||||||
toast({
|
toast({
|
||||||
@ -59,9 +63,31 @@ const Config = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchDNSData = async () => {
|
||||||
|
if (id === undefined) {
|
||||||
|
toast({
|
||||||
|
id: 'domain_cannot_find_project',
|
||||||
|
title: 'Cannot find project',
|
||||||
|
variant: 'error',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dnsRecordResponse = await client.getLatestDNSRecordByProjectId(id);
|
||||||
|
|
||||||
|
setDnsRecord(dnsRecordResponse.latestDNSRecord);
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchDNSData();
|
||||||
|
}, [id, client]);
|
||||||
|
|
||||||
// TODO: Figure out DNS Provider if possible and update appropriatly
|
// TODO: Figure out DNS Provider if possible and update appropriatly
|
||||||
return (
|
return (
|
||||||
<ProjectSettingContainer headingText="Setup domain name">
|
<ProjectSettingContainer headingText="Setup domain name">
|
||||||
|
{dnsRecord ? (
|
||||||
|
<>
|
||||||
<p className="text-blue-gray-500">
|
<p className="text-blue-gray-500">
|
||||||
Add the following records to your domain.
|
Add the following records to your domain.
|
||||||
</p>
|
</p>
|
||||||
@ -77,26 +103,29 @@ const Config = () => {
|
|||||||
|
|
||||||
<Table.Body>
|
<Table.Body>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.RowHeaderCell>A</Table.RowHeaderCell>
|
<Table.RowHeaderCell>
|
||||||
|
{dnsRecord.resourceType}
|
||||||
|
</Table.RowHeaderCell>
|
||||||
<Table.Cell>@</Table.Cell>
|
<Table.Cell>@</Table.Cell>
|
||||||
<Table.Cell>IP.OF.THE.SP</Table.Cell>
|
<Table.Cell>
|
||||||
</Table.Row>
|
<p className={!dnsRecord.value ? 'text-red-500' : ''}>
|
||||||
|
{dnsRecord.value ?? 'Not available'}
|
||||||
<Table.Row>
|
</p>
|
||||||
<Table.RowHeaderCell>CNAME</Table.RowHeaderCell>
|
</Table.Cell>
|
||||||
<Table.Cell>subdomain</Table.Cell>
|
|
||||||
<Table.Cell>domain.of.the.sp</Table.Cell>
|
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
</Table.Body>
|
</Table.Body>
|
||||||
</Table>
|
</Table>
|
||||||
|
|
||||||
|
{dnsRecord?.value && (
|
||||||
<InlineNotification
|
<InlineNotification
|
||||||
variant="info"
|
variant="info"
|
||||||
title={`It can take up to 48 hours for these updates to reflect
|
title={`It can take up to 48 hours for these updates to reflect
|
||||||
globally.`}
|
globally.`}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
className="w-fit"
|
className="w-fit"
|
||||||
|
disabled={!dnsRecord?.value}
|
||||||
onClick={handleSubmitDomain}
|
onClick={handleSubmitDomain}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
shape="default"
|
shape="default"
|
||||||
@ -104,6 +133,10 @@ const Config = () => {
|
|||||||
>
|
>
|
||||||
FINISH
|
FINISH
|
||||||
</Button>
|
</Button>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<p className={'text-red-500'}>DNS record data not available</p>
|
||||||
|
)}
|
||||||
</ProjectSettingContainer>
|
</ProjectSettingContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,7 @@ import {
|
|||||||
Domain,
|
Domain,
|
||||||
Environment,
|
Environment,
|
||||||
Permission,
|
Permission,
|
||||||
|
AppDeploymentRecordAttributes,
|
||||||
} from 'gql-client';
|
} from 'gql-client';
|
||||||
|
|
||||||
export const user: User = {
|
export const user: User = {
|
||||||
@ -99,7 +100,6 @@ export const deployment0: Deployment = {
|
|||||||
environment: Environment.Development,
|
environment: Environment.Development,
|
||||||
isCurrent: true,
|
isCurrent: true,
|
||||||
commitHash: 'Commit Hash',
|
commitHash: 'Commit Hash',
|
||||||
domain: domain0,
|
|
||||||
commitMessage: 'Commit Message',
|
commitMessage: 'Commit Message',
|
||||||
createdBy: user,
|
createdBy: user,
|
||||||
deployer: {
|
deployer: {
|
||||||
@ -111,6 +111,7 @@ export const deployment0: Deployment = {
|
|||||||
},
|
},
|
||||||
applicationDeploymentRequestId:
|
applicationDeploymentRequestId:
|
||||||
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
||||||
|
applicationDeploymentRecordData: {} as AppDeploymentRecordAttributes,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const project: Project = {
|
export const project: Project = {
|
||||||
|
@ -8,8 +8,6 @@ export const VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO = import.meta.env
|
|||||||
export const VITE_GITHUB_NEXT_APP_TEMPLATE_REPO = import.meta.env
|
export const VITE_GITHUB_NEXT_APP_TEMPLATE_REPO = import.meta.env
|
||||||
.VITE_GITHUB_NEXT_APP_TEMPLATE_REPO;
|
.VITE_GITHUB_NEXT_APP_TEMPLATE_REPO;
|
||||||
export const VITE_GITHUB_CLIENT_ID = import.meta.env.VITE_GITHUB_CLIENT_ID;
|
export const VITE_GITHUB_CLIENT_ID = import.meta.env.VITE_GITHUB_CLIENT_ID;
|
||||||
export const VITE_WALLET_CONNECT_ID = import.meta.env.VITE_WALLET_CONNECT_ID;
|
|
||||||
export const VITE_BUGSNAG_API_KEY = import.meta.env.VITE_BUGSNAG_API_KEY;
|
export const VITE_BUGSNAG_API_KEY = import.meta.env.VITE_BUGSNAG_API_KEY;
|
||||||
export const VITE_LIT_RELAY_API_KEY = import.meta.env.VITE_LIT_RELAY_API_KEY;
|
export const VITE_LIT_RELAY_API_KEY = import.meta.env.VITE_LIT_RELAY_API_KEY;
|
||||||
export const VITE_LACONICD_CHAIN_ID = import.meta.env.VITE_LACONICD_CHAIN_ID;
|
|
||||||
export const VITE_WALLET_IFRAME_URL = import.meta.env.VITE_WALLET_IFRAME_URL;
|
export const VITE_WALLET_IFRAME_URL = import.meta.env.VITE_WALLET_IFRAME_URL;
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import { WalletConnectModal } from '@walletconnect/modal';
|
|
||||||
|
|
||||||
import { VITE_WALLET_CONNECT_ID } from 'utils/constants';
|
|
||||||
|
|
||||||
export const walletConnectModal = new WalletConnectModal({
|
|
||||||
projectId: VITE_WALLET_CONNECT_ID,
|
|
||||||
chains: [],
|
|
||||||
});
|
|
@ -414,14 +414,25 @@ export class GQLClient {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAuctionData(auctionId: string): Promise<types.Auction> {
|
async getAuctionData(auctionId: string): Promise<types.Auction | null> {
|
||||||
const { data } = await this.client.query({
|
const { data, errors } = await this.client.query({
|
||||||
query: queries.getAuctionData,
|
query: queries.getAuctionData,
|
||||||
variables: {
|
variables: {
|
||||||
auctionId,
|
auctionId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (errors && errors.length) {
|
||||||
|
const isAuctionNotFound = errors.some((error) =>
|
||||||
|
error.message?.includes('Auction not found')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isAuctionNotFound) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return data.getAuctionData;
|
return data.getAuctionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,4 +464,15 @@ export class GQLClient {
|
|||||||
|
|
||||||
return data.verifyTx;
|
return data.verifyTx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getLatestDNSRecordByProjectId(projectId: string): Promise<types.GetLatestDNSDataResponse> {
|
||||||
|
const { data } = await this.client.query({
|
||||||
|
query: queries.getLatestDNSRecordByProjectId,
|
||||||
|
variables: {
|
||||||
|
projectId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,17 +57,12 @@ query ($projectId: String!) {
|
|||||||
commitHash
|
commitHash
|
||||||
createdAt
|
createdAt
|
||||||
environment
|
environment
|
||||||
|
applicationDeploymentRecordData {
|
||||||
|
url
|
||||||
|
}
|
||||||
deployer {
|
deployer {
|
||||||
baseDomain
|
baseDomain
|
||||||
}
|
}
|
||||||
domain {
|
|
||||||
status
|
|
||||||
branch
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
createdBy {
|
createdBy {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -112,13 +107,8 @@ query ($organizationSlug: String!) {
|
|||||||
commitMessage
|
commitMessage
|
||||||
createdAt
|
createdAt
|
||||||
environment
|
environment
|
||||||
domain {
|
applicationDeploymentRecordData {
|
||||||
status
|
url
|
||||||
branch
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,14 +131,6 @@ export const getDeployments = gql`
|
|||||||
query ($projectId: String!) {
|
query ($projectId: String!) {
|
||||||
deployments(projectId: $projectId) {
|
deployments(projectId: $projectId) {
|
||||||
id
|
id
|
||||||
domain{
|
|
||||||
branch
|
|
||||||
createdAt
|
|
||||||
id
|
|
||||||
name
|
|
||||||
status
|
|
||||||
updatedAt
|
|
||||||
}
|
|
||||||
branch
|
branch
|
||||||
commitHash
|
commitHash
|
||||||
commitMessage
|
commitMessage
|
||||||
@ -343,3 +325,15 @@ query ($txHash: String!, $amount: String!, $senderAddress: String!) {
|
|||||||
verifyTx(txHash: $txHash, amount: $amount, senderAddress: $senderAddress)
|
verifyTx(txHash: $txHash, amount: $amount, senderAddress: $senderAddress)
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const getLatestDNSRecordByProjectId = gql`
|
||||||
|
query($projectId: String!) {
|
||||||
|
latestDNSRecord(projectId: $projectId) {
|
||||||
|
name
|
||||||
|
value
|
||||||
|
request
|
||||||
|
resourceType
|
||||||
|
version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
@ -99,7 +99,6 @@ export type User = {
|
|||||||
|
|
||||||
export type Deployment = {
|
export type Deployment = {
|
||||||
id: string;
|
id: string;
|
||||||
domain: Domain;
|
|
||||||
branch: string;
|
branch: string;
|
||||||
commitHash: string;
|
commitHash: string;
|
||||||
commitMessage: string;
|
commitMessage: string;
|
||||||
@ -108,6 +107,7 @@ export type Deployment = {
|
|||||||
environment: Environment;
|
environment: Environment;
|
||||||
isCurrent: boolean;
|
isCurrent: boolean;
|
||||||
baseDomain?: string;
|
baseDomain?: string;
|
||||||
|
applicationDeploymentRecordData: AppDeploymentRecordAttributes;
|
||||||
status: DeploymentStatus;
|
status: DeploymentStatus;
|
||||||
createdBy: User;
|
createdBy: User;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
@ -376,3 +376,28 @@ export type AuctionParams = {
|
|||||||
maxPrice: string;
|
maxPrice: string;
|
||||||
numProviders: number;
|
numProviders: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type DNSRecordAttributes = {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
request: string;
|
||||||
|
resourceType: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GetLatestDNSDataResponse = {
|
||||||
|
latestDNSRecord: DNSRecordAttributes | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AppDeploymentRecordAttributes {
|
||||||
|
application: string;
|
||||||
|
auction: string;
|
||||||
|
deployer: string;
|
||||||
|
dns: string;
|
||||||
|
meta: string;
|
||||||
|
name: string;
|
||||||
|
request: string;
|
||||||
|
type: string;
|
||||||
|
url: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
7
standards/init-commit.md
Normal file
7
standards/init-commit.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Initial Commit for QWRK UX Changes
|
||||||
|
|
||||||
|
This is the first commit for QWRK UX changes to a fork of the `snowballtools-base` repository in Gitea. This commit sets the foundation for the upcoming user experience improvements and modifications.
|
||||||
|
|
||||||
|
- Repository: `snowballtools-base`
|
||||||
|
- Platform: Gitea
|
||||||
|
- Purpose: QWRK UX changes
|
Loading…
Reference in New Issue
Block a user