From c46e6370deccc03bbc015b81b44a4a0973bde02d Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 15 Nov 2022 17:00:22 +0000 Subject: [PATCH 1/3] change examples to use pythnet --- examples/dump.py | 10 +++++----- examples/read_one_price_feed.py | 8 ++++---- pythclient/solana.py | 3 +++ pythclient/utils.py | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/dump.py b/examples/dump.py index af75ca6..5d903dc 100644 --- a/examples/dump.py +++ b/examples/dump.py @@ -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 SOLANA_DEVNET_HTTP_ENDPOINT, SOLANA_DEVNET_WS_ENDPOINT, 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 @@ -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() diff --git a/examples/read_one_price_feed.py b/examples/read_one_price_feed.py index 0dea35e..41fda1c 100644 --- a/examples/read_one_price_feed.py +++ b/examples/read_one_price_feed.py @@ -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, SOLANA_DEVNET_HTTP_ENDPOINT, SOLANA_DEVNET_WS_ENDPOINT, 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() diff --git a/pythclient/solana.py b/pythclient/solana.py index a2b3589..e066d2f 100644 --- a/pythclient/solana.py +++ b/pythclient/solana.py @@ -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 @@ -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: """ diff --git a/pythclient/utils.py b/pythclient/utils.py index 36384ff..6d6752a 100644 --- a/pythclient/utils.py +++ b/pythclient/utils.py @@ -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: From e3b75ca801c59892a076efe96502337f31b3f982 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 15 Nov 2022 17:01:09 +0000 Subject: [PATCH 2/3] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 323be74..bde7049 100644 --- a/setup.py +++ b/setup.py @@ -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', From d4ab827b5f364b6a175ee502d59c8cbcbe4b338c Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 15 Nov 2022 17:04:27 +0000 Subject: [PATCH 3/3] remove unused variables --- examples/dump.py | 2 +- examples/read_one_price_feed.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/dump.py b/examples/dump.py index 5d903dc..5704b10 100644 --- a/examples/dump.py +++ b/examples/dump.py @@ -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, PYTHNET_HTTP_ENDPOINT, PYTHNET_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 diff --git a/examples/read_one_price_feed.py b/examples/read_one_price_feed.py index 41fda1c..0688382 100644 --- a/examples/read_one_price_feed.py +++ b/examples/read_one_price_feed.py @@ -3,7 +3,7 @@ import asyncio from pythclient.pythaccounts import PythPriceAccount, PythPriceStatus -from pythclient.solana import SolanaClient, SolanaPublicKey, SOLANA_DEVNET_HTTP_ENDPOINT, SOLANA_DEVNET_WS_ENDPOINT, PYTHNET_HTTP_ENDPOINT, PYTHNET_WS_ENDPOINT +from pythclient.solana import SolanaClient, SolanaPublicKey, PYTHNET_HTTP_ENDPOINT, PYTHNET_WS_ENDPOINT async def get_price(): # pythnet DOGE/USD price account key (available on pyth.network website)