Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

purpleflea

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

purpleflea - npm Package Compare versions

Comparing version
0.1.0
to
0.2.0
+156
purpleflea/wallet.py
"""Client for the Purple Flea Wallet API (/api/v1/wallet/)."""
from __future__ import annotations
from typing import Any
from .client import PurpleFleaClient
class WalletClient:
"""High-level wrapper around the Purple Flea Wallet service.
Handles deposits, withdrawals, balance queries, transaction history,
and crypto address management. Routes live under ``/api/v1/wallet/``.
"""
PREFIX = "/api/v1/wallet"
DEFAULT_BASE_URL = "http://80.78.27.26:3000"
def __init__(
self,
api_key: str,
base_url: str | None = None,
timeout: float = 30.0,
) -> None:
self._http = PurpleFleaClient(
api_key,
base_url=base_url or self.DEFAULT_BASE_URL,
timeout=timeout,
)
def _path(self, route: str) -> str:
return f"{self.PREFIX}/{route.lstrip('/')}"
# -- balance & info -------------------------------------------------------
def get_balance(self) -> dict[str, Any]:
"""Get current wallet balance across all currencies."""
return self._http.get(self.PREFIX)
def get_address(self, currency: str) -> dict[str, Any]:
"""Get the deposit address for a given currency (e.g. ``"BTC"``, ``"ETH"``)."""
return self._http.get(self._path(f"address/{currency}"))
# -- deposits -------------------------------------------------------------
def deposit(self, amount: float, currency: str = "USDC", **extra: Any) -> dict[str, Any]:
"""Initiate a deposit into the wallet.
Parameters
----------
amount:
Amount to deposit.
currency:
Currency code (default ``"USDC"``).
"""
return self._http.post(self._path("deposit"), amount=amount, currency=currency, **extra)
def get_deposit(self, deposit_id: str) -> dict[str, Any]:
"""Get the status of a specific deposit."""
return self._http.get(self._path(f"deposits/{deposit_id}"))
def list_deposits(self, **filters: Any) -> dict[str, Any]:
"""List all deposits, optionally filtered by status or currency."""
return self._http.get(self._path("deposits"), **filters)
# -- withdrawals ----------------------------------------------------------
def withdraw(
self,
amount: float,
address: str,
currency: str = "USDC",
**extra: Any,
) -> dict[str, Any]:
"""Withdraw funds to an external address.
Parameters
----------
amount:
Amount to withdraw.
address:
Destination wallet address.
currency:
Currency code (default ``"USDC"``).
"""
return self._http.post(
self._path("withdraw"),
amount=amount,
address=address,
currency=currency,
**extra,
)
def get_withdrawal(self, withdrawal_id: str) -> dict[str, Any]:
"""Get the status of a specific withdrawal."""
return self._http.get(self._path(f"withdrawals/{withdrawal_id}"))
def list_withdrawals(self, **filters: Any) -> dict[str, Any]:
"""List all withdrawals, optionally filtered by status or currency."""
return self._http.get(self._path("withdrawals"), **filters)
# -- transaction history --------------------------------------------------
def list_transactions(self, limit: int = 50, **filters: Any) -> dict[str, Any]:
"""List all wallet transactions (deposits, withdrawals, game credits).
Parameters
----------
limit:
Maximum number of transactions to return (default 50).
"""
return self._http.get(self._path("transactions"), limit=limit, **filters)
def get_transaction(self, transaction_id: str) -> dict[str, Any]:
"""Get details for a specific transaction."""
return self._http.get(self._path(f"transactions/{transaction_id}"))
# -- internal transfers ---------------------------------------------------
def transfer(
self,
to_account: str,
amount: float,
currency: str = "USDC",
**extra: Any,
) -> dict[str, Any]:
"""Transfer funds to another Purple Flea account.
Parameters
----------
to_account:
Recipient username or account ID.
amount:
Amount to transfer.
currency:
Currency code (default ``"USDC"``).
"""
return self._http.post(
self._path("transfer"),
to_account=to_account,
amount=amount,
currency=currency,
**extra,
)
# -- lifecycle ------------------------------------------------------------
def close(self) -> None:
self._http.close()
def __enter__(self) -> WalletClient:
return self
def __exit__(self, *args: object) -> None:
self.close()
+82
-18

@@ -1,12 +0,12 @@

