diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index 37f1f830..1519da71 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -5,7 +5,7 @@ import { Octokit } from 'octokit'; import { inc as semverInc } from 'semver'; import { DeepPartial } from 'typeorm'; -import { Registry as LaconicRegistry, getGasPrice, parseGasAndFees } from '@cerc-io/registry-sdk'; +import { Account, Registry as LaconicRegistry, getGasPrice, parseGasAndFees } from '@cerc-io/registry-sdk'; import { RegistryConfig } from './config'; import { @@ -498,6 +498,13 @@ export class Registry { ); } + async getAddress(): Promise { + const account = new Account(Buffer.from(this.registryConfig.privateKey, 'hex')); + await account.init(); + + return account.address; + } + getLrn(appName: string): string { assert(this.registryConfig.authority, "Authority doesn't exist"); return `lrn://${this.registryConfig.authority}/applications/${appName}`; diff --git a/packages/backend/src/resolvers.ts b/packages/backend/src/resolvers.ts index e4692d99..7995765d 100644 --- a/packages/backend/src/resolvers.ts +++ b/packages/backend/src/resolvers.ts @@ -80,6 +80,10 @@ export const createResolvers = async (service: Service): Promise => { deployers: async (_: any, __: any, context: any) => { return service.getDeployers(); }, + + address: async (_: any, __: any, context: any) => { + return service.getAddress(); + }, }, // TODO: Return error in GQL response diff --git a/packages/backend/src/schema.gql b/packages/backend/src/schema.gql index 81f3ac85..c4427b02 100644 --- a/packages/backend/src/schema.gql +++ b/packages/backend/src/schema.gql @@ -264,6 +264,7 @@ type Query { getAuctionData(auctionId: String!): Auction! domains(projectId: String!, filter: FilterDomainsInput): [Domain] deployers: [Deployer] + address: String! } type Mutation { diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 0801ebfa..6f48cc9e 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -1401,4 +1401,8 @@ export class Service { return deployers; } + + async getAddress(): Promise { + return this.laconicRegistry.getAddress(); + } } diff --git a/packages/gql-client/src/client.ts b/packages/gql-client/src/client.ts index 87e4bc80..558ccc2c 100644 --- a/packages/gql-client/src/client.ts +++ b/packages/gql-client/src/client.ts @@ -432,4 +432,12 @@ export class GQLClient { return data; } + + async getAddress(): Promise { + const { data } = await this.client.query({ + query: queries.getAddress, + }); + + return data; + } } diff --git a/packages/gql-client/src/queries.ts b/packages/gql-client/src/queries.ts index e3274827..4aa12b83 100644 --- a/packages/gql-client/src/queries.ts +++ b/packages/gql-client/src/queries.ts @@ -323,3 +323,9 @@ query { } } `; + +export const getAddress = gql` +query { + address +} +`;