ostium-python-sdk 0.1.8__tar.gz → 0.1.9__tar.gz

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.
Files changed (22) hide show
  1. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/PKG-INFO +1 -1
  2. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/sdk.py +16 -7
  3. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk.egg-info/PKG-INFO +1 -1
  4. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/setup.py +1 -1
  5. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/README.md +0 -0
  6. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/__init__.py +0 -0
  7. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/abi.py +0 -0
  8. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/balance.py +0 -0
  9. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/config.py +0 -0
  10. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/constants.py +0 -0
  11. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/formulae.py +0 -0
  12. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/formulae_wrapper.py +0 -0
  13. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/ostium.py +0 -0
  14. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/price.py +0 -0
  15. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/subgraph.py +0 -0
  16. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk/utils.py +0 -0
  17. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk.egg-info/SOURCES.txt +0 -0
  18. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk.egg-info/dependency_links.txt +0 -0
  19. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk.egg-info/requires.txt +0 -0
  20. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/ostium_python_sdk.egg-info/top_level.txt +0 -0
  21. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/pyproject.toml +0 -0
  22. {ostium_python_sdk-0.1.8 → ostium_python_sdk-0.1.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ostium-python-sdk
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: A python based SDK developed for interacting with Ostium, a leveraged trading application for trading currencies, commodities, indices, crypto and more.
5
5
  Home-page: https://github.com/0xOstium/ostium-python-sdk
6
6
  Author: ami@ostium.io
@@ -3,10 +3,11 @@ import os
3
3
  from web3 import Web3
4
4
  from .ostium import Ostium
5
5
  from .config import NetworkConfig
6
+ from typing import Union
6
7
 
7
8
 
8
9
  class OstiumSDK:
9
- def __init__(self, network="mainnet", private_key: str = None, rpc_url: str = None):
10
+ def __init__(self, network: Union[str, NetworkConfig], private_key: str = None, rpc_url: str = None):
10
11
  load_dotenv()
11
12
  self.private_key = private_key or os.getenv('PRIVATE_KEY')
12
13
  if not self.private_key:
@@ -15,20 +16,28 @@ class OstiumSDK:
15
16
 
16
17
  self.rpc_url = rpc_url or os.getenv('RPC_URL')
17
18
  if not self.rpc_url:
19
+ network_name = "mainnet" if isinstance(
20
+ network, str) and network == "mainnet" else "testnet"
18
21
  raise ValueError(
19
- f"No RPC URL provided for {network}. Please provide via constructor or RPC_URL environment variable")
22
+ f"No RPC URL provided for {network_name}. Please provide via constructor or RPC_URL environment variable")
20
23
 
21
24
  # Initialize Web3
22
25
  self.w3 = Web3(Web3.HTTPProvider(self.rpc_url))
23
26
 
24
27
  # Get network configuration
25
- if network == "mainnet":
26
- self.network_config = NetworkConfig.mainnet()
27
- elif network == "testnet":
28
- self.network_config = NetworkConfig.testnet()
28
+ if isinstance(network, NetworkConfig):
29
+ self.network_config = network
30
+ elif isinstance(network, str):
31
+ if network == "mainnet":
32
+ self.network_config = NetworkConfig.mainnet()
33
+ elif network == "testnet":
34
+ self.network_config = NetworkConfig.testnet()
35
+ else:
36
+ raise ValueError(
37
+ f"Unsupported network: {network}. Use 'mainnet' or 'testnet'")
29
38
  else:
30
39
  raise ValueError(
31
- f"Unsupported network: {network}. Use 'mainnet' or 'testnet'")
40
+ "Network must be either a NetworkConfig instance or a string ('mainnet' or 'testnet')")
32
41
 
33
42
  # Initialize Ostium instance
34
43
  self.ostium = Ostium(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ostium-python-sdk
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: A python based SDK developed for interacting with Ostium, a leveraged trading application for trading currencies, commodities, indices, crypto and more.
5
5
  Home-page: https://github.com/0xOstium/ostium-python-sdk
6
6
  Author: ami@ostium.io
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="ostium-python-sdk",
5
- version="0.1.8",
5
+ version="0.1.9",
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  "web3>=6.0.0",