diff --git a/README.md b/README.md index 6ac6801..8e746eb 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 931da42..1adbab8 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 7186344..d475a10 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 98d34c3..f9840e8 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 9162f71..f25d79b 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 27fb9d9..8f2f97b 100644 --- a/packages/frontend/public/index.html +++ b/packages/frontend/public/index.html @@ -5,10 +5,6 @@ -