-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add ts publish example #41
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.
Just giving some small thoughts. Not super well versed yet on the chain verification side. I'm assuming this has been run and works? Depending on how serious this is, perhaps we can add a unit test which runs this? Maybe get @cprussin help for organizing it.
|
||
const SOLANA_RPC_URL = "https://api.devnet.solana.com"; | ||
const PAYER_SECRET_KEY = Uint8Array.from( | ||
JSON.parse(fs.readFileSync("/path/to/private-key.json", "utf8")) as number[], |
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.
Perhaps we can pull out the file path as a constant or read it from config/env? I'd prefer env since we can use .env files for having these tokens and secrets around.
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.
this is just an example on how to use the functions. Users have different needs and they'll implement the key they way they want to.
const main = async () => { | ||
const client = await PythLazerClient.create( | ||
["wss://pyth-lazer-staging.dourolabs.app/v1/stream"], | ||
"my_token", |
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.
Can we read token from env too?
|
||
// We are expecting a JSON messages | ||
if (message.type !== "json") { | ||
console.log("unexpected message type:", message.type); |
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.
Maybe a nitpick but the log levels could be tuned differently. Like making this a war/error, some others debug, etc.
1, | ||
42, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, |
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.
Is this like a constant thing we need to pass in? Can we make it a constant with a descriptive name? Assuming these are some kind of headers.
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.
this is the data that our example contract receives. I think adding a comment would be enough.
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.
I think it will be easier to understand if you use Buffer.writeInt64LE
instead of writing the representation manually.
return; | ||
} | ||
|
||
// ignore the subscribed message |
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.
If we want to ignore the subscribed message, should we only shutdown if we receive a non-subscribed message?
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.
i think this is the current behavior
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.
Ah the return slipped my mind. You're right.
@@ -0,0 +1,176 @@ | |||
import { |
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.
Just to confirm, this file is meant to test if an update we receive from lazer can be verified on chain?
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.
it's not a test. It's just an example to show how to create ixs for pyth lazer data using ts.
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.
Maybe it's better to call it publish_to_solana
because it's different on EVM.
It's too much work, i don't think it's worth it. |
No description provided.