Implement payments for app deployments #17

Merged
nabarun merged 27 commits from iv-integrate-payments into main 2024-10-28 09:46:19 +00:00
6 changed files with 31 additions and 1 deletions
Showing only changes of commit 7383d5c36d - Show all commits

View File

@ -5,7 +5,7 @@ import { Octokit } from 'octokit';
import { inc as semverInc } from 'semver'; import { inc as semverInc } from 'semver';
import { DeepPartial } from 'typeorm'; 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 { RegistryConfig } from './config';
import { import {
@ -498,6 +498,13 @@ export class Registry {
); );
} }
async getAddress(): Promise<any> {
const account = new Account(Buffer.from(this.registryConfig.privateKey, 'hex'));
await account.init();
return account.address;
}
getLrn(appName: string): string { getLrn(appName: string): string {
assert(this.registryConfig.authority, "Authority doesn't exist"); assert(this.registryConfig.authority, "Authority doesn't exist");
return `lrn://${this.registryConfig.authority}/applications/${appName}`; return `lrn://${this.registryConfig.authority}/applications/${appName}`;

View File

@ -80,6 +80,10 @@ export const createResolvers = async (service: Service): Promise<any> => {
deployers: async (_: any, __: any, context: any) => { deployers: async (_: any, __: any, context: any) => {
return service.getDeployers(); return service.getDeployers();
}, },
address: async (_: any, __: any, context: any) => {
return service.getAddress();
},
}, },
// TODO: Return error in GQL response // TODO: Return error in GQL response

View File

@ -264,6 +264,7 @@ type Query {
getAuctionData(auctionId: String!): Auction! getAuctionData(auctionId: String!): Auction!
domains(projectId: String!, filter: FilterDomainsInput): [Domain] domains(projectId: String!, filter: FilterDomainsInput): [Domain]
deployers: [Deployer] deployers: [Deployer]
address: String!
} }
type Mutation { type Mutation {

View File

@ -1401,4 +1401,8 @@ export class Service {
return deployers; return deployers;
} }
async getAddress(): Promise<any> {
return this.laconicRegistry.getAddress();
}
} }

View File

@ -432,4 +432,12 @@ export class GQLClient {
return data; return data;
} }
async getAddress(): Promise<string> {
const { data } = await this.client.query({
query: queries.getAddress,
});
return data;
}
} }

View File

@ -323,3 +323,9 @@ query {
} }
} }
`; `;
export const getAddress = gql`
query {
address
}
`;