@solana/rpc-graphql 2.0.0-experimental.f16a625 → 2.0.0-experimental.f4436f4

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 (74) hide show
  1. package/dist/index.browser.cjs +1221 -752
  2. package/dist/index.browser.cjs.map +1 -1
  3. package/dist/index.browser.js +1222 -753
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.native.js +1222 -753
  6. package/dist/index.native.js.map +1 -1
  7. package/dist/index.node.cjs +1221 -752
  8. package/dist/index.node.cjs.map +1 -1
  9. package/dist/index.node.js +1222 -753
  10. package/dist/index.node.js.map +1 -1
  11. package/dist/types/context.d.ts +15 -3
  12. package/dist/types/context.d.ts.map +1 -1
  13. package/dist/types/index.d.ts +2 -4
  14. package/dist/types/index.d.ts.map +1 -1
  15. package/dist/types/loaders/account.d.ts +12 -2
  16. package/dist/types/loaders/account.d.ts.map +1 -1
  17. package/dist/types/loaders/block.d.ts.map +1 -1
  18. package/dist/types/loaders/coalescer.d.ts +55 -0
  19. package/dist/types/loaders/coalescer.d.ts.map +1 -0
  20. package/dist/types/loaders/index.d.ts +1 -1
  21. package/dist/types/loaders/index.d.ts.map +1 -1
  22. package/dist/types/loaders/loader.d.ts +29 -10
  23. package/dist/types/loaders/loader.d.ts.map +1 -1
  24. package/dist/types/loaders/program-accounts.d.ts +5 -1
  25. package/dist/types/loaders/program-accounts.d.ts.map +1 -1
  26. package/dist/types/loaders/transaction.d.ts.map +1 -1
  27. package/dist/types/resolvers/account.d.ts +160 -42
  28. package/dist/types/resolvers/account.d.ts.map +1 -1
  29. package/dist/types/resolvers/block.d.ts +95 -11
  30. package/dist/types/resolvers/block.d.ts.map +1 -1
  31. package/dist/types/resolvers/index.d.ts.map +1 -1
  32. package/dist/types/resolvers/instruction.d.ts +1531 -259
  33. package/dist/types/resolvers/instruction.d.ts.map +1 -1
  34. package/dist/types/resolvers/program-accounts.d.ts +12 -3
  35. package/dist/types/resolvers/program-accounts.d.ts.map +1 -1
  36. package/dist/types/resolvers/resolve-info/account.d.ts +15 -0
  37. package/dist/types/resolvers/resolve-info/account.d.ts.map +1 -0
  38. package/dist/types/resolvers/resolve-info/block.d.ts +13 -0
  39. package/dist/types/resolvers/resolve-info/block.d.ts.map +1 -0
  40. package/dist/types/resolvers/resolve-info/index.d.ts +6 -0
  41. package/dist/types/resolvers/resolve-info/index.d.ts.map +1 -0
  42. package/dist/types/resolvers/resolve-info/program-accounts.d.ts +20 -0
  43. package/dist/types/resolvers/resolve-info/program-accounts.d.ts.map +1 -0
  44. package/dist/types/resolvers/resolve-info/transaction.d.ts +15 -0
  45. package/dist/types/resolvers/resolve-info/transaction.d.ts.map +1 -0
  46. package/dist/types/resolvers/resolve-info/visitor.d.ts +18 -0
  47. package/dist/types/resolvers/resolve-info/visitor.d.ts.map +1 -0
  48. package/dist/types/resolvers/transaction.d.ts +32 -9
  49. package/dist/types/resolvers/transaction.d.ts.map +1 -1
  50. package/dist/types/resolvers/types.d.ts +77 -9
  51. package/dist/types/resolvers/types.d.ts.map +1 -1
  52. package/dist/types/schema/account.d.ts +1 -1
  53. package/dist/types/schema/account.d.ts.map +1 -1
  54. package/dist/types/schema/block.d.ts +1 -1
  55. package/dist/types/schema/block.d.ts.map +1 -1
  56. package/dist/types/schema/index.d.ts.map +1 -1
  57. package/dist/types/schema/instruction.d.ts +1 -1
  58. package/dist/types/schema/root.d.ts +1 -1
  59. package/dist/types/schema/root.d.ts.map +1 -1
  60. package/dist/types/schema/transaction.d.ts +1 -1
  61. package/dist/types/schema/transaction.d.ts.map +1 -1
  62. package/dist/types/schema/types.d.ts +2 -0
  63. package/dist/types/schema/types.d.ts.map +1 -0
  64. package/package.json +4 -3
  65. package/dist/types/resolvers/resolve-info.d.ts +0 -3
  66. package/dist/types/resolvers/resolve-info.d.ts.map +0 -1
  67. package/dist/types/resolvers/scalars.d.ts +0 -44
  68. package/dist/types/resolvers/scalars.d.ts.map +0 -1
  69. package/dist/types/schema/common/inputs.d.ts +0 -2
  70. package/dist/types/schema/common/inputs.d.ts.map +0 -1
  71. package/dist/types/schema/common/scalars.d.ts +0 -2
  72. package/dist/types/schema/common/scalars.d.ts.map +0 -1
  73. package/dist/types/schema/common/types.d.ts +0 -2
  74. package/dist/types/schema/common/types.d.ts.map +0 -1
@@ -1,5 +1,6 @@
1
1
  import { makeExecutableSchema } from '@graphql-tools/schema';
2
- import { graphql, Kind } from 'graphql';
2
+ import { graphql, Kind, visit, BREAK, isInterfaceType } from 'graphql';
3
+ import { getBase64Codec, getBase58Codec } from '@solana/codecs-strings';
3
4
  import DataLoader from 'dataloader';
4
5
  import stringify from 'json-stable-stringify';
5
6
 
@@ -12,54 +13,270 @@ function replacer(_, value) {
12
13
  }
13
14
  var cacheKeyFn = (obj) => stringify(obj, { replacer });
14
15
 
16
+ // src/loaders/coalescer.ts
17
+ var hashOmit = (args, omit) => {
18
+ const argsObj = {};
19
+ for (const [key, value] of Object.entries(args)) {
20
+ if (!omit.includes(key)) {
21
+ argsObj[key] = value;
22
+ }
23
+ }
24
+ return cacheKeyFn(argsObj);
25
+ };
26
+ function buildCoalescedFetchesByArgsHash(toFetchMap, orphanConfig) {
27
+ const fetchesByArgsHash = {};
28
+ const orphanedFetches = {};
29
+ Object.entries(toFetchMap).forEach(([signature, toFetch]) => {
30
+ toFetch.forEach(({ args, promiseCallback }) => {
31
+ if (orphanConfig.criteria(args)) {
32
+ const toFetch2 = orphanedFetches[signature] ||= [];
33
+ toFetch2.push({ args, promiseCallback });
34
+ return;
35
+ }
36
+ const argsHash = hashOmit(args, []);
37
+ const transactionFetches = fetchesByArgsHash[argsHash] ||= {
38
+ args,
39
+ fetches: {}
40
+ };
41
+ const { callbacks: promiseCallbacksForSignature } = transactionFetches.fetches[signature] ||= {
42
+ callbacks: []
43
+ };
44
+ promiseCallbacksForSignature.push(promiseCallback);
45
+ });
46
+ });
47
+ Object.entries(orphanedFetches).forEach(([signature, toFetch]) => {
48
+ toFetch.forEach(({ args: orphanArgs, promiseCallback: orphanPromiseCallback }) => {
49
+ if (Object.keys(fetchesByArgsHash).length !== 0) {
50
+ for (const { fetches, args: args2 } of Object.values(fetchesByArgsHash)) {
51
+ if (hashOmit(orphanArgs, orphanConfig.hashOmit) === hashOmit(args2, orphanConfig.hashOmit)) {
52
+ const { callbacks: promiseCallbacksForSignature2 } = fetches[signature] ||= {
53
+ callbacks: []
54
+ };
55
+ promiseCallbacksForSignature2.push(orphanPromiseCallback);
56
+ return;
57
+ }
58
+ }
59
+ }
60
+ const args = orphanConfig.defaults(orphanArgs);
61
+ const argsHash = hashOmit(args, []);
62
+ const transactionFetches = fetchesByArgsHash[argsHash] ||= {
63
+ args,
64
+ fetches: {}
65
+ };
66
+ const { callbacks: promiseCallbacksForSignature } = transactionFetches.fetches[signature] ||= {
67
+ callbacks: []
68
+ };
69
+ promiseCallbacksForSignature.push(orphanPromiseCallback);
70
+ });
71
+ });
72
+ return fetchesByArgsHash;
73
+ }
74
+ function buildCoalescedFetchesByArgsHashWithDataSlice(toFetchMap, maxDataSliceByteRange) {
75
+ const fetchesByArgsHash = {};
76
+ const orphanedFetches = {};
77
+ Object.entries(toFetchMap).forEach(([address, toFetch]) => {
78
+ toFetch.forEach(({ args, promiseCallback }) => {
79
+ if (!args.encoding) {
80
+ const toFetch2 = orphanedFetches[address] ||= [];
81
+ toFetch2.push({ args, promiseCallback });
82
+ return;
83
+ }
84
+ if (args.encoding != "base64+zstd" && args.dataSlice) {
85
+ const r = args.dataSlice;
86
+ for (const { fetches: fetchAddresses, args: fetchArgs } of Object.values(fetchesByArgsHash)) {
87
+ const addCallbackWithDataSlice = (updateDataSlice) => {
88
+ const { callbacks: promiseCallbacksForAddress2 } = fetchAddresses[address] ||= {
89
+ callbacks: []
90
+ };
91
+ promiseCallbacksForAddress2.push({
92
+ callback: promiseCallback,
93
+ dataSlice: args.dataSlice ?? null
94
+ });
95
+ if (fetchArgs.dataSlice && updateDataSlice) {
96
+ fetchArgs.dataSlice = updateDataSlice;
97
+ }
98
+ };
99
+ if (hashOmit(args, ["dataSlice"]) === hashOmit(fetchArgs, ["dataSlice"])) {
100
+ if (fetchArgs.dataSlice) {
101
+ const g = fetchArgs.dataSlice;
102
+ if (r.offset <= g.offset && g.offset - r.offset + r.length <= maxDataSliceByteRange) {
103
+ const length = Math.max(r.length, g.offset + g.length - r.offset);
104
+ const offset = r.offset;
105
+ addCallbackWithDataSlice({ length, offset });
106
+ return;
107
+ }
108
+ if (r.offset >= g.offset && r.offset - g.offset + g.length <= maxDataSliceByteRange) {
109
+ const length = Math.max(g.length, r.offset + r.length - g.offset);
110
+ const offset = g.offset;
111
+ addCallbackWithDataSlice({ length, offset });
112
+ return;
113
+ }
114
+ } else {
115
+ const { length, offset } = r;
116
+ addCallbackWithDataSlice({ length, offset });
117
+ return;
118
+ }
119
+ }
120
+ }
121
+ }
122
+ const argsHash = hashOmit(args, []);
123
+ const accountFetches = fetchesByArgsHash[argsHash] ||= {
124
+ args,
125
+ fetches: {}
126
+ };
127
+ const { callbacks: promiseCallbacksForAddress } = accountFetches.fetches[address] ||= {
128
+ callbacks: []
129
+ };
130
+ promiseCallbacksForAddress.push({ callback: promiseCallback, dataSlice: args.dataSlice ?? null });
131
+ });
132
+ });
133
+ Object.entries(orphanedFetches).forEach(([address, toFetch]) => {
134
+ toFetch.forEach(({ args: orphanedArgs, promiseCallback: orphanPromiseCallback }) => {
135
+ if (Object.keys(fetchesByArgsHash).length !== 0) {
136
+ for (const { fetches, args: args2 } of Object.values(fetchesByArgsHash)) {
137
+ if (hashOmit(orphanedArgs, ["encoding", "dataSlice"]) === hashOmit(args2, ["encoding", "dataSlice"])) {
138
+ const { callbacks: promiseCallbacksForAddress2 } = fetches[address] ||= {
139
+ callbacks: []
140
+ };
141
+ promiseCallbacksForAddress2.push({ callback: orphanPromiseCallback });
142
+ return;
143
+ }
144
+ }
145
+ }
146
+ const args = { ...orphanedArgs, encoding: "base64" };
147
+ const argsHash = hashOmit(args, []);
148
+ const accountFetches = fetchesByArgsHash[argsHash] ||= {
149
+ args,
150
+ fetches: {}
151
+ };
152
+ const { callbacks: promiseCallbacksForAddress } = accountFetches.fetches[address] ||= {
153
+ callbacks: []
154
+ };
155
+ promiseCallbacksForAddress.push({ callback: orphanPromiseCallback });
156
+ });
157
+ });
158
+ return fetchesByArgsHash;
159
+ }
160
+
15
161
  // src/loaders/account.ts
