@solana/rpc-graphql 2.0.0-experimental.f8c941c → 2.0.0-experimental.fb655dd

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