Metadata-Version: 2.1
Metadata-Version: 2.2
Name: purpleflea
Version: 0.1.0
Summary: Python SDK for Purple Flea Casino & Trading APIs
Version: 0.2.0
Summary: Python SDK for Purple Flea Casino, Trading & Wallet APIs
Author-email: Purple Flea <dev@purpleflea.com>
License: MIT
Project-URL: Homepage, https://github.com/Purple-flea/python-sdk
Project-URL: Repository, https://github.com/Purple-flea/python-sdk
Project-URL: Issues, https://github.com/Purple-flea/python-sdk/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3

@@ -19,8 +19,12 @@ Classifier: Programming Language :: Python :: 3.10

Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28
Provides-Extra: dev
License-File: LICENSE
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: responses>=0.23; extra == "dev"
# purpleflea
Python SDK for the [Purple Flea](https://purpleflea.com) Casino & Trading APIs.
Python SDK for the [Purple Flea](https://purpleflea.com) Casino, Trading & Wallet APIs.

@@ -40,2 +44,3 @@ ## Installation

# Defaults to http://80.78.27.26:3000
casino = CasinoClient("your-api-key")

@@ -47,3 +52,3 @@

# Deposit funds
casino.deposit(100.0, currency="USD")
casino.deposit(100.0, currency="USDC")

@@ -54,3 +59,3 @@ # List available games

# Play a round
result = casino.play("slots-classic", bet_amount=5.0)
result = casino.play("dice", bet_amount=5.0)

@@ -62,3 +67,3 @@ # Check balance & withdraw

# Referrals
casino.create_referral()
ref = casino.create_referral()
casino.redeem_referral("REF123")

@@ -74,2 +79,3 @@

# Defaults to http://80.78.27.26:3003
trading = TradingClient("your-api-key")

@@ -99,5 +105,34 @@

### Wallet
```python
from purpleflea import WalletClient
# Defaults to http://80.78.27.26:3000
wallet = WalletClient("your-api-key")
# Get balance
balance = wallet.get_balance()
# Get deposit address for BTC
addr = wallet.get_address("BTC")
# Deposit USDC
wallet.deposit(500.0, currency="USDC")
# Withdraw to external address
wallet.withdraw(100.0, address="0xYourAddress", currency="USDC")
# Transaction history
txns = wallet.list_transactions(limit=20)
# Transfer between accounts
wallet.transfer(to_account="carol", amount=25.0)
wallet.close()
```
### Context Manager
Both clients support context managers for automatic cleanup:
All clients support context managers for automatic cleanup:

@@ -109,3 +144,3 @@ ```python

casino.deposit(50.0)
result = casino.play("roulette", bet_amount=10.0)
result = casino.play("dice", bet_amount=10.0)
```

@@ -116,5 +151,6 @@

```python
from purpleflea import CasinoClient
from purpleflea import CasinoClient, TradingClient
casino = CasinoClient("your-api-key", base_url="https://staging.api.purpleflea.com")
casino = CasinoClient("your-api-key", base_url="http://80.78.27.26:3000")
trading = TradingClient("your-api-key", base_url="http://80.78.27.26:3003")
```

@@ -138,3 +174,3 @@

Casino API routes use the `/api/v1/` prefix.
Default base URL: `http://80.78.27.26:3000`. Routes use the `/api/v1/` prefix.

@@ -145,4 +181,4 @@ | Method | Description |

| `get_account()` | Get account details |
| `deposit(amount, currency="USD")` | Deposit funds |
| `withdraw(amount, currency="USD")` | Withdraw funds |
| `deposit(amount, currency="USDC")` | Deposit funds |
| `withdraw(amount, currency="USDC")` | Withdraw funds |
| `get_balance()` | Get wallet balance |

@@ -159,3 +195,3 @@ | `list_games()` | List available games |

Trading API routes use the `/v1/` prefix.
Default base URL: `http://80.78.27.26:3003`. Routes use the `/v1/` prefix.

@@ -177,2 +213,30 @@ | Method | Description |

### `WalletClient(api_key, base_url=None, timeout=30.0)`
Default base URL: `http://80.78.27.26:3000`. Routes use the `/api/v1/wallet/` prefix.
| Method | Description |
|---|---|
| `get_balance()` | Get balance across all currencies |
| `get_address(currency)` | Get deposit address for a currency |
| `deposit(amount, currency="USDC")` | Initiate a deposit |
| `get_deposit(deposit_id)` | Get deposit status |
| `list_deposits()` | List all deposits |
| `withdraw(amount, address, currency="USDC")` | Withdraw to external address |
| `get_withdrawal(withdrawal_id)` | Get withdrawal status |
| `list_withdrawals()` | List all withdrawals |
| `list_transactions(limit=50)` | List all transactions |
| `get_transaction(transaction_id)` | Get transaction details |
| `transfer(to_account, amount, currency="USDC")` | Transfer to another account |
## Changelog
### 0.2.0
- Added `WalletClient` with full deposit/withdrawal/transfer support
- Set correct default base URLs: casino `http://80.78.27.26:3000`, trading `http://80.78.27.26:3003`
- Promoted to Beta status
### 0.1.0
- Initial release with `CasinoClient` and `TradingClient`
## Development

@@ -179,0 +243,0 @@

@@ -1,12 +0,12 @@

Metadata-Version: 2.1
Metadata-Version: 2.2
Name: purpleflea
Version: 0.1.0
Summary: Python SDK for Purple Flea Casino & Trading APIs
Version: 0.2.0
Summary: Python SDK for Purple Flea Casino, Trading & Wallet APIs
Author-email: Purple Flea <dev@purpleflea.com>
License: MIT
Project-URL: Homepage, https://github.com/Purple-flea/python-sdk
Project-URL: Repository, https://github.com/Purple-flea/python-sdk
Project-URL: Issues, https://github.com/Purple-flea/python-sdk/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3

@@ -19,8 +19,12 @@ Classifier: Programming Language :: Python :: 3.10

Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28
Provides-Extra: dev
License-File: LICENSE
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: responses>=0.23; extra == "dev"
# purpleflea
Python SDK for the [Purple Flea](https://purpleflea.com) Casino & Trading APIs.
Python SDK for the [Purple Flea](https://purpleflea.com) Casino, Trading & Wallet APIs.

@@ -40,2 +44,3 @@ ## Installation

# Defaults to http://80.78.27.26:3000
casino = CasinoClient("your-api-key")

@@ -47,3 +52,3 @@

# Deposit funds
casino.deposit(100.0, currency="USD")
casino.deposit(100.0, currency="USDC")

@@ -54,3 +59,3 @@ # List available games

# Play a round
result = casino.play("slots-classic", bet_amount=5.0)
result = casino.play("dice", bet_amount=5.0)

@@ -62,3 +67,3 @@ # Check balance & withdraw

# Referrals
casino.create_referral()
ref = casino.create_referral()
casino.redeem_referral("REF123")

@@ -74,2 +79,3 @@

# Defaults to http://80.78.27.26:3003
trading = TradingClient("your-api-key")

@@ -99,5 +105,34 @@

### Wallet
```python
from purpleflea import WalletClient
# Defaults to http://80.78.27.26:3000
wallet = WalletClient("your-api-key")
# Get balance
balance = wallet.get_balance()
# Get deposit address for BTC
addr = wallet.get_address("BTC")
# Deposit USDC
wallet.deposit(500.0, currency="USDC")
# Withdraw to external address
wallet.withdraw(100.0, address="0xYourAddress", currency="USDC")
# Transaction history
txns = wallet.list_transactions(limit=20)
# Transfer between accounts
wallet.transfer(to_account="carol", amount=25.0)
wallet.close()
```
### Context Manager
Both clients support context managers for automatic cleanup:
All clients support context managers for automatic cleanup:

@@ -109,3 +144,3 @@ ```python

casino.deposit(50.0)
result = casino.play("roulette", bet_amount=10.0)
result = casino.play("dice", bet_amount=10.0)
```

@@ -116,5 +151,6 @@

```python
from purpleflea import CasinoClient
from purpleflea import CasinoClient, TradingClient
casino = CasinoClient("your-api-key", base_url="https://staging.api.purpleflea.com")
casino = CasinoClient("your-api-key", base_url="http://80.78.27.26:3000")
trading = TradingClient("your-api-key", base_url="http://80.78.27.26:3003")
```

@@ -138,3 +174,3 @@

Casino API routes use the `/api/v1/` prefix.
Default base URL: `http://80.78.27.26:3000`. Routes use the `/api/v1/` prefix.

@@ -145,4 +181,4 @@ | Method | Description |

| `get_account()` | Get account details |
| `deposit(amount, currency="USD")` | Deposit funds |
| `withdraw(amount, currency="USD")` | Withdraw funds |
| `deposit(amount, currency="USDC")` | Deposit funds |
| `withdraw(amount, currency="USDC")` | Withdraw funds |
| `get_balance()` | Get wallet balance |

@@ -159,3 +195,3 @@ | `list_games()` | List available games |

Trading API routes use the `/v1/` prefix.
Default base URL: `http://80.78.27.26:3003`. Routes use the `/v1/` prefix.

@@ -177,2 +213,30 @@ | Method | Description |

### `WalletClient(api_key, base_url=None, timeout=30.0)`
Default base URL: `http://80.78.27.26:3000`. Routes use the `/api/v1/wallet/` prefix.
| Method | Description |
|---|---|
| `get_balance()` | Get balance across all currencies |
| `get_address(currency)` | Get deposit address for a currency |
| `deposit(amount, currency="USDC")` | Initiate a deposit |
| `get_deposit(deposit_id)` | Get deposit status |
| `list_deposits()` | List all deposits |
| `withdraw(amount, address, currency="USDC")` | Withdraw to external address |
| `get_withdrawal(withdrawal_id)` | Get withdrawal status |
| `list_withdrawals()` | List all withdrawals |
| `list_transactions(limit=50)` | List all transactions |
| `get_transaction(transaction_id)` | Get transaction details |
| `transfer(to_account, amount, currency="USDC")` | Transfer to another account |
## Changelog
### 0.2.0
- Added `WalletClient` with full deposit/withdrawal/transfer support
- Set correct default base URLs: casino `http://80.78.27.26:3000`, trading `http://80.78.27.26:3003`
- Promoted to Beta status
### 0.1.0
- Initial release with `CasinoClient` and `TradingClient`
## Development

@@ -179,0 +243,0 @@

+1
-1
requests>=2.28
[dev]
pytest>=7.0
pytest-cov
pytest>=7.0
responses>=0.23

@@ -9,2 +9,3 @@ LICENSE

purpleflea/trading.py
purpleflea/wallet.py
purpleflea.egg-info/PKG-INFO

@@ -11,0 +12,0 @@ purpleflea.egg-info/SOURCES.txt

@@ -6,2 +6,3 @@ """Purple Flea Python SDK."""

from .trading import TradingClient
from .wallet import WalletClient

@@ -13,4 +14,5 @@ __all__ = [

"TradingClient",
"WalletClient",
]
__version__ = "0.1.0"
__version__ = "0.2.0"

@@ -17,2 +17,3 @@ """Client for the Purple Flea Casino API (/api/v1/)."""

PREFIX = "/api/v1"
DEFAULT_BASE_URL = "http://80.78.27.26:3000"

@@ -25,3 +26,7 @@ def __init__(

) -> None:
self._http = PurpleFleaClient(api_key, base_url=base_url, timeout=timeout)
self._http = PurpleFleaClient(
api_key,
base_url=base_url or self.DEFAULT_BASE_URL,
timeout=timeout,
)

@@ -28,0 +33,0 @@ def _path(self, route: str) -> str:

@@ -17,2 +17,3 @@ """Client for the Purple Flea Trading API (/v1/)."""

PREFIX = "/v1"
DEFAULT_BASE_URL = "http://80.78.27.26:3003"

@@ -25,3 +26,7 @@ def __init__(

) -> None:
self._http = PurpleFleaClient(api_key, base_url=base_url, timeout=timeout)
self._http = PurpleFleaClient(
api_key,
base_url=base_url or self.DEFAULT_BASE_URL,
timeout=timeout,
)

@@ -28,0 +33,0 @@ def _path(self, route: str) -> str:

[build-system]
requires = ["setuptools>=68.0", "wheel"]
requires = ["setuptools>=68.0,<77.0", "wheel"]
build-backend = "setuptools.build_meta"

@@ -7,6 +7,5 @@

name = "purpleflea"
version = "0.1.0"
description = "Python SDK for Purple Flea Casino & Trading APIs"
version = "0.2.0"
description = "Python SDK for Purple Flea Casino, Trading & Wallet APIs"
readme = "README.md"
license = {text = "MIT"}
requires-python = ">=3.10"

@@ -17,4 +16,5 @@ authors = [

classifiers = [
"Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",

@@ -21,0 +21,0 @@ "Programming Language :: Python :: 3.10",

+72
-12
# purpleflea
Python SDK for the [Purple Flea](https://purpleflea.com) Casino & Trading APIs.
Python SDK for the [Purple Flea](https://purpleflea.com) Casino, Trading & Wallet APIs.

@@ -18,2 +18,3 @@ ## Installation

# Defaults to http://80.78.27.26:3000
casino = CasinoClient("your-api-key")

@@ -25,3 +26,3 @@

# Deposit funds
casino.deposit(100.0, currency="USD")
casino.deposit(100.0, currency="USDC")

@@ -32,3 +33,3 @@ # List available games

# Play a round
result = casino.play("slots-classic", bet_amount=5.0)
result = casino.play("dice", bet_amount=5.0)

@@ -40,3 +41,3 @@ # Check balance & withdraw

# Referrals
casino.create_referral()
ref = casino.create_referral()
casino.redeem_referral("REF123")

@@ -52,2 +53,3 @@

# Defaults to http://80.78.27.26:3003
trading = TradingClient("your-api-key")

@@ -77,5 +79,34 @@

### Wallet
```python
from purpleflea import WalletClient
# Defaults to http://80.78.27.26:3000
wallet = WalletClient("your-api-key")
# Get balance
balance = wallet.get_balance()
# Get deposit address for BTC
addr = wallet.get_address("BTC")
# Deposit USDC
wallet.deposit(500.0, currency="USDC")
# Withdraw to external address
wallet.withdraw(100.0, address="0xYourAddress", currency="USDC")
# Transaction history
txns = wallet.list_transactions(limit=20)
# Transfer between accounts
wallet.transfer(to_account="carol", amount=25.0)
wallet.close()
```
### Context Manager
Both clients support context managers for automatic cleanup:
All clients support context managers for automatic cleanup:

@@ -87,3 +118,3 @@ ```python

casino.deposit(50.0)
result = casino.play("roulette", bet_amount=10.0)
result = casino.play("dice", bet_amount=10.0)
```

@@ -94,5 +125,6 @@

```python
from purpleflea import CasinoClient
from purpleflea import CasinoClient, TradingClient
casino = CasinoClient("your-api-key", base_url="https://staging.api.purpleflea.com")
casino = CasinoClient("your-api-key", base_url="http://80.78.27.26:3000")
trading = TradingClient("your-api-key", base_url="http://80.78.27.26:3003")
```

@@ -116,3 +148,3 @@

Casino API routes use the `/api/v1/` prefix.
Default base URL: `http://80.78.27.26:3000`. Routes use the `/api/v1/` prefix.

@@ -123,4 +155,4 @@ | Method | Description |

| `get_account()` | Get account details |
| `deposit(amount, currency="USD")` | Deposit funds |
| `withdraw(amount, currency="USD")` | Withdraw funds |
| `deposit(amount, currency="USDC")` | Deposit funds |
| `withdraw(amount, currency="USDC")` | Withdraw funds |
| `get_balance()` | Get wallet balance |

@@ -137,3 +169,3 @@ | `list_games()` | List available games |

Trading API routes use the `/v1/` prefix.
Default base URL: `http://80.78.27.26:3003`. Routes use the `/v1/` prefix.

@@ -155,2 +187,30 @@ | Method | Description |

### `WalletClient(api_key, base_url=None, timeout=30.0)`
Default base URL: `http://80.78.27.26:3000`. Routes use the `/api/v1/wallet/` prefix.
| Method | Description |
|---|---|
| `get_balance()` | Get balance across all currencies |
| `get_address(currency)` | Get deposit address for a currency |
| `deposit(amount, currency="USDC")` | Initiate a deposit |
| `get_deposit(deposit_id)` | Get deposit status |
| `list_deposits()` | List all deposits |
| `withdraw(amount, address, currency="USDC")` | Withdraw to external address |
| `get_withdrawal(withdrawal_id)` | Get withdrawal status |
| `list_withdrawals()` | List all withdrawals |
| `list_transactions(limit=50)` | List all transactions |
| `get_transaction(transaction_id)` | Get transaction details |
| `transfer(to_account, amount, currency="USDC")` | Transfer to another account |
## Changelog
### 0.2.0
- Added `WalletClient` with full deposit/withdrawal/transfer support
- Set correct default base URLs: casino `http://80.78.27.26:3000`, trading `http://80.78.27.26:3003`
- Promoted to Beta status
### 0.1.0
- Initial release with `CasinoClient` and `TradingClient`
## Development

@@ -157,0 +217,0 @@