16
- function applyDefaultArgs({
17
- address,
18
- commitment,
19
- dataSlice,
20
- encoding = "jsonParsed",
21
- minContextSlot
22
- }) {
23
- return {
24
- address,
25
- commitment,
26
- dataSlice,
27
- encoding,
28
- minContextSlot
29
- };
162
+ function getCodec(encoding) {
163
+ switch (encoding) {
164
+ case "base58":
165
+ return getBase58Codec();
166
+ default:
167
+ return getBase64Codec();
168
+ }
169
+ }
170
+ function sliceData(account, dataSlice, masterDataSlice) {
171
+ if (dataSlice) {
172
+ const masterOffset = masterDataSlice ? masterDataSlice.offset : 0;
173
+ const slicedData = (data, encoding) => {
174
+ if (encoding === "base64+zstd") {
175
+ return data;
176
+ }
177
+ const { offset, length } = dataSlice;
178
+ const trueOffset = offset - masterOffset;
179
+ const codec = getCodec(encoding);
180
+ return codec.decode(codec.encode(data).slice(trueOffset, trueOffset + length));
181
+ };
182
+ if (Array.isArray(account.data)) {
183
+ const [data, encoding] = account.data;
184
+ return {
185
+ ...account,
186
+ data: [slicedData(data, encoding), encoding]
187
+ };
188
+ } else if (typeof account.data === "string") {
189
+ const data = account.data;
190
+ return {
191
+ ...account,
192
+ data: slicedData(data, "base58")
193
+ };
194
+ }
195
+ }
196
+ return account;
30
197
  }
31
198
  async function loadAccount(rpc, { address, ...config }) {
32
199
  return await rpc.getAccountInfo(address, config).send().then((res) => res.value);
33
200
  }
34
- function createAccountBatchLoadFn(rpc) {
201
+ async function loadMultipleAccounts(rpc, { addresses, ...config }) {
202
+ return await rpc.getMultipleAccounts(addresses, config).send().then((res) => res.value);
203
+ }
204
+ function createAccountBatchLoadFn(rpc, config) {
35
205
  const resolveAccountUsingRpc = loadAccount.bind(null, rpc);
206
+ const resolveMultipleAccountsUsingRpc = loadMultipleAccounts.bind(null, rpc);
36
207
  return async (accountQueryArgs) => {
37
- return await Promise.all(
38
- accountQueryArgs.map(async (args) => await resolveAccountUsingRpc(applyDefaultArgs(args)))
39
- );
40
- };
41
- }
42
- function createAccountLoader(rpc) {
43
- const loader = new DataLoader(createAccountBatchLoadFn(rpc), { cacheKeyFn });
44
- return {
45
- load: async (args) => loader.load(applyDefaultArgs(args))
208
+ const accountsToFetch = {};
209
+ try {
210
+ return Promise.all(
211
+ accountQueryArgs.map(
212
+ ({ address, ...args }) => new Promise((resolve, reject) => {
213
+ const accountRecords = accountsToFetch[address] ||= [];
214
+ if (!args.commitment) {
215
+ args.commitment = "confirmed";
216
+ }
217
+ accountRecords.push({ args, promiseCallback: { reject, resolve } });
218
+ })
219
+ )
220
+ );
221
+ } finally {
222
+ const { maxDataSliceByteRange, maxMultipleAccountsBatchSize } = config;
223
+ const accountFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(
224
+ accountsToFetch,
225
+ maxDataSliceByteRange
226
+ );
227
+ Object.values(accountFetchesByArgsHash).map(({ args, fetches: addressCallbacks }) => {
228
+ const addresses = Object.keys(addressCallbacks);
229
+ if (addresses.length === 1) {
230
+ const address = addresses[0];
231
+ return Array.from({ length: 1 }, async () => {
232
+ try {
233
+ const result = await resolveAccountUsingRpc({ address, ...args });
234
+ addressCallbacks[address].callbacks.forEach(({ callback, dataSlice }) => {
235
+ callback.resolve(sliceData(result, dataSlice, args.dataSlice));
236
+ });
237
+ } catch (e) {
238
+ addressCallbacks[address].callbacks.forEach(({ callback }) => {
239
+ callback.reject(e);
240
+ });
241
+ }
242
+ });
243
+ } else {
244
+ return Array.from(
245
+ { length: Math.ceil(addresses.length / maxMultipleAccountsBatchSize) },
246
+ async (_, ii) => {
247
+ const startIndex = ii * maxMultipleAccountsBatchSize;
248
+ const endIndex = startIndex + maxMultipleAccountsBatchSize;
249
+ const chunk = addresses.slice(startIndex, endIndex);
250
+ try {
251
+ const results = await resolveMultipleAccountsUsingRpc({
252
+ addresses: chunk,
253
+ ...args
254
+ });
255
+ chunk.forEach((address, ii2) => {
256
+ const result = results[ii2];
257
+ addressCallbacks[address].callbacks.forEach(({ callback, dataSlice }) => {
258
+ callback.resolve(sliceData(result, dataSlice, args.dataSlice));
259
+ });
260
+ });
261
+ } catch (e) {
262
+ chunk.forEach((address) => {
263
+ addressCallbacks[address].callbacks.forEach(({ callback }) => {
264
+ callback.reject(e);
265
+ });
266
+ });
267
+ }
268
+ }
269
+ );
270
+ }
271
+ });
272
+ }
46
273
  };
47
274
  }
48
- function applyDefaultArgs2({
49
- slot,
50
- commitment,
51
- encoding = "jsonParsed",
52
- maxSupportedTransactionVersion = 0,
53
- rewards,
54
- transactionDetails = "full"
55
- }) {
275
+ function createAccountLoader(rpc, config) {
276
+ const loader = new DataLoader(createAccountBatchLoadFn(rpc, config), { cacheKeyFn });
56
277
  return {
57
- commitment,
58
- encoding,
59
- maxSupportedTransactionVersion,
60
- rewards,
61
- slot,
62
- transactionDetails
278
+ load: async (args) => loader.load(args),
279
+ loadMany: async (args) => loader.loadMany(args)
63
280
  };
64
281
  }
65
282
  async function loadBlock(rpc, { slot, ...config }) {
@@ -72,30 +289,51 @@ async function loadBlock(rpc, { slot, ...config }) {
72
289
  function createBlockBatchLoadFn(rpc) {
73
290
  const resolveBlockUsingRpc = loadBlock.bind(null, rpc);
74
291
  return async (blockQueryArgs) => {
75
- return await Promise.all(blockQueryArgs.map(async (args) => await resolveBlockUsingRpc(applyDefaultArgs2(args))));
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
+ }
76
330
  };
77
331
  }
78
332
  function createBlockLoader(rpc) {
79
333
  const loader = new DataLoader(createBlockBatchLoadFn(rpc), { cacheKeyFn });
80
334
  return {
81
- load: async (args) => loader.load(applyDefaultArgs2(args))
82
- };
83
- }
84
- function applyDefaultArgs3({
85
- commitment,
86
- dataSlice,
87
- encoding = "jsonParsed",
88
- filters,
89
- minContextSlot,
90
- programAddress
91
- }) {
92
- return {
93
- commitment,
94
- dataSlice,
95
- encoding,
96
- filters,
97
- minContextSlot,
98
- programAddress
335
+ load: async (args) => loader.load({ ...args, maxSupportedTransactionVersion: 0 }),
336
+ loadMany: async (args) => loader.loadMany(args.map((a) => ({ ...a, maxSupportedTransactionVersion: 0 })))
99
337
  };
100
338
  }
101
339
  async function loadProgramAccounts(rpc, { programAddress, ...config }) {
@@ -105,29 +343,55 @@ async function loadProgramAccounts(rpc, { programAddress, ...config }) {
105
343
  config
106
344
  ).send();
107
345
  }
108
- function createProgramAccountsBatchLoadFn(rpc) {
346
+ function createProgramAccountsBatchLoadFn(rpc, config) {
109
347
  const resolveProgramAccountsUsingRpc = loadProgramAccounts.bind(null, rpc);
110
- return async (programAccountsQueryArgs) => {
111
- return await Promise.all(
112
- programAccountsQueryArgs.map(async (args) => await resolveProgramAccountsUsingRpc(applyDefaultArgs3(args)))
113
- );
114
- };
115
- }
116
- function createProgramAccountsLoader(rpc) {
117
- const loader = new DataLoader(createProgramAccountsBatchLoadFn(rpc), { cacheKeyFn });
118
- return {
119
- load: async (args) => loader.load(applyDefaultArgs3(args))
348
+ return async (accountQueryArgs) => {
349
+ const programAccountsToFetch = {};
350
+ try {
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
+ );
362
+ } finally {
363
+ const { maxDataSliceByteRange } = config;
364
+ const programAccountsFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(
365
+ programAccountsToFetch,
366
+ maxDataSliceByteRange
367
+ );
368
+ Object.values(programAccountsFetchesByArgsHash).map(({ args, fetches: programAddressCallbacks }) => {
369
+ return Object.entries(programAddressCallbacks).map(([programAddress, { callbacks }]) => {
370
+ return Array.from({ length: 1 }, async () => {
371
+ try {
372
+ const result = await resolveProgramAccountsUsingRpc({
373
+ programAddress,
374
+ ...args
375
+ });
376
+ callbacks.forEach(({ callback, dataSlice }) => {
377
+ callback.resolve(sliceData(result, dataSlice, args.dataSlice));
378
+ });
379
+ } catch (e) {
380
+ callbacks.forEach(({ callback }) => {
381
+ callback.reject(e);
382
+ });
383
+ }
384
+ });
385
+ });
386
+ });
387
+ }
120
388
  };
121
389
  }
122
- function applyDefaultArgs4({
123
- commitment,
124
- encoding = "jsonParsed",
125
- signature
126
- }) {
390
+ function createProgramAccountsLoader(rpc, config) {
391
+ const loader = new DataLoader(createProgramAccountsBatchLoadFn(rpc, config), { cacheKeyFn });
127
392
  return {
128
- commitment,
129
- encoding,
130
- signature
393
+ load: async (args) => loader.load(args),
394
+ loadMany: async (args) => loader.loadMany(args)
131
395
  };
132
396
  }
133
397
  async function loadTransaction(rpc, { signature, ...config }) {
@@ -140,163 +404,388 @@ async function loadTransaction(rpc, { signature, ...config }) {
140
404
  function createTransactionBatchLoadFn(rpc) {
141
405
  const resolveTransactionUsingRpc = loadTransaction.bind(null, rpc);
142
406
  return async (transactionQueryArgs) => {
143
- return await Promise.all(
144
- transactionQueryArgs.map(async (args) => await resolveTransactionUsingRpc(applyDefaultArgs4(args)))
145
- );
407
+ const transactionsToFetch = {};
408
+ try {
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
+ );
420
+ } finally {
421
+ const transactionFetchesByArgsHash = buildCoalescedFetchesByArgsHash(transactionsToFetch, {
422
+ criteria: (args) => args.encoding === void 0,
423
+ defaults: (args) => ({ ...args, encoding: "base64" }),
424
+ hashOmit: ["encoding"]
425
+ });
426
+ Object.values(transactionFetchesByArgsHash).map(({ args, fetches: transactionCallbacks }) => {
427
+ return Object.entries(transactionCallbacks).map(([signature, { callbacks }]) => {
428
+ return Array.from({ length: 1 }, async () => {
429
+ try {
430
+ const result = await resolveTransactionUsingRpc({
431
+ signature,
432
+ ...args
433
+ });
434
+ callbacks.forEach((c) => c.resolve(result));
435
+ } catch (e) {
436
+ callbacks.forEach((c) => c.reject(e));
437
+ }
438
+ });
439
+ });
440
+ });
441
+ }
146
442
  };
147
443
  }
148
444
  function createTransactionLoader(rpc) {
149
445
  const loader = new DataLoader(createTransactionBatchLoadFn(rpc), { cacheKeyFn });
150
446
  return {
151
- load: async (args) => loader.load(applyDefaultArgs4(args))
447
+ load: async (args) => loader.load(args),
448
+ loadMany: async (args) => loader.loadMany(args)
152
449
  };
153
450
  }
154
451
 
155
452
  // src/context.ts
156
- function createSolanaGraphQLContext(rpc) {
453
+ function createSolanaGraphQLContext(rpc, config) {
157
454
  return {
158
455
  loaders: {
159
- account: createAccountLoader(rpc),
456
+ account: createAccountLoader(rpc, config),
160
457
  block: createBlockLoader(rpc),
161
- programAccounts: createProgramAccountsLoader(rpc),
458
+ programAccounts: createProgramAccountsLoader(rpc, config),
162
459
  transaction: createTransactionLoader(rpc)
163
460
  }
164
461
  };
165
462
  }
166
-
167
- // src/resolvers/resolve-info.ts
168
- function onlyPresentFieldRequested(fieldName, info) {
169
- if (info && info.fieldNodes[0].selectionSet) {
170
- const selectionSet = info.fieldNodes[0].selectionSet;
171
- const requestedFields = selectionSet.selections.map((field) => {
172
- if (field.kind === "Field") {
173
- return field.name.value;
463
+ function injectableRootVisitor(info, rootNode, operations) {
464
+ const { fieldNodes } = info;
465
+ const root = rootNode ?? fieldNodes[0];
466
+ const parentIsRoot = (ancestors) => (Array.isArray(ancestors) ? ancestors[0] : ancestors) === root;
467
+ visit(root, {
468
+ Field(node, key, parent, path, ancestors) {
469
+ if (!parentIsRoot(ancestors))
470
+ return;
471
+ return operations.fieldNodeOperation(info, node, key, parent, path, ancestors);
472
+ },
473
+ FragmentSpread(node, key, parent, path, ancestors) {
474
+ const fragmentDefinition = info.fragments[node.name.value];
475
+ return operations.fragmentSpreadNodeOperation(info, fragmentDefinition, node, key, parent, path, ancestors);
476
+ },
477
+ InlineFragment(node, key, parent, path, ancestors) {
478
+ if (!parentIsRoot(ancestors))
479
+ return;
480
+ return operations.inlineFragmentNodeOperation(info, node, key, parent, path, ancestors);
481
+ }
482
+ });
483
+ }
484
+ function onlyFieldsRequested(fieldNames, info, rootNode) {
485
+ let onlyFieldsRequested2 = true;
486
+ function checkFieldsWithVisitor(root) {
487
+ injectableRootVisitor(info, root, {
488
+ fieldNodeOperation(_info, node) {
489
+ onlyFieldsRequested2 = fieldNames.includes(node.name.value);
490
+ if (!onlyFieldsRequested2) {
491
+ return BREAK;
492
+ }
493
+ },
494
+ fragmentSpreadNodeOperation(_info, fragment) {
495
+ checkFieldsWithVisitor(fragment);
496
+ },
497
+ inlineFragmentNodeOperation(_info, node) {
498
+ checkFieldsWithVisitor(node);
174
499
  }
175
- return null;
176
500
  });
177
- if (requestedFields && requestedFields.length === 1 && requestedFields[0] === fieldName) {
178
- return true;
179
- }
180
501
  }
181
- return false;
502
+ checkFieldsWithVisitor(rootNode ?? null);
503
+ return onlyFieldsRequested2;
182
504
  }
183
505
 
184
- // src/resolvers/account.ts
185
- function transformParsedAccountData(parsedAccountData) {
186
- const {
187
- parsed: { info: result, type: accountType },
188
- program: programName,
189
- programId
190
- } = parsedAccountData;
191
- result.accountType = accountType;
192
- result.programId = programId;
193
- result.programName = programName;
194
- return result;
506
+ // src/resolvers/resolve-info/account.ts
507
+ function findArgumentNodeByName(argumentNodes, name) {
508
+ return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
195
509
  }
196
- function transformLoadedAccount({
197
- account,
198
- address,
199
- encoding = "jsonParsed"
200
- }) {
201
- const [
202
- // The account's data, either encoded or parsed.
203
- data,
204
- // Tells GraphQL which encoding has been returned
205
- // by the RPC.
206
- responseEncoding
207
- ] = Array.isArray(account.data) ? encoding === "jsonParsed" ? (
208
- // The requested encoding is jsonParsed,
209
- // but the data could not be parsed.
210
- // Defaults to base64 encoding.
211
- [{ data: account.data[0] }, "base64"]
212
- ) : (
213
- // The requested encoding is base58,
214
- // base64, or base64+zstd.
215
- [{ data: account.data[0] }, encoding]
216
- ) : (
217
- // The account data was returned as an object,
218
- // so it was parsed successfully.
219
- [transformParsedAccountData(account.data), "jsonParsed"]
220
- );
221
- account.address = address;
222
- account.encoding = responseEncoding;
223
- account.ownerProgram = account.owner;
224
- return {
225
- ...account,
226
- ...data
227
- };
228
- }
229
- var resolveAccount = (fieldName) => {
230
- return async (parent, args, context, info) => {
231
- const address = fieldName ? parent[fieldName] : args.address;
232
- if (!address) {
233
- return null;
510
+ function parseAccountEncodingArgument(argumentNodes, variableValues) {
511
+ const argumentNode = findArgumentNodeByName(argumentNodes, "encoding");
512
+ if (argumentNode) {
513
+ if (argumentNode.value.kind === "EnumValue") {
514
+ if (argumentNode.value.value === "BASE_58") {
515
+ return "base58";
516
+ }
517
+ if (argumentNode.value.value === "BASE_64") {
518
+ return "base64";
519
+ }
520
+ if (argumentNode.value.value === "BASE_64_ZSTD") {
521
+ return "base64+zstd";
522
+ }
234
523
  }
235
- if (onlyPresentFieldRequested("address", info)) {
236
- return { address };
524
+ if (argumentNode.value.kind === "Variable") {
525
+ return variableValues[argumentNode.value.name.value];
237
526
  }
238
- const account = await context.loaders.account.load({ ...args, address });
239
- return account === null ? { address } : transformLoadedAccount({ account, address, encoding: args.encoding });
240
- };
241
- };
242
- var accountResolvers = {
243
- Account: {
244
- __resolveType(account) {
245
- if (account.encoding === "base58") {
246
- return "AccountBase58";
527
+ } else {
528
+ return void 0;
529
+ }
530
+ }
531
+ function parseAccountDataSliceArgument(argumentNodes, variableValues) {
532
+ const argumentNode = findArgumentNodeByName(argumentNodes, "dataSlice");
533
+ if (argumentNode) {
534
+ if (argumentNode.value.kind === "ObjectValue") {
535
+ const offsetArg = argumentNode.value.fields?.find((field) => field.name.value === "offset");
536
+ const lengthArg = argumentNode.value.fields?.find((field) => field.name.value === "length");
537
+ const length = lengthArg?.value.kind === "IntValue" ? parseInt(lengthArg.value.value) : lengthArg?.value.kind === "Variable" ? variableValues[lengthArg.value.name.value] : void 0;
538
+ const offset = offsetArg?.value.kind === "IntValue" ? parseInt(offsetArg.value.value) : offsetArg?.value.kind === "Variable" ? variableValues[offsetArg.value.name.value] : void 0;
539
+ return length !== void 0 && length !== null && offset !== void 0 && offset !== null ? { length, offset } : void 0;
540
+ }
541
+ if (argumentNode.value.kind === "Variable") {
542
+ return variableValues[argumentNode.value.name.value];
543
+ }
544
+ } else {
545
+ return void 0;
546
+ }
547
+ }
548
+ function buildAccountArgSetWithVisitor(args, info) {
549
+ const argSet = [args];
550
+ function buildArgSetWithVisitor(root) {
551
+ injectableRootVisitor(info, root, {
552
+ fieldNodeOperation(info2, node) {
553
+ if (node.name.value !== "data") {
554
+ return;
555
+ }
556
+ if (node.arguments) {
557
+ const { variableValues } = info2;
558
+ const encoding = parseAccountEncodingArgument(node.arguments, variableValues);
559
+ const dataSlice = parseAccountDataSliceArgument(node.arguments, variableValues);
560
+ argSet.push({ ...args, dataSlice, encoding });
561
+ }
562
+ },
563
+ fragmentSpreadNodeOperation(_info, fragment) {
564
+ buildArgSetWithVisitor(fragment);
565
+ },
566
+ inlineFragmentNodeOperation(info2, node) {
567
+ const { schema } = info2;
568
+ const accountInterface = schema.getType("Account");
569
+ if (isInterfaceType(accountInterface) && // Recursively check if the inline fragment requests any
570
+ // fields outside of the `Account` interface.
571
+ !onlyFieldsRequested(Object.keys(accountInterface.getFields()), info2, node)) {
572
+ argSet.push({ ...args, encoding: "jsonParsed" });
573
+ }
247
574
  }
248
- if (account.encoding === "base64") {
249
- return "AccountBase64";
575
+ });
576
+ }
577
+ buildArgSetWithVisitor(null);
578
+ return argSet;
579
+ }
580
+ function buildAccountLoaderArgSetFromResolveInfo(args, info) {
581
+ return buildAccountArgSetWithVisitor(args, info);
582
+ }
583
+
584
+ // src/resolvers/resolve-info/transaction.ts
585
+ function findArgumentNodeByName2(argumentNodes, name) {
586
+ return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
587
+ }
588
+ function parseTransactionEncodingArgument(argumentNodes, variableValues) {
589
+ const argumentNode = findArgumentNodeByName2(argumentNodes, "encoding");
590
+ if (argumentNode) {
591
+ if (argumentNode.value.kind === "EnumValue") {
592
+ if (argumentNode.value.value === "BASE_58") {
593
+ return "base58";
250
594
  }
251
- if (account.encoding === "base64+zstd") {
252
- return "AccountBase64Zstd";
595
+ if (argumentNode.value.value === "BASE_64") {
596
+ return "base64";
253
597
  }
254
- if (account.encoding === "jsonParsed") {
255
- if (account.programName === "nonce") {
256
- return "NonceAccount";
598
+ }
599
+ if (argumentNode.value.kind === "Variable") {
600
+ return variableValues[argumentNode.value.name.value];
601
+ }
602
+ } else {
603
+ return void 0;
604
+ }
605
+ }
606
+ function buildTransactionArgSetWithVisitor(args, info) {
607
+ const argSet = [args];
608
+ function buildArgSetWithVisitor(root) {
609
+ injectableRootVisitor(info, root, {
610
+ fieldNodeOperation(info2, node) {
611
+ if (node.name.value === "message" || node.name.value === "meta") {
612
+ argSet.push({ ...args, encoding: "jsonParsed" });
613
+ } else if (node.name.value === "data") {
614
+ if (node.arguments) {
615
+ const { variableValues } = info2;
616
+ const encoding = parseTransactionEncodingArgument(
617
+ node.arguments,
618
+ variableValues
619
+ );
620
+ argSet.push({ ...args, encoding });
621
+ }
257
622
  }
258
- if (account.accountType === "mint" && account.programName === "spl-token") {
259
- return "MintAccount";
623
+ },
624
+ fragmentSpreadNodeOperation(_info, fragment) {
625
+ buildArgSetWithVisitor(fragment);
626
+ },
627
+ inlineFragmentNodeOperation(_info, _node) {
628
+ return;
629
+ }
630
+ });
631
+ }
632
+ buildArgSetWithVisitor(null);
633
+ return argSet;
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));
260
649
  }
261
- if (account.accountType === "account" && account.programName === "spl-token") {
262
- return "TokenAccount";
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
+ }
667
+
668
+ // src/resolvers/account.ts
669
+ var resolveAccountData = () => {
670
+ return (parent, args) => {
671
+ return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
672
+ };
673
+ };
674
+ var resolveAccount = (fieldName) => {
675
+ return async (parent, args, context, info) => {
676
+ const address = fieldName ? parent[fieldName] : args.address;
677
+ if (address) {
678
+ if (onlyFieldsRequested(["address"], info)) {
679
+ return { address };
680
+ }
681
+ const argsSet = buildAccountLoaderArgSetFromResolveInfo({ ...args, address }, info);
682
+ const loadedAccounts = await context.loaders.account.loadMany(argsSet);
683
+ let result = {
684
+ address,
685
+ encodedData: {}
686
+ };
687
+ loadedAccounts.forEach((account, i) => {
688
+ if (account instanceof Error) {
689
+ console.error(account);
690
+ return;
263
691
  }
264
- if (account.programName === "stake") {
265
- return "StakeAccount";
692
+ if (account === null) {
693
+ return;
266
694
  }
267
- if (account.accountType === "vote" && account.programName === "vote") {
268
- return "VoteAccount";
695
+ if (!result.ownerProgram) {
696
+ result = {
697
+ ...result,
698
+ ...account,
699
+ ownerProgram: account.owner
700
+ };
269
701
  }
270
- if (account.accountType === "lookupTable" && account.programName === "address-lookup-table") {
271
- return "LookupTableAccount";
702
+ const { data } = account;
703
+ const { encoding, dataSlice } = argsSet[i];
704
+ if (encoding && result.encodedData) {
705
+ if (Array.isArray(data)) {
706
+ result.encodedData[cacheKeyFn({
707
+ dataSlice,
708
+ encoding: encoding === "jsonParsed" ? "base64" : encoding
709
+ })] = data[0];
710
+ } else if (typeof data === "string") {
711
+ result.encodedData[cacheKeyFn({
712
+ dataSlice,
713
+ encoding: "base58"
714
+ })] = data;
715
+ } else if (typeof data === "object") {
716
+ const {
717
+ parsed: { info: parsedData, type: accountType },
718
+ program: programName,
719
+ programId
720
+ } = data;
721
+ result.jsonParsedConfigs = {
722
+ accountType,
723
+ programId,
724
+ programName
725
+ };
726
+ result = {
727
+ ...result,
728
+ ...parsedData
729
+ };
730
+ }
272
731
  }
273
- }
274
- return "AccountBase64";
732
+ });
733
+ return result;
275
734
  }
735
+ return null;
736
+ };
737
+ };
738
+ function resolveAccountType(accountResult) {
739
+ const { jsonParsedConfigs } = accountResult;
740
+ if (jsonParsedConfigs) {
741
+ if (jsonParsedConfigs.programName === "nonce") {
742
+ return "NonceAccount";
743
+ }
744
+ if (jsonParsedConfigs.accountType === "mint" && jsonParsedConfigs.programName === "spl-token") {
745
+ return "MintAccount";
746
+ }
747
+ if (jsonParsedConfigs.accountType === "account" && jsonParsedConfigs.programName === "spl-token") {
748
+ return "TokenAccount";
749
+ }
750
+ if (jsonParsedConfigs.programName === "stake") {
751
+ return "StakeAccount";
752
+ }
753
+ if (jsonParsedConfigs.accountType === "vote" && jsonParsedConfigs.programName === "vote") {
754
+ return "VoteAccount";
755
+ }
756
+ if (jsonParsedConfigs.accountType === "lookupTable" && jsonParsedConfigs.programName === "address-lookup-table") {
757
+ return "LookupTableAccount";
758
+ }
759
+ }
760
+ return "GenericAccount";
761
+ }
762
+ var accountResolvers = {
763
+ Account: {
764
+ __resolveType: resolveAccountType,
765
+ data: resolveAccountData()
276
766
  },
277
- AccountBase58: {
278
- ownerProgram: resolveAccount("ownerProgram")
279
- },
280
- AccountBase64: {
281
- ownerProgram: resolveAccount("ownerProgram")
282
- },
283
- AccountBase64Zstd: {
767
+ GenericAccount: {
768
+ data: resolveAccountData(),
284
769
  ownerProgram: resolveAccount("ownerProgram")
285
770
  },
286
771
  LookupTableAccount: {
287
772
  authority: resolveAccount("authority"),
773
+ data: resolveAccountData(),
288
774
  ownerProgram: resolveAccount("ownerProgram")
289
775
  },
290
776
  MintAccount: {
777
+ data: resolveAccountData(),
291
778
  freezeAuthority: resolveAccount("freezeAuthority"),
292
779
  mintAuthority: resolveAccount("mintAuthority"),
293
780
  ownerProgram: resolveAccount("ownerProgram")
294
781
  },
295
782
  NonceAccount: {
296
783
  authority: resolveAccount("authority"),
784
+ data: resolveAccountData(),
297
785
  ownerProgram: resolveAccount("ownerProgram")
298
786
  },
299
787
  StakeAccount: {
788
+ data: resolveAccountData(),
300
789
  ownerProgram: resolveAccount("ownerProgram")
301
790
  },
302
791
  StakeAccountDataMetaAuthorized: {
@@ -310,12 +799,14 @@ var accountResolvers = {
310
799
  voter: resolveAccount("voter")
311
800
  },
312
801
  TokenAccount: {
802
+ data: resolveAccountData(),
313
803
  mint: resolveAccount("mint"),
314
804
  owner: resolveAccount("owner"),
315
805
  ownerProgram: resolveAccount("ownerProgram")
316
806
  },
317
807
  VoteAccount: {
318
808
  authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
809
+ data: resolveAccountData(),
319
810
  node: resolveAccount("nodePubkey"),
320
811
  ownerProgram: resolveAccount("ownerProgram")
321
812
  },
@@ -325,147 +816,207 @@ var accountResolvers = {
325
816
  };
326
817
 
327
818
  // src/resolvers/transaction.ts
328
- function transformParsedInstruction(parsedInstruction) {
329
- if ("parsed" in parsedInstruction) {
330
- if (typeof parsedInstruction.parsed === "string" && parsedInstruction.program === "spl-memo") {
331
- const { parsed: memo, program: programName2, programId: programId2 } = parsedInstruction;
332
- const instructionType2 = "memo";
333
- return { instructionType: instructionType2, memo, programId: programId2, programName: programName2 };
334
- }
335
- const {
336
- parsed: { info: data, type: instructionType },
337
- program: programName,
338
- programId
339
- } = parsedInstruction;
340
- return { instructionType, programId, programName, ...data };
341
- } else {
342
- return parsedInstruction;
343
- }
344
- }
345
- function transformParsedTransaction(parsedTransaction) {
346
- const transactionData = parsedTransaction.transaction;
347
- const transactionMeta = parsedTransaction.meta;
348
- transactionData.message.instructions = transactionData.message.instructions.map(transformParsedInstruction);
349
- transactionMeta.innerInstructions = transactionMeta.innerInstructions.map((innerInstruction) => {
350
- innerInstruction.instructions = innerInstruction.instructions.map(transformParsedInstruction);
351
- return innerInstruction;
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
+ }
352
846
  });
353
- return [transactionData, transactionMeta];
354
847
  }
355
- function transformLoadedTransaction({
356
- encoding = "jsonParsed",
357
- transaction
358
- }) {
359
- const [transactionData, transactionMeta] = Array.isArray(transaction.transaction) ? (
360
- // The requested encoding is base58 or base64.
361
- [transaction.transaction[0], transaction.meta]
362
- ) : (
363
- // The transaction was either partially parsed or
364
- // fully JSON-parsed, which will be sorted later.
365
- transformParsedTransaction(transaction)
366
- );
367
- transaction.data = transactionData;
368
- transaction.encoding = encoding;
369
- transaction.meta = transactionMeta;
370
- 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
+ }));
371
854
  }
855
+ var resolveTransactionData = () => {
856
+ return (parent, args) => {
857
+ return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
858
+ };
859
+ };
372
860
  function resolveTransaction(fieldName) {
373
861
  return async (parent, args, context, info) => {
374
862
  const signature = fieldName ? parent[fieldName] : args.signature;
375
- if (!signature) {
376
- return null;
377
- }
378
- if (onlyPresentFieldRequested("signature", info)) {
379
- return { signature };
380
- }
381
- const transaction = await context.loaders.transaction.load({ ...args, signature });
382
- if (!transaction) {
383
- return null;
384
- }
385
- if (args.encoding !== "jsonParsed") {
386
- const transactionJsonParsed = await context.loaders.transaction.load({
387
- ...args,
388
- encoding: "jsonParsed",
863
+ if (signature) {
864
+ if (onlyFieldsRequested(["signature"], info)) {
865
+ return { signature };
866
+ }
867
+ const argsSet = buildTransactionLoaderArgSetFromResolveInfo({ ...args, signature }, info);
868
+ const loadedTransactions = await context.loaders.transaction.loadMany(argsSet);
869
+ let result = {
870
+ encodedData: {},
389
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
+ }
390
919
  });
391
- if (transactionJsonParsed === null) {
392
- return null;
393
- }
394
- transaction.meta = transactionJsonParsed.meta;
920
+ return result;
395
921
  }
396
- return transformLoadedTransaction({ encoding: args.encoding, transaction });
922
+ return null;
397
923
  };
398
924
  }
399
925
  var transactionResolvers = {
400
926
  Transaction: {
401
- __resolveType(transaction) {
402
- switch (transaction.encoding) {
403
- case "base58":
404
- return "TransactionBase58";
405
- case "base64":
406
- return "TransactionBase64";
407
- default:
408
- return "TransactionParsed";
409
- }
410
- }
927
+ data: resolveTransactionData()
411
928
  }
412
929
  };
413
930
 
414
931
  // src/resolvers/block.ts
415
- function transformLoadedBlock({
416
- block,
417
- encoding = "jsonParsed",
418
- transactionDetails = "full"
419
- }) {
420
- const transformedBlock = block;
421
- if (typeof block === "object" && "transactions" in block) {
422
- transformedBlock.transactions = block.transactions.map((transaction) => {
423
- if (transactionDetails === "accounts") {
424
- return {
425
- data: transaction.transaction,
426
- meta: transaction.meta,
427
- version: transaction.version
428
- };
429
- } else {
430
- return transformLoadedTransaction({ encoding, transaction });
431
- }
432
- });
433
- }
434
- block.encoding = encoding;
435
- block.transactionDetails = transactionDetails;
436
- return block;
437
- }
438
932
  var resolveBlock = (fieldName) => {
439
933
  return async (parent, args, context, info) => {
440
934
  const slot = fieldName ? parent[fieldName] : args.slot;
441
- if (!slot) {
442
- return null;
443
- }
444
- if (onlyPresentFieldRequested("slot", info)) {
445
- return { slot };
446
- }
447
- const block = await context.loaders.block.load({ ...args, slot });
448
- if (block === null) {
449
- 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;
450
1013
  }
451
- const { encoding, transactionDetails } = args;
452
- return transformLoadedBlock({ block, encoding, transactionDetails });
1014
+ return null;
453
1015
  };
454
1016
  };
455
1017
  var blockResolvers = {
456
1018
  Block: {
457
- __resolveType(block) {
458
- switch (block.transactionDetails) {
459
- case "accounts":
460
- return "BlockWithAccounts";
461
- case "none":
462
- return "BlockWithNone";
463
- case "signatures":
464
- return "BlockWithSignatures";
465
- default:
466
- return "BlockWithFull";
467
- }
468
- }
1019
+ transactions: (parent) => parent?.transactionResults ? Object.values(parent.transactionResults) : null
469
1020
  }
470
1021
  };
471
1022
 
@@ -473,7 +1024,8 @@ var blockResolvers = {
473
1024
  var instructionResolvers = {
474
1025
  AdvanceNonceAccountInstruction: {
475
1026
  nonceAccount: resolveAccount("nonceAccount"),
476
- nonceAuthority: resolveAccount("nonceAuthority")
1027
+ nonceAuthority: resolveAccount("nonceAuthority"),
1028
+ recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar")
477
1029
  },
478
1030
  AllocateInstruction: {
479
1031
  account: resolveAccount("account")
@@ -510,9 +1062,11 @@ var instructionResolvers = {
510
1062
  BpfUpgradeableLoaderDeployWithMaxDataLenInstruction: {
511
1063
  authority: resolveAccount("authority"),
512
1064
  bufferAccount: resolveAccount("bufferAccount"),
1065
+ clockSysvar: resolveAccount("clockSysvar"),
513
1066
  payerAccount: resolveAccount("payerAccount"),
514
1067
  programAccount: resolveAccount("programAccount"),
515
- programDataAccount: resolveAccount("programDataAccount")
1068
+ programDataAccount: resolveAccount("programDataAccount"),
1069
+ rentSysvar: resolveAccount("rentSysvar")
516
1070
  },
517
1071
  BpfUpgradeableLoaderExtendProgramInstruction: {
518
1072
  payerAccount: resolveAccount("payerAccount"),
@@ -536,8 +1090,10 @@ var instructionResolvers = {
536
1090
  BpfUpgradeableLoaderUpgradeInstruction: {
537
1091
  authority: resolveAccount("authority"),
538
1092
  bufferAccount: resolveAccount("bufferAccount"),
1093
+ clockSysvar: resolveAccount("clockSysvar"),
539
1094
  programAccount: resolveAccount("programAccount"),
540
- programDataAccount: resolveAccount("programDataAccount")
1095
+ programDataAccount: resolveAccount("programDataAccount"),
1096
+ rentSysvar: resolveAccount("rentSysvar")
541
1097
  },
542
1098
  BpfUpgradeableLoaderWriteInstruction: {
543
1099
  account: resolveAccount("account"),
@@ -580,7 +1136,9 @@ var instructionResolvers = {
580
1136
  },
581
1137
  InitializeNonceAccountInstruction: {
582
1138
  nonceAccount: resolveAccount("nonceAccount"),
583
- nonceAuthority: resolveAccount("nonceAuthority")
1139
+ nonceAuthority: resolveAccount("nonceAuthority"),
1140
+ recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
1141
+ rentSysvar: resolveAccount("rentSysvar")
584
1142
  },
585
1143
  Lockup: {
586
1144
  custodian: resolveAccount("custodian")
@@ -656,7 +1214,8 @@ var instructionResolvers = {
656
1214
  SplTokenInitializeAccount2Instruction: {
657
1215
  account: resolveAccount("account"),
658
1216
  mint: resolveAccount("mint"),
659
- owner: resolveAccount("owner")
1217
+ owner: resolveAccount("owner"),
1218
+ rentSysvar: resolveAccount("rentSysvar")
660
1219
  },
661
1220
  SplTokenInitializeAccount3Instruction: {
662
1221
  account: resolveAccount("account"),
@@ -666,7 +1225,8 @@ var instructionResolvers = {
666
1225
  SplTokenInitializeAccountInstruction: {
667
1226
  account: resolveAccount("account"),
668
1227
  mint: resolveAccount("mint"),
669
- owner: resolveAccount("owner")
1228
+ owner: resolveAccount("owner"),
1229
+ rentSysvar: resolveAccount("rentSysvar")
670
1230
  },
671
1231
  SplTokenInitializeMint2Instruction: {
672
1232
  freezeAuthority: resolveAccount("freezeAuthority"),
@@ -680,13 +1240,15 @@ var instructionResolvers = {
680
1240
  SplTokenInitializeMintInstruction: {
681
1241
  freezeAuthority: resolveAccount("freezeAuthority"),
682
1242
  mint: resolveAccount("mint"),
683
- mintAuthority: resolveAccount("mintAuthority")
1243
+ mintAuthority: resolveAccount("mintAuthority"),
1244
+ rentSysvar: resolveAccount("rentSysvar")
684
1245
  },
685
1246
  SplTokenInitializeMultisig2Instruction: {
686
1247
  multisig: resolveAccount("multisig")
687
1248
  },
688
1249
  SplTokenInitializeMultisigInstruction: {
689
- multisig: resolveAccount("multisig")
1250
+ multisig: resolveAccount("multisig"),
1251
+ rentSysvar: resolveAccount("rentSysvar")
690
1252
  },
691
1253
  SplTokenMintToCheckedInstruction: {
692
1254
  account: resolveAccount("account"),
@@ -739,6 +1301,7 @@ var instructionResolvers = {
739
1301
  },
740
1302
  StakeAuthorizeCheckedInstruction: {
741
1303
  authority: resolveAccount("authority"),
1304
+ clockSysvar: resolveAccount("clockSysvar"),
742
1305
  custodian: resolveAccount("custodian"),
743
1306
  newAuthority: resolveAccount("newAuthority"),
744
1307
  stakeAccount: resolveAccount("stakeAccount")
@@ -746,12 +1309,14 @@ var instructionResolvers = {
746
1309
  StakeAuthorizeCheckedWithSeedInstruction: {
747
1310
  authorityBase: resolveAccount("authorityBase"),
748
1311
  authorityOwner: resolveAccount("authorityOwner"),
1312
+ clockSysvar: resolveAccount("clockSysvar"),
749
1313
  custodian: resolveAccount("custodian"),
750
1314
  newAuthorized: resolveAccount("newAuthorized"),
751
1315
  stakeAccount: resolveAccount("stakeAccount")
752
1316
  },
753
1317
  StakeAuthorizeInstruction: {
754
1318
  authority: resolveAccount("authority"),
1319
+ clockSysvar: resolveAccount("clockSysvar"),
755
1320
  custodian: resolveAccount("custodian"),
756
1321
  newAuthority: resolveAccount("newAuthority"),
757
1322
  stakeAccount: resolveAccount("stakeAccount")
@@ -759,6 +1324,7 @@ var instructionResolvers = {
759
1324
  StakeAuthorizeWithSeedInstruction: {
760
1325
  authorityBase: resolveAccount("authorityBase"),
761
1326
  authorityOwner: resolveAccount("authorityOwner"),
1327
+ clockSysvar: resolveAccount("clockSysvar"),
762
1328
  custodian: resolveAccount("custodian"),
763
1329
  newAuthorized: resolveAccount("newAuthorized"),
764
1330
  stakeAccount: resolveAccount("stakeAccount")
@@ -769,20 +1335,28 @@ var instructionResolvers = {
769
1335
  voteAccount: resolveAccount("voteAccount")
770
1336
  },
771
1337
  StakeDeactivateInstruction: {
1338
+ clockSysvar: resolveAccount("clockSysvar"),
772
1339
  stakeAccount: resolveAccount("stakeAccount"),
773
1340
  stakeAuthority: resolveAccount("stakeAuthority")
774
1341
  },
775
1342
  StakeDelegateStakeInstruction: {
1343
+ clockSysvar: resolveAccount("clockSysvar"),
776
1344
  stakeAccount: resolveAccount("stakeAccount"),
777
1345
  stakeAuthority: resolveAccount("stakeAuthority"),
778
1346
  stakeConfigAccount: resolveAccount("stakeConfigAccount"),
1347
+ stakeHistorySysvar: resolveAccount("stakeHistorySysvar"),
779
1348
  voteAccount: resolveAccount("voteAccount")
780
1349
  },
1350
+ StakeInitializeCheckedInstruction: {
1351
+ rentSysvar: resolveAccount("rentSysvar"),
1352
+ stakeAccount: resolveAccount("stakeAccount")
1353
+ },
781
1354
  StakeInitializeCheckedInstructionDataAuthorized: {
782
1355
  staker: resolveAccount("staker"),
783
1356
  withdrawer: resolveAccount("withdrawer")
784
1357
  },
785
1358
  StakeInitializeInstruction: {
1359
+ rentSysvar: resolveAccount("rentSysvar"),
786
1360
  stakeAccount: resolveAccount("stakeAccount")
787
1361
  },
788
1362
  StakeInitializeInstructionDataAuthorized: {
@@ -790,9 +1364,11 @@ var instructionResolvers = {
790
1364
  withdrawer: resolveAccount("withdrawer")
791
1365
  },
792
1366
  StakeMergeInstruction: {
1367
+ clockSysvar: resolveAccount("clockSysvar"),
793
1368
  destination: resolveAccount("destination"),
794
1369
  source: resolveAccount("source"),
795
- stakeAuthority: resolveAccount("stakeAuthority")
1370
+ stakeAuthority: resolveAccount("stakeAuthority"),
1371
+ stakeHistorySysvar: resolveAccount("stakeHistorySysvar")
796
1372
  },
797
1373
  StakeRedelegateInstruction: {
798
1374
  newStakeAccount: resolveAccount("newStakeAccount"),
@@ -815,287 +1391,289 @@ var instructionResolvers = {
815
1391
  stakeAuthority: resolveAccount("stakeAuthority")
816
1392
  },
817
1393
  StakeWithdrawInstruction: {
1394
+ clockSysvar: resolveAccount("clockSysvar"),
818
1395
  destination: resolveAccount("destination"),
819
1396
  stakeAccount: resolveAccount("stakeAccount"),
820
1397
  withdrawAuthority: resolveAccount("withdrawAuthority")
821
1398
  },
822
1399
  TransactionInstruction: {
823
- __resolveType(instruction) {
824
- if (instruction.programName) {
825
- if (instruction.programName === "address-lookup-table") {
826
- if (instruction.instructionType === "createLookupTable") {
1400
+ __resolveType(instructionResult) {
1401
+ const { jsonParsedConfigs } = instructionResult;
1402
+ if (jsonParsedConfigs) {
1403
+ if (jsonParsedConfigs.programName === "address-lookup-table") {
1404
+ if (jsonParsedConfigs.instructionType === "createLookupTable") {
827
1405
  return "CreateLookupTableInstruction";
828
1406
  }
829
- if (instruction.instructionType === "freezeLookupTable") {
1407
+ if (jsonParsedConfigs.instructionType === "freezeLookupTable") {
830
1408
  return "FreezeLookupTableInstruction";
831
1409
  }
832
- if (instruction.instructionType === "extendLookupTable") {
1410
+ if (jsonParsedConfigs.instructionType === "extendLookupTable") {
833
1411
  return "ExtendLookupTableInstruction";
834
1412
  }
835
- if (instruction.instructionType === "deactivateLookupTable") {
1413
+ if (jsonParsedConfigs.instructionType === "deactivateLookupTable") {
836
1414
  return "DeactivateLookupTableInstruction";
837
1415
  }
838
- if (instruction.instructionType === "closeLookupTable") {
1416
+ if (jsonParsedConfigs.instructionType === "closeLookupTable") {
839
1417
  return "CloseLookupTableInstruction";
840
1418
  }
841
1419
  }
842
- if (instruction.programName === "bpf-loader") {
843
- if (instruction.instructionType === "write") {
1420
+ if (jsonParsedConfigs.programName === "bpf-loader") {
1421
+ if (jsonParsedConfigs.instructionType === "write") {
844
1422
  return "BpfLoaderWriteInstruction";
845
1423
  }
846
- if (instruction.instructionType === "finalize") {
1424
+ if (jsonParsedConfigs.instructionType === "finalize") {
847
1425
  return "BpfLoaderFinalizeInstruction";
848
1426
  }
849
1427
  }
850
- if (instruction.programName === "bpf-upgradeable-loader") {
851
- if (instruction.instructionType === "initializeBuffer") {
1428
+ if (jsonParsedConfigs.programName === "bpf-upgradeable-loader") {
1429
+ if (jsonParsedConfigs.instructionType === "initializeBuffer") {
852
1430
  return "BpfUpgradeableLoaderInitializeBufferInstruction";
853
1431
  }
854
- if (instruction.instructionType === "write") {
1432
+ if (jsonParsedConfigs.instructionType === "write") {
855
1433
  return "BpfUpgradeableLoaderWriteInstruction";
856
1434
  }
857
- if (instruction.instructionType === "deployWithMaxDataLen") {
1435
+ if (jsonParsedConfigs.instructionType === "deployWithMaxDataLen") {
858
1436
  return "BpfUpgradeableLoaderDeployWithMaxDataLenInstruction";
859
1437
  }
860
- if (instruction.instructionType === "upgrade") {
1438
+ if (jsonParsedConfigs.instructionType === "upgrade") {
861
1439
  return "BpfUpgradeableLoaderUpgradeInstruction";
862
1440
  }
863
- if (instruction.instructionType === "setAuthority") {
1441
+ if (jsonParsedConfigs.instructionType === "setAuthority") {
864
1442
  return "BpfUpgradeableLoaderSetAuthorityInstruction";
865
1443
  }
866
- if (instruction.instructionType === "setAuthorityChecked") {
1444
+ if (jsonParsedConfigs.instructionType === "setAuthorityChecked") {
867
1445
  return "BpfUpgradeableLoaderSetAuthorityCheckedInstruction";
868
1446
  }
869
- if (instruction.instructionType === "close") {
1447
+ if (jsonParsedConfigs.instructionType === "close") {
870
1448
  return "BpfUpgradeableLoaderCloseInstruction";
871
1449
  }
872
- if (instruction.instructionType === "extendProgram") {
1450
+ if (jsonParsedConfigs.instructionType === "extendProgram") {
873
1451
  return "BpfUpgradeableLoaderExtendProgramInstruction";
874
1452
  }
875
1453
  }
876
- if (instruction.programName === "spl-associated-token-account") {
877
- if (instruction.instructionType === "create") {
1454
+ if (jsonParsedConfigs.programName === "spl-associated-token-account") {
1455
+ if (jsonParsedConfigs.instructionType === "create") {
878
1456
  return "SplAssociatedTokenCreateInstruction";
879
1457
  }
880
- if (instruction.instructionType === "createIdempotent") {
1458
+ if (jsonParsedConfigs.instructionType === "createIdempotent") {
881
1459
  return "SplAssociatedTokenCreateIdempotentInstruction";
882
1460
  }
883
- if (instruction.instructionType === "recoverNested") {
1461
+ if (jsonParsedConfigs.instructionType === "recoverNested") {
884
1462
  return "SplAssociatedTokenRecoverNestedInstruction";
885
1463
  }
886
1464
  }
887
- if (instruction.programName === "spl-memo") {
1465
+ if (jsonParsedConfigs.programName === "spl-memo") {
888
1466
  return "SplMemoInstruction";
889
1467
  }
890
- if (instruction.programName === "spl-token") {
891
- if (instruction.instructionType === "initializeMint") {
1468
+ if (jsonParsedConfigs.programName === "spl-token") {
1469
+ if (jsonParsedConfigs.instructionType === "initializeMint") {
892
1470
  return "SplTokenInitializeMintInstruction";
893
1471
  }
894
- if (instruction.instructionType === "initializeMint2") {
1472
+ if (jsonParsedConfigs.instructionType === "initializeMint2") {
895
1473
  return "SplTokenInitializeMint2Instruction";
896
1474
  }
897
- if (instruction.instructionType === "initializeAccount") {
1475
+ if (jsonParsedConfigs.instructionType === "initializeAccount") {
898
1476
  return "SplTokenInitializeAccountInstruction";
899
1477
  }
900
- if (instruction.instructionType === "initializeAccount2") {
1478
+ if (jsonParsedConfigs.instructionType === "initializeAccount2") {
901
1479
  return "SplTokenInitializeAccount2Instruction";
902
1480
  }
903
- if (instruction.instructionType === "initializeAccount3") {
1481
+ if (jsonParsedConfigs.instructionType === "initializeAccount3") {
904
1482
  return "SplTokenInitializeAccount3Instruction";
905
1483
  }
906
- if (instruction.instructionType === "initializeMultisig") {
1484
+ if (jsonParsedConfigs.instructionType === "initializeMultisig") {
907
1485
  return "SplTokenInitializeMultisigInstruction";
908
1486
  }
909
- if (instruction.instructionType === "initializeMultisig2") {
1487
+ if (jsonParsedConfigs.instructionType === "initializeMultisig2") {
910
1488
  return "SplTokenInitializeMultisig2Instruction";
911
1489
  }
912
- if (instruction.instructionType === "transfer") {
1490
+ if (jsonParsedConfigs.instructionType === "transfer") {
913
1491
  return "SplTokenTransferInstruction";
914
1492
  }
915
- if (instruction.instructionType === "approve") {
1493
+ if (jsonParsedConfigs.instructionType === "approve") {
916
1494
  return "SplTokenApproveInstruction";
917
1495
  }
918
- if (instruction.instructionType === "revoke") {
1496
+ if (jsonParsedConfigs.instructionType === "revoke") {
919
1497
  return "SplTokenRevokeInstruction";
920
1498
  }
921
- if (instruction.instructionType === "setAuthority") {
1499
+ if (jsonParsedConfigs.instructionType === "setAuthority") {
922
1500
  return "SplTokenSetAuthorityInstruction";
923
1501
  }
924
- if (instruction.instructionType === "mintTo") {
1502
+ if (jsonParsedConfigs.instructionType === "mintTo") {
925
1503
  return "SplTokenMintToInstruction";
926
1504
  }
927
- if (instruction.instructionType === "burn") {
1505
+ if (jsonParsedConfigs.instructionType === "burn") {
928
1506
  return "SplTokenBurnInstruction";
929
1507
  }
930
- if (instruction.instructionType === "closeAccount") {
1508
+ if (jsonParsedConfigs.instructionType === "closeAccount") {
931
1509
  return "SplTokenCloseAccountInstruction";
932
1510
  }
933
- if (instruction.instructionType === "freezeAccount") {
1511
+ if (jsonParsedConfigs.instructionType === "freezeAccount") {
934
1512
  return "SplTokenFreezeAccountInstruction";
935
1513
  }
936
- if (instruction.instructionType === "thawAccount") {
1514
+ if (jsonParsedConfigs.instructionType === "thawAccount") {
937
1515
  return "SplTokenThawAccountInstruction";
938
1516
  }
939
- if (instruction.instructionType === "transferChecked") {
1517
+ if (jsonParsedConfigs.instructionType === "transferChecked") {
940
1518
  return "SplTokenTransferCheckedInstruction";
941
1519
  }
942
- if (instruction.instructionType === "approveChecked") {
1520
+ if (jsonParsedConfigs.instructionType === "approveChecked") {
943
1521
  return "SplTokenApproveCheckedInstruction";
944
1522
  }
945
- if (instruction.instructionType === "mintToChecked") {
1523
+ if (jsonParsedConfigs.instructionType === "mintToChecked") {
946
1524
  return "SplTokenMintToCheckedInstruction";
947
1525
  }
948
- if (instruction.instructionType === "burnChecked") {
1526
+ if (jsonParsedConfigs.instructionType === "burnChecked") {
949
1527
  return "SplTokenBurnCheckedInstruction";
950
1528
  }
951
- if (instruction.instructionType === "syncNative") {
1529
+ if (jsonParsedConfigs.instructionType === "syncNative") {
952
1530
  return "SplTokenSyncNativeInstruction";
953
1531
  }
954
- if (instruction.instructionType === "getAccountDataSize") {
1532
+ if (jsonParsedConfigs.instructionType === "getAccountDataSize") {
955
1533
  return "SplTokenGetAccountDataSizeInstruction";
956
1534
  }
957
- if (instruction.instructionType === "initializeImmutableOwner") {
1535
+ if (jsonParsedConfigs.instructionType === "initializeImmutableOwner") {
958
1536
  return "SplTokenInitializeImmutableOwnerInstruction";
959
1537
  }
960
- if (instruction.instructionType === "amountToUiAmount") {
1538
+ if (jsonParsedConfigs.instructionType === "amountToUiAmount") {
961
1539
  return "SplTokenAmountToUiAmountInstruction";
962
1540
  }
963
- if (instruction.instructionType === "uiAmountToAmount") {
1541
+ if (jsonParsedConfigs.instructionType === "uiAmountToAmount") {
964
1542
  return "SplTokenUiAmountToAmountInstruction";
965
1543
  }
966
- if (instruction.instructionType === "initializeMintCloseAuthority") {
1544
+ if (jsonParsedConfigs.instructionType === "initializeMintCloseAuthority") {
967
1545
  return "SplTokenInitializeMintCloseAuthorityInstruction";
968
1546
  }
969
1547
  }
970
- if (instruction.programName === "stake") {
971
- if (instruction.instructionType === "initialize") {
1548
+ if (jsonParsedConfigs.programName === "stake") {
1549
+ if (jsonParsedConfigs.instructionType === "initialize") {
972
1550
  return "StakeInitializeInstruction";
973
1551
  }
974
- if (instruction.instructionType === "authorize") {
1552
+ if (jsonParsedConfigs.instructionType === "authorize") {
975
1553
  return "StakeAuthorizeInstruction";
976
1554
  }
977
- if (instruction.instructionType === "delegate") {
1555
+ if (jsonParsedConfigs.instructionType === "delegate") {
978
1556
  return "StakeDelegateStakeInstruction";
979
1557
  }
980
- if (instruction.instructionType === "split") {
1558
+ if (jsonParsedConfigs.instructionType === "split") {
981
1559
  return "StakeSplitInstruction";
982
1560
  }
983
- if (instruction.instructionType === "withdraw") {
1561
+ if (jsonParsedConfigs.instructionType === "withdraw") {
984
1562
  return "StakeWithdrawInstruction";
985
1563
  }
986
- if (instruction.instructionType === "deactivate") {
1564
+ if (jsonParsedConfigs.instructionType === "deactivate") {
987
1565
  return "StakeDeactivateInstruction";
988
1566
  }
989
- if (instruction.instructionType === "setLockup") {
1567
+ if (jsonParsedConfigs.instructionType === "setLockup") {
990
1568
  return "StakeSetLockupInstruction";
991
1569
  }
992
- if (instruction.instructionType === "merge") {
1570
+ if (jsonParsedConfigs.instructionType === "merge") {
993
1571
  return "StakeMergeInstruction";
994
1572
  }
995
- if (instruction.instructionType === "authorizeWithSeed") {
1573
+ if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
996
1574
  return "StakeAuthorizeWithSeedInstruction";
997
1575
  }
998
- if (instruction.instructionType === "initializeChecked") {
1576
+ if (jsonParsedConfigs.instructionType === "initializeChecked") {
999
1577
  return "StakeInitializeCheckedInstruction";
1000
1578
  }
1001
- if (instruction.instructionType === "authorizeChecked") {
1579
+ if (jsonParsedConfigs.instructionType === "authorizeChecked") {
1002
1580
  return "StakeAuthorizeCheckedInstruction";
1003
1581
  }
1004
- if (instruction.instructionType === "authorizeCheckedWithSeed") {
1582
+ if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
1005
1583
  return "StakeAuthorizeCheckedWithSeedInstruction";
1006
1584
  }
1007
- if (instruction.instructionType === "setLockupChecked") {
1585
+ if (jsonParsedConfigs.instructionType === "setLockupChecked") {
1008
1586
  return "StakeSetLockupCheckedInstruction";
1009
1587
  }
1010
- if (instruction.instructionType === "deactivateDelinquent") {
1588
+ if (jsonParsedConfigs.instructionType === "deactivateDelinquent") {
1011
1589
  return "StakeDeactivateDelinquentInstruction";
1012
1590
  }
1013
- if (instruction.instructionType === "redelegate") {
1591
+ if (jsonParsedConfigs.instructionType === "redelegate") {
1014
1592
  return "StakeRedelegateInstruction";
1015
1593
  }
1016
1594
  }
1017
- if (instruction.programName === "system") {
1018
- if (instruction.instructionType === "createAccount") {
1595
+ if (jsonParsedConfigs.programName === "system") {
1596
+ if (jsonParsedConfigs.instructionType === "createAccount") {
1019
1597
  return "CreateAccountInstruction";
1020
1598
  }
1021
- if (instruction.instructionType === "assign") {
1599
+ if (jsonParsedConfigs.instructionType === "assign") {
1022
1600
  return "AssignInstruction";
1023
1601
  }
1024
- if (instruction.instructionType === "transfer") {
1602
+ if (jsonParsedConfigs.instructionType === "transfer") {
1025
1603
  return "TransferInstruction";
1026
1604
  }
1027
- if (instruction.instructionType === "createAccountWithSeed") {
1605
+ if (jsonParsedConfigs.instructionType === "createAccountWithSeed") {
1028
1606
  return "CreateAccountWithSeedInstruction";
1029
1607
  }
1030
- if (instruction.instructionType === "advanceNonceAccount") {
1608
+ if (jsonParsedConfigs.instructionType === "advanceNonceAccount") {
1031
1609
  return "AdvanceNonceAccountInstruction";
1032
1610
  }
1033
- if (instruction.instructionType === "withdrawNonceAccount") {
1611
+ if (jsonParsedConfigs.instructionType === "withdrawNonceAccount") {
1034
1612
  return "WithdrawNonceAccountInstruction";
1035
1613
  }
1036
- if (instruction.instructionType === "initializeNonceAccount") {
1614
+ if (jsonParsedConfigs.instructionType === "initializeNonceAccount") {
1037
1615
  return "InitializeNonceAccountInstruction";
1038
1616
  }
1039
- if (instruction.instructionType === "authorizeNonceAccount") {
1617
+ if (jsonParsedConfigs.instructionType === "authorizeNonceAccount") {
1040
1618
  return "AuthorizeNonceAccountInstruction";
1041
1619
  }
1042
- if (instruction.instructionType === "upgradeNonceAccount") {
1620
+ if (jsonParsedConfigs.instructionType === "upgradeNonceAccount") {
1043
1621
  return "UpgradeNonceAccountInstruction";
1044
1622
  }
1045
- if (instruction.instructionType === "allocate") {
1623
+ if (jsonParsedConfigs.instructionType === "allocate") {
1046
1624
  return "AllocateInstruction";
1047
1625
  }
1048
- if (instruction.instructionType === "allocateWithSeed") {
1626
+ if (jsonParsedConfigs.instructionType === "allocateWithSeed") {
1049
1627
  return "AllocateWithSeedInstruction";
1050
1628
  }
1051
- if (instruction.instructionType === "assignWithSeed") {
1629
+ if (jsonParsedConfigs.instructionType === "assignWithSeed") {
1052
1630
  return "AssignWithSeedInstruction";
1053
1631
  }
1054
- if (instruction.instructionType === "transferWithSeed") {
1632
+ if (jsonParsedConfigs.instructionType === "transferWithSeed") {
1055
1633
  return "TransferWithSeedInstruction";
1056
1634
  }
1057
1635
  }
1058
- if (instruction.programName === "vote") {
1059
- if (instruction.instructionType === "initialize") {
1636
+ if (jsonParsedConfigs.programName === "vote") {
1637
+ if (jsonParsedConfigs.instructionType === "initialize") {
1060
1638
  return "VoteInitializeAccountInstruction";
1061
1639
  }
1062
- if (instruction.instructionType === "authorize") {
1640
+ if (jsonParsedConfigs.instructionType === "authorize") {
1063
1641
  return "VoteAuthorizeInstruction";
1064
1642
  }
1065
- if (instruction.instructionType === "authorizeWithSeed") {
1643
+ if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
1066
1644
  return "VoteAuthorizeWithSeedInstruction";
1067
1645
  }
1068
- if (instruction.instructionType === "authorizeCheckedWithSeed") {
1646
+ if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
1069
1647
  return "VoteAuthorizeCheckedWithSeedInstruction";
1070
1648
  }
1071
- if (instruction.instructionType === "vote") {
1649
+ if (jsonParsedConfigs.instructionType === "vote") {
1072
1650
  return "VoteVoteInstruction";
1073
1651
  }
1074
- if (instruction.instructionType === "updatevotestate") {
1652
+ if (jsonParsedConfigs.instructionType === "updatevotestate") {
1075
1653
  return "VoteUpdateVoteStateInstruction";
1076
1654
  }
1077
- if (instruction.instructionType === "updatevotestateswitch") {
1655
+ if (jsonParsedConfigs.instructionType === "updatevotestateswitch") {
1078
1656
  return "VoteUpdateVoteStateSwitchInstruction";
1079
1657
  }
1080
- if (instruction.instructionType === "compactupdatevotestate") {
1658
+ if (jsonParsedConfigs.instructionType === "compactupdatevotestate") {
1081
1659
  return "VoteCompactUpdateVoteStateInstruction";
1082
1660
  }
1083
- if (instruction.instructionType === "compactupdatevotestateswitch") {
1661
+ if (jsonParsedConfigs.instructionType === "compactupdatevotestateswitch") {
1084
1662
  return "VoteCompactUpdateVoteStateSwitchInstruction";
1085
1663
  }
1086
- if (instruction.instructionType === "withdraw") {
1664
+ if (jsonParsedConfigs.instructionType === "withdraw") {
1087
1665
  return "VoteWithdrawInstruction";
1088
1666
  }
1089
- if (instruction.instructionType === "updateValidatorIdentity") {
1667
+ if (jsonParsedConfigs.instructionType === "updateValidatorIdentity") {
1090
1668
  return "VoteUpdateValidatorIdentityInstruction";
1091
1669
  }
1092
- if (instruction.instructionType === "updateCommission") {
1670
+ if (jsonParsedConfigs.instructionType === "updateCommission") {
1093
1671
  return "VoteUpdateCommissionInstruction";
1094
1672
  }
1095
- if (instruction.instructionType === "voteSwitch") {
1673
+ if (jsonParsedConfigs.instructionType === "voteSwitch") {
1096
1674
  return "VoteVoteSwitchInstruction";
1097
1675
  }
1098
- if (instruction.instructionType === "authorizeChecked") {
1676
+ if (jsonParsedConfigs.instructionType === "authorizeChecked") {
1099
1677
  return "VoteAuthorizeCheckedInstruction";
1100
1678
  }
1101
1679
  }
@@ -1118,21 +1696,25 @@ var instructionResolvers = {
1118
1696
  },
1119
1697
  VoteAuthorizeCheckedInstruction: {
1120
1698
  authority: resolveAccount("authority"),
1699
+ clockSysvar: resolveAccount("clockSysvar"),
1121
1700
  newAuthority: resolveAccount("newAuthority"),
1122
1701
  voteAccount: resolveAccount("voteAccount")
1123
1702
  },
1124
1703
  VoteAuthorizeCheckedWithSeedInstruction: {
1125
1704
  authorityOwner: resolveAccount("authorityOwner"),
1705
+ clockSysvar: resolveAccount("clockSysvar"),
1126
1706
  newAuthority: resolveAccount("newAuthority"),
1127
1707
  voteAccount: resolveAccount("voteAccount")
1128
1708
  },
1129
1709
  VoteAuthorizeInstruction: {
1130
1710
  authority: resolveAccount("authority"),
1711
+ clockSysvar: resolveAccount("clockSysvar"),
1131
1712
  newAuthority: resolveAccount("newAuthority"),
1132
1713
  voteAccount: resolveAccount("voteAccount")
1133
1714
  },
1134
1715
  VoteAuthorizeWithSeedInstruction: {
1135
1716
  authorityOwner: resolveAccount("authorityOwner"),
1717
+ clockSysvar: resolveAccount("clockSysvar"),
1136
1718
  newAuthority: resolveAccount("newAuthority"),
1137
1719
  voteAccount: resolveAccount("voteAccount")
1138
1720
  },
@@ -1147,7 +1729,9 @@ var instructionResolvers = {
1147
1729
  VoteInitializeAccountInstruction: {
1148
1730
  authorizedVoter: resolveAccount("authorizedVoter"),
1149
1731
  authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
1732
+ clockSysvar: resolveAccount("clockSysvar"),
1150
1733
  node: resolveAccount("node"),
1734
+ rentSysvar: resolveAccount("rentSysvar"),
1151
1735
  voteAccount: resolveAccount("voteAccount")
1152
1736
  },
1153
1737
  VoteUpdateCommissionInstruction: {
@@ -1168,10 +1752,14 @@ var instructionResolvers = {
1168
1752
  voteAuthority: resolveAccount("voteAuthority")
1169
1753
  },
1170
1754
  VoteVoteInstruction: {
1755
+ clockSysvar: resolveAccount("clockSysvar"),
1756
+ slotHashesSysvar: resolveAccount("slotHashesSysvar"),
1171
1757
  voteAccount: resolveAccount("voteAccount"),
1172
1758
  voteAuthority: resolveAccount("voteAuthority")
1173
1759
  },
1174
1760
  VoteVoteSwitchInstruction: {
1761
+ clockSysvar: resolveAccount("clockSysvar"),
1762
+ slotHashesSysvar: resolveAccount("slotHashesSysvar"),
1175
1763
  voteAccount: resolveAccount("voteAccount"),
1176
1764
  voteAuthority: resolveAccount("voteAuthority")
1177
1765
  },
@@ -1182,7 +1770,9 @@ var instructionResolvers = {
1182
1770
  WithdrawNonceAccountInstruction: {
1183
1771
  destination: resolveAccount("destination"),
1184
1772
  nonceAccount: resolveAccount("nonceAccount"),
1185
- nonceAuthority: resolveAccount("nonceAuthority")
1773
+ nonceAuthority: resolveAccount("nonceAuthority"),
1774
+ recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
1775
+ rentSysvar: resolveAccount("rentSysvar")
1186
1776
  }
1187
1777
  };
1188
1778
 
@@ -1190,20 +1780,57 @@ var instructionResolvers = {
1190
1780
  function resolveProgramAccounts(fieldName) {
1191
1781
  return async (parent, args, context, info) => {
1192
1782
  const programAddress = fieldName ? parent[fieldName] : args.programAddress;
1193
- if (!programAddress) {
1194
- return null;
1195
- }
1196
- if (onlyPresentFieldRequested("programAddress", info)) {
1197
- return { programAddress };
1198
- }
1199
- const programAccounts = await context.loaders.programAccounts.load({ ...args, programAddress });
1200
- return programAccounts === null ? { programAddress } : programAccounts.map(
1201
- (programAccount) => transformLoadedAccount({
1202
- account: programAccount.account,
1203
- address: programAccount.pubkey,
1204
- encoding: args.encoding
1205
- })
1206
- );
1783
+ if (programAddress) {
1784
+ const argsSet = buildProgramAccountsLoaderArgSetFromResolveInfo({ ...args, programAddress }, info);
1785
+ const loadedProgramAccountsLists = await context.loaders.programAccounts.loadMany(argsSet);
1786
+ const result = {};
1787
+ loadedProgramAccountsLists.forEach((programAccounts, i) => {
1788
+ if (programAccounts instanceof Error) {
1789
+ console.error(programAccounts);
1790
+ return;
1791
+ }
1792
+ programAccounts.forEach((programAccount) => {
1793
+ const { account, pubkey: address } = programAccount;
1794
+ const thisResult = result[address] ||= {
1795
+ ...account,
1796
+ address,
1797
+ encodedData: {},
1798
+ ownerProgram: account.owner
1799
+ };
1800
+ const { data } = account;
1801
+ const { encoding, dataSlice } = argsSet[i];
1802
+ if (encoding && thisResult.encodedData) {
1803
+ if (Array.isArray(data)) {
1804
+ thisResult.encodedData[cacheKeyFn({
1805
+ dataSlice,
1806
+ encoding: encoding === "jsonParsed" ? "base64" : encoding
1807
+ })] = data[0];
1808
+ } else if (typeof data === "string") {
1809
+ thisResult.encodedData[cacheKeyFn({
1810
+ dataSlice,
1811
+ encoding: "base58"
1812
+ })] = data;
1813
+ } else if (typeof data === "object") {
1814
+ const {
1815
+ parsed: { info: parsedData, type: accountType },
1816
+ program: programName,
1817
+ programId
1818
+ } = data;
1819
+ thisResult.jsonParsedConfigs = {
1820
+ accountType,
1821
+ programId,
1822
+ programName
1823
+ };
1824
+ for (const key in parsedData) {
1825
+ thisResult[key] = parsedData[key];
1826
+ }
1827
+ }
1828
+ }
1829
+ });
1830
+ });
1831
+ return Object.values(result);
1832
+ }
1833
+ return null;
1207
1834
  };
1208
1835
  }
1209
1836
 
@@ -1230,47 +1857,49 @@ var stringScalarAlias = {
1230
1857
  return value;
1231
1858
  }
1232
1859
  };
1233
- var scalarResolvers = {
1234
- Address: stringScalarAlias,
1235
- Base58EncodedBytes: stringScalarAlias,
1236
- Base64EncodedBytes: stringScalarAlias,
1237
- Base64ZstdEncodedBytes: stringScalarAlias,
1238
- BigInt: {
1239
- __parseLiteral(ast) {
1240
- if (ast.kind === Kind.STRING) {
1241
- return BigInt(ast.value);
1242
- }
1243
- return null;
1244
- },
1245
- __parseValue(value) {
1246
- return BigInt(value);
1247
- },
1248
- __serialize(value) {
1249
- return BigInt(value);
1860
+ var bigIntScalarAlias = {
1861
+ __parseLiteral(ast) {
1862
+ if (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {
1863
+ return BigInt(ast.value);
1250
1864
  }
1865
+ return null;
1866
+ },
1867
+ __parseValue(value) {
1868
+ return BigInt(value);
1869
+ },
1870
+ __serialize(value) {
1871
+ return BigInt(value);
1251
1872
  }
1252
1873
  };
1253
-
1254
- // src/resolvers/types.ts
1255
- var commonTypeResolvers = {
1874
+ var typeTypeResolvers = {
1256
1875
  AccountEncoding: {
1257
1876
  BASE_58: "base58",
1258
1877
  BASE_64: "base64",
1259
- BASE_64_ZSTD: "base64+zstd",
1260
- PARSED: "jsonParsed"
1878
+ BASE_64_ZSTD: "base64+zstd"
1261
1879
  },
1880
+ Address: stringScalarAlias,
1881
+ Base58EncodedBytes: stringScalarAlias,
1882
+ Base64EncodedBytes: stringScalarAlias,
1883
+ Base64ZstdEncodedBytes: stringScalarAlias,
1884
+ BigInt: bigIntScalarAlias,
1885
+ Commitment: {
1886
+ CONFIRMED: "confirmed",
1887
+ FINALIZED: "finalized",
1888
+ PROCESSED: "processed"
1889
+ },
1890
+ CommitmentWithoutProcessed: {
1891
+ CONFIRMED: "confirmed",
1892
+ FINALIZED: "finalized"
1893
+ },
1894
+ Signature: stringScalarAlias,
1895
+ Slot: bigIntScalarAlias,
1262
1896
  TokenBalance: {
1263
1897
  mint: resolveAccount("mint"),
1264
1898
  owner: resolveAccount("owner")
1265
1899
  },
1266
1900
  TransactionEncoding: {
1267
1901
  BASE_58: "base58",
1268
- BASE_64: "base64",
1269
- PARSED: "jsonParsed"
1270
- },
1271
- TransactionVersion: {
1272
- LEGACY: "legacy",
1273
- ZERO: 0
1902
+ BASE_64: "base64"
1274
1903
  }
1275
1904
  };
1276
1905
 
@@ -1279,11 +1908,10 @@ function createSolanaGraphQLResolvers() {
1279
1908
  return {
1280
1909
  ...accountResolvers,
1281
1910
  ...blockResolvers,
1282
- ...commonTypeResolvers,
1283
1911
  ...instructionResolvers,
1284
1912
  ...rootResolvers,
1285
- ...scalarResolvers,
1286
- ...transactionResolvers
1913
+ ...transactionResolvers,
1914
+ ...typeTypeResolvers
1287
1915
  };
1288
1916
  }
1289
1917
 
@@ -1296,6 +1924,7 @@ var accountTypeDefs = (
1296
1924
  """
1297
1925
  interface Account {
1298
1926
  address: Address
1927
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1299
1928
  executable: Boolean
1300
1929
  lamports: BigInt
1301
1930
  ownerProgram: Account
@@ -1304,37 +1933,11 @@ var accountTypeDefs = (
1304
1933
  }
1305
1934
 
1306
1935
  """
1307
- An account with base58 encoded data
1936
+ Generic base account type
1308
1937
  """
1309
- type AccountBase58 implements Account {
1938
+ type GenericAccount implements Account {
1310
1939
  address: Address
1311
- data: Base58EncodedBytes
1312
- executable: Boolean
1313
- lamports: BigInt
1314
- ownerProgram: Account
1315
- space: BigInt
1316
- rentEpoch: BigInt
1317
- }
1318
-
1319
- """
1320
- An account with base64 encoded data
1321
- """
1322
- type AccountBase64 implements Account {
1323
- address: Address
1324
- data: Base64EncodedBytes
1325
- executable: Boolean
1326
- lamports: BigInt
1327
- ownerProgram: Account
1328
- space: BigInt
1329
- rentEpoch: BigInt
1330
- }
1331
-
1332
- """
1333
- An account with base64+zstd encoded data
1334
- """
1335
- type AccountBase64Zstd implements Account {
1336
- address: Address
1337
- data: Base64ZstdEncodedBytes
1940
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1338
1941
  executable: Boolean
1339
1942
  lamports: BigInt
1340
1943
  ownerProgram: Account
@@ -1350,6 +1953,7 @@ var accountTypeDefs = (
1350
1953
  """
1351
1954
  type NonceAccount implements Account {
1352
1955
  address: Address
1956
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1353
1957
  executable: Boolean
1354
1958
  lamports: BigInt
1355
1959
  ownerProgram: Account
@@ -1365,6 +1969,7 @@ var accountTypeDefs = (
1365
1969
  """
1366
1970
  type LookupTableAccount implements Account {
1367
1971
  address: Address
1972
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1368
1973
  executable: Boolean
1369
1974
  lamports: BigInt
1370
1975
  ownerProgram: Account
@@ -1382,6 +1987,7 @@ var accountTypeDefs = (
1382
1987
  """
1383
1988
  type MintAccount implements Account {
1384
1989
  address: Address
1990
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1385
1991
  executable: Boolean
1386
1992
  lamports: BigInt
1387
1993
  ownerProgram: Account
@@ -1399,6 +2005,7 @@ var accountTypeDefs = (
1399
2005
  """
1400
2006
  type TokenAccount implements Account {
1401
2007
  address: Address
2008
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1402
2009
  executable: Boolean
1403
2010
  lamports: BigInt
1404
2011
  ownerProgram: Account
@@ -1441,6 +2048,7 @@ var accountTypeDefs = (
1441
2048
  """
1442
2049
  type StakeAccount implements Account {
1443
2050
  address: Address
2051
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1444
2052
  executable: Boolean
1445
2053
  lamports: BigInt
1446
2054
  ownerProgram: Account
@@ -1472,6 +2080,7 @@ var accountTypeDefs = (
1472
2080
  """
1473
2081
  type VoteAccount implements Account {
1474
2082
  address: Address
2083
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1475
2084
  executable: Boolean
1476
2085
  lamports: BigInt
1477
2086
  ownerProgram: Account
@@ -1494,188 +2103,18 @@ var accountTypeDefs = (
1494
2103
  var blockTypeDefs = (
1495
2104
  /* GraphQL */
1496
2105
  `
1497
- type TransactionMetaForAccounts {
1498
- err: String
1499
- fee: BigInt
1500
- postBalances: [BigInt]
1501
- postTokenBalances: [TokenBalance]
1502
- preBalances: [BigInt]
1503
- preTokenBalances: [TokenBalance]
1504
- status: TransactionStatus
1505
- }
1506
-
1507
- type TransactionDataForAccounts {
1508
- accountKeys: [Address]
1509
- signatures: [String]
1510
- }
1511
-
1512
- type BlockTransactionAccounts {
1513
- meta: TransactionMetaForAccounts
1514
- data: TransactionDataForAccounts
1515
- version: String
1516
- }
1517
-
1518
2106
  """
1519
- Block interface
2107
+ A Solana block
1520
2108
  """
1521
- interface Block {
2109
+ type Block {
1522
2110
  blockhash: String
1523
2111
  blockHeight: BigInt
1524
2112
  blockTime: BigInt
1525
- parentSlot: BigInt
1526
- previousBlockhash: String
1527
- rewards: [Reward]
1528
- transactionDetails: String
1529
- }
1530
-
1531
- """
1532
- A block with account transaction details
1533
- """
1534
- type BlockWithAccounts implements Block {
1535
- blockhash: String
1536
- blockHeight: BigInt
1537
- blockTime: BigInt
1538
- parentSlot: BigInt
1539
- previousBlockhash: String
1540
- rewards: [Reward]
1541
- transactions: [BlockTransactionAccounts]
1542
- transactionDetails: String
1543
- }
1544
-
1545
- """
1546
- A block with full transaction details
1547
- """
1548
- type BlockWithFull implements Block {
1549
- blockhash: String
1550
- blockHeight: BigInt
1551
- blockTime: BigInt
1552
- parentSlot: BigInt
2113
+ parentSlot: Slot
1553
2114
  previousBlockhash: String
1554
2115
  rewards: [Reward]
2116
+ signatures: [Signature]
1555
2117
  transactions: [Transaction]
1556
- transactionDetails: String
1557
- }
1558
-
1559
- """
1560
- A block with no transaction details
1561
- """
1562
- type BlockWithNone implements Block {
1563
- blockhash: String
1564
- blockHeight: BigInt
1565
- blockTime: BigInt
1566
- parentSlot: BigInt
1567
- previousBlockhash: String
1568
- rewards: [Reward]
1569
- transactionDetails: String
1570
- }
1571
-
1572
- """
1573
- A block with signature transaction details
1574
- """
1575
- type BlockWithSignatures implements Block {
1576
- blockhash: String
1577
- blockHeight: BigInt
1578
- blockTime: BigInt
1579
- parentSlot: BigInt
1580
- previousBlockhash: String
1581
- rewards: [Reward]
1582
- signatures: [String]
1583
- transactionDetails: String
1584
- }
1585
- `
1586
- );
1587
-
1588
- // src/schema/common/inputs.ts
1589
- var inputTypeDefs = (
1590
- /* GraphQL */
1591
- `
1592
- input DataSlice {
1593
- offset: Int
1594
- length: Int
1595
- }
1596
-
1597
- input ProgramAccountsFilter {
1598
- bytes: BigInt
1599
- dataSize: BigInt
1600
- encoding: AccountEncoding
1601
- offset: BigInt
1602
- }
1603
- `
1604
- );
1605
-
1606
- // src/schema/common/scalars.ts
1607
- var scalarTypeDefs = (
1608
- /* GraphQL */
1609
- `
1610
- scalar Address
1611
- scalar Base58EncodedBytes
1612
- scalar Base64EncodedBytes
1613
- scalar Base64ZstdEncodedBytes
1614
- scalar BigInt
1615
- `
1616
- );
1617
-
1618
- // src/schema/common/types.ts
1619
- var commonTypeDefs = (
1620
- /* GraphQL */
1621
- `
1622
- enum AccountEncoding {
1623
- BASE_58
1624
- BASE_64
1625
- BASE_64_ZSTD
1626
- PARSED
1627
- }
1628
-
1629
- enum BlockTransactionDetails {
1630
- accounts
1631
- full
1632
- none
1633
- signatures
1634
- }
1635
-
1636
- enum Commitment {
1637
- confirmed
1638
- finalized
1639
- processed
1640
- }
1641
-
1642
- type ReturnData {
1643
- data: Base64EncodedBytes
1644
- programId: Address
1645
- }
1646
-
1647
- type Reward {
1648
- commission: Int
1649
- lamports: BigInt
1650
- postBalance: BigInt
1651
- pubkey: Address
1652
- rewardType: String
1653
- }
1654
-
1655
- type TokenAmount {
1656
- amount: String
1657
- decimals: Int
1658
- uiAmount: BigInt
1659
- uiAmountString: String
1660
- }
1661
-
1662
- type TokenBalance {
1663
- accountIndex: Int
1664
- mint: Account
1665
- owner: Account
1666
- programId: Address
1667
- uiTokenAmount: TokenAmount
1668
- }
1669
-
1670
- enum TransactionEncoding {
1671
- BASE_58
1672
- BASE_64
1673
- PARSED
1674
- }
1675
-
1676
- enum TransactionVersion {
1677
- LEGACY
1678
- ZERO
1679
2118
  }
1680
2119
  `
1681
2120
  );
@@ -1797,12 +2236,12 @@ var instructionTypeDefs = (
1797
2236
  programId: Address
1798
2237
  authority: Account
1799
2238
  bufferAccount: Account
1800
- clockSysvar: Address
2239
+ clockSysvar: Account
1801
2240
  maxDataLen: BigInt
1802
2241
  payerAccount: Account
1803
2242
  programAccount: Account
1804
2243
  programDataAccount: Account
1805
- rentSysvar: Address
2244
+ rentSysvar: Account
1806
2245
  }
1807
2246
 
1808
2247
  """
@@ -1812,10 +2251,10 @@ var instructionTypeDefs = (
1812
2251
  programId: Address
1813
2252
  authority: Account
1814
2253
  bufferAccount: Account
1815
- clockSysvar: Address
2254
+ clockSysvar: Account
1816
2255
  programAccount: Account
1817
2256
  programDataAccount: Account
1818
- rentSysvar: Address
2257
+ rentSysvar: Account
1819
2258
  spillAccount: Account
1820
2259
  }
1821
2260
 
@@ -1868,7 +2307,7 @@ var instructionTypeDefs = (
1868
2307
  type SplAssociatedTokenCreateInstruction implements TransactionInstruction {
1869
2308
  programId: Address
1870
2309
  account: Account
1871
- mint: Address
2310
+ mint: Account
1872
2311
  source: Account
1873
2312
  systemProgram: Account
1874
2313
  tokenProgram: Account
@@ -1881,7 +2320,7 @@ var instructionTypeDefs = (
1881
2320
  type SplAssociatedTokenCreateIdempotentInstruction implements TransactionInstruction {
1882
2321
  programId: Address
1883
2322
  account: Account
1884
- mint: Address
2323
+ mint: Account
1885
2324
  source: Account
1886
2325
  systemProgram: Account
1887
2326
  tokenProgram: Account
@@ -1919,7 +2358,7 @@ var instructionTypeDefs = (
1919
2358
  freezeAuthority: Account
1920
2359
  mint: Account
1921
2360
  mintAuthority: Account
1922
- rentSysvar: Address
2361
+ rentSysvar: Account
1923
2362
  }
1924
2363
 
1925
2364
  """
@@ -1941,7 +2380,7 @@ var instructionTypeDefs = (
1941
2380
  account: Account
1942
2381
  mint: Account
1943
2382
  owner: Account
1944
- rentSysvar: Address
2383
+ rentSysvar: Account
1945
2384
  }
1946
2385
 
1947
2386
  """
@@ -1952,7 +2391,7 @@ var instructionTypeDefs = (
1952
2391
  account: Account
1953
2392
  mint: Account
1954
2393
  owner: Account
1955
- rentSysvar: Address
2394
+ rentSysvar: Account
1956
2395
  }
1957
2396
 
1958
2397
  """
@@ -1972,7 +2411,7 @@ var instructionTypeDefs = (
1972
2411
  programId: Address
1973
2412
  m: BigInt # FIXME:*
1974
2413
  multisig: Account
1975
- rentSysvar: Address
2414
+ rentSysvar: Account
1976
2415
  signers: [Address]
1977
2416
  }
1978
2417
 
@@ -2227,7 +2666,7 @@ var instructionTypeDefs = (
2227
2666
  programId: Address
2228
2667
  authorized: StakeInitializeInstructionDataAuthorized
2229
2668
  lockup: Lockup
2230
- rentSysvar: Address
2669
+ rentSysvar: Account
2231
2670
  stakeAccount: Account
2232
2671
  }
2233
2672
 
@@ -2238,7 +2677,7 @@ var instructionTypeDefs = (
2238
2677
  programId: Address
2239
2678
  authority: Account
2240
2679
  authorityType: String
2241
- clockSysvar: Address
2680
+ clockSysvar: Account
2242
2681
  custodian: Account
2243
2682
  newAuthority: Account
2244
2683
  stakeAccount: Account
@@ -2249,11 +2688,11 @@ var instructionTypeDefs = (
2249
2688
  """
2250
2689
  type StakeDelegateStakeInstruction implements TransactionInstruction {
2251
2690
  programId: Address
2252
- clockSysvar: Address
2691
+ clockSysvar: Account
2253
2692
  stakeAccount: Account
2254
2693
  stakeAuthority: Account
2255
2694
  stakeConfigAccount: Account
2256
- stakeHistorySysvar: Address
2695
+ stakeHistorySysvar: Account
2257
2696
  voteAccount: Account
2258
2697
  }
2259
2698
 
@@ -2273,7 +2712,7 @@ var instructionTypeDefs = (
2273
2712
  """
2274
2713
  type StakeWithdrawInstruction implements TransactionInstruction {
2275
2714
  programId: Address
2276
- clockSysvar: Address
2715
+ clockSysvar: Account
2277
2716
  destination: Account
2278
2717
  lamports: BigInt
2279
2718
  stakeAccount: Account
@@ -2285,7 +2724,7 @@ var instructionTypeDefs = (
2285
2724
  """
2286
2725
  type StakeDeactivateInstruction implements TransactionInstruction {
2287
2726
  programId: Address
2288
- clockSysvar: Address
2727
+ clockSysvar: Account
2289
2728
  stakeAccount: Account
2290
2729
  stakeAuthority: Account
2291
2730
  }
@@ -2305,11 +2744,11 @@ var instructionTypeDefs = (
2305
2744
  """
2306
2745
  type StakeMergeInstruction implements TransactionInstruction {
2307
2746
  programId: Address
2308
- clockSysvar: Address
2747
+ clockSysvar: Account
2309
2748
  destination: Account
2310
2749
  source: Account
2311
2750
  stakeAuthority: Account
2312
- stakeHistorySysvar: Address
2751
+ stakeHistorySysvar: Account
2313
2752
  }
2314
2753
 
2315
2754
  """
@@ -2321,7 +2760,7 @@ var instructionTypeDefs = (
2321
2760
  authorityOwner: Account
2322
2761
  authoritySeed: String
2323
2762
  authorityType: String
2324
- clockSysvar: Address
2763
+ clockSysvar: Account
2325
2764
  custodian: Account
2326
2765
  newAuthorized: Account
2327
2766
  stakeAccount: Account
@@ -2338,7 +2777,7 @@ var instructionTypeDefs = (
2338
2777
  programId: Address
2339
2778
  authorized: StakeInitializeCheckedInstructionDataAuthorized
2340
2779
  lockup: Lockup
2341
- rentSysvar: Address
2780
+ rentSysvar: Account
2342
2781
  stakeAccount: Account
2343
2782
  }
2344
2783
 
@@ -2349,7 +2788,7 @@ var instructionTypeDefs = (
2349
2788
  programId: Address
2350
2789
  authority: Account
2351
2790
  authorityType: String
2352
- clockSysvar: Address
2791
+ clockSysvar: Account
2353
2792
  custodian: Account
2354
2793
  newAuthority: Account
2355
2794
  stakeAccount: Account
@@ -2364,7 +2803,7 @@ var instructionTypeDefs = (
2364
2803
  authorityOwner: Account
2365
2804
  authoritySeed: String
2366
2805
  authorityType: String
2367
- clockSysvar: Address
2806
+ clockSysvar: Account
2368
2807
  custodian: Account
2369
2808
  newAuthorized: Account
2370
2809
  stakeAccount: Account
@@ -2452,7 +2891,7 @@ var instructionTypeDefs = (
2452
2891
  programId: Address
2453
2892
  nonceAccount: Account
2454
2893
  nonceAuthority: Account
2455
- recentBlockhashesSysvar: Address
2894
+ recentBlockhashesSysvar: Account
2456
2895
  }
2457
2896
 
2458
2897
  """
@@ -2464,8 +2903,8 @@ var instructionTypeDefs = (
2464
2903
  lamports: BigInt
2465
2904
  nonceAccount: Account
2466
2905
  nonceAuthority: Account
2467
- recentBlockhashesSysvar: Address
2468
- rentSysvar: Address
2906
+ recentBlockhashesSysvar: Account
2907
+ rentSysvar: Account
2469
2908
  }
2470
2909
 
2471
2910
  """
@@ -2475,8 +2914,8 @@ var instructionTypeDefs = (
2475
2914
  programId: Address
2476
2915
  nonceAccount: Account
2477
2916
  nonceAuthority: Account
2478
- recentBlockhashesSysvar: Address
2479
- rentSysvar: Address
2917
+ recentBlockhashesSysvar: Account
2918
+ rentSysvar: Account
2480
2919
  }
2481
2920
 
2482
2921
  """
@@ -2550,10 +2989,10 @@ var instructionTypeDefs = (
2550
2989
  programId: Address
2551
2990
  authorizedVoter: Account
2552
2991
  authorizedWithdrawer: Account
2553
- clockSysvar: Address
2992
+ clockSysvar: Account
2554
2993
  commission: BigInt # FIXME:*
2555
2994
  node: Account
2556
- rentSysvar: Address
2995
+ rentSysvar: Account
2557
2996
  voteAccount: Account
2558
2997
  }
2559
2998
 
@@ -2564,7 +3003,7 @@ var instructionTypeDefs = (
2564
3003
  programId: Address
2565
3004
  authority: Account
2566
3005
  authorityType: String
2567
- clockSysvar: Address
3006
+ clockSysvar: Account
2568
3007
  newAuthority: Account
2569
3008
  voteAccount: Account
2570
3009
  }
@@ -2578,7 +3017,7 @@ var instructionTypeDefs = (
2578
3017
  authorityOwner: Account
2579
3018
  authoritySeed: String
2580
3019
  authorityType: String
2581
- clockSysvar: Address
3020
+ clockSysvar: Account
2582
3021
  newAuthority: Account
2583
3022
  voteAccount: Account
2584
3023
  }
@@ -2592,7 +3031,7 @@ var instructionTypeDefs = (
2592
3031
  authorityOwner: Account
2593
3032
  authoritySeed: String
2594
3033
  authorityType: String
2595
- clockSysvar: Address
3034
+ clockSysvar: Account
2596
3035
  newAuthority: Account
2597
3036
  voteAccount: Account
2598
3037
  }
@@ -2608,8 +3047,8 @@ var instructionTypeDefs = (
2608
3047
  """
2609
3048
  type VoteVoteInstruction implements TransactionInstruction {
2610
3049
  programId: Address
2611
- clockSysvar: Address
2612
- slotHashesSysvar: Address
3050
+ clockSysvar: Account
3051
+ slotHashesSysvar: Account
2613
3052
  vote: Vote
2614
3053
  voteAccount: Account
2615
3054
  voteAuthority: Account
@@ -2706,9 +3145,9 @@ var instructionTypeDefs = (
2706
3145
  """
2707
3146
  type VoteVoteSwitchInstruction implements TransactionInstruction {
2708
3147
  programId: Address
2709
- clockSysvar: Address
3148
+ clockSysvar: Account
2710
3149
  hash: String
2711
- slotHashesSysvar: Address
3150
+ slotHashesSysvar: Account
2712
3151
  vote: Vote
2713
3152
  voteAccount: Account
2714
3153
  voteAuthority: Account
@@ -2721,7 +3160,7 @@ var instructionTypeDefs = (
2721
3160
  programId: Address
2722
3161
  authority: Account
2723
3162
  authorityType: String
2724
- clockSysvar: Address
3163
+ clockSysvar: Account
2725
3164
  newAuthority: Account
2726
3165
  voteAccount: Account
2727
3166
  }
@@ -2733,28 +3172,15 @@ var rootTypeDefs = (
2733
3172
  /* GraphQL */
2734
3173
  `
2735
3174
  type Query {
2736
- account(
2737
- address: String!
2738
- commitment: Commitment
2739
- dataSlice: DataSlice
2740
- encoding: AccountEncoding
2741
- minContextSlot: BigInt
2742
- ): Account
2743
- block(
2744
- slot: BigInt!
2745
- commitment: Commitment
2746
- encoding: TransactionEncoding
2747
- transactionDetails: BlockTransactionDetails
2748
- ): Block
3175
+ account(address: Address!, commitment: Commitment, minContextSlot: Slot): Account
3176
+ block(slot: Slot!, commitment: CommitmentWithoutProcessed): Block
2749
3177
  programAccounts(
2750
- programAddress: String!
3178
+ programAddress: Address!
2751
3179
  commitment: Commitment
2752
- dataSlice: DataSlice
2753
- encoding: AccountEncoding
2754
3180
  filters: [ProgramAccountsFilter]
2755
- minContextSlot: BigInt
3181
+ minContextSlot: Slot
2756
3182
  ): [Account]
2757
- transaction(signature: String!, commitment: Commitment, encoding: TransactionEncoding): Transaction
3183
+ transaction(signature: Signature!, commitment: CommitmentWithoutProcessed): Transaction
2758
3184
  }
2759
3185
 
2760
3186
  schema {
@@ -2829,77 +3255,120 @@ var transactionTypeDefs = (
2829
3255
  }
2830
3256
 
2831
3257
  """
2832
- Transaction interface
3258
+ A Solana transaction
2833
3259
  """
2834
- interface Transaction {
3260
+ type Transaction {
2835
3261
  blockTime: BigInt
3262
+ data(encoding: TransactionEncoding!): String
3263
+ message: TransactionMessage
2836
3264
  meta: TransactionMeta
2837
- slot: BigInt
3265
+ signatures: [Signature]
3266
+ slot: Slot
2838
3267
  version: String
2839
3268
  }
3269
+ `
3270
+ );
2840
3271
 
2841
- """
2842
- A transaction with base58 encoded data
2843
- """
2844
- type TransactionBase58 implements Transaction {
2845
- blockTime: BigInt
2846
- data: Base58EncodedBytes
2847
- meta: TransactionMeta
2848
- slot: BigInt
2849
- version: String
3272
+ // src/schema/types.ts
3273
+ var typeTypeDefs = (
3274
+ /* GraphQL */
3275
+ `
3276
+ enum AccountEncoding {
3277
+ BASE_58
3278
+ BASE_64
3279
+ BASE_64_ZSTD
2850
3280
  }
2851
3281
 
2852
- """
2853
- A transaction with base64 encoded data
2854
- """
2855
- type TransactionBase64 implements Transaction {
2856
- blockTime: BigInt
3282
+ scalar Address
3283
+
3284
+ scalar Base58EncodedBytes
3285
+
3286
+ scalar Base64EncodedBytes
3287
+
3288
+ scalar Base64ZstdEncodedBytes
3289
+
3290
+ scalar BigInt
3291
+
3292
+ enum Commitment {
3293
+ CONFIRMED
3294
+ FINALIZED
3295
+ PROCESSED
3296
+ }
3297
+
3298
+ enum CommitmentWithoutProcessed {
3299
+ CONFIRMED
3300
+ FINALIZED
3301
+ }
3302
+
3303
+ input DataSlice {
3304
+ offset: Int!
3305
+ length: Int!
3306
+ }
3307
+
3308
+ input ProgramAccountsFilter {
3309
+ bytes: BigInt
3310
+ dataSize: BigInt
3311
+ encoding: AccountEncoding
3312
+ offset: BigInt
3313
+ }
3314
+
3315
+ type ReturnData {
2857
3316
  data: Base64EncodedBytes
2858
- meta: TransactionMeta
2859
- slot: BigInt
2860
- version: String
3317
+ programId: Address
2861
3318
  }
2862
3319
 
2863
- """
2864
- A transaction with JSON encoded data
2865
- """
2866
- type TransactionDataParsed {
2867
- message: TransactionMessage
2868
- signatures: [String]
3320
+ type Reward {
3321
+ commission: Int
3322
+ lamports: BigInt
3323
+ postBalance: BigInt
3324
+ pubkey: Address
3325
+ rewardType: String
2869
3326
  }
2870
- type TransactionParsed implements Transaction {
2871
- blockTime: BigInt
2872
- data: TransactionDataParsed
2873
- meta: TransactionMeta
2874
- slot: BigInt
2875
- version: String
3327
+
3328
+ scalar Signature
3329
+
3330
+ scalar Slot
3331
+
3332
+ type TokenAmount {
3333
+ amount: String
3334
+ decimals: Int
3335
+ uiAmount: BigInt
3336
+ uiAmountString: String
3337
+ }
3338
+
3339
+ type TokenBalance {
3340
+ accountIndex: Int
3341
+ mint: Account
3342
+ owner: Account
3343
+ programId: Address
3344
+ uiTokenAmount: TokenAmount
3345
+ }
3346
+
3347
+ enum TransactionEncoding {
3348
+ BASE_58
3349
+ BASE_64
2876
3350
  }
2877
3351
  `
2878
3352
  );
2879
3353
 
2880
3354
  // src/schema/index.ts
2881
3355
  function createSolanaGraphQLTypeDefs() {
2882
- return [
2883
- accountTypeDefs,
2884
- blockTypeDefs,
2885
- commonTypeDefs,
2886
- inputTypeDefs,
2887
- instructionTypeDefs,
2888
- rootTypeDefs,
2889
- scalarTypeDefs,
2890
- transactionTypeDefs
2891
- ];
3356
+ return [accountTypeDefs, blockTypeDefs, instructionTypeDefs, rootTypeDefs, typeTypeDefs, transactionTypeDefs];
2892
3357
  }
2893
3358
 
2894
3359
  // src/index.ts
2895
- function createRpcGraphQL(rpc) {
3360
+ function createRpcGraphQL(rpc, config) {
3361
+ const rpcGraphQLConfig = {
3362
+ maxDataSliceByteRange: config?.maxDataSliceByteRange ?? 200,
3363
+ maxMultipleAccountsBatchSize: config?.maxMultipleAccountsBatchSize ?? 100
3364
+ };
2896
3365
  const schema = makeExecutableSchema({
2897
3366
  resolvers: createSolanaGraphQLResolvers(),
2898
3367
  typeDefs: createSolanaGraphQLTypeDefs()
2899
3368
  });
2900
3369
  return {
2901
3370
  async query(source, variableValues) {
2902
- const contextValue = createSolanaGraphQLContext(rpc);
3371
+ const contextValue = createSolanaGraphQLContext(rpc, rpcGraphQLConfig);
2903
3372
  return graphql({
2904
3373
  contextValue,
2905
3374
  schema,