Skip to content

Commit fd14acb

Browse files
authored
pythnet (#29)
* change examples to use pythnet * bump version * remove unused variables
1 parent 9716905 commit fd14acb

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

examples/dump.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import List, Any
99

1010
from loguru import logger
11-
from pythclient.solana import SOLANA_DEVNET_HTTP_ENDPOINT, SOLANA_DEVNET_WS_ENDPOINT
11+
from pythclient.solana import PYTHNET_HTTP_ENDPOINT, PYTHNET_WS_ENDPOINT
1212

1313
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
1414
from pythclient.pythclient import PythClient # noqa
@@ -34,13 +34,13 @@ def set_to_exit(sig: Any, frame: Any):
3434
async def main():
3535
global to_exit
3636
use_program = len(sys.argv) >= 2 and sys.argv[1] == "program"
37-
v2_first_mapping_account_key = get_key("devnet", "mapping")
38-
v2_program_key = get_key("devnet", "program")
37+
v2_first_mapping_account_key = get_key("pythnet", "mapping")
38+
v2_program_key = get_key("pythnet", "program")
3939
async with PythClient(
4040
first_mapping_account_key=v2_first_mapping_account_key,
4141
program_key=v2_program_key if use_program else None,
42-
solana_endpoint=SOLANA_DEVNET_HTTP_ENDPOINT, # replace with the relevant cluster endpoints
43-
solana_ws_endpoint=SOLANA_DEVNET_WS_ENDPOINT # replace with the relevant cluster endpoints
42+
solana_endpoint=PYTHNET_HTTP_ENDPOINT, # replace with the relevant cluster endpoints
43+
solana_ws_endpoint=PYTHNET_WS_ENDPOINT # replace with the relevant cluster endpoints
4444
) as c:
4545
await c.refresh_all_prices()
4646
products = await c.get_products()

examples/read_one_price_feed.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import asyncio
44

55
from pythclient.pythaccounts import PythPriceAccount, PythPriceStatus
6-
from pythclient.solana import SolanaClient, SolanaPublicKey, SOLANA_DEVNET_HTTP_ENDPOINT, SOLANA_DEVNET_WS_ENDPOINT
6+
from pythclient.solana import SolanaClient, SolanaPublicKey, PYTHNET_HTTP_ENDPOINT, PYTHNET_WS_ENDPOINT
77

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

1414
await price.update()

pythclient/solana.py

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
DEVNET_ENDPOINT = "api.devnet.solana.com"
2020
TESTNET_ENDPOINT = "api.testnet.solana.com"
2121
MAINNET_ENDPOINT = "api.mainnet-beta.solana.com"
22+
PYTHNET_ENDPOINT = "pythnet.rpcpool.com"
2223

2324
SOLANA_DEVNET_WS_ENDPOINT = WS_PREFIX + "://" + DEVNET_ENDPOINT
2425
SOLANA_DEVNET_HTTP_ENDPOINT = HTTP_PREFIX + "://" + DEVNET_ENDPOINT
@@ -29,6 +30,8 @@
2930
SOLANA_MAINNET_WS_ENDPOINT = WS_PREFIX + "://" + MAINNET_ENDPOINT
3031
SOLANA_MAINNET_HTTP_ENDPOINT = HTTP_PREFIX + "://" + MAINNET_ENDPOINT
3132

33+
PYTHNET_WS_ENDPOINT = WS_PREFIX + "://" + PYTHNET_ENDPOINT
34+
PYTHNET_HTTP_ENDPOINT = HTTP_PREFIX + "://" + PYTHNET_ENDPOINT
3235

3336
class SolanaPublicKey:
3437
"""

pythclient/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def get_key(network: str, type: str, version: str = DEFAULT_VERSION) -> Optional
1717
devnet-program-v2.pyth.network
1818
mainnet-program-v2.pyth.network
1919
testnet-mapping-v2.pyth.network
20+
pythnet-mapping-v2.pyth.network
2021
"""
2122
url = f"{network}-{type}-{version}.pyth.network"
2223
try:

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='pythclient',
10-
version='0.1.2',
10+
version='0.1.3',
1111
packages=['pythclient'],
1212
author='Pyth Developers',
1313
author_email='[email protected]',

0 commit comments

Comments
 (0)