pyth-network / pyth-client-py Goto Github PK
View Code? Open in Web Editor NEWPython client for pyth on-chain data
Home Page: https://pyth.network
License: Apache License 2.0
Python client for pyth on-chain data
Home Page: https://pyth.network
License: Apache License 2.0
I'm trying to read all price from solana by each time I call the function. When I set solana_network
with devnet
, it was working perfect. However, when I try to use mainet
, testnet
, or pythnet
, it can't work anymore.
solana_network="mainnet"
use_program = True
async def SolanaPythClientPriceFunction():
async with PythClient(
first_mapping_account_key=get_key(solana_network, "mapping"),
program_key=get_key(solana_network, "program") if use_program else None,
) as c:
await c.refresh_all_prices()
.....venv\Lib\site-packages\pythclient\pythclient.py", line 185, in _refresh_mapping_accounts
raise exceptions.MissingAccountException(f"need account {key} but missing in getProgramAccount response")
pythclient.exceptions.MissingAccountException: need account AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J but missing in getProgramAccount response
I checked the variables with debugger.
pyth-client-py/pythclient/pythclient.py
Lines 174 to 193 in bdd32b4
Until L180, everything works fine. Both key was correctly assigned values. But then, at L183,
m_data = account_json.get(AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J )
it reads empty data.
Is this an error with mapping key? ( I checked with Pyth Network Website, the key is as same as here) Or with the method that I calling it?
Hardcoding mapping or program keys is not ideal. This is also hardcoded only for devnet.
pyth-client-py/pythclient/pythclient.py
Lines 17 to 19 in 8f7ade6
There are new dns records for all of these which should be looked up at runtime via a helper:
The following dns TXT records exist as authoritative references to these keys:
devnet-mapping-v2.pyth.network
devnet-program-v2.pyth.network
mainnet-mapping-v2.pyth.network
mainnet-program-v2.pyth.network
testnet-mapping-v2.pyth.network
testnet-program-v2.pyth.network
A shell example of looking them up:
$ for network in dev main test; do
for type in mapping program; do
key=$(host -t TXT ${network}net-${type}-v2.pyth.network | awk -F'[="]' '/(mapping|program)=/{print $3}')
echo "$network $type key=$key"
done
done
dev mapping key=BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2
dev program key=gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s
main mapping key=AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J
main program key=FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH
test mapping key=AFmdnt9ng1uVxqCmqwQJDAYC5cKTkw8gJKSM5PnzuF6z
test program key=8tfDNiaEyrV6Q1U4DEXrEigs9DoDtkugzFbybENEbCDz
Implement some helpers to look up these keys from dns. Have that be the way to solve this in the python client.
Pytest with pytest-timeout, pytest-socket
Hi, just wondering how I would:
thank you
On a pull_request
a github action will execute and do the following:
Python-3.9
FreeBSD 14.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.