chipi-stack 2.0.0__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.
- chipi_sdk/__init__.py +342 -0
- chipi_sdk/client.py +505 -0
- chipi_sdk/constants.py +171 -0
- chipi_sdk/encryption.py +179 -0
- chipi_sdk/errors.py +130 -0
- chipi_sdk/execute_paymaster.py +434 -0
- chipi_sdk/formatters.py +154 -0
- chipi_sdk/models/__init__.py +145 -0
- chipi_sdk/models/core.py +96 -0
- chipi_sdk/models/session.py +119 -0
- chipi_sdk/models/sku.py +28 -0
- chipi_sdk/models/sku_transaction.py +30 -0
- chipi_sdk/models/transaction.py +192 -0
- chipi_sdk/models/user.py +31 -0
- chipi_sdk/models/wallet.py +178 -0
- chipi_sdk/models/x402.py +117 -0
- chipi_sdk/py.typed +1 -0
- chipi_sdk/sdk.py +1021 -0
- chipi_sdk/sessions.py +836 -0
- chipi_sdk/sku_transactions.py +58 -0
- chipi_sdk/skus.py +93 -0
- chipi_sdk/transactions.py +447 -0
- chipi_sdk/users.py +92 -0
- chipi_sdk/validators.py +75 -0
- chipi_sdk/wallets.py +465 -0
- chipi_sdk/x402_client.py +207 -0
- chipi_sdk/x402_facilitator.py +200 -0
- chipi_sdk/x402_middleware.py +280 -0
- chipi_stack-2.0.0.dist-info/METADATA +366 -0
- chipi_stack-2.0.0.dist-info/RECORD +33 -0
- chipi_stack-2.0.0.dist-info/WHEEL +5 -0
- chipi_stack-2.0.0.dist-info/licenses/LICENSE +21 -0
- chipi_stack-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Pydantic models for Chipi SDK."""
|
|
2
|
+
|
|
3
|
+
# Core types
|
|
4
|
+
from .core import (
|
|
5
|
+
Chain,
|
|
6
|
+
ChainToken,
|
|
7
|
+
ChipiSDKConfig,
|
|
8
|
+
PaginatedResponse,
|
|
9
|
+
PaginationQuery,
|
|
10
|
+
StarknetContract,
|
|
11
|
+
STARKNET_CONTRACTS,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# Wallet types
|
|
15
|
+
from .wallet import (
|
|
16
|
+
CreateCustodialWalletParams,
|
|
17
|
+
CreateWalletParams,
|
|
18
|
+
CreateWalletResponse,
|
|
19
|
+
DeploymentData,
|
|
20
|
+
GetTokenBalanceParams,
|
|
21
|
+
GetTokenBalanceResponse,
|
|
22
|
+
GetWalletParams,
|
|
23
|
+
GetWalletResponse,
|
|
24
|
+
PasskeyMetadata,
|
|
25
|
+
PrepareWalletCreationResponse,
|
|
26
|
+
WalletData,
|
|
27
|
+
WalletType,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Transaction types
|
|
31
|
+
from .transaction import (
|
|
32
|
+
ApproveParams,
|
|
33
|
+
Call,
|
|
34
|
+
CallAnyContractParams,
|
|
35
|
+
ExecuteSponsoredTransactionParams,
|
|
36
|
+
ExecuteSponsoredTransactionResponse,
|
|
37
|
+
ExecuteTransactionParams,
|
|
38
|
+
GetTransactionListQuery,
|
|
39
|
+
PrepareTypedDataParams,
|
|
40
|
+
PrepareTypedDataResponse,
|
|
41
|
+
RecordSendTransactionParams,
|
|
42
|
+
StakeVesuUsdcParams,
|
|
43
|
+
Transaction,
|
|
44
|
+
TransferParams,
|
|
45
|
+
WithdrawVesuUsdcParams,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# Session types
|
|
49
|
+
from .session import (
|
|
50
|
+
AddSessionKeyParams,
|
|
51
|
+
CreateSessionKeyParams,
|
|
52
|
+
ExecuteWithSessionParams,
|
|
53
|
+
GetSessionDataParams,
|
|
54
|
+
GetSpendingPolicyParams,
|
|
55
|
+
RemoveSpendingPolicyParams,
|
|
56
|
+
RevokeSessionKeyParams,
|
|
57
|
+
SessionConfig,
|
|
58
|
+
SessionDataResponse,
|
|
59
|
+
SessionKeyData,
|
|
60
|
+
SetSpendingPolicyParams,
|
|
61
|
+
SpendingPolicyConfig,
|
|
62
|
+
SpendingPolicyData,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# SKU types
|
|
66
|
+
from .sku import (
|
|
67
|
+
GetSkuListQuery,
|
|
68
|
+
Sku,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# SKU transaction types
|
|
72
|
+
from .sku_transaction import (
|
|
73
|
+
CreateSkuTransactionParams,
|
|
74
|
+
SkuTransaction,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# User types
|
|
78
|
+
from .user import (
|
|
79
|
+
CreateUserParams,
|
|
80
|
+
GetUserParams,
|
|
81
|
+
User,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
__all__ = [
|
|
85
|
+
# Core
|
|
86
|
+
"Chain",
|
|
87
|
+
"ChainToken",
|
|
88
|
+
"ChipiSDKConfig",
|
|
89
|
+
"PaginatedResponse",
|
|
90
|
+
"PaginationQuery",
|
|
91
|
+
"StarknetContract",
|
|
92
|
+
"STARKNET_CONTRACTS",
|
|
93
|
+
# Wallet
|
|
94
|
+
"CreateCustodialWalletParams",
|
|
95
|
+
"CreateWalletParams",
|
|
96
|
+
"CreateWalletResponse",
|
|
97
|
+
"DeploymentData",
|
|
98
|
+
"GetTokenBalanceParams",
|
|
99
|
+
"GetTokenBalanceResponse",
|
|
100
|
+
"GetWalletParams",
|
|
101
|
+
"GetWalletResponse",
|
|
102
|
+
"PasskeyMetadata",
|
|
103
|
+
"PrepareWalletCreationResponse",
|
|
104
|
+
"WalletData",
|
|
105
|
+
"WalletType",
|
|
106
|
+
# Transaction
|
|
107
|
+
"ApproveParams",
|
|
108
|
+
"Call",
|
|
109
|
+
"CallAnyContractParams",
|
|
110
|
+
"ExecuteSponsoredTransactionParams",
|
|
111
|
+
"ExecuteSponsoredTransactionResponse",
|
|
112
|
+
"ExecuteTransactionParams",
|
|
113
|
+
"GetTransactionListQuery",
|
|
114
|
+
"PrepareTypedDataParams",
|
|
115
|
+
"PrepareTypedDataResponse",
|
|
116
|
+
"RecordSendTransactionParams",
|
|
117
|
+
"StakeVesuUsdcParams",
|
|
118
|
+
"Transaction",
|
|
119
|
+
"TransferParams",
|
|
120
|
+
"WithdrawVesuUsdcParams",
|
|
121
|
+
# Session
|
|
122
|
+
"AddSessionKeyParams",
|
|
123
|
+
"CreateSessionKeyParams",
|
|
124
|
+
"ExecuteWithSessionParams",
|
|
125
|
+
"GetSessionDataParams",
|
|
126
|
+
"GetSpendingPolicyParams",
|
|
127
|
+
"RemoveSpendingPolicyParams",
|
|
128
|
+
"RevokeSessionKeyParams",
|
|
129
|
+
"SessionConfig",
|
|
130
|
+
"SessionDataResponse",
|
|
131
|
+
"SessionKeyData",
|
|
132
|
+
"SetSpendingPolicyParams",
|
|
133
|
+
"SpendingPolicyConfig",
|
|
134
|
+
"SpendingPolicyData",
|
|
135
|
+
# SKU
|
|
136
|
+
"GetSkuListQuery",
|
|
137
|
+
"Sku",
|
|
138
|
+
# SKU Transaction
|
|
139
|
+
"CreateSkuTransactionParams",
|
|
140
|
+
"SkuTransaction",
|
|
141
|
+
# User
|
|
142
|
+
"CreateUserParams",
|
|
143
|
+
"GetUserParams",
|
|
144
|
+
"User",
|
|
145
|
+
]
|
chipi_sdk/models/core.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Core configuration and base types for Chipi SDK."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Generic, Optional, TypeVar
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Chain(str, Enum):
|
|
9
|
+
"""Supported blockchain networks."""
|
|
10
|
+
STARKNET = "STARKNET"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ChainToken(str, Enum):
|
|
14
|
+
"""Supported token types."""
|
|
15
|
+
USDC_E = "USDC_E"
|
|
16
|
+
USDC = "USDC"
|
|
17
|
+
USDT = "USDT"
|
|
18
|
+
ETH = "ETH"
|
|
19
|
+
STRK = "STRK"
|
|
20
|
+
DAI = "DAI"
|
|
21
|
+
WBTC = "WBTC"
|
|
22
|
+
OTHER = "OTHER"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ChipiSDKConfig(BaseModel):
|
|
26
|
+
"""Configuration for initializing the Chipi SDK."""
|
|
27
|
+
|
|
28
|
+
api_public_key: str = Field(..., description="Public API key for authentication")
|
|
29
|
+
alpha_url: Optional[str] = Field(None, description="Optional custom API URL")
|
|
30
|
+
node_url: Optional[str] = Field(None, description="Optional custom Starknet node URL")
|
|
31
|
+
api_secret_key: Optional[str] = Field(None, description="Optional API secret key for server-side operations")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class PaginationQuery(BaseModel):
|
|
35
|
+
"""Pagination parameters for list queries."""
|
|
36
|
+
|
|
37
|
+
page: Optional[int] = Field(None, ge=1, description="Page number")
|
|
38
|
+
limit: Optional[int] = Field(None, ge=1, le=100, description="Items per page")
|
|
39
|
+
offset: Optional[int] = Field(None, ge=0, description="Offset for pagination")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
T = TypeVar('T')
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class PaginatedResponse(BaseModel, Generic[T]):
|
|
46
|
+
"""Generic paginated response."""
|
|
47
|
+
|
|
48
|
+
data: list[T]
|
|
49
|
+
total: int = Field(..., description="Total number of items")
|
|
50
|
+
page: int = Field(..., description="Current page number")
|
|
51
|
+
limit: int = Field(..., description="Items per page")
|
|
52
|
+
total_pages: int = Field(..., description="Total number of pages")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class StarknetContract(BaseModel):
|
|
56
|
+
"""Starknet contract information."""
|
|
57
|
+
|
|
58
|
+
contract_address: str
|
|
59
|
+
decimals: int
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# Contract mappings for tokens
|
|
63
|
+
STARKNET_CONTRACTS: dict[ChainToken, StarknetContract] = {
|
|
64
|
+
ChainToken.USDC: StarknetContract(
|
|
65
|
+
contract_address="0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",
|
|
66
|
+
decimals=6
|
|
67
|
+
),
|
|
68
|
+
ChainToken.USDC_E: StarknetContract(
|
|
69
|
+
contract_address="0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
|
|
70
|
+
decimals=6
|
|
71
|
+
),
|
|
72
|
+
ChainToken.USDT: StarknetContract(
|
|
73
|
+
contract_address="0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",
|
|
74
|
+
decimals=6
|
|
75
|
+
),
|
|
76
|
+
ChainToken.DAI: StarknetContract(
|
|
77
|
+
contract_address="0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",
|
|
78
|
+
decimals=18
|
|
79
|
+
),
|
|
80
|
+
ChainToken.STRK: StarknetContract(
|
|
81
|
+
contract_address="0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
|
|
82
|
+
decimals=18
|
|
83
|
+
),
|
|
84
|
+
ChainToken.ETH: StarknetContract(
|
|
85
|
+
contract_address="0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
86
|
+
decimals=18
|
|
87
|
+
),
|
|
88
|
+
ChainToken.WBTC: StarknetContract(
|
|
89
|
+
contract_address="0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",
|
|
90
|
+
decimals=8
|
|
91
|
+
),
|
|
92
|
+
ChainToken.OTHER: StarknetContract(
|
|
93
|
+
contract_address="",
|
|
94
|
+
decimals=18
|
|
95
|
+
),
|
|
96
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""Session key management types and models."""
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
from pydantic import BaseModel, Field
|
|
5
|
+
|
|
6
|
+
from .transaction import Call
|
|
7
|
+
from .wallet import WalletData
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SessionKeyData(BaseModel):
|
|
11
|
+
"""Session key information."""
|
|
12
|
+
|
|
13
|
+
public_key: str = Field(..., description="Session public key")
|
|
14
|
+
encrypted_private_key: str = Field(..., description="AES encrypted session private key")
|
|
15
|
+
valid_until: int = Field(..., description="Unix timestamp when session expires")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CreateSessionKeyParams(BaseModel):
|
|
19
|
+
"""Parameters for creating a session key."""
|
|
20
|
+
|
|
21
|
+
encrypt_key: str = Field(..., description="Encryption key for session private key")
|
|
22
|
+
duration_seconds: Optional[int] = Field(21600, description="Session duration in seconds (default 6 hours)")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class SessionConfig(BaseModel):
|
|
26
|
+
"""Session key configuration for on-chain registration."""
|
|
27
|
+
|
|
28
|
+
session_public_key: str = Field(..., description="Public key of the session")
|
|
29
|
+
valid_until: int = Field(..., description="Unix timestamp when session expires")
|
|
30
|
+
max_calls: int = Field(..., description="Maximum number of calls allowed")
|
|
31
|
+
allowed_entrypoints: list[str] = Field(..., description="List of allowed contract entrypoints (empty = all allowed)")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class AddSessionKeyParams(BaseModel):
|
|
35
|
+
"""Parameters for adding a session key to contract."""
|
|
36
|
+
|
|
37
|
+
encrypt_key: str = Field(..., description="Encryption key for owner private key")
|
|
38
|
+
wallet: WalletData
|
|
39
|
+
session_config: SessionConfig
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class RevokeSessionKeyParams(BaseModel):
|
|
43
|
+
"""Parameters for revoking a session key."""
|
|
44
|
+
|
|
45
|
+
encrypt_key: str = Field(..., description="Encryption key for owner private key")
|
|
46
|
+
wallet: WalletData
|
|
47
|
+
session_public_key: str = Field(..., description="Public key of session to revoke")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class GetSessionDataParams(BaseModel):
|
|
51
|
+
"""Parameters for querying session data."""
|
|
52
|
+
|
|
53
|
+
wallet_address: str = Field(..., description="Wallet contract address")
|
|
54
|
+
session_public_key: str = Field(..., description="Session public key to query")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class SessionDataResponse(BaseModel):
|
|
58
|
+
"""Response from session data query."""
|
|
59
|
+
|
|
60
|
+
is_active: bool = Field(..., description="Whether session is currently active")
|
|
61
|
+
valid_until: int = Field(..., description="Unix timestamp when session expires")
|
|
62
|
+
remaining_calls: int = Field(..., description="Number of calls remaining")
|
|
63
|
+
allowed_entrypoints: list[str] = Field(..., description="List of allowed entrypoints")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class ExecuteWithSessionParams(BaseModel):
|
|
67
|
+
"""Parameters for executing transaction with session key."""
|
|
68
|
+
|
|
69
|
+
encrypt_key: str = Field(..., description="Encryption key for session private key")
|
|
70
|
+
wallet: WalletData
|
|
71
|
+
session: SessionKeyData
|
|
72
|
+
calls: list[Call]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# --- Spending Policy Types ---
|
|
76
|
+
|
|
77
|
+
class SpendingPolicyConfig(BaseModel):
|
|
78
|
+
"""Configuration for setting a spending policy on a session key."""
|
|
79
|
+
|
|
80
|
+
session_public_key: str = Field(..., description="Session public key to apply the policy to")
|
|
81
|
+
token: str = Field(..., description="ERC-20 token contract address")
|
|
82
|
+
max_per_call: int = Field(..., description="Maximum amount per single call (u256)")
|
|
83
|
+
max_per_window: int = Field(..., description="Maximum cumulative amount within rolling window (u256)")
|
|
84
|
+
window_seconds: int = Field(..., description="Rolling window duration in seconds")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class SpendingPolicyData(BaseModel):
|
|
88
|
+
"""On-chain spending policy state returned by get_spending_policy."""
|
|
89
|
+
|
|
90
|
+
max_per_call: int = Field(..., description="Maximum amount per single call")
|
|
91
|
+
max_per_window: int = Field(..., description="Maximum cumulative amount within rolling window")
|
|
92
|
+
window_seconds: int = Field(..., description="Rolling window duration in seconds")
|
|
93
|
+
spent_in_window: int = Field(..., description="Amount spent in the current active window")
|
|
94
|
+
window_start: int = Field(..., description="Unix timestamp when the current window started")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class SetSpendingPolicyParams(BaseModel):
|
|
98
|
+
"""Parameters for setting a spending policy."""
|
|
99
|
+
|
|
100
|
+
encrypt_key: str = Field(..., description="Encryption key for owner private key")
|
|
101
|
+
wallet: WalletData
|
|
102
|
+
spending_policy_config: SpendingPolicyConfig
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class GetSpendingPolicyParams(BaseModel):
|
|
106
|
+
"""Parameters for querying a spending policy."""
|
|
107
|
+
|
|
108
|
+
wallet_address: str = Field(..., description="Wallet contract address")
|
|
109
|
+
session_public_key: str = Field(..., description="Session public key")
|
|
110
|
+
token: str = Field(..., description="ERC-20 token contract address")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class RemoveSpendingPolicyParams(BaseModel):
|
|
114
|
+
"""Parameters for removing a spending policy."""
|
|
115
|
+
|
|
116
|
+
encrypt_key: str = Field(..., description="Encryption key for owner private key")
|
|
117
|
+
wallet: WalletData
|
|
118
|
+
session_public_key: str = Field(..., description="Session public key")
|
|
119
|
+
token: str = Field(..., description="ERC-20 token contract address")
|
chipi_sdk/models/sku.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""SKU-related types and models."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Sku(BaseModel):
|
|
9
|
+
"""SKU (Stock Keeping Unit) model."""
|
|
10
|
+
|
|
11
|
+
id: str
|
|
12
|
+
org_id: str
|
|
13
|
+
name: str
|
|
14
|
+
description: Optional[str] = None
|
|
15
|
+
price: str
|
|
16
|
+
currency: str
|
|
17
|
+
metadata: Optional[dict] = None
|
|
18
|
+
is_active: bool
|
|
19
|
+
created_at: datetime
|
|
20
|
+
updated_at: datetime
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class GetSkuListQuery(BaseModel):
|
|
24
|
+
"""Query parameters for SKU list."""
|
|
25
|
+
|
|
26
|
+
page: Optional[int] = Field(None, ge=1)
|
|
27
|
+
limit: Optional[int] = Field(None, ge=1, le=100)
|
|
28
|
+
is_active: Optional[bool] = None
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""SKU transaction types and models."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CreateSkuTransactionParams(BaseModel):
|
|
9
|
+
"""Parameters for creating a SKU transaction."""
|
|
10
|
+
|
|
11
|
+
sku_id: str = Field(..., description="SKU identifier")
|
|
12
|
+
wallet_address: str = Field(..., description="Buyer wallet address")
|
|
13
|
+
quantity: int = Field(1, ge=1, description="Quantity to purchase")
|
|
14
|
+
metadata: Optional[dict] = Field(None, description="Additional transaction metadata")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SkuTransaction(BaseModel):
|
|
18
|
+
"""SKU transaction record."""
|
|
19
|
+
|
|
20
|
+
id: str
|
|
21
|
+
sku_id: str
|
|
22
|
+
wallet_address: str
|
|
23
|
+
transaction_hash: Optional[str] = None
|
|
24
|
+
quantity: int
|
|
25
|
+
total_price: str
|
|
26
|
+
currency: str
|
|
27
|
+
status: str
|
|
28
|
+
metadata: Optional[dict] = None
|
|
29
|
+
created_at: datetime
|
|
30
|
+
updated_at: datetime
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"""Transaction-related types and models."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from enum import Enum
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
from pydantic import BaseModel, Field, ConfigDict
|
|
7
|
+
|
|
8
|
+
from .core import Chain, ChainToken
|
|
9
|
+
from .wallet import WalletData, to_camel
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Call(BaseModel):
|
|
13
|
+
"""Starknet contract call structure."""
|
|
14
|
+
|
|
15
|
+
model_config = ConfigDict(populate_by_name=True)
|
|
16
|
+
|
|
17
|
+
contract_address: str = Field(..., alias="contractAddress")
|
|
18
|
+
entrypoint: str
|
|
19
|
+
calldata: list[str]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ExecuteTransactionParams(BaseModel):
|
|
23
|
+
"""Parameters for executing a transaction."""
|
|
24
|
+
|
|
25
|
+
encrypt_key: Optional[str] = Field(None, description="Encryption key for private key")
|
|
26
|
+
wallet: WalletData
|
|
27
|
+
calls: list[Call]
|
|
28
|
+
use_passkey: Optional[bool] = Field(False, description="Whether to use passkey authentication")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class TransferParams(BaseModel):
|
|
32
|
+
"""Parameters for token transfer."""
|
|
33
|
+
|
|
34
|
+
encrypt_key: Optional[str] = Field(None, description="Encryption key for private key")
|
|
35
|
+
wallet: WalletData
|
|
36
|
+
token: ChainToken
|
|
37
|
+
other_token: Optional[dict[str, Any]] = Field(None, description="Custom token info for OTHER type")
|
|
38
|
+
recipient: str
|
|
39
|
+
amount: str
|
|
40
|
+
use_passkey: Optional[bool] = Field(False, description="Whether to use passkey authentication")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ApproveParams(BaseModel):
|
|
44
|
+
"""Parameters for token approval."""
|
|
45
|
+
|
|
46
|
+
encrypt_key: Optional[str] = Field(None, description="Encryption key for private key")
|
|
47
|
+
wallet: WalletData
|
|
48
|
+
contract_address: str
|
|
49
|
+
spender: str
|
|
50
|
+
amount: str
|
|
51
|
+
decimals: Optional[int] = Field(18, description="Token decimals")
|
|
52
|
+
use_passkey: Optional[bool] = Field(False, description="Whether to use passkey authentication")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class CallAnyContractParams(BaseModel):
|
|
56
|
+
"""Parameters for calling any contract."""
|
|
57
|
+
|
|
58
|
+
encrypt_key: Optional[str] = Field(None, description="Encryption key for private key")
|
|
59
|
+
wallet: WalletData
|
|
60
|
+
contract_address: str
|
|
61
|
+
calls: list[Call]
|
|
62
|
+
use_passkey: Optional[bool] = Field(False, description="Whether to use passkey authentication")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class StakeVesuUsdcParams(BaseModel):
|
|
66
|
+
"""Parameters for staking USDC in Vesu protocol."""
|
|
67
|
+
|
|
68
|
+
encrypt_key: Optional[str] = Field(None, description="Encryption key for private key")
|
|
69
|
+
wallet: WalletData
|
|
70
|
+
amount: str
|
|
71
|
+
receiver_wallet: str
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class WithdrawVesuUsdcParams(BaseModel):
|
|
75
|
+
"""Parameters for withdrawing USDC from Vesu protocol."""
|
|
76
|
+
|
|
77
|
+
encrypt_key: Optional[str] = Field(None, description="Encryption key for private key")
|
|
78
|
+
wallet: WalletData
|
|
79
|
+
amount: str
|
|
80
|
+
recipient: str
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class RecordSendTransactionParams(BaseModel):
|
|
84
|
+
"""Parameters for recording a send transaction."""
|
|
85
|
+
|
|
86
|
+
transaction_hash: str
|
|
87
|
+
expected_sender: str
|
|
88
|
+
expected_recipient: str
|
|
89
|
+
expected_token: ChainToken
|
|
90
|
+
expected_amount: str
|
|
91
|
+
chain: Chain
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class Transaction(BaseModel):
|
|
95
|
+
"""Transaction record."""
|
|
96
|
+
|
|
97
|
+
id: str
|
|
98
|
+
chain: str
|
|
99
|
+
api_public_key: str
|
|
100
|
+
transaction_hash: str
|
|
101
|
+
block_number: int
|
|
102
|
+
sender_address: str
|
|
103
|
+
destination_address: str
|
|
104
|
+
amount: str
|
|
105
|
+
token: str
|
|
106
|
+
called_function: Optional[str] = None
|
|
107
|
+
amount_in_usd: float = Field(..., alias="amountInUSD")
|
|
108
|
+
status: str
|
|
109
|
+
is_chipi_wallet: bool
|
|
110
|
+
created_at: datetime
|
|
111
|
+
updated_at: datetime
|
|
112
|
+
|
|
113
|
+
class Config:
|
|
114
|
+
populate_by_name = True
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class PrepareTypedDataParams(BaseModel):
|
|
118
|
+
"""Parameters for preparing typed data."""
|
|
119
|
+
|
|
120
|
+
calls: list[Call]
|
|
121
|
+
wallet_address: str
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class PrepareTypedDataResponse(BaseModel):
|
|
125
|
+
"""Response from typed data preparation."""
|
|
126
|
+
|
|
127
|
+
typed_data: dict
|
|
128
|
+
wallet_type: str
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class ExecuteSponsoredTransactionParams(BaseModel):
|
|
132
|
+
"""Parameters for executing sponsored transaction."""
|
|
133
|
+
|
|
134
|
+
calls: list[Call]
|
|
135
|
+
wallet_address: str
|
|
136
|
+
signature: list[str]
|
|
137
|
+
api_public_key: str
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class ExecuteSponsoredTransactionResponse(BaseModel):
|
|
141
|
+
"""Response from sponsored transaction execution."""
|
|
142
|
+
|
|
143
|
+
transaction_hash: str
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class GetTransactionListQuery(BaseModel):
|
|
147
|
+
"""Query parameters for transaction list."""
|
|
148
|
+
|
|
149
|
+
model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel)
|
|
150
|
+
|
|
151
|
+
page: Optional[int] = Field(None, ge=1)
|
|
152
|
+
limit: Optional[int] = Field(None, ge=1, le=100)
|
|
153
|
+
called_function: Optional[str] = None
|
|
154
|
+
wallet_address: str = Field(..., description="Wallet address to filter transactions")
|
|
155
|
+
day: Optional[int] = Field(None, ge=1, le=31, description="Day of the month")
|
|
156
|
+
month: Optional[int] = Field(None, ge=1, le=12, description="Month of the year")
|
|
157
|
+
year: Optional[int] = Field(None, description="Year")
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class GetTransactionParams(BaseModel):
|
|
161
|
+
"""Parameters for fetching a single transaction by hash or ID."""
|
|
162
|
+
|
|
163
|
+
hash_or_id: str = Field(..., description="Transaction hash (0x...) or internal database ID")
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class GetTransactionStatusParams(BaseModel):
|
|
167
|
+
"""Parameters for fetching on-chain transaction status."""
|
|
168
|
+
|
|
169
|
+
hash: str = Field(..., description="Transaction hash (0x...)")
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class OnChainTxStatus(str, Enum):
|
|
173
|
+
"""On-chain transaction status from StarkNet sequencer."""
|
|
174
|
+
|
|
175
|
+
RECEIVED = "RECEIVED"
|
|
176
|
+
PENDING = "PENDING"
|
|
177
|
+
ACCEPTED_ON_L2 = "ACCEPTED_ON_L2"
|
|
178
|
+
ACCEPTED_ON_L1 = "ACCEPTED_ON_L1"
|
|
179
|
+
REJECTED = "REJECTED"
|
|
180
|
+
REVERTED = "REVERTED"
|
|
181
|
+
NOT_RECEIVED = "NOT_RECEIVED"
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
class TransactionStatusResponse(BaseModel):
|
|
185
|
+
"""Response from the transaction status endpoint."""
|
|
186
|
+
|
|
187
|
+
model_config = ConfigDict(populate_by_name=True)
|
|
188
|
+
|
|
189
|
+
transaction_hash: str = Field(..., alias="transactionHash")
|
|
190
|
+
status: OnChainTxStatus
|
|
191
|
+
block_number: Optional[int] = Field(None, alias="blockNumber")
|
|
192
|
+
revert_reason: Optional[str] = Field(None, alias="revertReason")
|
chipi_sdk/models/user.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""User-related types and models."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CreateUserParams(BaseModel):
|
|
9
|
+
"""Parameters for creating a user."""
|
|
10
|
+
|
|
11
|
+
external_user_id: str = Field(..., description="External user identifier")
|
|
12
|
+
email: Optional[str] = Field(None, description="User email")
|
|
13
|
+
metadata: Optional[dict] = Field(None, description="Additional user metadata")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class GetUserParams(BaseModel):
|
|
17
|
+
"""Parameters for retrieving a user."""
|
|
18
|
+
|
|
19
|
+
external_user_id: str = Field(..., description="External user identifier")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class User(BaseModel):
|
|
23
|
+
"""User model."""
|
|
24
|
+
|
|
25
|
+
id: str
|
|
26
|
+
org_id: str
|
|
27
|
+
external_user_id: str
|
|
28
|
+
email: Optional[str] = None
|
|
29
|
+
metadata: Optional[dict] = None
|
|
30
|
+
created_at: datetime
|
|
31
|
+
updated_at: datetime
|