@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.
- package/dist/index.browser.cjs +297 -355
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +297 -355
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +297 -355
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +297 -355
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +297 -355
- package/dist/index.node.js.map +1 -1
- package/dist/types/loaders/block.d.ts.map +1 -1
- package/dist/types/loaders/loader.d.ts +4 -2
- package/dist/types/loaders/loader.d.ts.map +1 -1
- package/dist/types/loaders/program-accounts.d.ts.map +1 -1
- package/dist/types/loaders/transaction.d.ts.map +1 -1
- package/dist/types/resolvers/account.d.ts.map +1 -1
- package/dist/types/resolvers/block.d.ts +95 -15
- package/dist/types/resolvers/block.d.ts.map +1 -1
- package/dist/types/resolvers/program-accounts.d.ts.map +1 -1
- package/dist/types/resolvers/resolve-info/block.d.ts +13 -0
- package/dist/types/resolvers/resolve-info/block.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/index.d.ts +1 -0
- package/dist/types/resolvers/resolve-info/index.d.ts.map +1 -1
- package/dist/types/resolvers/resolve-info/transaction.d.ts +3 -5
- package/dist/types/resolvers/resolve-info/transaction.d.ts.map +1 -1
- package/dist/types/resolvers/transaction.d.ts.map +1 -1
- package/dist/types/resolvers/types.d.ts +0 -11
- package/dist/types/resolvers/types.d.ts.map +1 -1
- package/dist/types/schema/block.d.ts +1 -1
- package/dist/types/schema/block.d.ts.map +1 -1
- package/dist/types/schema/root.d.ts +1 -1
- package/dist/types/schema/root.d.ts.map +1 -1
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/schema/types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.node.cjs
CHANGED
|
@@ -286,23 +286,6 @@ function createAccountLoader(rpc, config) {
|
|
|
286
286
|
loadMany: async (args) => loader.loadMany(args)
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
-
function applyDefaultArgs({
|
|
290
|
-
slot,
|
|
291
|
-
commitment,
|
|
292
|
-
encoding = "jsonParsed",
|
|
293
|
-
maxSupportedTransactionVersion = 0,
|
|
294
|
-
rewards,
|
|
295
|
-
transactionDetails = "full"
|
|
296
|
-
}) {
|
|
297
|
-
return {
|
|
298
|
-
commitment,
|
|
299
|
-
encoding,
|
|
300
|
-
maxSupportedTransactionVersion,
|
|
301
|
-
rewards,
|
|
302
|
-
slot,
|
|
303
|
-
transactionDetails
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
289
|
async function loadBlock(rpc, { slot, ...config }) {
|
|
307
290
|
return await rpc.getBlock(
|
|
308
291
|
slot,
|
|
@@ -312,13 +295,52 @@ async function loadBlock(rpc, { slot, ...config }) {
|
|
|
312
295
|
}
|
|
313
296
|
function createBlockBatchLoadFn(rpc) {
|
|
314
297
|
const resolveBlockUsingRpc = loadBlock.bind(null, rpc);
|
|
315
|
-
return async (blockQueryArgs) =>
|
|
298
|
+
return async (blockQueryArgs) => {
|
|
299
|
+
const blocksToFetch = {};
|
|
300
|
+
try {
|
|
301
|
+
return Promise.all(
|
|
302
|
+
blockQueryArgs.map(
|
|
303
|
+
({ slot, ...args }) => new Promise((resolve, reject) => {
|
|
304
|
+
const blockRecords = blocksToFetch[slot.toString()] ||= [];
|
|
305
|
+
if (!args.commitment) {
|
|
306
|
+
args.commitment = "confirmed";
|
|
307
|
+
}
|
|
308
|
+
blockRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
309
|
+
})
|
|
310
|
+
)
|
|
311
|
+
);
|
|
312
|
+
} finally {
|
|
313
|
+
const blockFetchesByArgsHash = buildCoalescedFetchesByArgsHash(blocksToFetch, {
|
|
314
|
+
criteria: (args) => args.encoding === void 0 && args.transactionDetails !== "signatures",
|
|
315
|
+
defaults: (args) => ({
|
|
316
|
+
...args,
|
|
317
|
+
transactionDetails: "none"
|
|
318
|
+
}),
|
|
319
|
+
hashOmit: ["encoding", "transactionDetails"]
|
|
320
|
+
});
|
|
321
|
+
Object.values(blockFetchesByArgsHash).map(({ args, fetches: blockCallbacks }) => {
|
|
322
|
+
return Object.entries(blockCallbacks).map(([slot, { callbacks }]) => {
|
|
323
|
+
return Array.from({ length: 1 }, async () => {
|
|
324
|
+
try {
|
|
325
|
+
const result = await resolveBlockUsingRpc({
|
|
326
|
+
slot: BigInt(slot),
|
|
327
|
+
...args
|
|
328
|
+
});
|
|
329
|
+
callbacks.forEach((c) => c.resolve(result));
|
|
330
|
+
} catch (e) {
|
|
331
|
+
callbacks.forEach((c) => c.reject(e));
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
};
|
|
316
338
|
}
|
|
317
339
|
function createBlockLoader(rpc) {
|
|
318
340
|
const loader = new DataLoader__default.default(createBlockBatchLoadFn(rpc), { cacheKeyFn });
|
|
319
341
|
return {
|
|
320
|
-
load: async (args) => loader.load(
|
|
321
|
-
loadMany: async (args) => loader.loadMany(args.map(
|
|
342
|
+
load: async (args) => loader.load({ ...args, maxSupportedTransactionVersion: 0 }),
|
|
343
|
+
loadMany: async (args) => loader.loadMany(args.map((a) => ({ ...a, maxSupportedTransactionVersion: 0 })))
|
|
322
344
|
};
|
|
323
345
|
}
|
|
324
346
|
async function loadProgramAccounts(rpc, { programAddress, ...config }) {
|
|
@@ -333,18 +355,23 @@ function createProgramAccountsBatchLoadFn(rpc, config) {
|
|
|
333
355
|
return async (accountQueryArgs) => {
|
|
334
356
|
const programAccountsToFetch = {};
|
|
335
357
|
try {
|
|
336
|
-
return Promise.all(
|
|
337
|
-
(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
args.commitment
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
358
|
+
return Promise.all(
|
|
359
|
+
accountQueryArgs.map(
|
|
360
|
+
({ programAddress, ...args }) => new Promise((resolve, reject) => {
|
|
361
|
+
const accountRecords = programAccountsToFetch[programAddress] ||= [];
|
|
362
|
+
if (!args.commitment) {
|
|
363
|
+
args.commitment = "confirmed";
|
|
364
|
+
}
|
|
365
|
+
accountRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
366
|
+
})
|
|
367
|
+
)
|
|
368
|
+
);
|
|
345
369
|
} finally {
|
|
346
370
|
const { maxDataSliceByteRange } = config;
|
|
347
|
-
const programAccountsFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(
|
|
371
|
+
const programAccountsFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(
|
|
372
|
+
programAccountsToFetch,
|
|
373
|
+
maxDataSliceByteRange
|
|
374
|
+
);
|
|
348
375
|
Object.values(programAccountsFetchesByArgsHash).map(({ args, fetches: programAddressCallbacks }) => {
|
|
349
376
|
return Object.entries(programAddressCallbacks).map(([programAddress, { callbacks }]) => {
|
|
350
377
|
return Array.from({ length: 1 }, async () => {
|
|
@@ -386,15 +413,17 @@ function createTransactionBatchLoadFn(rpc) {
|
|
|
386
413
|
return async (transactionQueryArgs) => {
|
|
387
414
|
const transactionsToFetch = {};
|
|
388
415
|
try {
|
|
389
|
-
return Promise.all(
|
|
390
|
-
(
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
args.commitment
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
416
|
+
return Promise.all(
|
|
417
|
+
transactionQueryArgs.map(
|
|
418
|
+
({ signature, ...args }) => new Promise((resolve, reject) => {
|
|
419
|
+
const transactionRecords = transactionsToFetch[signature] ||= [];
|
|
420
|
+
if (!args.commitment) {
|
|
421
|
+
args.commitment = "confirmed";
|
|
422
|
+
}
|
|
423
|
+
transactionRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
424
|
+
})
|
|
425
|
+
)
|
|
426
|
+
);
|
|
398
427
|
} finally {
|
|
399
428
|
const transactionFetchesByArgsHash = buildCoalescedFetchesByArgsHash(transactionsToFetch, {
|
|
400
429
|
criteria: (args) => args.encoding === void 0,
|
|
@@ -559,11 +588,6 @@ function buildAccountLoaderArgSetFromResolveInfo(args, info) {
|
|
|
559
588
|
return buildAccountArgSetWithVisitor(args, info);
|
|
560
589
|
}
|
|
561
590
|
|
|
562
|
-
// src/resolvers/resolve-info/program-accounts.ts
|
|
563
|
-
function buildProgramAccountsLoaderArgSetFromResolveInfo(args, info) {
|
|
564
|
-
return buildAccountArgSetWithVisitor(args, info);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
591
|
// src/resolvers/resolve-info/transaction.ts
|
|
568
592
|
function findArgumentNodeByName2(argumentNodes, name) {
|
|
569
593
|
return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
|
|
@@ -586,7 +610,7 @@ function parseTransactionEncodingArgument(argumentNodes, variableValues) {
|
|
|
586
610
|
return void 0;
|
|
587
611
|
}
|
|
588
612
|
}
|
|
589
|
-
function
|
|
613
|
+
function buildTransactionArgSetWithVisitor(args, info) {
|
|
590
614
|
const argSet = [args];
|
|
591
615
|
function buildArgSetWithVisitor(root) {
|
|
592
616
|
injectableRootVisitor(info, root, {
|
|
@@ -615,6 +639,38 @@ function buildTransactionLoaderArgSetFromResolveInfo(args, info) {
|
|
|
615
639
|
buildArgSetWithVisitor(null);
|
|
616
640
|
return argSet;
|
|
617
641
|
}
|
|
642
|
+
function buildTransactionLoaderArgSetFromResolveInfo(args, info) {
|
|
643
|
+
return buildTransactionArgSetWithVisitor(args, info);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// src/resolvers/resolve-info/block.ts
|
|
647
|
+
function buildBlockLoaderArgSetFromResolveInfo(args, info) {
|
|
648
|
+
const argSet = [args];
|
|
649
|
+
function buildArgSetWithVisitor(root) {
|
|
650
|
+
injectableRootVisitor(info, root, {
|
|
651
|
+
fieldNodeOperation(info2, node) {
|
|
652
|
+
if (node.name.value === "signatures") {
|
|
653
|
+
argSet.push({ ...args, transactionDetails: "signatures" });
|
|
654
|
+
} else if (node.name.value === "transactions") {
|
|
655
|
+
argSet.push(...buildTransactionArgSetWithVisitor({ ...args, transactionDetails: "full" }, info2));
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
659
|
+
buildArgSetWithVisitor(fragment);
|
|
660
|
+
},
|
|
661
|
+
inlineFragmentNodeOperation(_info, _node) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
buildArgSetWithVisitor(null);
|
|
667
|
+
return argSet;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// src/resolvers/resolve-info/program-accounts.ts
|
|
671
|
+
function buildProgramAccountsLoaderArgSetFromResolveInfo(args, info) {
|
|
672
|
+
return buildAccountArgSetWithVisitor(args, info);
|
|
673
|
+
}
|
|
618
674
|
|
|
619
675
|
// src/resolvers/account.ts
|
|
620
676
|
var resolveAccountData = () => {
|
|
@@ -766,105 +822,208 @@ var accountResolvers = {
|
|
|
766
822
|
}
|
|
767
823
|
};
|
|
768
824
|
|
|
769
|
-
// src/resolvers/
|
|
770
|
-
function
|
|
771
|
-
|
|
772
|
-
if (
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
825
|
+
// src/resolvers/transaction.ts
|
|
826
|
+
function mapJsonParsedInstructions(instructions) {
|
|
827
|
+
return instructions.map((instruction) => {
|
|
828
|
+
if ("parsed" in instruction) {
|
|
829
|
+
if (typeof instruction.parsed === "string" && instruction.program === "spl-memo") {
|
|
830
|
+
const { parsed: memo, program: programName2, programId: programId2 } = instruction;
|
|
831
|
+
const instructionType2 = "memo";
|
|
832
|
+
const jsonParsedConfigs2 = {
|
|
833
|
+
instructionType: instructionType2,
|
|
834
|
+
programId: programId2,
|
|
835
|
+
programName: programName2
|
|
836
|
+
};
|
|
837
|
+
return { jsonParsedConfigs: jsonParsedConfigs2, memo, programId: programId2 };
|
|
838
|
+
}
|
|
839
|
+
const {
|
|
840
|
+
parsed: { info: data, type: instructionType },
|
|
841
|
+
program: programName,
|
|
842
|
+
programId
|
|
843
|
+
} = instruction;
|
|
844
|
+
const jsonParsedConfigs = {
|
|
845
|
+
instructionType,
|
|
846
|
+
programId,
|
|
847
|
+
programName
|
|
848
|
+
};
|
|
849
|
+
return { jsonParsedConfigs, ...data, programId };
|
|
850
|
+
} else {
|
|
851
|
+
return instruction;
|
|
852
|
+
}
|
|
794
853
|
});
|
|
795
|
-
return [transactionData, transactionMeta];
|
|
796
854
|
}
|
|
797
|
-
function
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
[transaction.transaction[0], transaction.meta]
|
|
804
|
-
) : (
|
|
805
|
-
// The transaction was either partially parsed or
|
|
806
|
-
// fully JSON-parsed, which will be sorted later.
|
|
807
|
-
transformParsedTransaction(transaction)
|
|
808
|
-
);
|
|
809
|
-
transaction.data = transactionData;
|
|
810
|
-
transaction.encoding = encoding;
|
|
811
|
-
transaction.meta = transactionMeta;
|
|
812
|
-
return transaction;
|
|
855
|
+
function mapJsonParsedInnerInstructions(innerInstructions) {
|
|
856
|
+
return innerInstructions.map(({ index, instructions }) => ({
|
|
857
|
+
index,
|
|
858
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
859
|
+
instructions: mapJsonParsedInstructions(instructions)
|
|
860
|
+
}));
|
|
813
861
|
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
meta: transaction.meta,
|
|
826
|
-
version: transaction.version
|
|
827
|
-
};
|
|
828
|
-
} else {
|
|
829
|
-
return transformLoadedTransaction({ encoding, transaction });
|
|
862
|
+
var resolveTransactionData = () => {
|
|
863
|
+
return (parent, args) => {
|
|
864
|
+
return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
|
|
865
|
+
};
|
|
866
|
+
};
|
|
867
|
+
function resolveTransaction(fieldName) {
|
|
868
|
+
return async (parent, args, context, info) => {
|
|
869
|
+
const signature = fieldName ? parent[fieldName] : args.signature;
|
|
870
|
+
if (signature) {
|
|
871
|
+
if (onlyFieldsRequested(["signature"], info)) {
|
|
872
|
+
return { signature };
|
|
830
873
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
874
|
+
const argsSet = buildTransactionLoaderArgSetFromResolveInfo({ ...args, signature }, info);
|
|
875
|
+
const loadedTransactions = await context.loaders.transaction.loadMany(argsSet);
|
|
876
|
+
let result = {
|
|
877
|
+
encodedData: {},
|
|
878
|
+
signature
|
|
879
|
+
};
|
|
880
|
+
loadedTransactions.forEach((loadedTransaction, i) => {
|
|
881
|
+
if (loadedTransaction instanceof Error) {
|
|
882
|
+
console.error(loadedTransaction);
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
if (loadedTransaction === null) {
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
if (!result.slot) {
|
|
889
|
+
result = {
|
|
890
|
+
...result,
|
|
891
|
+
...loadedTransaction
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
const { transaction: data } = loadedTransaction;
|
|
895
|
+
const { encoding } = argsSet[i];
|
|
896
|
+
if (encoding && result.encodedData) {
|
|
897
|
+
if (Array.isArray(data)) {
|
|
898
|
+
result.encodedData[cacheKeyFn({
|
|
899
|
+
encoding
|
|
900
|
+
})] = data[0];
|
|
901
|
+
} else if (typeof data === "object") {
|
|
902
|
+
const jsonParsedData = data;
|
|
903
|
+
jsonParsedData.message.instructions = mapJsonParsedInstructions(
|
|
904
|
+
jsonParsedData.message.instructions
|
|
905
|
+
);
|
|
906
|
+
const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
|
|
907
|
+
if (loadedInnerInstructions) {
|
|
908
|
+
const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
|
|
909
|
+
const jsonParsedMeta = {
|
|
910
|
+
...loadedTransaction.meta,
|
|
911
|
+
innerInstructions
|
|
912
|
+
};
|
|
913
|
+
result = {
|
|
914
|
+
...result,
|
|
915
|
+
...jsonParsedData,
|
|
916
|
+
meta: jsonParsedMeta
|
|
917
|
+
};
|
|
918
|
+
} else {
|
|
919
|
+
result = {
|
|
920
|
+
...result,
|
|
921
|
+
...jsonParsedData
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
});
|
|
927
|
+
return result;
|
|
928
|
+
}
|
|
929
|
+
return null;
|
|
930
|
+
};
|
|
836
931
|
}
|
|
932
|
+
var transactionResolvers = {
|
|
933
|
+
Transaction: {
|
|
934
|
+
data: resolveTransactionData()
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
// src/resolvers/block.ts
|
|
837
939
|
var resolveBlock = (fieldName) => {
|
|
838
940
|
return async (parent, args, context, info) => {
|
|
839
941
|
const slot = fieldName ? parent[fieldName] : args.slot;
|
|
840
|
-
if (
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
942
|
+
if (slot) {
|
|
943
|
+
if (onlyFieldsRequested(["slot"], info)) {
|
|
944
|
+
return { slot };
|
|
945
|
+
}
|
|
946
|
+
const argsSet = buildBlockLoaderArgSetFromResolveInfo({ ...args, slot }, info);
|
|
947
|
+
const loadedBlocks = await context.loaders.block.loadMany(argsSet);
|
|
948
|
+
let result = {
|
|
949
|
+
slot
|
|
950
|
+
};
|
|
951
|
+
loadedBlocks.forEach((loadedBlock, i) => {
|
|
952
|
+
if (loadedBlock instanceof Error) {
|
|
953
|
+
console.error(loadedBlock);
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
if (loadedBlock === null) {
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
if (!result.blockhash) {
|
|
960
|
+
result = {
|
|
961
|
+
...result,
|
|
962
|
+
...loadedBlock
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
if (!result.signatures && loadedBlock.signatures) {
|
|
966
|
+
result = {
|
|
967
|
+
...result,
|
|
968
|
+
// @ts-expect-error FIX ME: https://github.com/solana-labs/solana-web3.js/pull/2052
|
|
969
|
+
signatures: loadedBlock.signatures
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
if (!result.transactionResults && loadedBlock.transactions) {
|
|
973
|
+
result.transactionResults = Array.from({ length: loadedBlock.transactions.length }, (_, i2) => ({
|
|
974
|
+
[i2]: { encodedData: {} }
|
|
975
|
+
}));
|
|
976
|
+
}
|
|
977
|
+
const { transactions } = loadedBlock;
|
|
978
|
+
const { encoding } = argsSet[i];
|
|
979
|
+
if (encoding) {
|
|
980
|
+
transactions.forEach((loadedTransaction, j) => {
|
|
981
|
+
const { transaction: data } = loadedTransaction;
|
|
982
|
+
if (result.transactionResults) {
|
|
983
|
+
const thisTransactionResult = result.transactionResults[j] ||= {
|
|
984
|
+
encodedData: {}
|
|
985
|
+
};
|
|
986
|
+
if (Array.isArray(data)) {
|
|
987
|
+
const thisEncodedData = thisTransactionResult.encodedData ||= {};
|
|
988
|
+
thisEncodedData[cacheKeyFn({
|
|
989
|
+
encoding
|
|
990
|
+
})] = data[0];
|
|
991
|
+
} else if (typeof data === "object") {
|
|
992
|
+
const jsonParsedData = data;
|
|
993
|
+
jsonParsedData.message.instructions = mapJsonParsedInstructions(
|
|
994
|
+
jsonParsedData.message.instructions
|
|
995
|
+
);
|
|
996
|
+
const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
|
|
997
|
+
if (loadedInnerInstructions) {
|
|
998
|
+
const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
|
|
999
|
+
const jsonParsedMeta = {
|
|
1000
|
+
...loadedTransaction.meta,
|
|
1001
|
+
innerInstructions
|
|
1002
|
+
};
|
|
1003
|
+
result.transactionResults[j] = {
|
|
1004
|
+
...thisTransactionResult,
|
|
1005
|
+
...jsonParsedData,
|
|
1006
|
+
meta: jsonParsedMeta
|
|
1007
|
+
};
|
|
1008
|
+
} else {
|
|
1009
|
+
result.transactionResults[j] = {
|
|
1010
|
+
...thisTransactionResult,
|
|
1011
|
+
...jsonParsedData
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
return result;
|
|
849
1020
|
}
|
|
850
|
-
|
|
851
|
-
return transformLoadedBlock({ block, encoding, transactionDetails });
|
|
1021
|
+
return null;
|
|
852
1022
|
};
|
|
853
1023
|
};
|
|
854
1024
|
var blockResolvers = {
|
|
855
1025
|
Block: {
|
|
856
|
-
|
|
857
|
-
switch (block.transactionDetails) {
|
|
858
|
-
case "accounts":
|
|
859
|
-
return "BlockWithAccounts";
|
|
860
|
-
case "none":
|
|
861
|
-
return "BlockWithNone";
|
|
862
|
-
case "signatures":
|
|
863
|
-
return "BlockWithSignatures";
|
|
864
|
-
default:
|
|
865
|
-
return "BlockWithFull";
|
|
866
|
-
}
|
|
867
|
-
}
|
|
1026
|
+
transactions: (parent) => parent?.transactionResults ? Object.values(parent.transactionResults) : null
|
|
868
1027
|
}
|
|
869
1028
|
};
|
|
870
1029
|
|
|
@@ -1682,119 +1841,6 @@ function resolveProgramAccounts(fieldName) {
|
|
|
1682
1841
|
};
|
|
1683
1842
|
}
|
|
1684
1843
|
|
|
1685
|
-
// src/resolvers/transaction.ts
|
|
1686
|
-
function mapJsonParsedInstructions(instructions) {
|
|
1687
|
-
return instructions.map((instruction) => {
|
|
1688
|
-
if ("parsed" in instruction) {
|
|
1689
|
-
if (typeof instruction.parsed === "string" && instruction.program === "spl-memo") {
|
|
1690
|
-
const { parsed: memo, program: programName2, programId: programId2 } = instruction;
|
|
1691
|
-
const instructionType2 = "memo";
|
|
1692
|
-
const jsonParsedConfigs2 = {
|
|
1693
|
-
instructionType: instructionType2,
|
|
1694
|
-
programId: programId2,
|
|
1695
|
-
programName: programName2
|
|
1696
|
-
};
|
|
1697
|
-
return { jsonParsedConfigs: jsonParsedConfigs2, memo, programId: programId2 };
|
|
1698
|
-
}
|
|
1699
|
-
const {
|
|
1700
|
-
parsed: { info: data, type: instructionType },
|
|
1701
|
-
program: programName,
|
|
1702
|
-
programId
|
|
1703
|
-
} = instruction;
|
|
1704
|
-
const jsonParsedConfigs = {
|
|
1705
|
-
instructionType,
|
|
1706
|
-
programId,
|
|
1707
|
-
programName
|
|
1708
|
-
};
|
|
1709
|
-
return { jsonParsedConfigs, ...data, programId };
|
|
1710
|
-
} else {
|
|
1711
|
-
return instruction;
|
|
1712
|
-
}
|
|
1713
|
-
});
|
|
1714
|
-
}
|
|
1715
|
-
function mapJsonParsedInnerInstructions(innerInstructions) {
|
|
1716
|
-
return innerInstructions.map(({ index, instructions }) => ({
|
|
1717
|
-
index,
|
|
1718
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1719
|
-
instructions: mapJsonParsedInstructions(instructions)
|
|
1720
|
-
}));
|
|
1721
|
-
}
|
|
1722
|
-
var resolveTransactionData = () => {
|
|
1723
|
-
return (parent, args) => {
|
|
1724
|
-
return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
|
|
1725
|
-
};
|
|
1726
|
-
};
|
|
1727
|
-
function resolveTransaction(fieldName) {
|
|
1728
|
-
return async (parent, args, context, info) => {
|
|
1729
|
-
const signature = fieldName ? parent[fieldName] : args.signature;
|
|
1730
|
-
if (signature) {
|
|
1731
|
-
if (onlyFieldsRequested(["signature"], info)) {
|
|
1732
|
-
return { signature };
|
|
1733
|
-
}
|
|
1734
|
-
const argsSet = buildTransactionLoaderArgSetFromResolveInfo({ ...args, signature }, info);
|
|
1735
|
-
const loadedTransactions = await context.loaders.transaction.loadMany(argsSet);
|
|
1736
|
-
let result = {
|
|
1737
|
-
encodedData: {},
|
|
1738
|
-
signature
|
|
1739
|
-
};
|
|
1740
|
-
loadedTransactions.forEach((loadedTransaction, i) => {
|
|
1741
|
-
if (loadedTransaction instanceof Error) {
|
|
1742
|
-
console.error(loadedTransaction);
|
|
1743
|
-
return;
|
|
1744
|
-
}
|
|
1745
|
-
if (loadedTransaction === null) {
|
|
1746
|
-
return;
|
|
1747
|
-
}
|
|
1748
|
-
if (!result.slot) {
|
|
1749
|
-
result = {
|
|
1750
|
-
...result,
|
|
1751
|
-
...loadedTransaction
|
|
1752
|
-
};
|
|
1753
|
-
}
|
|
1754
|
-
const { transaction: data } = loadedTransaction;
|
|
1755
|
-
const { encoding } = argsSet[i];
|
|
1756
|
-
if (encoding && result.encodedData) {
|
|
1757
|
-
if (Array.isArray(data)) {
|
|
1758
|
-
result.encodedData[cacheKeyFn({
|
|
1759
|
-
encoding
|
|
1760
|
-
})] = data[0];
|
|
1761
|
-
} else if (typeof data === "object") {
|
|
1762
|
-
const jsonParsedData = data;
|
|
1763
|
-
jsonParsedData.message.instructions = mapJsonParsedInstructions(
|
|
1764
|
-
jsonParsedData.message.instructions
|
|
1765
|
-
);
|
|
1766
|
-
const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
|
|
1767
|
-
if (loadedInnerInstructions) {
|
|
1768
|
-
const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
|
|
1769
|
-
const jsonParsedMeta = {
|
|
1770
|
-
...loadedTransaction.meta,
|
|
1771
|
-
innerInstructions
|
|
1772
|
-
};
|
|
1773
|
-
result = {
|
|
1774
|
-
...result,
|
|
1775
|
-
...jsonParsedData,
|
|
1776
|
-
meta: jsonParsedMeta
|
|
1777
|
-
};
|
|
1778
|
-
} else {
|
|
1779
|
-
result = {
|
|
1780
|
-
...result,
|
|
1781
|
-
...jsonParsedData
|
|
1782
|
-
};
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
});
|
|
1787
|
-
return result;
|
|
1788
|
-
}
|
|
1789
|
-
return null;
|
|
1790
|
-
};
|
|
1791
|
-
}
|
|
1792
|
-
var transactionResolvers = {
|
|
1793
|
-
Transaction: {
|
|
1794
|
-
data: resolveTransactionData()
|
|
1795
|
-
}
|
|
1796
|
-
};
|
|
1797
|
-
|
|
1798
1844
|
// src/resolvers/root.ts
|
|
1799
1845
|
var rootResolvers = {
|
|
1800
1846
|
Query: {
|
|
@@ -1820,7 +1866,7 @@ var stringScalarAlias = {
|
|
|
1820
1866
|
};
|
|
1821
1867
|
var bigIntScalarAlias = {
|
|
1822
1868
|
__parseLiteral(ast) {
|
|
1823
|
-
if (ast.kind === graphql.Kind.STRING) {
|
|
1869
|
+
if (ast.kind === graphql.Kind.STRING || ast.kind === graphql.Kind.INT || ast.kind === graphql.Kind.FLOAT) {
|
|
1824
1870
|
return BigInt(ast.value);
|
|
1825
1871
|
}
|
|
1826
1872
|
return null;
|
|
@@ -1843,12 +1889,6 @@ var typeTypeResolvers = {
|
|
|
1843
1889
|
Base64EncodedBytes: stringScalarAlias,
|
|
1844
1890
|
Base64ZstdEncodedBytes: stringScalarAlias,
|
|
1845
1891
|
BigInt: bigIntScalarAlias,
|
|
1846
|
-
BlockTransactionDetails: {
|
|
1847
|
-
ACCOUNTS: "accounts",
|
|
1848
|
-
FULL: "full",
|
|
1849
|
-
NONE: "none",
|
|
1850
|
-
SIGNATURES: "signatures"
|
|
1851
|
-
},
|
|
1852
1892
|
Commitment: {
|
|
1853
1893
|
CONFIRMED: "confirmed",
|
|
1854
1894
|
FINALIZED: "finalized",
|
|
@@ -1866,12 +1906,7 @@ var typeTypeResolvers = {
|
|
|
1866
1906
|
},
|
|
1867
1907
|
TransactionEncoding: {
|
|
1868
1908
|
BASE_58: "base58",
|
|
1869
|
-
BASE_64: "base64"
|
|
1870
|
-
PARSED: "jsonParsed"
|
|
1871
|
-
},
|
|
1872
|
-
TransactionVersion: {
|
|
1873
|
-
LEGACY: "legacy",
|
|
1874
|
-
ZERO: 0
|
|
1909
|
+
BASE_64: "base64"
|
|
1875
1910
|
}
|
|
1876
1911
|
};
|
|
1877
1912
|
|
|
@@ -2075,93 +2110,18 @@ var accountTypeDefs = (
|
|
|
2075
2110
|
var blockTypeDefs = (
|
|
2076
2111
|
/* GraphQL */
|
|
2077
2112
|
`
|
|
2078
|
-
type TransactionMetaForAccounts {
|
|
2079
|
-
err: String
|
|
2080
|
-
fee: BigInt
|
|
2081
|
-
postBalances: [BigInt]
|
|
2082
|
-
postTokenBalances: [TokenBalance]
|
|
2083
|
-
preBalances: [BigInt]
|
|
2084
|
-
preTokenBalances: [TokenBalance]
|
|
2085
|
-
status: TransactionStatus
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
type TransactionDataForAccounts {
|
|
2089
|
-
accountKeys: [Address]
|
|
2090
|
-
signatures: [String]
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
type BlockTransactionAccounts {
|
|
2094
|
-
meta: TransactionMetaForAccounts
|
|
2095
|
-
data: TransactionDataForAccounts
|
|
2096
|
-
version: String
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2099
|
-
"""
|
|
2100
|
-
Block interface
|
|
2101
|
-
"""
|
|
2102
|
-
interface Block {
|
|
2103
|
-
blockhash: String
|
|
2104
|
-
blockHeight: BigInt
|
|
2105
|
-
blockTime: BigInt
|
|
2106
|
-
parentSlot: BigInt
|
|
2107
|
-
previousBlockhash: String
|
|
2108
|
-
rewards: [Reward]
|
|
2109
|
-
transactionDetails: String
|
|
2110
|
-
}
|
|
2111
|
-
|
|
2112
|
-
"""
|
|
2113
|
-
A block with account transaction details
|
|
2114
|
-
"""
|
|
2115
|
-
type BlockWithAccounts implements Block {
|
|
2116
|
-
blockhash: String
|
|
2117
|
-
blockHeight: BigInt
|
|
2118
|
-
blockTime: BigInt
|
|
2119
|
-
parentSlot: BigInt
|
|
2120
|
-
previousBlockhash: String
|
|
2121
|
-
rewards: [Reward]
|
|
2122
|
-
transactions: [BlockTransactionAccounts]
|
|
2123
|
-
transactionDetails: String
|
|
2124
|
-
}
|
|
2125
|
-
|
|
2126
2113
|
"""
|
|
2127
|
-
A block
|
|
2114
|
+
A Solana block
|
|
2128
2115
|
"""
|
|
2129
|
-
type
|
|
2116
|
+
type Block {
|
|
2130
2117
|
blockhash: String
|
|
2131
2118
|
blockHeight: BigInt
|
|
2132
2119
|
blockTime: BigInt
|
|
2133
|
-
parentSlot:
|
|
2120
|
+
parentSlot: Slot
|
|
2134
2121
|
previousBlockhash: String
|
|
2135
2122
|
rewards: [Reward]
|
|
2123
|
+
signatures: [Signature]
|
|
2136
2124
|
transactions: [Transaction]
|
|
2137
|
-
transactionDetails: String
|
|
2138
|
-
}
|
|
2139
|
-
|
|
2140
|
-
"""
|
|
2141
|
-
A block with no transaction details
|
|
2142
|
-
"""
|
|
2143
|
-
type BlockWithNone implements Block {
|
|
2144
|
-
blockhash: String
|
|
2145
|
-
blockHeight: BigInt
|
|
2146
|
-
blockTime: BigInt
|
|
2147
|
-
parentSlot: BigInt
|
|
2148
|
-
previousBlockhash: String
|
|
2149
|
-
rewards: [Reward]
|
|
2150
|
-
transactionDetails: String
|
|
2151
|
-
}
|
|
2152
|
-
|
|
2153
|
-
"""
|
|
2154
|
-
A block with signature transaction details
|
|
2155
|
-
"""
|
|
2156
|
-
type BlockWithSignatures implements Block {
|
|
2157
|
-
blockhash: String
|
|
2158
|
-
blockHeight: BigInt
|
|
2159
|
-
blockTime: BigInt
|
|
2160
|
-
parentSlot: BigInt
|
|
2161
|
-
previousBlockhash: String
|
|
2162
|
-
rewards: [Reward]
|
|
2163
|
-
signatures: [String]
|
|
2164
|
-
transactionDetails: String
|
|
2165
2125
|
}
|
|
2166
2126
|
`
|
|
2167
2127
|
);
|
|
@@ -3220,12 +3180,7 @@ var rootTypeDefs = (
|
|
|
3220
3180
|
`
|
|
3221
3181
|
type Query {
|
|
3222
3182
|
account(address: Address!, commitment: Commitment, minContextSlot: Slot): Account
|
|
3223
|
-
block(
|
|
3224
|
-
slot: Slot!
|
|
3225
|
-
commitment: Commitment
|
|
3226
|
-
encoding: TransactionEncoding
|
|
3227
|
-
transactionDetails: BlockTransactionDetails
|
|
3228
|
-
): Block
|
|
3183
|
+
block(slot: Slot!, commitment: CommitmentWithoutProcessed): Block
|
|
3229
3184
|
programAccounts(
|
|
3230
3185
|
programAddress: Address!
|
|
3231
3186
|
commitment: Commitment
|
|
@@ -3341,13 +3296,6 @@ var typeTypeDefs = (
|
|
|
3341
3296
|
|
|
3342
3297
|
scalar BigInt
|
|
3343
3298
|
|
|
3344
|
-
enum BlockTransactionDetails {
|
|
3345
|
-
ACCOUNTS
|
|
3346
|
-
FULL
|
|
3347
|
-
NONE
|
|
3348
|
-
SIGNATURES
|
|
3349
|
-
}
|
|
3350
|
-
|
|
3351
3299
|
enum Commitment {
|
|
3352
3300
|
CONFIRMED
|
|
3353
3301
|
FINALIZED
|
|
@@ -3406,12 +3354,6 @@ var typeTypeDefs = (
|
|
|
3406
3354
|
enum TransactionEncoding {
|
|
3407
3355
|
BASE_58
|
|
3408
3356
|
BASE_64
|
|
3409
|
-
PARSED
|
|
3410
|
-
}
|
|
3411
|
-
|
|
3412
|
-
enum TransactionVersion {
|
|
3413
|
-
LEGACY
|
|
3414
|
-
ZERO
|
|
3415
3357
|
}
|
|
3416
3358
|
`
|
|
3417
3359
|
);
|