@solana/rpc-graphql 2.0.0-experimental.eb14acd → 2.0.0-experimental.eb951b0

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.
Files changed (35) hide show
  1. package/dist/index.browser.cjs +297 -355
  2. package/dist/index.browser.cjs.map +1 -1
  3. package/dist/index.browser.js +297 -355
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.native.js +297 -355
  6. package/dist/index.native.js.map +1 -1
  7. package/dist/index.node.cjs +297 -355
  8. package/dist/index.node.cjs.map +1 -1
  9. package/dist/index.node.js +297 -355
  10. package/dist/index.node.js.map +1 -1
  11. package/dist/types/loaders/block.d.ts.map +1 -1
  12. package/dist/types/loaders/loader.d.ts +4 -2
  13. package/dist/types/loaders/loader.d.ts.map +1 -1
  14. package/dist/types/loaders/program-accounts.d.ts.map +1 -1
  15. package/dist/types/loaders/transaction.d.ts.map +1 -1
  16. package/dist/types/resolvers/account.d.ts.map +1 -1
  17. package/dist/types/resolvers/block.d.ts +95 -15
  18. package/dist/types/resolvers/block.d.ts.map +1 -1
  19. package/dist/types/resolvers/program-accounts.d.ts.map +1 -1
  20. package/dist/types/resolvers/resolve-info/block.d.ts +13 -0
  21. package/dist/types/resolvers/resolve-info/block.d.ts.map +1 -0
  22. package/dist/types/resolvers/resolve-info/index.d.ts +1 -0
  23. package/dist/types/resolvers/resolve-info/index.d.ts.map +1 -1
  24. package/dist/types/resolvers/resolve-info/transaction.d.ts +3 -5
  25. package/dist/types/resolvers/resolve-info/transaction.d.ts.map +1 -1
  26. package/dist/types/resolvers/transaction.d.ts.map +1 -1
  27. package/dist/types/resolvers/types.d.ts +0 -11
  28. package/dist/types/resolvers/types.d.ts.map +1 -1
  29. package/dist/types/schema/block.d.ts +1 -1
  30. package/dist/types/schema/block.d.ts.map +1 -1
  31. package/dist/types/schema/root.d.ts +1 -1
  32. package/dist/types/schema/root.d.ts.map +1 -1
  33. package/dist/types/schema/types.d.ts +1 -1
  34. package/dist/types/schema/types.d.ts.map +1 -1
  35. package/package.json +4 -4
@@ -279,23 +279,6 @@ function createAccountLoader(rpc, config) {
279
279
  loadMany: async (args) => loader.loadMany(args)
280
280
  };
281
281
  }
