@0dotxyz/p0-ts-sdk 1.2.3 → 1.2.4-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -44875,6 +44875,16 @@ async function makeUpdateSwbFeedIx(props) {
44875
44875
  const crossbarClient = new CrossbarClient(
44876
44876
  process.env.NEXT_PUBLIC_SWITCHBOARD_CROSSSBAR_API || "https://integrator-crossbar.prod.mrgn.app"
44877
44877
  );
44878
+ const onChainDatas = await PullFeed.loadMany(swbProgram, pullFeedInstances);
44879
+ for (let i = 0; i < pullFeedInstances.length; i++) {
44880
+ const feed = pullFeedInstances[i];
44881
+ const onChainData = onChainDatas[i];
44882
+ const configHash = feed.configs?.feedHash ? Buffer.from(feed.configs.feedHash).toString("hex") : "none";
44883
+ const onChainHash = onChainData?.feedHash ? Buffer.from(onChainData.feedHash).toString("hex") : "none";
44884
+ console.log(
44885
+ `[makeUpdateSwbFeedIx] Feed ${feed.pubkey.toBase58()} | configs.feedHash: ${configHash} | onChain.feedHash: ${onChainHash} | loaded: ${!!onChainData}`
44886
+ );
44887
+ }
44878
44888
  console.log(`[makeUpdateSwbFeedIx] Fetching update ix for ${pullFeedInstances.length} feeds`);
44879
44889
  console.log(
44880
44890
  `[makeUpdateSwbFeedIx] pullFeedInstances:`,
@@ -44883,9 +44893,29 @@ async function makeUpdateSwbFeedIx(props) {
44883
44893
  const [pullIx, luts] = await PullFeed.fetchUpdateManyIx(swbProgram, {
44884
44894
  feeds: pullFeedInstances,
44885
44895
  numSignatures: 1,
44886
- crossbarClient
44896
+ crossbarClient,
44897
+ payer: props.feePayer
44887
44898
  });
44888
44899
  console.log(`[makeUpdateSwbFeedIx] Got ${pullIx.length} instructions, ${luts.length} LUTs`);
44900
+ const feedPubkeySet = new Set(pullFeedInstances.map((f) => f.pubkey.toBase58()));
44901
+ if (pullIx.length >= 2) {
44902
+ const submitIx = pullIx[1];
44903
+ const defaultKey = PublicKey.default.toBase58();
44904
+ const presentFeedKeys = new Set(
44905
+ submitIx.keys.filter((k) => feedPubkeySet.has(k.pubkey.toBase58())).map((k) => k.pubkey.toBase58())
44906
+ );
44907
+ const missingFeedKeys = pullFeedInstances.map((f) => f.pubkey).filter((pk) => !presentFeedKeys.has(pk.toBase58()));
44908
+ let missingIdx = 0;
44909
+ for (const key of submitIx.keys) {
44910
+ if (key.pubkey.toBase58() === defaultKey && missingIdx < missingFeedKeys.length) {
44911
+ console.log(
44912
+ `[makeUpdateSwbFeedIx] Replacing PublicKey.default with ${missingFeedKeys[missingIdx].toBase58()}`
44913
+ );
44914
+ key.pubkey = missingFeedKeys[missingIdx];
44915
+ missingIdx++;
44916
+ }
44917
+ }
44918
+ }
44889
44919
  return { instructions: pullIx, luts };
44890
44920
  }
44891
44921