@0dotxyz/p0-ts-sdk 1.2.5 → 1.2.7-alpha.1

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
@@ -44873,16 +44873,22 @@ async function makeUpdateSwbFeedIx(props) {
44873
44873
  `[makeUpdateSwbFeedIx] - ${o.key.toBase58()} (hasSwitchboardData: ${!!o.price?.switchboardData})`
44874
44874
  )
44875
44875
  );
44876
- const dummyWallet = {
44877
- publicKey: props.feePayer,
44878
- signTransaction: async (tx) => tx,
44879
- signAllTransactions: async (txs) => txs
44880
- };
44881
- const swbProgram = await onDemand.AnchorUtils.loadProgramFromConnection(props.connection, dummyWallet);
44876
+ console.log(`[makeUpdateSwbFeedIx] Loading SWB program from connection...`);
44877
+ const swbProgram = await onDemand.AnchorUtils.loadProgramFromConnection(props.connection);
44878
+ console.log(
44879
+ `[makeUpdateSwbFeedIx] SWB program loaded - programId: ${swbProgram.programId.toBase58()}`
44880
+ );
44882
44881
  const pullFeedInstances = uniqueOracles.map((oracle) => {
44883
44882
  const pullFeed = new onDemand.PullFeed(swbProgram, oracle.key);
44883
+ console.log(
44884
+ `[makeUpdateSwbFeedIx] Created PullFeed for ${oracle.key.toBase58()} - no switchboardData set (commented out)`
44885
+ );
44884
44886
  return pullFeed;
44885
44887
  });
44888
+ console.log(
44889
+ `[makeUpdateSwbFeedIx] pullFeedInstances:`,
44890
+ pullFeedInstances.map((f) => ({ key: f.pubkey.toBase58(), hasConfigs: !!f.configs }))
44891
+ );
44886
44892
  if (pullFeedInstances.length === 0) {
44887
44893
  console.log(`[makeUpdateSwbFeedIx] No pull feed instances, returning early`);
44888
44894
  return { instructions: [], luts: [] };
@@ -44890,19 +44896,66 @@ async function makeUpdateSwbFeedIx(props) {
44890
44896
  const crossbarClient = new common.CrossbarClient(
44891
44897
  process.env.NEXT_PUBLIC_SWITCHBOARD_CROSSSBAR_API || "https://integrator-crossbar.prod.mrgn.app"
44892
44898
  );
44893
- console.log(`[makeUpdateSwbFeedIx] Fetching update ix for ${pullFeedInstances.length} feeds`);
44894
44899
  console.log(
44895
- `[makeUpdateSwbFeedIx] pullFeedInstances:`,
44896
- pullFeedInstances.map((f) => ({ key: f.pubkey.toBase58(), hasConfigs: !!f.configs }))
44900
+ `[makeUpdateSwbFeedIx] crossbarClient URL: ${process.env.NEXT_PUBLIC_SWITCHBOARD_CROSSSBAR_API || "https://integrator-crossbar.prod.mrgn.app"}`
44897
44901
  );
44898
- const [pullIx, luts] = await onDemand.PullFeed.fetchUpdateManyIx(swbProgram, {
44899
- feeds: pullFeedInstances,
44900
- numSignatures: 1,
44901
- crossbarClient,
44902
- payer: props.feePayer
44903
- });
44904
- console.log(`[makeUpdateSwbFeedIx] Got ${pullIx.length} instructions, ${luts.length} LUTs`);
44905
- return { instructions: pullIx, luts };
44902
+ console.log(
44903
+ `[makeUpdateSwbFeedIx] SWB on-demand version: 2.14.4, common version: 4.1.0 (alpha.1)`
44904
+ );
44905
+ console.log(`[makeUpdateSwbFeedIx] Fetching gateways for mainnet...`);
44906
+ const gatewayUrls = await crossbarClient.fetchGateways("mainnet");
44907
+ console.log(`[makeUpdateSwbFeedIx] Gateway URLs received:`, gatewayUrls);
44908
+ if (!gatewayUrls || gatewayUrls.length === 0) {
44909
+ throw new Error(`No gateways available for mainnet`);
44910
+ }
44911
+ const gatewayUrl = gatewayUrls[0];
44912
+ if (!gatewayUrl) {
44913
+ throw new Error(`Invalid gateway URL received for mainnet`);
44914
+ }
44915
+ console.log(`[makeUpdateSwbFeedIx] Using gateway: ${gatewayUrl}`);
44916
+ const gateway = new onDemand.Gateway(swbProgram, gatewayUrl);
44917
+ console.log(`[makeUpdateSwbFeedIx] Gateway gatewayUrl: ${gateway.gatewayUrl}`);
44918
+ try {
44919
+ for (const feed of pullFeedInstances) {
44920
+ try {
44921
+ const accountInfo = await props.connection.getAccountInfo(feed.pubkey);
44922
+ console.log(
44923
+ `[makeUpdateSwbFeedIx] Feed account ${feed.pubkey.toBase58()}: exists=${!!accountInfo}, owner=${accountInfo?.owner?.toBase58() ?? "N/A"}, dataLen=${accountInfo?.data?.length ?? 0}`
44924
+ );
44925
+ if (accountInfo?.data) {
44926
+ const discriminator = accountInfo.data.slice(0, 8);
44927
+ console.log(
44928
+ `[makeUpdateSwbFeedIx] Feed account ${feed.pubkey.toBase58()} discriminator: [${Array.from(discriminator).join(", ")}]`
44929
+ );
44930
+ }
44931
+ } catch (accErr) {
44932
+ console.error(
44933
+ `[makeUpdateSwbFeedIx] Failed to fetch account info for ${feed.pubkey.toBase58()}:`,
44934
+ accErr
44935
+ );
44936
+ }
44937
+ }
44938
+ console.log(`[makeUpdateSwbFeedIx] Calling PullFeed.fetchUpdateManyIx...`);
44939
+ const [pullIx, luts] = await onDemand.PullFeed.fetchUpdateManyIx(swbProgram, {
44940
+ feeds: pullFeedInstances,
44941
+ gateway: gateway.gatewayUrl,
44942
+ numSignatures: 1,
44943
+ payer: props.feePayer,
44944
+ crossbarClient
44945
+ });
44946
+ console.log(`[makeUpdateSwbFeedIx] Got ${pullIx.length} instructions, ${luts.length} LUTs`);
44947
+ return { instructions: pullIx, luts };
44948
+ } catch (err) {
44949
+ console.error(`[makeUpdateSwbFeedIx] fetchUpdateManyIx FAILED:`, err?.message || err);
44950
+ console.error(`[makeUpdateSwbFeedIx] Error name: ${err?.name}, code: ${err?.code}`);
44951
+ if (err?.logs) {
44952
+ console.error(`[makeUpdateSwbFeedIx] Error logs:`, err.logs);
44953
+ }
44954
+ if (err?.stack) {
44955
+ console.error(`[makeUpdateSwbFeedIx] Stack:`, err.stack);
44956
+ }
44957
+ throw err;
44958
+ }
44906
44959
  }
44907
44960
 
44908
44961
  // src/services/price/actions/klend-reserve-refresh.ts