Skip to content

Commit 5033174

Browse files
authored
feat(core): add Vault deployment endpoint (#51)
* feat(core): add Vault deployment endpoint * docs(core): update README with Prisma workflow guide and add migration scripts
1 parent e9b5b28 commit 5033174

14 files changed

+238
-27
lines changed

apps/core/README.md

Lines changed: 90 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
<p align="center">
2-
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
3-
</p>
4-
5-
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
6-
[circleci-url]: https://circleci.com/gh/nestjs/nest
7-
8-
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
9-
<p align="center">
10-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
11-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
12-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
13-
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
14-
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
15-
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
16-
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
17-
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
18-
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
19-
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
20-
</p>
21-
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
22-
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
23-
241
## Description
252

263
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
@@ -29,10 +6,99 @@
296

307
```bash
318
$ npm install
9+
```
10+
11+
## Variables de entorno
12+
13+
Copia el archivo de ejemplo y configura la URL de la base de datos:
14+
15+
```bash
16+
$ cp .env.example .env
17+
```
18+
19+
Edita el `.env` con las credenciales de la base de datos proporcionadas por el equipo:
20+
21+
```env
22+
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE"
23+
```
24+
25+
---
26+
27+
## 🗄️ Base de datos y Prisma
28+
29+
Este proyecto usa una base de datos PostgreSQL compartida en la nube. Todo el equipo apunta a la misma instancia.
30+
31+
### Comandos disponibles
32+
33+
```bash
34+
# Genera el Prisma Client (tipos y métodos ORM) a partir del schema.prisma
3235
$ npm run prisma:generate
33-
$ npm run prisma:migrate -- --name init
36+
37+
# Crea una nueva migración Y la aplica en la DB (solo quien hace el cambio)
38+
$ npm run prisma:migrate -- --name nombre_descriptivo
39+
40+
# Aplica migraciones pendientes sin generar ni resetear nada (todos los demás)
41+
$ npm run prisma:deploy
42+
```
43+
44+
---
45+
46+
### 🟢 Soy nuevo en el proyecto
47+
48+
Estos son los únicos comandos que debes correr para dejar la DB lista:
49+
50+
```bash
51+
$ npm run prisma:deploy # aplica todas las migraciones existentes en la DB
52+
$ npm run prisma:generate # genera el cliente con los tipos actuales
53+
```
54+
55+
> ⚠️ **Nunca corras `prisma:migrate` si no hiciste un cambio al schema, y nunca corras `prisma migrate reset` — eso borra todos los datos de la base de datos compartida.**
56+
57+
---
58+
59+
### 🔵 Hice pull y alguien modificó el schema
60+
61+
Cuando hagas `git pull` y veas cambios en `prisma/schema.prisma` o en `prisma/migrations/`, ejecuta:
62+
63+
```bash
64+
$ npm run prisma:deploy # sincroniza las migraciones nuevas con la DB
65+
$ npm run prisma:generate # regenera el cliente con los nuevos tipos
3466
```
3567

68+
---
69+
70+
### 🟡 Necesito modificar el schema de la base de datos
71+
72+
1. Edita `prisma/schema.prisma` con tus cambios
73+
2. Crea y aplica la migración en la DB:
74+
75+
```bash
76+
$ npm run prisma:migrate -- --name descripcion_del_cambio
77+
```
78+
79+
3. Commitea **ambos** archivos, esto es obligatorio:
80+
81+
```bash
82+
$ git add prisma/schema.prisma
83+
$ git add prisma/migrations/
84+
$ git commit -m "feat: descripcion del cambio"
85+
$ git push
86+
```
87+
88+
> El resto del equipo solo necesita hacer `git pull` y luego correr `prisma:deploy` + `prisma:generate`.
89+
90+
---
91+
92+
### Resumen del flujo
93+
94+
| Situación | Comandos |
95+
|---|---|
96+
| Soy nuevo en el proyecto | `prisma:deploy``prisma:generate` |
97+
| Hice pull con cambios de otro | `prisma:deploy``prisma:generate` |
98+
| Modifiqué el schema | `prisma:migrate -- --name <nombre>` → commit y push |
99+
100+
---
101+
36102
## Compile and run the project
37103

38104
```bash

apps/core/dist/deploy/deploy.controller.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DeployService } from './deploy.service';
22
import { DeployParticipationTokenDto } from './dto/deploy-participation-token.dto';
33
import { DeployTokenFactoryDto } from './dto/deploy-token-factory.dto';
4+
import { DeployVaultDto } from './dto/deploy-vault.dto';
45
export declare class DeployController {
56
private readonly deployService;
67
constructor(deployService: DeployService);
@@ -10,4 +11,7 @@ export declare class DeployController {
1011
deployTokenFactory(dto: DeployTokenFactoryDto): Promise<{
1112
unsignedXdr: string;
1213
}>;
14+
deployVault(dto: DeployVaultDto): Promise<{
15+
unsignedXdr: string;
16+
}>;
1317
}

apps/core/dist/deploy/deploy.controller.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/core/dist/deploy/deploy.controller.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { SorobanService } from '../soroban/soroban.service';
22
import { DeployParticipationTokenDto } from './dto/deploy-participation-token.dto';
33
import { DeployTokenFactoryDto } from './dto/deploy-token-factory.dto';
4+
import { DeployVaultDto } from './dto/deploy-vault.dto';
45
export declare class DeployService {
56
private readonly soroban;
67
private readonly participationTokenWasmHash;
78
private readonly tokenFactoryWasmHash;
9+
private readonly vaultWasmHash;
810
constructor(soroban: SorobanService);
911
deployParticipationToken(dto: DeployParticipationTokenDto): Promise<string>;
1012
deployTokenFactory(dto: DeployTokenFactoryDto): Promise<string>;
13+
deployVault(dto: DeployVaultDto): Promise<string>;
1114
}

apps/core/dist/deploy/deploy.service.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/core/dist/deploy/deploy.service.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export declare class DeployVaultDto {
2+
admin: string;
3+
enabled: boolean;
4+
roiPercentage: number;
5+
token: string;
6+
usdc: string;
7+
callerPublicKey: string;
8+
}

apps/core/dist/deploy/dto/deploy-vault.dto.js

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/core/dist/deploy/dto/deploy-vault.dto.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)