From 353fd0f6219a955be186b5914e93baa9058b4473 Mon Sep 17 00:00:00 2001 From: Nabarun Gogoi Date: Fri, 23 Feb 2024 14:47:29 +0530 Subject: [PATCH] Set authority for record name from backend config (#104) * Fix format of eth address to display * Set authority for record name from backend config * Add functionality to open repo button * Use commit author image and commit url in activity card * Handle review changes * Fix commit author as null * Add timeout to move to next page on project creation --------- Co-authored-by: neeraj --- README.md | 4 ++++ packages/backend/environments/local.toml | 1 + packages/backend/src/config.ts | 1 + packages/backend/src/registry.ts | 12 +++++------ packages/backend/test/initialize-registry.ts | 8 ++++---- packages/frontend/public/index.html | 4 ---- .../src/components/projects/create/Deploy.tsx | 19 +++++++++--------- .../projects/project/ActivityCard.tsx | 9 +++++---- .../src/pages/org-slug/projects/Id.tsx | 20 ++++++++++++++++--- .../pages/org-slug/projects/id/Overview.tsx | 8 ++++++-- packages/frontend/src/types.ts | 4 ++++ packages/frontend/src/utils/format.ts | 4 ++-- 12 files changed, 59 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 6ac68010..8e746eb9 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,8 @@ # Set Bond ID to be used for publishing records bondId = "8xk8c2pb61kajwixpm223zvptr2x2ncajq0vd998p6aqhvqqep2reu6pik245epf" chainId = "laconic_9000-1" + # Set authority that is existing in the chain + authority = "laconic" [registryConfig.fee] amount = "200000" denom = "aphoton" @@ -125,6 +127,8 @@ laconic-so --stack fixturenet-laconic-loaded deploy port laconicd 9473 # 0.0.0.0:32771 ``` + - Set authority in `registryConfig.authority` in backend [config file](packages/backend/environments/local.toml) + - Run the script to create bond, reserve the authority and set authority bond ```bash yarn test:registry:init diff --git a/packages/backend/environments/local.toml b/packages/backend/environments/local.toml index 931da422..1adbab8c 100644 --- a/packages/backend/environments/local.toml +++ b/packages/backend/environments/local.toml @@ -24,6 +24,7 @@ chainId = "laconic_9000-1" privateKey = "" bondId = "" + authority = "" [registryConfig.fee] amount = "200000" denom = "aphoton" diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 7186344e..d475a109 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -34,6 +34,7 @@ export interface RegistryConfig { privateKey: string; bondId: string; fetchDeploymentRecordDelay: number; + authority: string; fee: { amount: string; denom: string; diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index 98d34c3b..f9840e8f 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -81,7 +81,7 @@ export class Registry { log('Application record data:', applicationRecord); // TODO: Discuss computation of CRN - const crn = this.getCrn(packageJSON.name, appName); + const crn = this.getCrn(appName); log(`Setting name: ${crn} for record ID: ${result.data.id}`); await this.registry.setName({ cid: result.data.id, crn }, this.registryConfig.privateKey, this.registryConfig.fee); @@ -101,7 +101,7 @@ export class Registry { applicationDeploymentRequestId: string, applicationDeploymentRequestData: ApplicationDeploymentRequest }> { - const crn = this.getCrn(data.packageJsonName, data.appName); + const crn = this.getCrn(data.appName); const records = await this.registry.resolveNames([crn]); const applicationRecord = records[0]; @@ -160,10 +160,8 @@ export class Registry { return records.filter((record: AppDeploymentRecord) => deployments.some(deployment => deployment.applicationRecordId === record.attributes.application)); } - getCrn (packageJsonName: string, appName: string): string { - const [arg1] = packageJsonName.split('/'); - const authority = arg1.replace('@', ''); - - return `crn://${authority}/applications/${appName}`; + getCrn (appName: string): string { + assert(this.registryConfig.authority, "Authority doesn't exist"); + return `crn://${this.registryConfig.authority}/applications/${appName}`; } } diff --git a/packages/backend/test/initialize-registry.ts b/packages/backend/test/initialize-registry.ts index 9162f718..f25d79bc 100644 --- a/packages/backend/test/initialize-registry.ts +++ b/packages/backend/test/initialize-registry.ts @@ -11,19 +11,19 @@ const log = debug('snowball:initialize-registry'); const DENOM = 'aphoton'; const BOND_AMOUNT = '1000000000'; -// TODO: Get authority names from args -const AUTHORITY_NAMES = ['snowballtools', 'cerc-io']; - async function main () { const { registryConfig } = await getConfig(DEFAULT_CONFIG_FILE_PATH); + // TODO: Get authority names from args + const authorityNames = ['snowballtools', registryConfig.authority]; + const registry = new Registry(registryConfig.gqlEndpoint, registryConfig.restEndpoint, registryConfig.chainId); const bondId = await registry.getNextBondId(registryConfig.privateKey); log('bondId:', bondId); await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, registryConfig.privateKey, registryConfig.fee); - for await (const name of AUTHORITY_NAMES) { + for await (const name of authorityNames) { await registry.reserveAuthority({ name }, registryConfig.privateKey, registryConfig.fee); log('Reserved authority name:', name); await registry.setAuthorityBond({ name, bondId }, registryConfig.privateKey, registryConfig.fee); diff --git a/packages/frontend/public/index.html b/packages/frontend/public/index.html index 27fb9d99..8f2f97be 100644 --- a/packages/frontend/public/index.html +++ b/packages/frontend/public/index.html @@ -5,10 +5,6 @@ -