Return extra funds to owner on successful deployment
This commit is contained in:
parent
bae0d1323a
commit
92a270afa2
@ -483,6 +483,21 @@ export class Registry {
|
|||||||
return this.registry.getAuctionsByIds([auctionId]);
|
return this.registry.getAuctionsByIds([auctionId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async sendTokensToAccount(receiverAddress: string, amount: string): Promise<any> {
|
||||||
|
const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees);
|
||||||
|
await registryTransactionWithRetry(() =>
|
||||||
|
this.registry.sendCoins(
|
||||||
|
{
|
||||||
|
amount,
|
||||||
|
denom: 'tlnt',
|
||||||
|
destinationAddress: receiverAddress
|
||||||
|
},
|
||||||
|
this.registryConfig.privateKey,
|
||||||
|
fee
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
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}`;
|
||||||
|
@ -212,6 +212,9 @@ export class Service {
|
|||||||
if (!deployment.project.fundsReleased) {
|
if (!deployment.project.fundsReleased) {
|
||||||
const fundsReleased = await this.releaseDeployerFundsByProjectId(deployment.projectId);
|
const fundsReleased = await this.releaseDeployerFundsByProjectId(deployment.projectId);
|
||||||
|
|
||||||
|
// Return remaining amount to owner
|
||||||
|
await this.returnCreatorFundsByProjectId(deployment.projectId);
|
||||||
|
|
||||||
await this.db.updateProjectById(deployment.projectId, {
|
await this.db.updateProjectById(deployment.projectId, {
|
||||||
fundsReleased,
|
fundsReleased,
|
||||||
});
|
});
|
||||||
@ -1324,6 +1327,24 @@ export class Service {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async returnCreatorFundsByProjectId(projectId: string) {
|
||||||
|
const project = await this.db.getProjectById(projectId);
|
||||||
|
|
||||||
|
if (!project || !project.auctionId) {
|
||||||
|
log(`Project ${projectId} ${!project ? 'not found' : 'does not have an auction'}`);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auction = await this.getAuctionData(project.auctionId);
|
||||||
|
const amountToBeReturned = auction.winnerPrice * auction.numProviders
|
||||||
|
|
||||||
|
await this.laconicRegistry.sendTokensToAccount(
|
||||||
|
project.paymentAddress,
|
||||||
|
amountToBeReturned.toString()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async getDeployers(): Promise<Deployer[]> {
|
async getDeployers(): Promise<Deployer[]> {
|
||||||
const dbDeployers = await this.db.getDeployers();
|
const dbDeployers = await this.db.getDeployers();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user