Skip to content

pythnet #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import List, Any

from loguru import logger
from pythclient.solana import SOLANA_DEVNET_HTTP_ENDPOINT, SOLANA_DEVNET_WS_ENDPOINT
from pythclient.solana import PYTHNET_HTTP_ENDPOINT, PYTHNET_WS_ENDPOINT

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from pythclient.pythclient import PythClient # noqa
Expand All @@ -34,13 +34,13 @@ def set_to_exit(sig: Any, frame: Any):
async def main():
global to_exit
use_program = len(sys.argv) >= 2 and sys.argv[1] == "program"
v2_first_mapping_account_key = get_key("devnet", "mapping")
v2_program_key = get_key("devnet", "program")
v2_first_mapping_account_key = get_key("pythnet", "mapping")
v2_program_key = get_key("pythnet", "program")
async with PythClient(
first_mapping_account_key=v2_first_mapping_account_key,
program_key=v2_program_key if use_program else None,
solana_endpoint=SOLANA_DEVNET_HTTP_ENDPOINT, # replace with the relevant cluster endpoints
solana_ws_endpoint=SOLANA_DEVNET_WS_ENDPOINT # replace with the relevant cluster endpoints
solana_endpoint=PYTHNET_HTTP_ENDPOINT, # replace with the relevant cluster endpoints
solana_ws_endpoint=PYTHNET_WS_ENDPOINT # replace with the relevant cluster endpoints
) as c:
await c.refresh_all_prices()
products = await c.get_products()
Expand Down
8 changes: 4 additions & 4 deletions examples/read_one_price_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import asyncio

from pythclient.pythaccounts import PythPriceAccount, PythPriceStatus
from pythclient.solana import SolanaClient, SolanaPublicKey, SOLANA_DEVNET_HTTP_ENDPOINT, SOLANA_DEVNET_WS_ENDPOINT
from pythclient.solana import SolanaClient, SolanaPublicKey, PYTHNET_HTTP_ENDPOINT, PYTHNET_WS_ENDPOINT

async def get_price():
# devnet DOGE/USD price account key (available on pyth.network website)
account_key = SolanaPublicKey("4L6YhY8VvUgmqG5MvJkUJATtzB2rFqdrJwQCmFLv4Jzy")
solana_client = SolanaClient(endpoint=SOLANA_DEVNET_HTTP_ENDPOINT, ws_endpoint=SOLANA_DEVNET_WS_ENDPOINT)
# pythnet DOGE/USD price account key (available on pyth.network website)
account_key = SolanaPublicKey("FsSM3s38PX9K7Dn6eGzuE29S2Dsk1Sss1baytTQdCaQj")
solana_client = SolanaClient(endpoint=PYTHNET_HTTP_ENDPOINT, ws_endpoint=PYTHNET_WS_ENDPOINT)
price: PythPriceAccount = PythPriceAccount(account_key, solana_client)

await price.update()
Expand Down
3 changes: 3 additions & 0 deletions pythclient/solana.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
DEVNET_ENDPOINT = "api.devnet.solana.com"
TESTNET_ENDPOINT = "api.testnet.solana.com"
MAINNET_ENDPOINT = "api.mainnet-beta.solana.com"
PYTHNET_ENDPOINT = "pythnet.rpcpool.com"

SOLANA_DEVNET_WS_ENDPOINT = WS_PREFIX + "://" + DEVNET_ENDPOINT
SOLANA_DEVNET_HTTP_ENDPOINT = HTTP_PREFIX + "://" + DEVNET_ENDPOINT
Expand All @@ -29,6 +30,8 @@
SOLANA_MAINNET_WS_ENDPOINT = WS_PREFIX + "://" + MAINNET_ENDPOINT
SOLANA_MAINNET_HTTP_ENDPOINT = HTTP_PREFIX + "://" + MAINNET_ENDPOINT

PYTHNET_WS_ENDPOINT = WS_PREFIX + "://" + PYTHNET_ENDPOINT
PYTHNET_HTTP_ENDPOINT = HTTP_PREFIX + "://" + PYTHNET_ENDPOINT

class SolanaPublicKey:
"""
Expand Down
1 change: 1 addition & 0 deletions pythclient/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def get_key(network: str, type: str, version: str = DEFAULT_VERSION) -> Optional
devnet-program-v2.pyth.network
mainnet-program-v2.pyth.network
testnet-mapping-v2.pyth.network
pythnet-mapping-v2.pyth.network
"""
url = f"{network}-{type}-{version}.pyth.network"
try:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='pythclient',
version='0.1.2',
version='0.1.3',
packages=['pythclient'],
author='Pyth Developers',
author_email='contact@pyth.network',
Expand Down