282
- function applyDefaultArgs({
283
- slot,
284
- commitment,
285
- encoding = "jsonParsed",
286
- maxSupportedTransactionVersion = 0,
287
- rewards,
288
- transactionDetails = "full"
289
- }) {
290
- return {
291
- commitment,
292
- encoding,
293
- maxSupportedTransactionVersion,
294
- rewards,
295
- slot,
296
- transactionDetails
297
- };
298
- }
299
282
  async function loadBlock(rpc, { slot, ...config }) {
300
283
  return await rpc.getBlock(
301
284
  slot,
@@ -305,13 +288,52 @@ async function loadBlock(rpc, { slot, ...config }) {
305
288
  }
306
289
  function createBlockBatchLoadFn(rpc) {
307
290
  const resolveBlockUsingRpc = loadBlock.bind(null, rpc);
308
- return async (blockQueryArgs) => Promise.all(blockQueryArgs.map(async (args) => resolveBlockUsingRpc(applyDefaultArgs(args))));
291
+ return async (blockQueryArgs) => {
292
+ const blocksToFetch = {};
293
+ try {
294
+ return Promise.all(
295
+ blockQueryArgs.map(
296
+ ({ slot, ...args }) => new Promise((resolve, reject) => {
297
+ const blockRecords = blocksToFetch[slot.toString()] ||= [];
298
+ if (!args.commitment) {
299
+ args.commitment = "confirmed";
300
+ }
301
+ blockRecords.push({ args, promiseCallback: { reject, resolve } });
302
+ })
303
+ )
304
+ );
305
+ } finally {
306
+ const blockFetchesByArgsHash = buildCoalescedFetchesByArgsHash(blocksToFetch, {
307
+ criteria: (args) => args.encoding === void 0 && args.transactionDetails !== "signatures",
308
+ defaults: (args) => ({
309
+ ...args,
310
+ transactionDetails: "none"
311
+ }),
312
+ hashOmit: ["encoding", "transactionDetails"]
313
+ });
314
+ Object.values(blockFetchesByArgsHash).map(({ args, fetches: blockCallbacks }) => {
315
+ return Object.entries(blockCallbacks).map(([slot, { callbacks }]) => {
316
+ return Array.from({ length: 1 }, async () => {
317
+ try {
318
+ const result = await resolveBlockUsingRpc({
319
+ slot: BigInt(slot),
320
+ ...args
321
+ });
322
+ callbacks.forEach((c) => c.resolve(result));
323
+ } catch (e) {
324
+ callbacks.forEach((c) => c.reject(e));
325
+ }
326
+ });
327
+ });
328
+ });
329
+ }
330
+ };
309
331
  }
310
332
  function createBlockLoader(rpc) {
311
333
  const loader = new DataLoader(createBlockBatchLoadFn(rpc), { cacheKeyFn });
312
334
  return {
313
- load: async (args) => loader.load(applyDefaultArgs(args)),
314
- loadMany: async (args) => loader.loadMany(args.map(applyDefaultArgs))
335
+ load: async (args) => loader.load({ ...args, maxSupportedTransactionVersion: 0 }),
336
+ loadMany: async (args) => loader.loadMany(args.map((a) => ({ ...a, maxSupportedTransactionVersion: 0 })))
315
337
  };
316
338
  }
317
339
  async function loadProgramAccounts(rpc, { programAddress, ...config }) {
@@ -326,18 +348,23 @@ function createProgramAccountsBatchLoadFn(rpc, config) {
326
348
  return async (accountQueryArgs) => {
327
349
  const programAccountsToFetch = {};
328
350
  try {
329
- return Promise.all(accountQueryArgs.map(
330
- ({ programAddress, ...args }) => new Promise((resolve, reject) => {
331
- const accountRecords = programAccountsToFetch[programAddress] ||= [];
332
- if (!args.commitment) {
333
- args.commitment = "confirmed";
334
- }
335
- accountRecords.push({ args, promiseCallback: { reject, resolve } });
336
- })
337
- ));
351
+ return Promise.all(
352
+ accountQueryArgs.map(
353
+ ({ programAddress, ...args }) => new Promise((resolve, reject) => {
354
+ const accountRecords = programAccountsToFetch[programAddress] ||= [];
355
+ if (!args.commitment) {
356
+ args.commitment = "confirmed";
357
+ }
358
+ accountRecords.push({ args, promiseCallback: { reject, resolve } });
359
+ })
360
+ )
361
+ );
338
362
  } finally {
339
363
  const { maxDataSliceByteRange } = config;
340
- const programAccountsFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(programAccountsToFetch, maxDataSliceByteRange);
364
+ const programAccountsFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(
365
+ programAccountsToFetch,
366
+ maxDataSliceByteRange
367
+ );
341
368
  Object.values(programAccountsFetchesByArgsHash).map(({ args, fetches: programAddressCallbacks }) => {
342
369
  return Object.entries(programAddressCallbacks).map(([programAddress, { callbacks }]) => {
343
370
  return Array.from({ length: 1 }, async () => {
@@ -379,15 +406,17 @@ function createTransactionBatchLoadFn(rpc) {
379
406
  return async (transactionQueryArgs) => {
380
407
  const transactionsToFetch = {};
381
408
  try {
382
- return Promise.all(transactionQueryArgs.map(
383
- ({ signature, ...args }) => new Promise((resolve, reject) => {
384
- const transactionRecords = transactionsToFetch[signature] ||= [];
385
- if (!args.commitment) {
386
- args.commitment = "confirmed";
387
- }
388
- transactionRecords.push({ args, promiseCallback: { reject, resolve } });
389
- })
390
- ));
409
+ return Promise.all(
410
+ transactionQueryArgs.map(
411
+ ({ signature, ...args }) => new Promise((resolve, reject) => {
412
+ const transactionRecords = transactionsToFetch[signature] ||= [];
413
+ if (!args.commitment) {
414
+ args.commitment = "confirmed";
415
+ }
416
+ transactionRecords.push({ args, promiseCallback: { reject, resolve } });
417
+ })
418
+ )
419
+ );
391
420
  } finally {
392
421
  const transactionFetchesByArgsHash = buildCoalescedFetchesByArgsHash(transactionsToFetch, {
393
422
  criteria: (args) => args.encoding === void 0,
@@ -552,11 +581,6 @@ function buildAccountLoaderArgSetFromResolveInfo(args, info) {
552
581
  return buildAccountArgSetWithVisitor(args, info);
553
582
  }
554
583
 
555
- // src/resolvers/resolve-info/program-accounts.ts
556
- function buildProgramAccountsLoaderArgSetFromResolveInfo(args, info) {
557
- return buildAccountArgSetWithVisitor(args, info);
558
- }
559
-
560
584
  // src/resolvers/resolve-info/transaction.ts
561
585
  function findArgumentNodeByName2(argumentNodes, name) {
562
586
  return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
@@ -579,7 +603,7 @@ function parseTransactionEncodingArgument(argumentNodes, variableValues) {
579
603
  return void 0;
580
604
  }
581
605
  }
582
- function buildTransactionLoaderArgSetFromResolveInfo(args, info) {
606
+ function buildTransactionArgSetWithVisitor(args, info) {
583
607
  const argSet = [args];
584
608
  function buildArgSetWithVisitor(root) {
585
609
  injectableRootVisitor(info, root, {
@@ -608,6 +632,38 @@ function buildTransactionLoaderArgSetFromResolveInfo(args, info) {
608
632
  buildArgSetWithVisitor(null);
609
633
  return argSet;
610
634
  }
635
+ function buildTransactionLoaderArgSetFromResolveInfo(args, info) {
636
+ return buildTransactionArgSetWithVisitor(args, info);
637
+ }
638
+
639
+ // src/resolvers/resolve-info/block.ts
640
+ function buildBlockLoaderArgSetFromResolveInfo(args, info) {
641
+ const argSet = [args];
642
+ function buildArgSetWithVisitor(root) {
643
+ injectableRootVisitor(info, root, {
644
+ fieldNodeOperation(info2, node) {
645
+ if (node.name.value === "signatures") {
646
+ argSet.push({ ...args, transactionDetails: "signatures" });
647
+ } else if (node.name.value === "transactions") {
648
+ argSet.push(...buildTransactionArgSetWithVisitor({ ...args, transactionDetails: "full" }, info2));
649
+ }
650
+ },
651
+ fragmentSpreadNodeOperation(_info, fragment) {
652
+ buildArgSetWithVisitor(fragment);
653
+ },
654
+ inlineFragmentNodeOperation(_info, _node) {
655
+ return;
656
+ }
657
+ });
658
+ }
659
+ buildArgSetWithVisitor(null);
660
+ return argSet;
661
+ }
662
+
663
+ // src/resolvers/resolve-info/program-accounts.ts
664
+ function buildProgramAccountsLoaderArgSetFromResolveInfo(args, info) {
665
+ return buildAccountArgSetWithVisitor(args, info);
666
+ }
611
667
 
612
668
  // src/resolvers/account.ts
613
669
  var resolveAccountData = () => {
@@ -759,105 +815,208 @@ var accountResolvers = {
759
815
  }
760
816
  };
761
817
 
762
- // src/resolvers/block.ts
763
- function transformParsedInstruction(parsedInstruction) {
764
- if ("parsed" in parsedInstruction) {
765
- if (typeof parsedInstruction.parsed === "string" && parsedInstruction.program === "spl-memo") {
766
- const { parsed: memo, program: programName2, programId: programId2 } = parsedInstruction;
767
- const instructionType2 = "memo";
768
- return { instructionType: instructionType2, memo, programId: programId2, programName: programName2 };
769
- }
770
- const {
771
- parsed: { info: data, type: instructionType },
772
- program: programName,
773
- programId
774
- } = parsedInstruction;
775
- return { instructionType, programId, programName, ...data };
776
- } else {
777
- return parsedInstruction;
778
- }
779
- }
780
- function transformParsedTransaction(parsedTransaction) {
781
- const transactionData = parsedTransaction.transaction;
782
- const transactionMeta = parsedTransaction.meta;
783
- transactionData.message.instructions = transactionData.message.instructions.map(transformParsedInstruction);
784
- transactionMeta.innerInstructions = transactionMeta.innerInstructions.map((innerInstruction) => {
785
- innerInstruction.instructions = innerInstruction.instructions.map(transformParsedInstruction);
786
- return innerInstruction;
818
+ // src/resolvers/transaction.ts
819
+ function mapJsonParsedInstructions(instructions) {
820
+ return instructions.map((instruction) => {
821
+ if ("parsed" in instruction) {
822
+ if (typeof instruction.parsed === "string" && instruction.program === "spl-memo") {
823
+ const { parsed: memo, program: programName2, programId: programId2 } = instruction;
824
+ const instructionType2 = "memo";
825
+ const jsonParsedConfigs2 = {
826
+ instructionType: instructionType2,
827
+ programId: programId2,
828
+ programName: programName2
829
+ };
830
+ return { jsonParsedConfigs: jsonParsedConfigs2, memo, programId: programId2 };
831
+ }
832
+ const {
833
+ parsed: { info: data, type: instructionType },
834
+ program: programName,
835
+ programId
836
+ } = instruction;
837
+ const jsonParsedConfigs = {
838
+ instructionType,
839
+ programId,
840
+ programName
841
+ };
842
+ return { jsonParsedConfigs, ...data, programId };
843
+ } else {
844
+ return instruction;
845
+ }
787
846
  });
788
- return [transactionData, transactionMeta];
789
847
  }
790
- function transformLoadedTransaction({
791
- encoding = "jsonParsed",
792
- transaction
793
- }) {
794
- const [transactionData, transactionMeta] = Array.isArray(transaction.transaction) ? (
795
- // The requested encoding is base58 or base64.
796
- [transaction.transaction[0], transaction.meta]
797
- ) : (
798
- // The transaction was either partially parsed or
799
- // fully JSON-parsed, which will be sorted later.
800
- transformParsedTransaction(transaction)
801
- );
802
- transaction.data = transactionData;
803
- transaction.encoding = encoding;
804
- transaction.meta = transactionMeta;
805
- return transaction;
848
+ function mapJsonParsedInnerInstructions(innerInstructions) {
849
+ return innerInstructions.map(({ index, instructions }) => ({
850
+ index,
851
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
852
+ instructions: mapJsonParsedInstructions(instructions)
853
+ }));
806
854
  }
807
- function transformLoadedBlock({
808
- block,
809
- encoding = "jsonParsed",
810
- transactionDetails = "full"
811
- }) {
812
- const transformedBlock = block;
813
- if (typeof block === "object" && "transactions" in block) {
814
- transformedBlock.transactions = block.transactions.map((transaction) => {
815
- if (transactionDetails === "accounts") {
816
- return {
817
- data: transaction.transaction,
818
- meta: transaction.meta,
819
- version: transaction.version
820
- };
821
- } else {
822
- return transformLoadedTransaction({ encoding, transaction });
855
+ var resolveTransactionData = () => {
856
+ return (parent, args) => {
857
+ return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
858
+ };
859
+ };
860
+ function resolveTransaction(fieldName) {
861
+ return async (parent, args, context, info) => {
862
+ const signature = fieldName ? parent[fieldName] : args.signature;
863
+ if (signature) {
864
+ if (onlyFieldsRequested(["signature"], info)) {
865
+ return { signature };
823
866
  }
824
- });
825
- }
826
- block.encoding = encoding;
827
- block.transactionDetails = transactionDetails;
828
- return block;
867
+ const argsSet = buildTransactionLoaderArgSetFromResolveInfo({ ...args, signature }, info);
868
+ const loadedTransactions = await context.loaders.transaction.loadMany(argsSet);
869
+ let result = {
870
+ encodedData: {},
871
+ signature
872
+ };
873
+ loadedTransactions.forEach((loadedTransaction, i) => {
874
+ if (loadedTransaction instanceof Error) {
875
+ console.error(loadedTransaction);
876
+ return;
877
+ }
878
+ if (loadedTransaction === null) {
879
+ return;
880
+ }
881
+ if (!result.slot) {
882
+ result = {
883
+ ...result,
884
+ ...loadedTransaction
885
+ };
886
+ }
887
+ const { transaction: data } = loadedTransaction;
888
+ const { encoding } = argsSet[i];
889
+ if (encoding && result.encodedData) {
890
+ if (Array.isArray(data)) {
891
+ result.encodedData[cacheKeyFn({
892
+ encoding
893
+ })] = data[0];
894
+ } else if (typeof data === "object") {
895
+ const jsonParsedData = data;
896
+ jsonParsedData.message.instructions = mapJsonParsedInstructions(
897
+ jsonParsedData.message.instructions
898
+ );
899
+ const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
900
+ if (loadedInnerInstructions) {
901
+ const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
902
+ const jsonParsedMeta = {
903
+ ...loadedTransaction.meta,
904
+ innerInstructions
905
+ };
906
+ result = {
907
+ ...result,
908
+ ...jsonParsedData,
909
+ meta: jsonParsedMeta
910
+ };
911
+ } else {
912
+ result = {
913
+ ...result,
914
+ ...jsonParsedData
915
+ };
916
+ }
917
+ }
918
+ }
919
+ });
920
+ return result;
921
+ }
922
+ return null;
923
+ };
829
924
  }
925
+ var transactionResolvers = {
926
+ Transaction: {
927
+ data: resolveTransactionData()
928
+ }
929
+ };
930
+
931
+ // src/resolvers/block.ts
830
932
  var resolveBlock = (fieldName) => {
831
933
  return async (parent, args, context, info) => {
832
934
  const slot = fieldName ? parent[fieldName] : args.slot;
833
- if (!slot) {
834
- return null;
835
- }
836
- if (onlyFieldsRequested(["slot"], info)) {
837
- return { slot };
838
- }
839
- const block = await context.loaders.block.load({ ...args, slot });
840
- if (block === null) {
841
- return null;
935
+ if (slot) {
936
+ if (onlyFieldsRequested(["slot"], info)) {
937
+ return { slot };
938
+ }
939
+ const argsSet = buildBlockLoaderArgSetFromResolveInfo({ ...args, slot }, info);
940
+ const loadedBlocks = await context.loaders.block.loadMany(argsSet);
941
+ let result = {
942
+ slot
943
+ };
944
+ loadedBlocks.forEach((loadedBlock, i) => {
945
+ if (loadedBlock instanceof Error) {
946
+ console.error(loadedBlock);
947
+ return;
948
+ }
949
+ if (loadedBlock === null) {
950
+ return;
951
+ }
952
+ if (!result.blockhash) {
953
+ result = {
954
+ ...result,
955
+ ...loadedBlock
956
+ };
957
+ }
958
+ if (!result.signatures && loadedBlock.signatures) {
959
+ result = {
960
+ ...result,
961
+ // @ts-expect-error FIX ME: https://github.com/solana-labs/solana-web3.js/pull/2052
962
+ signatures: loadedBlock.signatures
963
+ };
964
+ }
965
+ if (!result.transactionResults && loadedBlock.transactions) {
966
+ result.transactionResults = Array.from({ length: loadedBlock.transactions.length }, (_, i2) => ({
967
+ [i2]: { encodedData: {} }
968
+ }));
969
+ }
970
+ const { transactions } = loadedBlock;
971
+ const { encoding } = argsSet[i];
972
+ if (encoding) {
973
+ transactions.forEach((loadedTransaction, j) => {
974
+ const { transaction: data } = loadedTransaction;
975
+ if (result.transactionResults) {
976
+ const thisTransactionResult = result.transactionResults[j] ||= {
977
+ encodedData: {}
978
+ };
979
+ if (Array.isArray(data)) {
980
+ const thisEncodedData = thisTransactionResult.encodedData ||= {};
981
+ thisEncodedData[cacheKeyFn({
982
+ encoding
983
+ })] = data[0];
984
+ } else if (typeof data === "object") {
985
+ const jsonParsedData = data;
986
+ jsonParsedData.message.instructions = mapJsonParsedInstructions(
987
+ jsonParsedData.message.instructions
988
+ );
989
+ const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
990
+ if (loadedInnerInstructions) {
991
+ const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
992
+ const jsonParsedMeta = {
993
+ ...loadedTransaction.meta,
994
+ innerInstructions
995
+ };
996
+ result.transactionResults[j] = {
997
+ ...thisTransactionResult,
998
+ ...jsonParsedData,
999
+ meta: jsonParsedMeta
1000
+ };
1001
+ } else {
1002
+ result.transactionResults[j] = {
1003
+ ...thisTransactionResult,
1004
+ ...jsonParsedData
1005
+ };
1006
+ }
1007
+ }
1008
+ }
1009
+ });
1010
+ }
1011
+ });
1012
+ return result;
842
1013
  }
843
- const { encoding, transactionDetails } = args;
844
- return transformLoadedBlock({ block, encoding, transactionDetails });
1014
+ return null;
845
1015
  };
846
1016
  };
847
1017
  var blockResolvers = {
848
1018
  Block: {
849
- __resolveType(block) {
850
- switch (block.transactionDetails) {
851
- case "accounts":
852
- return "BlockWithAccounts";
853
- case "none":
854
- return "BlockWithNone";
855
- case "signatures":
856
- return "BlockWithSignatures";
857
- default:
858
- return "BlockWithFull";
859
- }
860
- }
1019
+ transactions: (parent) => parent?.transactionResults ? Object.values(parent.transactionResults) : null
861
1020
  }
862
1021
  };
863
1022
 
@@ -1675,119 +1834,6 @@ function resolveProgramAccounts(fieldName) {
1675
1834
  };
1676
1835
  }
1677
1836
 
1678
- // src/resolvers/transaction.ts
1679
- function mapJsonParsedInstructions(instructions) {
1680
- return instructions.map((instruction) => {
1681
- if ("parsed" in instruction) {
1682
- if (typeof instruction.parsed === "string" && instruction.program === "spl-memo") {
1683
- const { parsed: memo, program: programName2, programId: programId2 } = instruction;
1684
- const instructionType2 = "memo";
1685
- const jsonParsedConfigs2 = {
1686
- instructionType: instructionType2,
1687
- programId: programId2,
1688
- programName: programName2
1689
- };
1690
- return { jsonParsedConfigs: jsonParsedConfigs2, memo, programId: programId2 };
1691
- }
1692
- const {
1693
- parsed: { info: data, type: instructionType },
1694
- program: programName,
1695
- programId
1696
- } = instruction;
1697
- const jsonParsedConfigs = {
1698
- instructionType,
1699
- programId,
1700
- programName
1701
- };
1702
- return { jsonParsedConfigs, ...data, programId };
1703
- } else {
1704
- return instruction;
1705
- }
1706
- });
1707
- }
1708
- function mapJsonParsedInnerInstructions(innerInstructions) {
1709
- return innerInstructions.map(({ index, instructions }) => ({
1710
- index,
1711
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1712
- instructions: mapJsonParsedInstructions(instructions)
1713
- }));
1714
- }
1715
- var resolveTransactionData = () => {
1716
- return (parent, args) => {
1717
- return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
1718
- };
1719
- };
1720
- function resolveTransaction(fieldName) {
1721
- return async (parent, args, context, info) => {
1722
- const signature = fieldName ? parent[fieldName] : args.signature;
1723
- if (signature) {
1724
- if (onlyFieldsRequested(["signature"], info)) {
1725
- return { signature };
1726
- }
1727
- const argsSet = buildTransactionLoaderArgSetFromResolveInfo({ ...args, signature }, info);
1728
- const loadedTransactions = await context.loaders.transaction.loadMany(argsSet);
1729
- let result = {
1730
- encodedData: {},
1731
- signature
1732
- };
1733
- loadedTransactions.forEach((loadedTransaction, i) => {
1734
- if (loadedTransaction instanceof Error) {
1735
- console.error(loadedTransaction);
1736
- return;
1737
- }
1738
- if (loadedTransaction === null) {
1739
- return;
1740
- }
1741
- if (!result.slot) {
1742
- result = {
1743
- ...result,
1744
- ...loadedTransaction
1745
- };
1746
- }
1747
- const { transaction: data } = loadedTransaction;
1748
- const { encoding } = argsSet[i];
1749
- if (encoding && result.encodedData) {
1750
- if (Array.isArray(data)) {
1751
- result.encodedData[cacheKeyFn({
1752
- encoding
1753
- })] = data[0];
1754
- } else if (typeof data === "object") {
1755
- const jsonParsedData = data;
1756
- jsonParsedData.message.instructions = mapJsonParsedInstructions(
1757
- jsonParsedData.message.instructions
1758
- );
1759
- const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
1760
- if (loadedInnerInstructions) {
1761
- const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
1762
- const jsonParsedMeta = {
1763
- ...loadedTransaction.meta,
1764
- innerInstructions
1765
- };
1766
- result = {
1767
- ...result,
1768
- ...jsonParsedData,
1769
- meta: jsonParsedMeta
1770
- };
1771
- } else {
1772
- result = {
1773
- ...result,
1774
- ...jsonParsedData
1775
- };
1776
- }
1777
- }
1778
- }
1779
- });
1780
- return result;
1781
- }
1782
- return null;
1783
- };
1784
- }
1785
- var transactionResolvers = {
1786
- Transaction: {
1787
- data: resolveTransactionData()
1788
- }
1789
- };
1790
-
1791
1837
  // src/resolvers/root.ts
1792
1838
  var rootResolvers = {
1793
1839
  Query: {
@@ -1813,7 +1859,7 @@ var stringScalarAlias = {
1813
1859
  };
1814
1860
  var bigIntScalarAlias = {
1815
1861
  __parseLiteral(ast) {
1816
- if (ast.kind === Kind.STRING) {
1862
+ if (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {
1817
1863
  return BigInt(ast.value);
1818
1864
  }
1819
1865
  return null;
@@ -1836,12 +1882,6 @@ var typeTypeResolvers = {
1836
1882
  Base64EncodedBytes: stringScalarAlias,
1837
1883
  Base64ZstdEncodedBytes: stringScalarAlias,
1838
1884
  BigInt: bigIntScalarAlias,
1839
- BlockTransactionDetails: {
1840
- ACCOUNTS: "accounts",
1841
- FULL: "full",
1842
- NONE: "none",
1843
- SIGNATURES: "signatures"
1844
- },
1845
1885
  Commitment: {
1846
1886
  CONFIRMED: "confirmed",
1847
1887
  FINALIZED: "finalized",
@@ -1859,12 +1899,7 @@ var typeTypeResolvers = {
1859
1899
  },
1860
1900
  TransactionEncoding: {
1861
1901
  BASE_58: "base58",
1862
- BASE_64: "base64",
1863
- PARSED: "jsonParsed"
1864
- },
1865
- TransactionVersion: {
1866
- LEGACY: "legacy",
1867
- ZERO: 0
1902
+ BASE_64: "base64"
1868
1903
  }
1869
1904
  };
1870
1905
 
@@ -2068,93 +2103,18 @@ var accountTypeDefs = (
2068
2103
  var blockTypeDefs = (
2069
2104
  /* GraphQL */
2070
2105
  `
2071
- type TransactionMetaForAccounts {
2072
- err: String
2073
- fee: BigInt
2074
- postBalances: [BigInt]
2075
- postTokenBalances: [TokenBalance]
2076
- preBalances: [BigInt]
2077
- preTokenBalances: [TokenBalance]
2078
- status: TransactionStatus
2079
- }
2080
-
2081
- type TransactionDataForAccounts {
2082
- accountKeys: [Address]
2083
- signatures: [String]
2084
- }
2085
-
2086
- type BlockTransactionAccounts {
2087
- meta: TransactionMetaForAccounts
2088
- data: TransactionDataForAccounts
2089
- version: String
2090
- }
2091
-
2092
- """
2093
- Block interface
2094
- """
2095
- interface Block {
2096
- blockhash: String
2097
- blockHeight: BigInt
2098
- blockTime: BigInt
2099
- parentSlot: BigInt
2100
- previousBlockhash: String
2101
- rewards: [Reward]
2102
- transactionDetails: String
2103
- }
2104
-
2105
- """
2106
- A block with account transaction details
2107
- """
2108
- type BlockWithAccounts implements Block {
2109
- blockhash: String
2110
- blockHeight: BigInt
2111
- blockTime: BigInt
2112
- parentSlot: BigInt
2113
- previousBlockhash: String
2114
- rewards: [Reward]
2115
- transactions: [BlockTransactionAccounts]
2116
- transactionDetails: String
2117
- }
2118
-
2119
2106
  """
2120
- A block with full transaction details
2107
+ A Solana block
2121
2108
  """
2122
- type BlockWithFull implements Block {
2109
+ type Block {
2123
2110
  blockhash: String
2124
2111
  blockHeight: BigInt
2125
2112
  blockTime: BigInt
2126
- parentSlot: BigInt
2113
+ parentSlot: Slot
2127
2114
  previousBlockhash: String
2128
2115
  rewards: [Reward]
2116
+ signatures: [Signature]
2129
2117
  transactions: [Transaction]
2130
- transactionDetails: String
2131
- }
2132
-
2133
- """
2134
- A block with no transaction details
2135
- """
2136
- type BlockWithNone implements Block {
2137
- blockhash: String
2138
- blockHeight: BigInt
2139
- blockTime: BigInt
2140
- parentSlot: BigInt
2141
- previousBlockhash: String
2142
- rewards: [Reward]
2143
- transactionDetails: String
2144
- }
2145
-
2146
- """
2147
- A block with signature transaction details
2148
- """
2149
- type BlockWithSignatures implements Block {
2150
- blockhash: String
2151
- blockHeight: BigInt
2152
- blockTime: BigInt
2153
- parentSlot: BigInt
2154
- previousBlockhash: String
2155
- rewards: [Reward]
2156
- signatures: [String]
2157
- transactionDetails: String
2158
2118
  }
2159
2119
  `
2160
2120
  );
@@ -3213,12 +3173,7 @@ var rootTypeDefs = (
3213
3173
  `
3214
3174
  type Query {
3215
3175
  account(address: Address!, commitment: Commitment, minContextSlot: Slot): Account
3216
- block(
3217
- slot: Slot!
3218
- commitment: Commitment
3219
- encoding: TransactionEncoding
3220
- transactionDetails: BlockTransactionDetails
3221
- ): Block
3176
+ block(slot: Slot!, commitment: CommitmentWithoutProcessed): Block
3222
3177
  programAccounts(
3223
3178
  programAddress: Address!
3224
3179
  commitment: Commitment
@@ -3334,13 +3289,6 @@ var typeTypeDefs = (
3334
3289
 
3335
3290
  scalar BigInt
3336
3291
 
3337
- enum BlockTransactionDetails {
3338
- ACCOUNTS
3339
- FULL
3340
- NONE
3341
- SIGNATURES
3342
- }
3343
-
3344
3292
  enum Commitment {
3345
3293
  CONFIRMED
3346
3294
  FINALIZED
@@ -3399,12 +3347,6 @@ var typeTypeDefs = (
3399
3347
  enum TransactionEncoding {
3400
3348
  BASE_58
3401
3349
  BASE_64
3402
- PARSED
3403
- }
3404
-
3405
- enum TransactionVersion {
3406
- LEGACY
3407
- ZERO
3408
3350
  }
3409
3351
  `
3410
3352
  );