Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
c50224b
docs: añade auditoría técnica completa del proyecto
Adlgr87 Oct 23, 2026
f7c156c
docs: plan de implementación por fases con ADRs y gates verificables
Adlgr87 Oct 23, 2026
f479839
feat(fases 0-1): CI, guardarraíles y arreglo de la integridad on-chain
Adlgr87 Oct 23, 2026
b9c0784
docs: corrige el conteo de pruebas (263 en el commit auditado, 308 ah…
Adlgr87 Oct 23, 2026
97c3988
feat(fase 2): administración del contrato escrow (S-03, D-03)
Adlgr87 Oct 23, 2026
6183291
feat(fase 3): endurecimiento de la API (S-04, S-05, D-01, D-02)
Adlgr87 Oct 23, 2026
6bc6619
Fase 4: economía única (F-03), importes configurables (H-*) y U-05
Adlgr87 Oct 23, 2026
03798e0
Fase 5: capa Telegram (F-01, F-14, F-02, F-04, S-06, U-01…U-04, U-06)
Adlgr87 Oct 23, 2026
9b05bc1
Fase 6: rendimiento y activos (R-01, R-02, R-03, R-04, R-05, R-06, R-…
Adlgr87 Oct 23, 2026
3c684f5
CI: npm audit con excepciones caducables en vez de bajar el nivel
Adlgr87 Oct 23, 2026
596794b
R-07: dividir verify_ton_proof y settle_prediction + trinquete de com…
Adlgr87 Oct 23, 2026
0881643
docs: cobertura medida tras R-07 (85.0 %)
Adlgr87 Oct 23, 2026
2855c9f
fix(F-04): los avisos de una resolución salen solo del outbox
Adlgr87 Oct 23, 2026
0644ec4
Fase 7: mantenibilidad, dependencias y tooling del contrato
Adlgr87 Oct 23, 2026
e4ca53a
test(security): fijar la caducidad de los nonces
Adlgr87 Oct 23, 2026
d76378c
docs(auditoria): recuento de tests al día
Adlgr87 Oct 23, 2026
eb8a036
Identidad visual: el logo de BetPoly pasa a ser el icono y la marca d…
Adlgr87 Oct 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,24 @@ REMINDER_HOURS_BEFORE=24
# --- Contrato escrow ---------------------------------------------------------
# Dirección del contrato desplegado (contracts/escrow.fc), formato EQ... / 0:...
ESCROW_ADDRESS=
# Dirección del admin del contrato (la que firmará resolve/cancel). Informativo.
# Dirección del admin del contrato (firma resolve/cancel/pausa/comisión/retiro).
# El backend la usa para avisar si tu wallet vinculada no es la administradora;
# opcional, pero sin ella no puede comprobarlo.
ESCROW_ADMIN_ADDRESS=
# Apuesta mínima aceptada por el contrato, en nanoTON (0.1 TON)
MIN_STAKE_NANO=100000000
# Apuesta máxima que el backend acepta preparar, en nanoTON (5000 TON)
MAX_STAKE_NANO=5000000000000
MAX_OPTIONS=8
# Gas adjunto por operación, en nanoTON (0.03 / 0.05 / 0.05 / 0.02 TON)
BET_GAS_NANO=30000000
CREATE_GAS_NANO=50000000
ADMIN_GAS_NANO=50000000
CLAIM_GAS_NANO=20000000
# Ventana de creación de mercados y caducidad de la firma
MIN_MARKET_DURATION_MIN=15
MAX_MARKET_DURATION_DAYS=365
TX_TTL_SECONDS=300

# --- TON Connect / ton_proof -------------------------------------------------
PUBLIC_BASE_URL=https://betpoly.example.com
Expand Down Expand Up @@ -68,3 +81,11 @@ APP_TITLE=BetPoly
SUPPORT_URL=
# Orígenes que pueden embeber la Mini App (CSP frame-ancestors)
FRAME_ANCESTORS='self' https://*.telegram.org https://web.telegram.org https://*.e2b.app

# --- Proxy inverso (IP real para los límites de tasa) -------------------------
# Solo se honra X-Forwarded-For si TRUST_PROXY=true Y la conexión viene de una
# de estas redes. Con TRUST_PROXY=false la cabecera se ignora (recomendado si
# el proceso escucha directo en Internet).
TRUST_PROXY=false
# Lista de CIDR separada por comas, p. ej. 127.0.0.1/32,10.0.0.0/8
TRUSTED_PROXIES=
99 changes: 99 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI

on:
push:
branches: ["**"]
pull_request:
branches: [main]

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint (ruff + vulture)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- run: pip install -r requirements-dev.txt
- run: ruff check .
- name: Código muerto (vulture)
run: vulture bot config.py main.py scripts --min-confidence 80

test:
name: Tests (pytest + cobertura)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- run: pip install -r requirements-dev.txt
- name: Suite offline
env:
BOT_TOKEN: "123456:CI-TOKEN-NOT-REAL"
BET_MODE: points
DATABASE_PATH: /tmp/ci.db
run: |
pytest \
--cov=bot --cov=config --cov=main --cov=scripts \
--cov-report=term-missing:skip-covered \
--cov-fail-under=83
- name: Cobertura de la capa Telegram (Fase 5)
run: |
pytest tests/test_handlers_navigation.py tests/test_handlers_flows.py \
--cov=bot.handlers --cov=bot.keyboards --cov-fail-under=70

contract:
name: Contrato (build + sandbox + audit)
runs-on: ubuntu-latest
defaults:
run:
working-directory: contracts
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: contracts/package-lock.json
- run: npm ci
- name: Compilar y verificar hash
run: |
node scripts/build.js
node -e "
const fs = require('fs');
const boc = fs.readFileSync('build/escrow.code.boc');
const { Cell } = require('@ton/core');
const hash = Cell.fromBoc(boc)[0].hash().toString('hex');
const pinned = require('fs').readFileSync('../tests/test_contract_sync.py', 'utf8')
.match(/CODE_HASH = \"([0-9a-f]+)\"/)[1];
if (hash !== pinned) {
console.error('❌ hash compilado', hash, '≠ pinneado', pinned);
process.exit(1);
}
console.log('✅ hash reproducible', hash);
"
- name: Sandbox TVM
run: node tests/escrow.test.js
- name: Excepciones de auditoría (test)
run: node tests/audit.test.js
- name: npm audit
run: node scripts/audit.js

security:
name: Dependencias (pip-audit)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install pip-audit
- run: pip-audit -r requirements.txt --strict
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ contracts/build/deploy.json
*.db-shm
*.db-wal

# Tests / coverage
.coverage
.coverage.*
htmlcov/
coverage.xml
.mypy_cache/
.pytest_cache/

# Logs
*.log

Expand Down
Loading
Loading