Skip to content

Commit 92eda6b

Browse files
feat: implement Operation Protocol Improvements (OPI) architecture
- Add OPI registry system for extensible operation processing - Implement IntermediateState and Context for secure state management - Add BaseProcessor abstract class for OPI implementations - Create test OPI processor as reference implementation - Integrate OPI system with existing BRC20 indexer - Add comprehensive test suite for OPI functionality - Fix code quality issues and ensure all tests pass - Update CI/CD pipeline configuration - Add decimal conversion utilities for precise amount handling - Implement marketplace transfer prioritization - Add performance monitoring and security scanning - Reorganize test structure for better maintainability - Fix security vulnerabilities (authlib upgrade) - Resolve safety tool compatibility issues This commit introduces a complete OPI (Operation Protocol Improvements) architecture that allows for extensible operation processing while maintaining backward compatibility with existing BRC20 functionality.
1 parent c980137 commit 92eda6b

33 files changed

+2672
-292
lines changed

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ MANIFEST
2424

2525
# Environments
2626
.env
27+
.env.back
2728
.venv
2829
env/
2930
venv/
@@ -62,7 +63,10 @@ coverage.xml
6263
temp_docs/
6364
backups/
6465
dev/
66+
.rules/
67+
.cursor/
6568

6669
# Alembic
67-
alembic/versions/*.py
68-
!alembic/versions/eb4d511e7c2a_initial_database_schema.py
70+
# Ne pas ignorer les fichiers de migration
71+
!alembic/versions/
72+
.env.back
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""migrate_amounts_to_decimal
2+
3+
Revision ID: a11a308c0edc
4+
Revises: eb4d511e7c2a
5+
Create Date: 2025-08-27 23:39:23.309383
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
# revision identifiers, used by Alembic.
12+
revision: str = 'a11a308c0edc'
13+
down_revision: Union[str, Sequence[str], None] = 'eb4d511e7c2a'
14+
branch_labels: Union[str, Sequence[str], None] = None
15+
depends_on: Union[str, Sequence[str], None] = None
16+
17+
18+
def upgrade() -> None:
19+
"""Upgrade schema - migrate amounts from String to Numeric(38,8)."""
20+
# Convert balances.balance
21+
op.execute("ALTER TABLE balances ALTER COLUMN balance TYPE NUMERIC(38,8) USING balance::NUMERIC(38,8)")
22+
23+
# Convert brc20_operations.amount
24+
op.execute("ALTER TABLE brc20_operations ALTER COLUMN amount TYPE NUMERIC(38,8) USING amount::NUMERIC(38,8)")
25+
26+
# Convert deploys.max_supply
27+
op.execute("ALTER TABLE deploys ALTER COLUMN max_supply TYPE NUMERIC(38,8) USING max_supply::NUMERIC(38,8)")
28+
29+
# Convert deploys.limit_per_op
30+
op.execute("ALTER TABLE deploys ALTER COLUMN limit_per_op TYPE NUMERIC(38,8) USING limit_per_op::NUMERIC(38,8)")
31+
32+
33+
def downgrade() -> None:
34+
"""Downgrade schema - revert amounts back to String."""
35+
# Convert balances.balance back to String
36+
op.execute("ALTER TABLE balances ALTER COLUMN balance TYPE VARCHAR USING balance::VARCHAR")
37+
38+
# Convert brc20_operations.amount back to String
39+
op.execute("ALTER TABLE brc20_operations ALTER COLUMN amount TYPE VARCHAR USING amount::VARCHAR")
40+
41+
# Convert deploys.max_supply back to String
42+
op.execute("ALTER TABLE deploys ALTER COLUMN max_supply TYPE VARCHAR USING max_supply::VARCHAR")
43+
44+
# Convert deploys.limit_per_op back to String
45+
op.execute("ALTER TABLE deploys ALTER COLUMN limit_per_op TYPE VARCHAR USING limit_per_op::VARCHAR")
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"""migrate_amounts_to_decimal
2+
3+
Revision ID: f0e124fbfbf0
4+
Revises: eb4d511e7c2a
5+
Create Date: 2025-08-31 22:31:40.423836
6+
7+
"""
8+
from typing import Sequence, Union
9+
from decimal import Decimal
10+
11+
from alembic import op
12+
import sqlalchemy as sa
13+
from sqlalchemy.dialects import postgresql
14+
15+
# revision identifiers, used by Alembic.
16+
revision: str = 'f0e124fbfbf0'
17+
down_revision: Union[str, Sequence[str], None] = 'eb4d511e7c2a'
18+
branch_labels: Union[str, Sequence[str], None] = None
19+
depends_on: Union[str, Sequence[str], None] = None
20+
21+
22+
def upgrade() -> None:
23+
"""Upgrade schema."""
24+
op.alter_column('balances', 'balance',
25+
existing_type=sa.String(),
26+
type_=sa.Numeric(precision=38, scale=8),
27+
postgresql_using="balance::numeric(38,8)",
28+
existing_nullable=False)
29+
30+
op.alter_column('brc20_operations', 'amount',
31+
existing_type=sa.String(),
32+
type_=sa.Numeric(precision=38, scale=8),
33+
postgresql_using="amount::numeric(38,8)",
34+
existing_nullable=True)
35+
36+
op.alter_column('deploys', 'max_supply',
37+
existing_type=sa.String(),
38+
type_=sa.Numeric(precision=38, scale=8),
39+
postgresql_using="max_supply::numeric(38,8)",
40+
existing_nullable=False)
41+
42+
op.alter_column('deploys', 'limit_per_op',
43+
existing_type=sa.String(),
44+
type_=sa.Numeric(precision=38, scale=8),
45+
postgresql_using="limit_per_op::numeric(38,8)",
46+
existing_nullable=True)
47+
48+
49+
def downgrade() -> None:
50+
"""Downgrade schema."""
51+
op.alter_column('balances', 'balance',
52+
existing_type=sa.Numeric(precision=38, scale=8),
53+
type_=sa.String(),
54+
existing_nullable=False)
55+
56+
op.alter_column('brc20_operations', 'amount',
57+
existing_type=sa.Numeric(precision=38, scale=8),
58+
type_=sa.String(),
59+
existing_nullable=True)
60+
61+
op.alter_column('deploys', 'max_supply',
62+
existing_type=sa.Numeric(precision=38, scale=8),
63+
type_=sa.String(),
64+
existing_nullable=False)
65+
66+
op.alter_column('deploys', 'limit_per_op',
67+
existing_type=sa.Numeric(precision=38, scale=8),
68+
type_=sa.String(),
69+
existing_nullable=True)

0 commit comments

Comments
 (0)