Skip to content

Conversation

@keyvankhademi
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Sep 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 10, 2024 11:05pm
staking-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 10, 2024 11:05pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
xc-admin-frontend ⬜️ Ignored (Inspect) Visit Preview Sep 10, 2024 11:05pm

poolData: PoolDataAccount,
): PublisherData => {
return poolData.publishers
.filter((publisher) => !publisher.equals(PublicKey.default))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels wrong if there were gaps in the publishers (which can't happen in the program though)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes there are a lot of assumptions based on that.

Copy link
Collaborator

@cprussin cprussin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most important changes are:

  1. Calculate upcoming epoch APY rather than last epoch APY
  2. Move some stuff to Promise.all
  3. Validate publisher ranking response using schema instead of typecasting
  4. Remove the publishers-ranking endpoint and instead use nextjs rewrites; also rewrite to web-api directly instead of rewriting to www.pyth.network

Everything else is optional / minor

},
});
// TODO: use env var to support mainnet
const hermesClient = new HermesClient("https://hermes-beta.pyth.network");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should be in a separate react context, it doesn't really make sense to be in this context as it's not associated to the wallet state (I should rename this hook as it's no longer just about staking accounts, it's now really a hook for the wallet state, where the list of stake accounts & the selected stake account is part of the wallet state -- and the Pyth Staking Client is here because it is only valid in certain wallet states).

stakeAccount:
poolData.publisherStakeAccounts[index] === undefined ||
poolData.publisherStakeAccounts[index].equals(PublicKey.default)
? null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor preference but I suggest just using undefined instead of mixing undefined and null; the fact that javascript has both is a wart and it's very very easy to misuse them in subtle ways. For all intents and purposes they are typically used interchangeably, so best to just standardize on one and always use it. Due to the semantics of missing values, you generally can't avoid undefined, but null is generally only introduced in user code, so I generally suggest just standardizing on using undefined everywhere.

If you need a true ternary state, I will always recommend using the fake sum types pattern I shared with you earlier, it's far more explicit, easier to understand the intent, and less error-prone.

@keyvankhademi keyvankhademi merged commit b42d8ef into keyvan/hermes Sep 10, 2024
6 checks passed
@keyvankhademi keyvankhademi deleted the sdk branch September 10, 2024 23:16
@keyvankhademi keyvankhademi restored the sdk branch September 11, 2024 14:45
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