Repository navigation
feat(scripts): desplegar la factory en testnet y regenerar los bindings - #51
Merged
Merged
Conversation
jzelada97
requested review from
CarlosJX7,
Diego-Matoss and
RicardoMatosR
as code owners
October 25, 2026 20:27
RicardoMatosR
approved these changes
Oct 25, 2026
5 of 6 tasks
4 of 6 tasks
CarlosJX7
pushed a commit
that referenced
this pull request
Oct 25, 2026
) ## Qué cambia La API ya permite **crear, fondear, aprobar y consultar fianzas** contra la factory de testnet, con el bucle build → sign → submit de INTERFACES § 8 y sin cambiar la interfaz. **Builds** (`UnsignedTransactionResponse`): - Firmante **G**: XDR preparado, con el firmante como origen. - Firmante **C** (passkey): además, `soroban { func, auth, validUntilLedger = latest + 60 }` para `signAndSendBuilt` (#43). | Ruta | Contrato | |---|---| | `POST /fianzas/v1/fianzas` | `factory.create_fianza`. Lee `configVersion` si no viene (FAC-6), genera `nonce` si falta y devuelve el `contractId` predicho con `predict_address` | | `POST /fianzas/v1/fianzas/{contractId}/cancel` | `escrow.cancel` | | `POST /escrow/single-release/v2/fund` (TW) | `escrow.fund_escrow`. Los `Terms` se leen de la cadena y se reenvían **sin re-codificar** como `expected_terms`; un `amount` distinto da 422 `ESCROW_PROPERTIES_MISMATCH`; `inviteCode` opcional, nunca se registra | | `POST …/approve-milestones` (TW) | `escrow.approve_release`. Solo `milestoneIndexes: [0]` | | `POST …/approve-and-release-milestones` (TW) | Igual; si la aprobación no liquida, 422 `ESCROW_NOT_COMPLETED` | | `POST …/extend-ttl` (TW) | `escrow.extend_contract_ttl` | **Lecturas** (importes en string decimal y camelCase): - `GET /fianzas/v1/fianzas/by-id/{id}`, `{contractId}/terms` (las 4 comisiones), `{contractId}/view`, `{contractId}/yield` y `{contractId}/preview-settlement?deduction=`. - `GET /fianzas/v1/landlords/{address}/fianzas` y `tenants/{address}/fianzas`: índices de la factory + `get_fianzas` en lotes de 25, con cursor opaco y filtro `status`. **Seguridad:** - Antes de construir nada sobre un `contractId` se comprueba `factory.id_of`: los contratos ajenos dan 404 `ESCROW_NOT_FOUND` y no se construye nada contra ellos. - Los `Error(Contract, #N)` de escrow y factory se traducen a códigos TW/`FZ_*` (p. ej. `ConfigChanged` → 409 `FZ_CONFIG_CHANGED`, `VaultError` → 503 `FZ_VAULT_UNAVAILABLE`, reintentable), siempre con `extensions.contractError`. **Pendiente:** - `stop`, `assign-expert`, `record-report`, `resolve` y los dos `claim-*` siguen en 501 hasta que el escrow los tenga. - Las lecturas en forma TW (`GET /escrows…`) también siguen en 501, con el endpoint que las sustituye. ## Issue Closes #52 ## Cómo probarlo ```bash pnpm install && pnpm --filter @fianzas/api typecheck && pnpm --filter @fianzas/api test # 21 tests (11 nuevos) ``` **e2e en testnet a través de la API**, firmando con la CLI. Casero `fianzas-faucet`, inquilino `fianzas-admin`, `custody`, 1 USDC: 1. `POST /fianzas/v1/fianzas` → `contractId` predicho `CAGKN4…NASA`, `configVersion` 7. 2. Firmada y enviada con `send-transaction` → `SUCCESS`. 3. `terms` (id 1, 1 USDC, bond limitado a 1 USDC) y `by-id/1` coinciden. 4. `fund` → firmada y enviada → `SUCCESS`. 5. Aparece `Active` en la lista del casero y en la del inquilino. Con un firmante **C**, `create_fianza` devuelve una auth entry `sorobanCredentialsAddress` de esa C-address y `func` = `factory.create_fianza` (la raíz que acepta la `RelayPolicy`). ## Notas - #45 y #51 ya están en `main` (los fusionó Ricardo); la rama lleva `main` al día, incluido #43. - `view`, `yield`, `preview-settlement` y `approve_release` funcionan cuando entre #48 y suba su wasm con `scripts/deploy` (`set_escrow_wasm_hash`). Con el escrow actual la simulación falla y la API responde 502 `STELLAR_SIMULATION_FAILED`. - Toca `pnpm-lock.yaml` (`@fianzas/bindings` en la API) con el lock `deps` (#49). - **Para P3 y P4:** el flujo completo es `POST /api/fianzas/v1/fianzas` → `wallet.signAndSendBuilt(res)` → `POST /api/escrow/single-release/v2/fund` → `signAndSendBuilt`. Las listas del panel están en `/api/fianzas/v1/landlords/{address}/fianzas`. ## Checklist - [x] Solo toca mi área (api) + `pnpm-lock.yaml` con lock `deps` - [x] Tests y typecheck del workspace en verde en local - [x] No cambia `docs/INTERFACES.md` (implementa § 8 tal como está) - [x] No toca contratos - [x] Sin secretos: las direcciones salen de `deployments/testnet.json` - [ ] > 300 líneas: ~600 de código y ~250 de tests; es el conjunto mínimo para el camino feliz de la demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Qué cambia
La plataforma ya tiene factory desplegada en testnet y la API la lee.
scripts/deploy/deploy.mjs(idempotente;deployments/testnet.jsones el estado y firmafianzas-adminde la CLI, sin secretos en el repo):upgrade; escrow sinupgrade/sweep/rescue);escrowWasmHashesAllowed;timeout_secs120,review_timeout_secs300, bond mínimo de 10 USDC y 500 bps,vault_manager: Noneen testnet);usdc_fixedpor defecto;funding_allowedy la trustline de la tesorería.Si la factory ya existe y cambia el wasm del escrow, solo hace
set_escrow_wasm_hash. Lo usaré tal cual cuando entre feat(escrow): depositar en DeFindex y liquidar con approve_release #48.Desplegado (testnet):
CC3QA5DN37DBUFLFFOLXZYXRL4MZ2GAKQ5OTJDG2AQ7DMGRGCKV5W2IL(desde el ledger 5387195)4e841052…4a5b2f(el demain, todavía sin vault: conusdc_fixed/usdc_mockel fondeo daVaultErrorhasta feat(escrow): depositar en DeFindex y liquidar con approve_release #48;custodyfunciona)usdc_fixedCDKNUO…OQO,max_vault_fee_bps200 (comisión actual: 100)usdc_mockCBHM2L…CRYUcustodyconfig_version@fianzas/bindingsregenerado paraescrow,factoryymock_vault.scripts/bindings.shdeja solosrc/de cada contrato, y el paquete declara@stellar/stellar-sdk16.4.1 (igual que wallet y api) ybuffer, con su propiotypecheck.WASM_HASHES.txtcoincide con los wasm desplegados (comprobado constellar contract fetch).API:
GET /fianzas/v1/configdaba 500 con factory (BigInten JSON). Ahora devuelve la misma forma camelCase que sin factory, másconfigVersion(FAC-6: lo que firma el casero enexpected_config_version), timeouts, bond yvaultManager.pricePerShareesnullen un vault sin shares, en vez de "0".Issue
Closes #50
Cómo probarlo
Comprobado en testnet:
create_fianzasimulado concustodyy conusdc_fixed: despliega en la dirección depredict_addressy copia el snapshot de comisiones (100/2000).expected_config_version6 →Error(Contract, #21)(ConfigChanged).configVersion: 7yusdc_fixeda 1,0000125 USDC por share.Notas
pnpm-lock.yamlcon el lockdeps(LOCK: deps #49).fix(api); con el squash da igual.FianzaParams.expected_config_versionsale deGET /api/fianzas/v1/config→configVersion.Checklist
pnpm-lock.yamlcon lockdepsdocs/INTERFACES.mddeployments/testnet.json