Skip to content

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

Merged
merged 5 commits into from
Jan 16, 2025
Merged

feat: add ts publish example #41

merged 5 commits into from
Jan 16, 2025

Conversation

keyvankhademi
Copy link
Contributor

No description provided.

Copy link
Contributor

@darunrs darunrs left a 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[],
Copy link
Contributor

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.

Copy link
Contributor Author

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",
Copy link
Contributor

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);
Copy link
Contributor

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.

Comment on lines +94 to +102
1,
42,
0,
0,
0,
0,
0,
0,
0,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@keyvankhademi
Copy link
Contributor Author

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.

It's too much work, i don't think it's worth it.

@keyvankhademi keyvankhademi merged commit ae783da into main Jan 16, 2025
4 checks passed
@keyvankhademi keyvankhademi deleted the drift branch January 16, 2025 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants