@solana/rpc-graphql 2.0.0-experimental.f025b33 → 2.0.0-experimental.f054d90

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