@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.cjs CHANGED
@@ -44900,6 +44900,16 @@ async function makeUpdateSwbFeedIx(props) {
44900
44900
  const crossbarClient = new common.CrossbarClient(
44901
44901
  process.env.NEXT_PUBLIC_SWITCHBOARD_CROSSSBAR_API || "https://integrator-crossbar.prod.mrgn.app"
44902
44902
  );
44903
+ const onChainDatas = await onDemand.PullFeed.loadMany(swbProgram, pullFeedInstances);
44904
+ for (let i = 0; i < pullFeedInstances.length; i++) {
44905
+ const feed = pullFeedInstances[i];
44906
+ const onChainData = onChainDatas[i];
44907
+ const configHash = feed.configs?.feedHash ? Buffer.from(feed.configs.feedHash).toString("hex") : "none";
44908
+ const onChainHash = onChainData?.feedHash ? Buffer.from(onChainData.feedHash).toString("hex") : "none";
44909
+ console.log(
44910
+ `[makeUpdateSwbFeedIx] Feed ${feed.pubkey.toBase58()} | configs.feedHash: ${configHash} | onChain.feedHash: ${onChainHash} | loaded: ${!!onChainData}`
44911
+ );
44912
+ }
44903
44913
  console.log(`[makeUpdateSwbFeedIx] Fetching update ix for ${pullFeedInstances.length} feeds`);
44904
44914
  console.log(
44905
44915
  `[makeUpdateSwbFeedIx] pullFeedInstances:`,
@@ -44908,9 +44918,29 @@ async function makeUpdateSwbFeedIx(props) {
44908
44918
  const [pullIx, luts] = await onDemand.PullFeed.fetchUpdateManyIx(swbProgram, {
44909
44919
  feeds: pullFeedInstances,
44910
44920
  numSignatures: 1,
44911
- crossbarClient
44921
+ crossbarClient,
44922
+ payer: props.feePayer
44912
44923
  });
44913
44924
  console.log(`[makeUpdateSwbFeedIx] Got ${pullIx.length} instructions, ${luts.length} LUTs`);
44925
+ const feedPubkeySet = new Set(pullFeedInstances.map((f) => f.pubkey.toBase58()));
44926
+ if (pullIx.length >= 2) {
44927
+ const submitIx = pullIx[1];
44928
+ const defaultKey = web3_js.PublicKey.default.toBase58();
44929
+ const presentFeedKeys = new Set(
44930
+ submitIx.keys.filter((k) => feedPubkeySet.has(k.pubkey.toBase58())).map((k) => k.pubkey.toBase58())
44931
+ );
44932
+ const missingFeedKeys = pullFeedInstances.map((f) => f.pubkey).filter((pk) => !presentFeedKeys.has(pk.toBase58()));
44933
+ let missingIdx = 0;
44934
+ for (const key of submitIx.keys) {
44935
+ if (key.pubkey.toBase58() === defaultKey && missingIdx < missingFeedKeys.length) {
44936
+ console.log(
44937
+ `[makeUpdateSwbFeedIx] Replacing PublicKey.default with ${missingFeedKeys[missingIdx].toBase58()}`
44938
+ );
44939
+ key.pubkey = missingFeedKeys[missingIdx];
44940
+ missingIdx++;
44941
+ }
44942
+ }
44943
+ }
44914
44944
  return { instructions: pullIx, luts };
44915
44945
  }
44916
44946