uvd-x402-sdk 0.2.2__py3-none-any.whl → 0.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uvd_x402_sdk/__init__.py +169 -169
- uvd_x402_sdk/client.py +527 -527
- uvd_x402_sdk/config.py +248 -248
- uvd_x402_sdk/decorators.py +325 -325
- uvd_x402_sdk/exceptions.py +254 -254
- uvd_x402_sdk/integrations/__init__.py +74 -74
- uvd_x402_sdk/integrations/django_integration.py +237 -237
- uvd_x402_sdk/integrations/fastapi_integration.py +330 -330
- uvd_x402_sdk/integrations/flask_integration.py +259 -259
- uvd_x402_sdk/integrations/lambda_integration.py +320 -320
- uvd_x402_sdk/models.py +397 -397
- uvd_x402_sdk/networks/__init__.py +54 -54
- uvd_x402_sdk/networks/base.py +347 -347
- uvd_x402_sdk/networks/evm.py +215 -215
- uvd_x402_sdk/networks/near.py +397 -397
- uvd_x402_sdk/networks/solana.py +282 -282
- uvd_x402_sdk/networks/stellar.py +129 -129
- uvd_x402_sdk/response.py +439 -439
- {uvd_x402_sdk-0.2.2.dist-info → uvd_x402_sdk-0.2.3.dist-info}/LICENSE +21 -21
- {uvd_x402_sdk-0.2.2.dist-info → uvd_x402_sdk-0.2.3.dist-info}/METADATA +814 -778
- uvd_x402_sdk-0.2.3.dist-info/RECORD +23 -0
- uvd_x402_sdk-0.2.2.dist-info/RECORD +0 -23
- {uvd_x402_sdk-0.2.2.dist-info → uvd_x402_sdk-0.2.3.dist-info}/WHEEL +0 -0
- {uvd_x402_sdk-0.2.2.dist-info → uvd_x402_sdk-0.2.3.dist-info}/top_level.txt +0 -0
uvd_x402_sdk/networks/stellar.py
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Stellar network configuration.
|
|
3
|
-
|
|
4
|
-
Stellar uses Soroban smart contracts for USDC transfers:
|
|
5
|
-
1. User signs a SorobanAuthorizationEntry (XDR format)
|
|
6
|
-
2. Authorization contains transfer function invocation
|
|
7
|
-
3. Facilitator wraps in fee-bump transaction
|
|
8
|
-
4. Facilitator pays all XLM fees - user pays ZERO XLM
|
|
9
|
-
|
|
10
|
-
Stellar USDC Details:
|
|
11
|
-
- Uses SAC (Soroban Asset Contract) for the Circle-issued USDC
|
|
12
|
-
- 7 decimals (stroops), different from other chains (6 decimals)
|
|
13
|
-
- Freighter wallet required for signing (Bitget doesn't support Stellar)
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
from uvd_x402_sdk.networks.base import (
|
|
17
|
-
NetworkConfig,
|
|
18
|
-
NetworkType,
|
|
19
|
-
register_network,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
# Stellar Mainnet
|
|
23
|
-
STELLAR = NetworkConfig(
|
|
24
|
-
name="stellar",
|
|
25
|
-
display_name="Stellar",
|
|
26
|
-
network_type=NetworkType.STELLAR,
|
|
27
|
-
chain_id=0, # Non-EVM, no chain ID
|
|
28
|
-
# Soroban Asset Contract (SAC) for USDC
|
|
29
|
-
usdc_address="CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75",
|
|
30
|
-
usdc_decimals=7, # Stellar uses 7 decimals (stroops)
|
|
31
|
-
usdc_domain_name="", # Not applicable for Stellar
|
|
32
|
-
usdc_domain_version="",
|
|
33
|
-
rpc_url="https://horizon.stellar.org",
|
|
34
|
-
enabled=True,
|
|
35
|
-
extra_config={
|
|
36
|
-
# Network passphrase for signing
|
|
37
|
-
"network_passphrase": "Public Global Stellar Network ; September 2015",
|
|
38
|
-
# Soroban RPC endpoint (different from Horizon)
|
|
39
|
-
"soroban_rpc_url": "https://mainnet.sorobanrpc.com",
|
|
40
|
-
# Block explorer
|
|
41
|
-
"explorer_url": "https://stellar.expert/explorer/public",
|
|
42
|
-
# Circle USDC issuer (G... address)
|
|
43
|
-
"usdc_issuer": "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
|
|
44
|
-
# Default ledger validity (~5 minutes, ~60 ledgers)
|
|
45
|
-
"default_ledger_validity": 60,
|
|
46
|
-
},
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
# Register Stellar network
|
|
50
|
-
register_network(STELLAR)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# =============================================================================
|
|
54
|
-
# Stellar-specific utilities
|
|
55
|
-
# =============================================================================
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def stroops_to_usd(stroops: int) -> float:
|
|
59
|
-
"""
|
|
60
|
-
Convert stroops (7 decimals) to USD amount.
|
|
61
|
-
|
|
62
|
-
Args:
|
|
63
|
-
stroops: Amount in stroops
|
|
64
|
-
|
|
65
|
-
Returns:
|
|
66
|
-
USD amount
|
|
67
|
-
"""
|
|
68
|
-
return stroops / 10_000_000
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def usd_to_stroops(usd: float) -> int:
|
|
72
|
-
"""
|
|
73
|
-
Convert USD amount to stroops (7 decimals).
|
|
74
|
-
|
|
75
|
-
Args:
|
|
76
|
-
usd: USD amount
|
|
77
|
-
|
|
78
|
-
Returns:
|
|
79
|
-
Amount in stroops
|
|
80
|
-
"""
|
|
81
|
-
return int(usd * 10_000_000)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def is_valid_stellar_address(address: str) -> bool:
|
|
85
|
-
"""
|
|
86
|
-
Validate a Stellar public key format.
|
|
87
|
-
|
|
88
|
-
Args:
|
|
89
|
-
address: Stellar address to validate
|
|
90
|
-
|
|
91
|
-
Returns:
|
|
92
|
-
True if valid G... address (56 characters, starts with G)
|
|
93
|
-
"""
|
|
94
|
-
return (
|
|
95
|
-
isinstance(address, str)
|
|
96
|
-
and len(address) == 56
|
|
97
|
-
and address.startswith("G")
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def is_valid_contract_address(address: str) -> bool:
|
|
102
|
-
"""
|
|
103
|
-
Validate a Soroban contract address format.
|
|
104
|
-
|
|
105
|
-
Args:
|
|
106
|
-
address: Contract address to validate
|
|
107
|
-
|
|
108
|
-
Returns:
|
|
109
|
-
True if valid C... address (56 characters, starts with C)
|
|
110
|
-
"""
|
|
111
|
-
return (
|
|
112
|
-
isinstance(address, str)
|
|
113
|
-
and len(address) == 56
|
|
114
|
-
and address.startswith("C")
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def calculate_expiration_ledger(current_ledger: int, validity_ledgers: int = 60) -> int:
|
|
119
|
-
"""
|
|
120
|
-
Calculate expiration ledger for authorization.
|
|
121
|
-
|
|
122
|
-
Args:
|
|
123
|
-
current_ledger: Current ledger sequence from RPC
|
|
124
|
-
validity_ledgers: Number of ledgers the auth is valid (~5 minutes at 5s/ledger)
|
|
125
|
-
|
|
126
|
-
Returns:
|
|
127
|
-
Expiration ledger number
|
|
128
|
-
"""
|
|
129
|
-
return current_ledger + validity_ledgers
|
|
1
|
+
"""
|
|
2
|
+
Stellar network configuration.
|
|
3
|
+
|
|
4
|
+
Stellar uses Soroban smart contracts for USDC transfers:
|
|
5
|
+
1. User signs a SorobanAuthorizationEntry (XDR format)
|
|
6
|
+
2. Authorization contains transfer function invocation
|
|
7
|
+
3. Facilitator wraps in fee-bump transaction
|
|
8
|
+
4. Facilitator pays all XLM fees - user pays ZERO XLM
|
|
9
|
+
|
|
10
|
+
Stellar USDC Details:
|
|
11
|
+
- Uses SAC (Soroban Asset Contract) for the Circle-issued USDC
|
|
12
|
+
- 7 decimals (stroops), different from other chains (6 decimals)
|
|
13
|
+
- Freighter wallet required for signing (Bitget doesn't support Stellar)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from uvd_x402_sdk.networks.base import (
|
|
17
|
+
NetworkConfig,
|
|
18
|
+
NetworkType,
|
|
19
|
+
register_network,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# Stellar Mainnet
|
|
23
|
+
STELLAR = NetworkConfig(
|
|
24
|
+
name="stellar",
|
|
25
|
+
display_name="Stellar",
|
|
26
|
+
network_type=NetworkType.STELLAR,
|
|
27
|
+
chain_id=0, # Non-EVM, no chain ID
|
|
28
|
+
# Soroban Asset Contract (SAC) for USDC
|
|
29
|
+
usdc_address="CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75",
|
|
30
|
+
usdc_decimals=7, # Stellar uses 7 decimals (stroops)
|
|
31
|
+
usdc_domain_name="", # Not applicable for Stellar
|
|
32
|
+
usdc_domain_version="",
|
|
33
|
+
rpc_url="https://horizon.stellar.org",
|
|
34
|
+
enabled=True,
|
|
35
|
+
extra_config={
|
|
36
|
+
# Network passphrase for signing
|
|
37
|
+
"network_passphrase": "Public Global Stellar Network ; September 2015",
|
|
38
|
+
# Soroban RPC endpoint (different from Horizon)
|
|
39
|
+
"soroban_rpc_url": "https://mainnet.sorobanrpc.com",
|
|
40
|
+
# Block explorer
|
|
41
|
+
"explorer_url": "https://stellar.expert/explorer/public",
|
|
42
|
+
# Circle USDC issuer (G... address)
|
|
43
|
+
"usdc_issuer": "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
|
|
44
|
+
# Default ledger validity (~5 minutes, ~60 ledgers)
|
|
45
|
+
"default_ledger_validity": 60,
|
|
46
|
+
},
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# Register Stellar network
|
|
50
|
+
register_network(STELLAR)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# =============================================================================
|
|
54
|
+
# Stellar-specific utilities
|
|
55
|
+
# =============================================================================
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def stroops_to_usd(stroops: int) -> float:
|
|
59
|
+
"""
|
|
60
|
+
Convert stroops (7 decimals) to USD amount.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
stroops: Amount in stroops
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
USD amount
|
|
67
|
+
"""
|
|
68
|
+
return stroops / 10_000_000
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def usd_to_stroops(usd: float) -> int:
|
|
72
|
+
"""
|
|
73
|
+
Convert USD amount to stroops (7 decimals).
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
usd: USD amount
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
Amount in stroops
|
|
80
|
+
"""
|
|
81
|
+
return int(usd * 10_000_000)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def is_valid_stellar_address(address: str) -> bool:
|
|
85
|
+
"""
|
|
86
|
+
Validate a Stellar public key format.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
address: Stellar address to validate
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
True if valid G... address (56 characters, starts with G)
|
|
93
|
+
"""
|
|
94
|
+
return (
|
|
95
|
+
isinstance(address, str)
|
|
96
|
+
and len(address) == 56
|
|
97
|
+
and address.startswith("G")
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def is_valid_contract_address(address: str) -> bool:
|
|
102
|
+
"""
|
|
103
|
+
Validate a Soroban contract address format.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
address: Contract address to validate
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
True if valid C... address (56 characters, starts with C)
|
|
110
|
+
"""
|
|
111
|
+
return (
|
|
112
|
+
isinstance(address, str)
|
|
113
|
+
and len(address) == 56
|
|
114
|
+
and address.startswith("C")
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def calculate_expiration_ledger(current_ledger: int, validity_ledgers: int = 60) -> int:
|
|
119
|
+
"""
|
|
120
|
+
Calculate expiration ledger for authorization.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
current_ledger: Current ledger sequence from RPC
|
|
124
|
+
validity_ledgers: Number of ledgers the auth is valid (~5 minutes at 5s/ledger)
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
Expiration ledger number
|
|
128
|
+
"""
|
|
129
|
+
return current_ledger + validity_ledgers
|