-
Notifications
You must be signed in to change notification settings - Fork 16
feat(lazer): update solana example #38
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Truth be told, I'm not really familiar with what is going on here. Mainly, I see we working with new accounts. Is this related to the addition of fees to verification?
@@ -49,6 +52,14 @@ fn main() -> anyhow::Result<()> { | |||
let signature = client.send_and_confirm_transaction(&tx)?; | |||
println!("OK {signature:?}"); | |||
} else if cmd == "update" { | |||
let state_data = client.get_account_data(&data_pda_key)?; | |||
let state = from_bytes::<State>(&state_data); | |||
println!("state: {state:?}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kinds of things are in state that we would want to print it out? I wonder if we can migrate to using tracing crate for logging to change visibility of some of these print statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can look at the state to figure out which price feed this contract instance wants to receive and what is the timestamp of the latest applied update (the contract will only allow updates with a greater timestamp).
I think println is fine for an example. I'd like it to be as easy to understand as possible, and tracing/log can be confusing if unfamiliar.
let _pyth_program_account = &accounts[2]; | ||
let pyth_storage_account = &accounts[3]; | ||
let pyth_treasury_account = &accounts[4]; | ||
let system_program_account = &accounts[5]; | ||
let instructions_sysvar_account = &accounts[6]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do all these accounts do? Are they actually different accounts entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Program accounts are required to allow the contract to call them. This contract calls the pyth contract (_pyth_program_account
) which calls the system program (system_program_account
) to make the fee transfer. pyth_storage_account
and pyth_treasury_account
are accounts that have to be accessed by the pyth contract. instructions_sysvar_account
is a special account that allows programs to inspect other instructions within the current transaction, which is needed to validate the signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
The example contract now calls the Pyth Lazer contract using the CPI.