diff --git a/apps/core/dist/app.module.js b/apps/core/dist/app.module.js index 58b8d4e..72f8654 100644 --- a/apps/core/dist/app.module.js +++ b/apps/core/dist/app.module.js @@ -15,12 +15,14 @@ const soroban_module_1 = require("./soroban/soroban.module"); const campaigns_module_1 = require("./campaigns/campaigns.module"); const investments_module_1 = require("./investments/investments.module"); const deploy_module_1 = require("./deploy/deploy.module"); +const loans_module_1 = require("./loans/loans.module"); +const participation_token_module_1 = require("./participation-token/participation-token.module"); let AppModule = class AppModule { }; exports.AppModule = AppModule; exports.AppModule = AppModule = __decorate([ (0, common_1.Module)({ - imports: [prisma_module_1.PrismaModule, soroban_module_1.SorobanModule, campaigns_module_1.CampaignsModule, investments_module_1.InvestmentsModule, deploy_module_1.DeployModule], + imports: [prisma_module_1.PrismaModule, soroban_module_1.SorobanModule, campaigns_module_1.CampaignsModule, investments_module_1.InvestmentsModule, deploy_module_1.DeployModule, loans_module_1.LoansModule, participation_token_module_1.ParticipationTokenModule], controllers: [app_controller_1.AppController], providers: [app_service_1.AppService], }) diff --git a/apps/core/dist/app.module.js.map b/apps/core/dist/app.module.js.map index 30da1eb..854dbc8 100644 --- a/apps/core/dist/app.module.js.map +++ b/apps/core/dist/app.module.js.map @@ -1 +1 @@ -{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,0DAAsD;AACtD,6DAAyD;AACzD,mEAA+D;AAC/D,yEAAqE;AACrE,0DAAsD;AAO/C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IALrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4BAAY,EAAE,8BAAa,EAAE,kCAAe,EAAE,sCAAiB,EAAE,4BAAY,CAAC;QACxF,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG"} \ No newline at end of file +{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,0DAAsD;AACtD,6DAAyD;AACzD,mEAA+D;AAC/D,yEAAqE;AACrE,0DAAsD;AACtD,uDAAmD;AACnD,iGAA4F;AAOrF,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IALrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4BAAY,EAAE,8BAAa,EAAE,kCAAe,EAAE,sCAAiB,EAAE,4BAAY,EAAE,0BAAW,EAAC,qDAAwB,CAAC;QAC9H,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG"} \ No newline at end of file diff --git a/apps/core/dist/deploy/deploy.service.js b/apps/core/dist/deploy/deploy.service.js index db47e95..3f75be3 100644 --- a/apps/core/dist/deploy/deploy.service.js +++ b/apps/core/dist/deploy/deploy.service.js @@ -28,8 +28,7 @@ let DeployService = class DeployService { deployParticipationToken(dto) { return this.soroban.buildDeployTransaction(this.participationTokenWasmHash, { escrow_contract: dto.escrowContractId, - participation_token: dto.callerPublicKey, - admin: dto.callerPublicKey, + participation_token: dto.tokenContractId, }, dto.callerPublicKey); } deployTokenFactory(dto) { diff --git a/apps/core/dist/deploy/deploy.service.js.map b/apps/core/dist/deploy/deploy.service.js.map index 2c99b1a..4074f40 100644 --- a/apps/core/dist/deploy/deploy.service.js.map +++ b/apps/core/dist/deploy/deploy.service.js.map @@ -1 +1 @@ -{"version":3,"file":"deploy.service.js","sourceRoot":"","sources":["../../src/deploy/deploy.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,gEAA4D;AAK5D,MAAM,aAAa,GAAG,CAAC,CAAC;AAGjB,IAAM,aAAa,GAAnB,MAAM,aAAa;IAKK;IAJZ,0BAA0B,CAAS;IACnC,oBAAoB,CAAS;IAC7B,aAAa,CAAS;IAEvC,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAClD,IAAI,CAAC,0BAA0B;YAC7B,OAAO,CAAC,GAAG,CAAC,6BAA8B,CAAC;QAC7C,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAwB,CAAC;QACjE,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,eAAgB,CAAC;IACpD,CAAC;IAED,wBAAwB,CAAC,GAAgC;QACvD,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CACxC,IAAI,CAAC,0BAA0B,EAC/B;YACE,eAAe,EAAE,GAAG,CAAC,gBAAgB;YACrC,mBAAmB,EAAE,GAAG,CAAC,eAAe;YACxC,KAAK,EAAE,GAAG,CAAC,eAAe;SAC3B,EACD,GAAG,CAAC,eAAe,CACpB,CAAC;IACJ,CAAC;IAED,kBAAkB,CAAC,GAA0B;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CACxC,IAAI,CAAC,oBAAoB,EACzB;YACE,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,SAAS,EAAE,GAAG,CAAC,gBAAgB;YAC/B,OAAO,EAAE,aAAa;YACtB,cAAc,EAAE,GAAG,CAAC,aAAa;SAClC,EACD,GAAG,CAAC,eAAe,CACpB,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,GAAmB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CACxC,IAAI,CAAC,aAAa,EAClB;YACE,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,cAAc,EAAE,GAAG,CAAC,aAAa;YACjC,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,EACD,GAAG,CAAC,eAAe,CACpB,CAAC;IACJ,CAAC;CACF,CAAA;AAnDY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAM2B,gCAAc;GALzC,aAAa,CAmDzB"} \ No newline at end of file +{"version":3,"file":"deploy.service.js","sourceRoot":"","sources":["../../src/deploy/deploy.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,gEAA4D;AAK5D,MAAM,aAAa,GAAG,CAAC,CAAC;AAGjB,IAAM,aAAa,GAAnB,MAAM,aAAa;IAKK;IAJZ,0BAA0B,CAAS;IACnC,oBAAoB,CAAS;IAC7B,aAAa,CAAS;IAEvC,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAClD,IAAI,CAAC,0BAA0B;YAC7B,OAAO,CAAC,GAAG,CAAC,6BAA8B,CAAC;QAC7C,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAwB,CAAC;QACjE,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,eAAgB,CAAC;IACpD,CAAC;IAED,wBAAwB,CAAC,GAAgC;QACvD,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CACxC,IAAI,CAAC,0BAA0B,EAC/B;YACE,eAAe,EAAE,GAAG,CAAC,gBAAgB;YACrC,mBAAmB,EAAE,GAAG,CAAC,eAAe;SACzC,EACD,GAAG,CAAC,eAAe,CACpB,CAAC;IACJ,CAAC;IAED,kBAAkB,CAAC,GAA0B;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CACxC,IAAI,CAAC,oBAAoB,EACzB;YACE,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,SAAS,EAAE,GAAG,CAAC,gBAAgB;YAC/B,OAAO,EAAE,aAAa;YACtB,cAAc,EAAE,GAAG,CAAC,aAAa;SAClC,EACD,GAAG,CAAC,eAAe,CACpB,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,GAAmB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CACxC,IAAI,CAAC,aAAa,EAClB;YACE,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,cAAc,EAAE,GAAG,CAAC,aAAa;YACjC,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,EACD,GAAG,CAAC,eAAe,CACpB,CAAC;IACJ,CAAC;CACF,CAAA;AAlDY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAM2B,gCAAc;GALzC,aAAa,CAkDzB"} \ No newline at end of file diff --git a/apps/core/dist/deploy/dto/deploy-participation-token.dto.d.ts b/apps/core/dist/deploy/dto/deploy-participation-token.dto.d.ts index 377f8e8..6516c4a 100644 --- a/apps/core/dist/deploy/dto/deploy-participation-token.dto.d.ts +++ b/apps/core/dist/deploy/dto/deploy-participation-token.dto.d.ts @@ -1,4 +1,5 @@ export declare class DeployParticipationTokenDto { escrowContractId: string; + tokenContractId: string; callerPublicKey: string; } diff --git a/apps/core/dist/deploy/dto/deploy-participation-token.dto.js b/apps/core/dist/deploy/dto/deploy-participation-token.dto.js index 07bcd5b..4dccbbc 100644 --- a/apps/core/dist/deploy/dto/deploy-participation-token.dto.js +++ b/apps/core/dist/deploy/dto/deploy-participation-token.dto.js @@ -13,6 +13,7 @@ exports.DeployParticipationTokenDto = void 0; const class_validator_1 = require("class-validator"); class DeployParticipationTokenDto { escrowContractId; + tokenContractId; callerPublicKey; } exports.DeployParticipationTokenDto = DeployParticipationTokenDto; @@ -21,6 +22,11 @@ __decorate([ (0, class_validator_1.IsNotEmpty)(), __metadata("design:type", String) ], DeployParticipationTokenDto.prototype, "escrowContractId", void 0); +__decorate([ + (0, class_validator_1.IsString)(), + (0, class_validator_1.IsNotEmpty)(), + __metadata("design:type", String) +], DeployParticipationTokenDto.prototype, "tokenContractId", void 0); __decorate([ (0, class_validator_1.IsString)(), (0, class_validator_1.IsNotEmpty)(), diff --git a/apps/core/dist/deploy/dto/deploy-participation-token.dto.js.map b/apps/core/dist/deploy/dto/deploy-participation-token.dto.js.map index 58339f4..5a20048 100644 --- a/apps/core/dist/deploy/dto/deploy-participation-token.dto.js.map +++ b/apps/core/dist/deploy/dto/deploy-participation-token.dto.js.map @@ -1 +1 @@ -{"version":3,"file":"deploy-participation-token.dto.js","sourceRoot":"","sources":["../../../src/deploy/dto/deploy-participation-token.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuD;AAEvD,MAAa,2BAA2B;IAGtC,gBAAgB,CAAS;IAIzB,eAAe,CAAS;CACzB;AARD,kEAQC;AALC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qEACY;AAIzB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;oEACW"} \ No newline at end of file +{"version":3,"file":"deploy-participation-token.dto.js","sourceRoot":"","sources":["../../../src/deploy/dto/deploy-participation-token.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuD;AAEvD,MAAa,2BAA2B;IAGtC,gBAAgB,CAAS;IAIzB,eAAe,CAAS;IAIxB,eAAe,CAAS;CACzB;AAZD,kEAYC;AATC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qEACY;AAIzB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;oEACW;AAIxB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;oEACW"} \ No newline at end of file diff --git a/apps/core/dist/loans/dto/create-loan.dto.d.ts b/apps/core/dist/loans/dto/create-loan.dto.d.ts new file mode 100644 index 0000000..7936573 --- /dev/null +++ b/apps/core/dist/loans/dto/create-loan.dto.d.ts @@ -0,0 +1,7 @@ +export declare class CreateLoanDto { + campaignId: string; + description: string; + amount: number; + receiver: string; + milestoneIndex?: number; +} diff --git a/apps/core/dist/loans/dto/create-loan.dto.js b/apps/core/dist/loans/dto/create-loan.dto.js new file mode 100644 index 0000000..6b36442 --- /dev/null +++ b/apps/core/dist/loans/dto/create-loan.dto.js @@ -0,0 +1,47 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CreateLoanDto = void 0; +const class_validator_1 = require("class-validator"); +class CreateLoanDto { + campaignId; + description; + amount; + receiver; + milestoneIndex; +} +exports.CreateLoanDto = CreateLoanDto; +__decorate([ + (0, class_validator_1.IsString)(), + (0, class_validator_1.IsNotEmpty)(), + __metadata("design:type", String) +], CreateLoanDto.prototype, "campaignId", void 0); +__decorate([ + (0, class_validator_1.IsString)(), + (0, class_validator_1.IsNotEmpty)(), + __metadata("design:type", String) +], CreateLoanDto.prototype, "description", void 0); +__decorate([ + (0, class_validator_1.IsNumber)(), + (0, class_validator_1.IsPositive)(), + __metadata("design:type", Number) +], CreateLoanDto.prototype, "amount", void 0); +__decorate([ + (0, class_validator_1.IsString)(), + (0, class_validator_1.IsNotEmpty)(), + __metadata("design:type", String) +], CreateLoanDto.prototype, "receiver", void 0); +__decorate([ + (0, class_validator_1.IsOptional)(), + (0, class_validator_1.IsNumber)(), + __metadata("design:type", Number) +], CreateLoanDto.prototype, "milestoneIndex", void 0); +//# sourceMappingURL=create-loan.dto.js.map \ No newline at end of file diff --git a/apps/core/dist/loans/dto/create-loan.dto.js.map b/apps/core/dist/loans/dto/create-loan.dto.js.map new file mode 100644 index 0000000..48edbe0 --- /dev/null +++ b/apps/core/dist/loans/dto/create-loan.dto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"create-loan.dto.js","sourceRoot":"","sources":["../../../src/loans/dto/create-loan.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAMyB;AAEzB,MAAa,aAAa;IAGxB,UAAU,CAAS;IAInB,WAAW,CAAS;IAIpB,MAAM,CAAS;IAIf,QAAQ,CAAS;IAIjB,cAAc,CAAU;CACzB;AApBD,sCAoBC;AAjBC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;iDACM;AAInB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;kDACO;AAIpB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;6CACE;AAIf;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;+CACI;AAIjB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACa"} \ No newline at end of file diff --git a/apps/core/dist/loans/dto/update-loan.dto.d.ts b/apps/core/dist/loans/dto/update-loan.dto.d.ts new file mode 100644 index 0000000..acc267f --- /dev/null +++ b/apps/core/dist/loans/dto/update-loan.dto.d.ts @@ -0,0 +1,7 @@ +import { LoanStatus } from '@prisma/client'; +export declare class UpdateLoanDto { + status?: LoanStatus; + milestoneIndex?: number; + disbursedAt?: string; + repaidAt?: string; +} diff --git a/apps/core/dist/loans/dto/update-loan.dto.js b/apps/core/dist/loans/dto/update-loan.dto.js new file mode 100644 index 0000000..de960f0 --- /dev/null +++ b/apps/core/dist/loans/dto/update-loan.dto.js @@ -0,0 +1,42 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UpdateLoanDto = void 0; +const class_validator_1 = require("class-validator"); +const client_1 = require("@prisma/client"); +class UpdateLoanDto { + status; + milestoneIndex; + disbursedAt; + repaidAt; +} +exports.UpdateLoanDto = UpdateLoanDto; +__decorate([ + (0, class_validator_1.IsOptional)(), + (0, class_validator_1.IsEnum)(client_1.LoanStatus), + __metadata("design:type", String) +], UpdateLoanDto.prototype, "status", void 0); +__decorate([ + (0, class_validator_1.IsOptional)(), + (0, class_validator_1.IsNumber)(), + __metadata("design:type", Number) +], UpdateLoanDto.prototype, "milestoneIndex", void 0); +__decorate([ + (0, class_validator_1.IsOptional)(), + (0, class_validator_1.IsDateString)(), + __metadata("design:type", String) +], UpdateLoanDto.prototype, "disbursedAt", void 0); +__decorate([ + (0, class_validator_1.IsOptional)(), + (0, class_validator_1.IsDateString)(), + __metadata("design:type", String) +], UpdateLoanDto.prototype, "repaidAt", void 0); +//# sourceMappingURL=update-loan.dto.js.map \ No newline at end of file diff --git a/apps/core/dist/loans/dto/update-loan.dto.js.map b/apps/core/dist/loans/dto/update-loan.dto.js.map new file mode 100644 index 0000000..87a33c1 --- /dev/null +++ b/apps/core/dist/loans/dto/update-loan.dto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"update-loan.dto.js","sourceRoot":"","sources":["../../../src/loans/dto/update-loan.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA6E;AAC7E,2CAA4C;AAE5C,MAAa,aAAa;IAGxB,MAAM,CAAc;IAIpB,cAAc,CAAU;IAIxB,WAAW,CAAU;IAIrB,QAAQ,CAAU;CACnB;AAhBD,sCAgBC;AAbC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,mBAAU,CAAC;;6CACC;AAIpB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACa;AAIxB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,8BAAY,GAAE;;kDACM;AAIrB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,8BAAY,GAAE;;+CACG"} \ No newline at end of file diff --git a/apps/core/dist/loans/loans.controller.d.ts b/apps/core/dist/loans/loans.controller.d.ts new file mode 100644 index 0000000..4a00069 --- /dev/null +++ b/apps/core/dist/loans/loans.controller.d.ts @@ -0,0 +1,151 @@ +import { LoansService } from './loans.service'; +import { CreateLoanDto } from './dto/create-loan.dto'; +import { UpdateLoanDto } from './dto/update-loan.dto'; +export declare class LoansController { + private readonly loansService; + constructor(loansService: LoansService); + create(dto: CreateLoanDto): Promise<{ + campaign: { + name: string; + description: string | null; + issuerAddress: string; + escrowId: string; + poolSize: import("@prisma/client/runtime/library").Decimal; + loanDuration: number; + expectedReturn: import("@prisma/client/runtime/library").Decimal; + loanSize: import("@prisma/client/runtime/library").Decimal; + vaultId: string | null; + tokenSaleId: string | null; + tokenFactoryId: string | null; + status: import("@prisma/client").$Enums.CampaignStatus; + id: string; + previousStatus: import("@prisma/client").$Enums.CampaignStatus | null; + createdAt: Date; + updatedAt: Date; + }; + } & { + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + }>; + findAll(): import("@prisma/client").Prisma.PrismaPromise<({ + campaign: { + name: string; + description: string | null; + issuerAddress: string; + escrowId: string; + poolSize: import("@prisma/client/runtime/library").Decimal; + loanDuration: number; + expectedReturn: import("@prisma/client/runtime/library").Decimal; + loanSize: import("@prisma/client/runtime/library").Decimal; + vaultId: string | null; + tokenSaleId: string | null; + tokenFactoryId: string | null; + status: import("@prisma/client").$Enums.CampaignStatus; + id: string; + previousStatus: import("@prisma/client").$Enums.CampaignStatus | null; + createdAt: Date; + updatedAt: Date; + }; + } & { + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + })[]>; + getCampaignLoanStats(campaignId: string): import("@prisma/client").Prisma.PrismaPromise>; + findByCampaign(campaignId: string): import("@prisma/client").Prisma.PrismaPromise<{ + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + }[]>; + findOne(id: string): Promise<{ + campaign: { + name: string; + description: string | null; + issuerAddress: string; + escrowId: string; + poolSize: import("@prisma/client/runtime/library").Decimal; + loanDuration: number; + expectedReturn: import("@prisma/client/runtime/library").Decimal; + loanSize: import("@prisma/client/runtime/library").Decimal; + vaultId: string | null; + tokenSaleId: string | null; + tokenFactoryId: string | null; + status: import("@prisma/client").$Enums.CampaignStatus; + id: string; + previousStatus: import("@prisma/client").$Enums.CampaignStatus | null; + createdAt: Date; + updatedAt: Date; + }; + } & { + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + }>; + update(id: string, dto: UpdateLoanDto): Promise<{ + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + }>; + remove(id: string): Promise<{ + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + }>; +} diff --git a/apps/core/dist/loans/loans.controller.js b/apps/core/dist/loans/loans.controller.js new file mode 100644 index 0000000..18b9651 --- /dev/null +++ b/apps/core/dist/loans/loans.controller.js @@ -0,0 +1,101 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LoansController = void 0; +const common_1 = require("@nestjs/common"); +const loans_service_1 = require("./loans.service"); +const create_loan_dto_1 = require("./dto/create-loan.dto"); +const update_loan_dto_1 = require("./dto/update-loan.dto"); +let LoansController = class LoansController { + loansService; + constructor(loansService) { + this.loansService = loansService; + } + create(dto) { + return this.loansService.create(dto); + } + findAll() { + return this.loansService.findAll(); + } + getCampaignLoanStats(campaignId) { + return this.loansService.getCampaignLoanStats(campaignId); + } + findByCampaign(campaignId) { + return this.loansService.findByCampaign(campaignId); + } + findOne(id) { + return this.loansService.findOne(id); + } + update(id, dto) { + return this.loansService.update(id, dto); + } + remove(id) { + return this.loansService.remove(id); + } +}; +exports.LoansController = LoansController; +__decorate([ + (0, common_1.Post)(), + __param(0, (0, common_1.Body)()), + __metadata("design:type", Function), + __metadata("design:paramtypes", [create_loan_dto_1.CreateLoanDto]), + __metadata("design:returntype", void 0) +], LoansController.prototype, "create", null); +__decorate([ + (0, common_1.Get)(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", void 0) +], LoansController.prototype, "findAll", null); +__decorate([ + (0, common_1.Get)('campaign/:campaignId/stats'), + __param(0, (0, common_1.Param)('campaignId')), + __metadata("design:type", Function), + __metadata("design:paramtypes", [String]), + __metadata("design:returntype", void 0) +], LoansController.prototype, "getCampaignLoanStats", null); +__decorate([ + (0, common_1.Get)('campaign/:campaignId'), + __param(0, (0, common_1.Param)('campaignId')), + __metadata("design:type", Function), + __metadata("design:paramtypes", [String]), + __metadata("design:returntype", void 0) +], LoansController.prototype, "findByCampaign", null); +__decorate([ + (0, common_1.Get)(':id'), + __param(0, (0, common_1.Param)('id')), + __metadata("design:type", Function), + __metadata("design:paramtypes", [String]), + __metadata("design:returntype", void 0) +], LoansController.prototype, "findOne", null); +__decorate([ + (0, common_1.Patch)(':id'), + __param(0, (0, common_1.Param)('id')), + __param(1, (0, common_1.Body)()), + __metadata("design:type", Function), + __metadata("design:paramtypes", [String, update_loan_dto_1.UpdateLoanDto]), + __metadata("design:returntype", void 0) +], LoansController.prototype, "update", null); +__decorate([ + (0, common_1.Delete)(':id'), + __param(0, (0, common_1.Param)('id')), + __metadata("design:type", Function), + __metadata("design:paramtypes", [String]), + __metadata("design:returntype", void 0) +], LoansController.prototype, "remove", null); +exports.LoansController = LoansController = __decorate([ + (0, common_1.Controller)('loans'), + __metadata("design:paramtypes", [loans_service_1.LoansService]) +], LoansController); +//# sourceMappingURL=loans.controller.js.map \ No newline at end of file diff --git a/apps/core/dist/loans/loans.controller.js.map b/apps/core/dist/loans/loans.controller.js.map new file mode 100644 index 0000000..88a70e4 --- /dev/null +++ b/apps/core/dist/loans/loans.controller.js.map @@ -0,0 +1 @@ +{"version":3,"file":"loans.controller.js","sourceRoot":"","sources":["../../src/loans/loans.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,mDAA+C;AAC/C,2DAAsD;AACtD,2DAAsD;AAG/C,IAAM,eAAe,GAArB,MAAM,eAAe;IACG;IAA7B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAG3D,MAAM,CAAS,GAAkB;QAC/B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAGD,OAAO;QACL,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;IAGD,oBAAoB,CAAsB,UAAkB;QAC1D,OAAO,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAC5D,CAAC;IAGD,cAAc,CAAsB,UAAkB;QACpD,OAAO,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACtD,CAAC;IAGD,OAAO,CAAc,EAAU;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IAGD,MAAM,CAAc,EAAU,EAAU,GAAkB;QACxD,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IAGD,MAAM,CAAc,EAAU;QAC5B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;CACF,CAAA;AArCY,0CAAe;AAI1B;IADC,IAAA,aAAI,GAAE;IACC,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,+BAAa;;6CAEhC;AAGD;IADC,IAAA,YAAG,GAAE;;;;8CAGL;AAGD;IADC,IAAA,YAAG,EAAC,4BAA4B,CAAC;IACZ,WAAA,IAAA,cAAK,EAAC,YAAY,CAAC,CAAA;;;;2DAExC;AAGD;IADC,IAAA,YAAG,EAAC,sBAAsB,CAAC;IACZ,WAAA,IAAA,cAAK,EAAC,YAAY,CAAC,CAAA;;;;qDAElC;AAGD;IADC,IAAA,YAAG,EAAC,KAAK,CAAC;IACF,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;8CAEnB;AAGD;IADC,IAAA,cAAK,EAAC,KAAK,CAAC;IACL,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,+BAAa;;6CAEzD;AAGD;IADC,IAAA,eAAM,EAAC,KAAK,CAAC;IACN,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;6CAElB;0BApCU,eAAe;IAD3B,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAEyB,4BAAY;GAD5C,eAAe,CAqC3B"} \ No newline at end of file diff --git a/apps/core/dist/loans/loans.module.d.ts b/apps/core/dist/loans/loans.module.d.ts new file mode 100644 index 0000000..2b6eef9 --- /dev/null +++ b/apps/core/dist/loans/loans.module.d.ts @@ -0,0 +1,2 @@ +export declare class LoansModule { +} diff --git a/apps/core/dist/loans/loans.module.js b/apps/core/dist/loans/loans.module.js new file mode 100644 index 0000000..2230163 --- /dev/null +++ b/apps/core/dist/loans/loans.module.js @@ -0,0 +1,22 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LoansModule = void 0; +const common_1 = require("@nestjs/common"); +const loans_controller_1 = require("./loans.controller"); +const loans_service_1 = require("./loans.service"); +let LoansModule = class LoansModule { +}; +exports.LoansModule = LoansModule; +exports.LoansModule = LoansModule = __decorate([ + (0, common_1.Module)({ + controllers: [loans_controller_1.LoansController], + providers: [loans_service_1.LoansService], + }) +], LoansModule); +//# sourceMappingURL=loans.module.js.map \ No newline at end of file diff --git a/apps/core/dist/loans/loans.module.js.map b/apps/core/dist/loans/loans.module.js.map new file mode 100644 index 0000000..34e5efe --- /dev/null +++ b/apps/core/dist/loans/loans.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"loans.module.js","sourceRoot":"","sources":["../../src/loans/loans.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yDAAqD;AACrD,mDAA+C;AAMxC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAJvB,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,4BAAY,CAAC;KAC1B,CAAC;GACW,WAAW,CAAG"} \ No newline at end of file diff --git a/apps/core/dist/loans/loans.service.d.ts b/apps/core/dist/loans/loans.service.d.ts new file mode 100644 index 0000000..d65c73c --- /dev/null +++ b/apps/core/dist/loans/loans.service.d.ts @@ -0,0 +1,152 @@ +import { PrismaService } from '../prisma/prisma.service'; +import { CreateLoanDto } from './dto/create-loan.dto'; +import { UpdateLoanDto } from './dto/update-loan.dto'; +export declare class LoansService { + private readonly prisma; + constructor(prisma: PrismaService); + findAll(): import("@prisma/client").Prisma.PrismaPromise<({ + campaign: { + name: string; + description: string | null; + issuerAddress: string; + escrowId: string; + poolSize: import("@prisma/client/runtime/library").Decimal; + loanDuration: number; + expectedReturn: import("@prisma/client/runtime/library").Decimal; + loanSize: import("@prisma/client/runtime/library").Decimal; + vaultId: string | null; + tokenSaleId: string | null; + tokenFactoryId: string | null; + status: import("@prisma/client").$Enums.CampaignStatus; + id: string; + previousStatus: import("@prisma/client").$Enums.CampaignStatus | null; + createdAt: Date; + updatedAt: Date; + }; + } & { + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + })[]>; + findOne(id: string): Promise<{ + campaign: { + name: string; + description: string | null; + issuerAddress: string; + escrowId: string; + poolSize: import("@prisma/client/runtime/library").Decimal; + loanDuration: number; + expectedReturn: import("@prisma/client/runtime/library").Decimal; + loanSize: import("@prisma/client/runtime/library").Decimal; + vaultId: string | null; + tokenSaleId: string | null; + tokenFactoryId: string | null; + status: import("@prisma/client").$Enums.CampaignStatus; + id: string; + previousStatus: import("@prisma/client").$Enums.CampaignStatus | null; + createdAt: Date; + updatedAt: Date; + }; + } & { + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + }>; + findByCampaign(campaignId: string): import("@prisma/client").Prisma.PrismaPromise<{ + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + }[]>; + create(dto: CreateLoanDto): Promise<{ + campaign: { + name: string; + description: string | null; + issuerAddress: string; + escrowId: string; + poolSize: import("@prisma/client/runtime/library").Decimal; + loanDuration: number; + expectedReturn: import("@prisma/client/runtime/library").Decimal; + loanSize: import("@prisma/client/runtime/library").Decimal; + vaultId: string | null; + tokenSaleId: string | null; + tokenFactoryId: string | null; + status: import("@prisma/client").$Enums.CampaignStatus; + id: string; + previousStatus: import("@prisma/client").$Enums.CampaignStatus | null; + createdAt: Date; + updatedAt: Date; + }; + } & { + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + }>; + update(id: string, dto: UpdateLoanDto): Promise<{ + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + }>; + remove(id: string): Promise<{ + description: string; + status: import("@prisma/client").$Enums.LoanStatus; + id: string; + createdAt: Date; + updatedAt: Date; + campaignId: string; + amount: import("@prisma/client/runtime/library").Decimal; + receiver: string; + milestoneIndex: number | null; + disbursedAt: Date | null; + repaidAt: Date | null; + }>; + getCampaignLoanStats(campaignId: string): import("@prisma/client").Prisma.PrismaPromise>; + private validateStatusTransition; +} diff --git a/apps/core/dist/loans/loans.service.js b/apps/core/dist/loans/loans.service.js new file mode 100644 index 0000000..2fca8d6 --- /dev/null +++ b/apps/core/dist/loans/loans.service.js @@ -0,0 +1,110 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LoansService = void 0; +const common_1 = require("@nestjs/common"); +const client_1 = require("@prisma/client"); +const prisma_service_1 = require("../prisma/prisma.service"); +const ALLOWED_TRANSITIONS = { + [client_1.LoanStatus.PENDING]: [client_1.LoanStatus.DISBURSED], + [client_1.LoanStatus.DISBURSED]: [client_1.LoanStatus.REPAID, client_1.LoanStatus.DEFAULTED], + [client_1.LoanStatus.REPAID]: [], + [client_1.LoanStatus.DEFAULTED]: [], +}; +let LoansService = class LoansService { + prisma; + constructor(prisma) { + this.prisma = prisma; + } + findAll() { + return this.prisma.loan.findMany({ + orderBy: { createdAt: 'desc' }, + include: { campaign: true }, + }); + } + async findOne(id) { + const loan = await this.prisma.loan.findUnique({ + where: { id }, + include: { campaign: true }, + }); + if (!loan) + throw new common_1.NotFoundException(`Loan ${id} not found`); + return loan; + } + findByCampaign(campaignId) { + return this.prisma.loan.findMany({ + where: { campaignId }, + orderBy: { createdAt: 'asc' }, + }); + } + async create(dto) { + const campaign = await this.prisma.campaign.findUnique({ + where: { id: dto.campaignId }, + }); + if (!campaign) { + throw new common_1.NotFoundException(`Campaign ${dto.campaignId} not found`); + } + if (dto.amount > Number(campaign.loanSize)) { + throw new common_1.BadRequestException(`Loan amount ${dto.amount} exceeds campaign loan size ${campaign.loanSize}`); + } + const stats = await this.prisma.loan.aggregate({ + where: { campaignId: dto.campaignId }, + _sum: { amount: true }, + }); + const currentTotal = Number(stats._sum.amount ?? 0); + if (currentTotal + dto.amount > Number(campaign.poolSize)) { + throw new common_1.BadRequestException(`Total loans (${currentTotal + dto.amount}) would exceed pool size ${campaign.poolSize}`); + } + return this.prisma.loan.create({ + data: dto, + include: { campaign: true }, + }); + } + async update(id, dto) { + const loan = await this.findOne(id); + if (dto.status) { + this.validateStatusTransition(loan.status, dto.status); + } + return this.prisma.loan.update({ + where: { id }, + data: dto, + }); + } + async remove(id) { + const loan = await this.findOne(id); + if (loan.status !== client_1.LoanStatus.PENDING) { + throw new common_1.BadRequestException(`Cannot delete loan in status ${loan.status}. Only PENDING loans can be deleted.`); + } + return this.prisma.loan.delete({ where: { id } }); + } + getCampaignLoanStats(campaignId) { + return this.prisma.loan.aggregate({ + where: { campaignId }, + _sum: { amount: true }, + _count: true, + }); + } + validateStatusTransition(current, next) { + if (current === next) { + throw new common_1.BadRequestException(`Loan is already in status ${current}`); + } + const allowed = ALLOWED_TRANSITIONS[current]; + if (!allowed.includes(next)) { + throw new common_1.BadRequestException(`Invalid status transition from ${current} to ${next}`); + } + } +}; +exports.LoansService = LoansService; +exports.LoansService = LoansService = __decorate([ + (0, common_1.Injectable)(), + __metadata("design:paramtypes", [prisma_service_1.PrismaService]) +], LoansService); +//# sourceMappingURL=loans.service.js.map \ No newline at end of file diff --git a/apps/core/dist/loans/loans.service.js.map b/apps/core/dist/loans/loans.service.js.map new file mode 100644 index 0000000..ff7e23d --- /dev/null +++ b/apps/core/dist/loans/loans.service.js.map @@ -0,0 +1 @@ +{"version":3,"file":"loans.service.js","sourceRoot":"","sources":["../../src/loans/loans.service.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/apps/core/dist/participation-token/dto/buy.dto.d.ts b/apps/core/dist/participation-token/dto/buy.dto.d.ts new file mode 100644 index 0000000..a9fbf0c --- /dev/null +++ b/apps/core/dist/participation-token/dto/buy.dto.d.ts @@ -0,0 +1,8 @@ +export declare class BuyDto { + contractId: string; + usdcAddress: string; + payer: string; + beneficiary: string; + amount: number; + callerPublicKey: string; +} diff --git a/apps/core/dist/participation-token/dto/buy.dto.js b/apps/core/dist/participation-token/dto/buy.dto.js new file mode 100644 index 0000000..533ba69 --- /dev/null +++ b/apps/core/dist/participation-token/dto/buy.dto.js @@ -0,0 +1,53 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BuyDto = void 0; +const class_validator_1 = require("class-validator"); +class BuyDto { + contractId; + usdcAddress; + payer; + beneficiary; + amount; + callerPublicKey; +} +exports.BuyDto = BuyDto; +__decorate([ + (0, class_validator_1.IsString)(), + (0, class_validator_1.IsNotEmpty)(), + __metadata("design:type", String) +], BuyDto.prototype, "contractId", void 0); +__decorate([ + (0, class_validator_1.IsString)(), + (0, class_validator_1.IsNotEmpty)(), + __metadata("design:type", String) +], BuyDto.prototype, "usdcAddress", void 0); +__decorate([ + (0, class_validator_1.IsString)(), + (0, class_validator_1.IsNotEmpty)(), + __metadata("design:type", String) +], BuyDto.prototype, "payer", void 0); +__decorate([ + (0, class_validator_1.IsString)(), + (0, class_validator_1.IsNotEmpty)(), + __metadata("design:type", String) +], BuyDto.prototype, "beneficiary", void 0); +__decorate([ + (0, class_validator_1.IsNumber)(), + (0, class_validator_1.IsPositive)(), + __metadata("design:type", Number) +], BuyDto.prototype, "amount", void 0); +__decorate([ + (0, class_validator_1.IsString)(), + (0, class_validator_1.IsNotEmpty)(), + __metadata("design:type", String) +], BuyDto.prototype, "callerPublicKey", void 0); +//# sourceMappingURL=buy.dto.js.map \ No newline at end of file diff --git a/apps/core/dist/participation-token/dto/buy.dto.js.map b/apps/core/dist/participation-token/dto/buy.dto.js.map new file mode 100644 index 0000000..7e44ce9 --- /dev/null +++ b/apps/core/dist/participation-token/dto/buy.dto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"buy.dto.js","sourceRoot":"","sources":["../../../src/participation-token/dto/buy.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA6E;AAE7E,MAAa,MAAM;IAGjB,UAAU,CAAS;IAInB,WAAW,CAAS;IAIpB,KAAK,CAAS;IAId,WAAW,CAAS;IAIpB,MAAM,CAAS;IAIf,eAAe,CAAS;CACzB;AAxBD,wBAwBC;AArBC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;0CACM;AAInB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;2CACO;AAIpB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qCACC;AAId;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;2CACO;AAIpB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;sCACE;AAIf;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;+CACW"} \ No newline at end of file diff --git a/apps/core/dist/participation-token/participation-token.controller.d.ts b/apps/core/dist/participation-token/participation-token.controller.d.ts new file mode 100644 index 0000000..99b9ca3 --- /dev/null +++ b/apps/core/dist/participation-token/participation-token.controller.d.ts @@ -0,0 +1,9 @@ +import { ParticipationTokenService } from './participation-token.service'; +import { BuyDto } from './dto/buy.dto'; +export declare class ParticipationTokenController { + private readonly participationTokenService; + constructor(participationTokenService: ParticipationTokenService); + buy(dto: BuyDto): Promise<{ + unsignedXdr: string; + }>; +} diff --git a/apps/core/dist/participation-token/participation-token.controller.js b/apps/core/dist/participation-token/participation-token.controller.js new file mode 100644 index 0000000..1dd1fc8 --- /dev/null +++ b/apps/core/dist/participation-token/participation-token.controller.js @@ -0,0 +1,41 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ParticipationTokenController = void 0; +const common_1 = require("@nestjs/common"); +const participation_token_service_1 = require("./participation-token.service"); +const buy_dto_1 = require("./dto/buy.dto"); +let ParticipationTokenController = class ParticipationTokenController { + participationTokenService; + constructor(participationTokenService) { + this.participationTokenService = participationTokenService; + } + async buy(dto) { + const unsignedXdr = await this.participationTokenService.buy(dto); + return { unsignedXdr }; + } +}; +exports.ParticipationTokenController = ParticipationTokenController; +__decorate([ + (0, common_1.Post)('buy'), + __param(0, (0, common_1.Body)()), + __metadata("design:type", Function), + __metadata("design:paramtypes", [buy_dto_1.BuyDto]), + __metadata("design:returntype", Promise) +], ParticipationTokenController.prototype, "buy", null); +exports.ParticipationTokenController = ParticipationTokenController = __decorate([ + (0, common_1.Controller)('participation-token'), + __metadata("design:paramtypes", [participation_token_service_1.ParticipationTokenService]) +], ParticipationTokenController); +//# sourceMappingURL=participation-token.controller.js.map \ No newline at end of file diff --git a/apps/core/dist/participation-token/participation-token.controller.js.map b/apps/core/dist/participation-token/participation-token.controller.js.map new file mode 100644 index 0000000..4fb2177 --- /dev/null +++ b/apps/core/dist/participation-token/participation-token.controller.js.map @@ -0,0 +1 @@ +{"version":3,"file":"participation-token.controller.js","sourceRoot":"","sources":["../../src/participation-token/participation-token.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwD;AACxD,+EAA0E;AAC1E,2CAAuC;AAGhC,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAEpB;IADnB,YACmB,yBAAoD;QAApD,8BAAyB,GAAzB,yBAAyB,CAA2B;IACpE,CAAC;IAGE,AAAN,KAAK,CAAC,GAAG,CAAS,GAAW;QAC3B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClE,OAAO,EAAE,WAAW,EAAE,CAAC;IACzB,CAAC;CACF,CAAA;AAVY,oEAA4B;AAMjC;IADL,IAAA,aAAI,EAAC,KAAK,CAAC;IACD,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,gBAAM;;uDAG5B;uCATU,4BAA4B;IADxC,IAAA,mBAAU,EAAC,qBAAqB,CAAC;qCAGc,uDAAyB;GAF5D,4BAA4B,CAUxC"} \ No newline at end of file diff --git a/apps/core/dist/participation-token/participation-token.module.d.ts b/apps/core/dist/participation-token/participation-token.module.d.ts new file mode 100644 index 0000000..3b13ea0 --- /dev/null +++ b/apps/core/dist/participation-token/participation-token.module.d.ts @@ -0,0 +1,2 @@ +export declare class ParticipationTokenModule { +} diff --git a/apps/core/dist/participation-token/participation-token.module.js b/apps/core/dist/participation-token/participation-token.module.js new file mode 100644 index 0000000..cf0b408 --- /dev/null +++ b/apps/core/dist/participation-token/participation-token.module.js @@ -0,0 +1,22 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ParticipationTokenModule = void 0; +const common_1 = require("@nestjs/common"); +const participation_token_controller_1 = require("./participation-token.controller"); +const participation_token_service_1 = require("./participation-token.service"); +let ParticipationTokenModule = class ParticipationTokenModule { +}; +exports.ParticipationTokenModule = ParticipationTokenModule; +exports.ParticipationTokenModule = ParticipationTokenModule = __decorate([ + (0, common_1.Module)({ + controllers: [participation_token_controller_1.ParticipationTokenController], + providers: [participation_token_service_1.ParticipationTokenService], + }) +], ParticipationTokenModule); +//# sourceMappingURL=participation-token.module.js.map \ No newline at end of file diff --git a/apps/core/dist/participation-token/participation-token.module.js.map b/apps/core/dist/participation-token/participation-token.module.js.map new file mode 100644 index 0000000..e4dd90d --- /dev/null +++ b/apps/core/dist/participation-token/participation-token.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"participation-token.module.js","sourceRoot":"","sources":["../../src/participation-token/participation-token.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qFAAgF;AAChF,+EAA0E;AAMnE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;CAAG,CAAA;AAA3B,4DAAwB;mCAAxB,wBAAwB;IAJpC,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,6DAA4B,CAAC;QAC3C,SAAS,EAAE,CAAC,uDAAyB,CAAC;KACvC,CAAC;GACW,wBAAwB,CAAG"} \ No newline at end of file diff --git a/apps/core/dist/participation-token/participation-token.service.d.ts b/apps/core/dist/participation-token/participation-token.service.d.ts new file mode 100644 index 0000000..1e1c02b --- /dev/null +++ b/apps/core/dist/participation-token/participation-token.service.d.ts @@ -0,0 +1,7 @@ +import { SorobanService } from '../soroban/soroban.service'; +import { BuyDto } from './dto/buy.dto'; +export declare class ParticipationTokenService { + private readonly soroban; + constructor(soroban: SorobanService); + buy(dto: BuyDto): Promise; +} diff --git a/apps/core/dist/participation-token/participation-token.service.js b/apps/core/dist/participation-token/participation-token.service.js new file mode 100644 index 0000000..8e58143 --- /dev/null +++ b/apps/core/dist/participation-token/participation-token.service.js @@ -0,0 +1,34 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ParticipationTokenService = void 0; +const common_1 = require("@nestjs/common"); +const soroban_service_1 = require("../soroban/soroban.service"); +let ParticipationTokenService = class ParticipationTokenService { + soroban; + constructor(soroban) { + this.soroban = soroban; + } + buy(dto) { + return this.soroban.buildContractCallTransaction(dto.contractId, 'buy', { + usdc: dto.usdcAddress, + payer: dto.payer, + beneficiary: dto.beneficiary, + amount: dto.amount, + }, dto.callerPublicKey); + } +}; +exports.ParticipationTokenService = ParticipationTokenService; +exports.ParticipationTokenService = ParticipationTokenService = __decorate([ + (0, common_1.Injectable)(), + __metadata("design:paramtypes", [soroban_service_1.SorobanService]) +], ParticipationTokenService); +//# sourceMappingURL=participation-token.service.js.map \ No newline at end of file diff --git a/apps/core/dist/participation-token/participation-token.service.js.map b/apps/core/dist/participation-token/participation-token.service.js.map new file mode 100644 index 0000000..f9e57c2 --- /dev/null +++ b/apps/core/dist/participation-token/participation-token.service.js.map @@ -0,0 +1 @@ +{"version":3,"file":"participation-token.service.js","sourceRoot":"","sources":["../../src/participation-token/participation-token.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,gEAA4D;AAIrD,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACP;IAA7B,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,4BAA4B,CAC9C,GAAG,CAAC,UAAU,EACd,KAAK,EACL;YACE,IAAI,EAAE,GAAG,CAAC,WAAW;YACrB,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,MAAM,EAAE,GAAG,CAAC,MAAM;SACnB,EACD,GAAG,CAAC,eAAe,CACpB,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;qCAE2B,gCAAc;GADzC,yBAAyB,CAgBrC"} \ No newline at end of file diff --git a/apps/core/src/app.module.ts b/apps/core/src/app.module.ts index d14e90f..9c0981d 100644 --- a/apps/core/src/app.module.ts +++ b/apps/core/src/app.module.ts @@ -7,9 +7,10 @@ import { CampaignsModule } from './campaigns/campaigns.module'; import { InvestmentsModule } from './investments/investments.module'; import { DeployModule } from './deploy/deploy.module'; import { LoansModule } from './loans/loans.module'; +import { ParticipationTokenModule } from './participation-token/participation-token.module'; @Module({ - imports: [PrismaModule, SorobanModule, CampaignsModule, InvestmentsModule, DeployModule, LoansModule], + imports: [PrismaModule, SorobanModule, CampaignsModule, InvestmentsModule, DeployModule, LoansModule,ParticipationTokenModule], controllers: [AppController], providers: [AppService], }) diff --git a/apps/core/src/deploy/deploy.service.ts b/apps/core/src/deploy/deploy.service.ts index 243253a..ffd8b08 100644 --- a/apps/core/src/deploy/deploy.service.ts +++ b/apps/core/src/deploy/deploy.service.ts @@ -24,8 +24,7 @@ export class DeployService { this.participationTokenWasmHash, { escrow_contract: dto.escrowContractId, - participation_token: dto.callerPublicKey, - admin: dto.callerPublicKey, + participation_token: dto.tokenContractId, }, dto.callerPublicKey, ); diff --git a/apps/core/src/deploy/dto/deploy-participation-token.dto.ts b/apps/core/src/deploy/dto/deploy-participation-token.dto.ts index cc91ed1..853e947 100644 --- a/apps/core/src/deploy/dto/deploy-participation-token.dto.ts +++ b/apps/core/src/deploy/dto/deploy-participation-token.dto.ts @@ -5,6 +5,10 @@ export class DeployParticipationTokenDto { @IsNotEmpty() escrowContractId: string; + @IsString() + @IsNotEmpty() + tokenContractId: string; + @IsString() @IsNotEmpty() callerPublicKey: string; diff --git a/apps/core/src/participation-token/dto/buy.dto.ts b/apps/core/src/participation-token/dto/buy.dto.ts new file mode 100644 index 0000000..4a1aca9 --- /dev/null +++ b/apps/core/src/participation-token/dto/buy.dto.ts @@ -0,0 +1,27 @@ +import { IsString, IsNotEmpty, IsNumber, IsPositive } from 'class-validator'; + +export class BuyDto { + @IsString() + @IsNotEmpty() + contractId: string; + + @IsString() + @IsNotEmpty() + usdcAddress: string; + + @IsString() + @IsNotEmpty() + payer: string; + + @IsString() + @IsNotEmpty() + beneficiary: string; + + @IsNumber() + @IsPositive() + amount: number; + + @IsString() + @IsNotEmpty() + callerPublicKey: string; +} diff --git a/apps/core/src/participation-token/participation-token.controller.ts b/apps/core/src/participation-token/participation-token.controller.ts new file mode 100644 index 0000000..33e2545 --- /dev/null +++ b/apps/core/src/participation-token/participation-token.controller.ts @@ -0,0 +1,16 @@ +import { Controller, Post, Body } from '@nestjs/common'; +import { ParticipationTokenService } from './participation-token.service'; +import { BuyDto } from './dto/buy.dto'; + +@Controller('participation-token') +export class ParticipationTokenController { + constructor( + private readonly participationTokenService: ParticipationTokenService, + ) {} + + @Post('buy') + async buy(@Body() dto: BuyDto) { + const unsignedXdr = await this.participationTokenService.buy(dto); + return { unsignedXdr }; + } +} diff --git a/apps/core/src/participation-token/participation-token.module.ts b/apps/core/src/participation-token/participation-token.module.ts new file mode 100644 index 0000000..32655ce --- /dev/null +++ b/apps/core/src/participation-token/participation-token.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { ParticipationTokenController } from './participation-token.controller'; +import { ParticipationTokenService } from './participation-token.service'; + +@Module({ + controllers: [ParticipationTokenController], + providers: [ParticipationTokenService], +}) +export class ParticipationTokenModule {} diff --git a/apps/core/src/participation-token/participation-token.service.ts b/apps/core/src/participation-token/participation-token.service.ts new file mode 100644 index 0000000..4f98bd8 --- /dev/null +++ b/apps/core/src/participation-token/participation-token.service.ts @@ -0,0 +1,22 @@ +import { Injectable } from '@nestjs/common'; +import { SorobanService } from '../soroban/soroban.service'; +import { BuyDto } from './dto/buy.dto'; + +@Injectable() +export class ParticipationTokenService { + constructor(private readonly soroban: SorobanService) {} + + buy(dto: BuyDto): Promise { + return this.soroban.buildContractCallTransaction( + dto.contractId, + 'buy', + { + usdc: dto.usdcAddress, + payer: dto.payer, + beneficiary: dto.beneficiary, + amount: dto.amount, + }, + dto.callerPublicKey, + ); + } +}