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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/index.browser.cjs +1216 -757
  2. package/dist/index.browser.cjs.map +1 -1
  3. package/dist/index.browser.js +1217 -758
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.native.js +1217 -758
  6. package/dist/index.native.js.map +1 -1
  7. package/dist/index.node.cjs +1216 -757
  8. package/dist/index.node.cjs.map +1 -1
  9. package/dist/index.node.js +1217 -758
  10. package/dist/index.node.js.map +1 -1
  11. package/dist/types/context.d.ts +15 -4
  12. package/dist/types/context.d.ts.map +1 -1
  13. package/dist/types/index.d.ts +2 -5
  14. package/dist/types/index.d.ts.map +1 -1
  15. package/dist/types/loaders/account.d.ts +12 -3
  16. package/dist/types/loaders/account.d.ts.map +1 -1
  17. package/dist/types/loaders/block.d.ts +1 -2
  18. package/dist/types/loaders/block.d.ts.map +1 -1
  19. package/dist/types/loaders/coalescer.d.ts +55 -0
  20. package/dist/types/loaders/coalescer.d.ts.map +1 -0
  21. package/dist/types/loaders/index.d.ts +1 -1
  22. package/dist/types/loaders/index.d.ts.map +1 -1
  23. package/dist/types/loaders/loader.d.ts +33 -14
  24. package/dist/types/loaders/loader.d.ts.map +1 -1
  25. package/dist/types/loaders/program-accounts.d.ts +6 -3
  26. package/dist/types/loaders/program-accounts.d.ts.map +1 -1
  27. package/dist/types/loaders/transaction.d.ts +1 -2
  28. package/dist/types/loaders/transaction.d.ts.map +1 -1
  29. package/dist/types/resolvers/account.d.ts +160 -42
  30. package/dist/types/resolvers/account.d.ts.map +1 -1
  31. package/dist/types/resolvers/block.d.ts +95 -11
  32. package/dist/types/resolvers/block.d.ts.map +1 -1
  33. package/dist/types/resolvers/index.d.ts.map +1 -1
  34. package/dist/types/resolvers/instruction.d.ts +1531 -259
  35. package/dist/types/resolvers/instruction.d.ts.map +1 -1
  36. package/dist/types/resolvers/program-accounts.d.ts +12 -3
  37. package/dist/types/resolvers/program-accounts.d.ts.map +1 -1
  38. package/dist/types/resolvers/resolve-info/account.d.ts +15 -0
  39. package/dist/types/resolvers/resolve-info/account.d.ts.map +1 -0
  40. package/dist/types/resolvers/resolve-info/block.d.ts +13 -0
  41. package/dist/types/resolvers/resolve-info/block.d.ts.map +1 -0
  42. package/dist/types/resolvers/resolve-info/index.d.ts +6 -0
  43. package/dist/types/resolvers/resolve-info/index.d.ts.map +1 -0
  44. package/dist/types/resolvers/resolve-info/program-accounts.d.ts +20 -0
  45. package/dist/types/resolvers/resolve-info/program-accounts.d.ts.map +1 -0
  46. package/dist/types/resolvers/resolve-info/transaction.d.ts +15 -0
  47. package/dist/types/resolvers/resolve-info/transaction.d.ts.map +1 -0
  48. package/dist/types/resolvers/resolve-info/visitor.d.ts +18 -0
  49. package/dist/types/resolvers/resolve-info/visitor.d.ts.map +1 -0
  50. package/dist/types/resolvers/transaction.d.ts +32 -9
  51. package/dist/types/resolvers/transaction.d.ts.map +1 -1
  52. package/dist/types/resolvers/types.d.ts +77 -9
  53. package/dist/types/resolvers/types.d.ts.map +1 -1
  54. package/dist/types/schema/account.d.ts +1 -1
  55. package/dist/types/schema/account.d.ts.map +1 -1
  56. package/dist/types/schema/block.d.ts +1 -1
  57. package/dist/types/schema/block.d.ts.map +1 -1
  58. package/dist/types/schema/index.d.ts.map +1 -1
  59. package/dist/types/schema/instruction.d.ts +1 -1
  60. package/dist/types/schema/root.d.ts +1 -1
  61. package/dist/types/schema/root.d.ts.map +1 -1
  62. package/dist/types/schema/transaction.d.ts +1 -1
  63. package/dist/types/schema/transaction.d.ts.map +1 -1
  64. package/dist/types/schema/types.d.ts +2 -0
  65. package/dist/types/schema/types.d.ts.map +1 -0
  66. package/package.json +12 -39
  67. package/dist/types/resolvers/resolve-info.d.ts +0 -3
  68. package/dist/types/resolvers/resolve-info.d.ts.map +0 -1
  69. package/dist/types/resolvers/scalars.d.ts +0 -44
  70. package/dist/types/resolvers/scalars.d.ts.map +0 -1
  71. package/dist/types/schema/common/inputs.d.ts +0 -2
  72. package/dist/types/schema/common/inputs.d.ts.map +0 -1
  73. package/dist/types/schema/common/scalars.d.ts +0 -2
  74. package/dist/types/schema/common/scalars.d.ts.map +0 -1
  75. package/dist/types/schema/common/types.d.ts +0 -2
  76. package/dist/types/schema/common/types.d.ts.map +0 -1
@@ -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,292 +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
- },
171
- rpc
458
+ }
172
459
  };
173
460
  }
174
-
175
- // src/resolvers/resolve-info.ts
176
- function onlyPresentFieldRequested(fieldName, info) {
177
- if (info && info.fieldNodes[0].selectionSet) {
178
- const selectionSet = info.fieldNodes[0].selectionSet;
179
- const requestedFields = selectionSet.selections.map((field) => {
180
- if (field.kind === "Field") {
181
- 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);
182
497
  }
183
- return null;
184
498
  });
185
- if (requestedFields && requestedFields.length === 1 && requestedFields[0] === fieldName) {
186
- return true;
187
- }
188
499
  }
189
- return false;
500
+ checkFieldsWithVisitor(rootNode ?? null);
501
+ return onlyFieldsRequested2;
190
502
  }
191
503
 
192
- // src/resolvers/account.ts
193
- function transformParsedAccountData(parsedAccountData) {
194
- const {
195
- parsed: { info: result, type: accountType },
196
- program: programName,
197
- programId
198
- } = parsedAccountData;
199
- result.accountType = accountType;
200
- result.programId = programId;
201
- result.programName = programName;
202
- return result;
203
- }
204
- function transformLoadedAccount({
205
- account,
206
- address,
207
- encoding = "jsonParsed"
208
- }) {
209
- const [
210
- // The account's data, either encoded or parsed.
211
- data,
212
- // Tells GraphQL which encoding has been returned
213
- // by the RPC.
214
- responseEncoding
215
- ] = Array.isArray(account.data) ? encoding === "jsonParsed" ? (
216
- // The requested encoding is jsonParsed,
217
- // but the data could not be parsed.
218
- // Defaults to base64 encoding.
219
- [{ data: account.data[0] }, "base64"]
220
- ) : (
221
- // The requested encoding is base58,
222
- // base64, or base64+zstd.
223
- [{ data: account.data[0] }, encoding]
224
- ) : (
225
- // The account data was returned as an object,
226
- // so it was parsed successfully.
227
- [transformParsedAccountData(account.data), "jsonParsed"]
228
- );
229
- account.address = address;
230
- account.encoding = responseEncoding;
231
- account.ownerProgram = account.owner;
232
- return {
233
- ...account,
234
- ...data
235
- };
504
+ // src/resolvers/resolve-info/account.ts
505
+ function findArgumentNodeByName(argumentNodes, name) {
506
+ return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
236
507
  }
237
- var resolveAccount = (fieldName) => {
238
- return async (parent, args, context, info) => {
239
- const address = fieldName ? parent[fieldName] : args.address;
240
- if (!address) {
241
- 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
+ }
242
521
  }
243
- if (onlyPresentFieldRequested("address", info)) {
244
- return { address };
522
+ if (argumentNode.value.kind === "Variable") {
523
+ return variableValues[argumentNode.value.name.value];
245
524
  }
246
- const account = await context.loaders.account.load({ ...args, address });
247
- return account === null ? { address } : transformLoadedAccount({ account, address, encoding: args.encoding });
248
- };
249
- };
250
- var accountResolvers = {
251
- Account: {
252
- __resolveType(account) {
253
- if (account.encoding === "base58") {
254
- 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
+ }
255
572
  }
256
- if (account.encoding === "base64") {
257
- 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";
258
592
  }
259
- if (account.encoding === "base64+zstd") {
260
- return "AccountBase64Zstd";
593
+ if (argumentNode.value.value === "BASE_64") {
594
+ return "base64";
261
595
  }
262
- if (account.encoding === "jsonParsed") {
263
- if (account.programName === "nonce") {
264
- 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
+ }
265
620
  }
266
- if (account.accountType === "mint" && account.programName === "spl-token") {
267
- 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));
268
647
  }
269
- if (account.accountType === "account" && account.programName === "spl-token") {
270
- 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;
271
689
  }
272
- if (account.programName === "stake") {
273
- return "StakeAccount";
690
+ if (account === null) {
691
+ return;
274
692
  }
275
- if (account.accountType === "vote" && account.programName === "vote") {
276
- return "VoteAccount";
693
+ if (!result.ownerProgram) {
694
+ result = {
695
+ ...result,
696
+ ...account,
697
+ ownerProgram: account.owner
698
+ };
277
699
  }
278
- if (account.accountType === "lookupTable" && account.programName === "address-lookup-table") {
279
- 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
+ }
280
729
  }
281
- }
282
- return "AccountBase64";
730
+ });
731
+ return result;
283
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()
284
764
  },
285
- AccountBase58: {
286
- ownerProgram: resolveAccount("ownerProgram")
287
- },
288
- AccountBase64: {
289
- ownerProgram: resolveAccount("ownerProgram")
290
- },
291
- AccountBase64Zstd: {
765
+ GenericAccount: {
766
+ data: resolveAccountData(),
292
767
  ownerProgram: resolveAccount("ownerProgram")
293
768
  },
294
769
  LookupTableAccount: {
295
770
  authority: resolveAccount("authority"),
771
+ data: resolveAccountData(),
296
772
  ownerProgram: resolveAccount("ownerProgram")
297
773
  },
298
774
  MintAccount: {
775
+ data: resolveAccountData(),
299
776
  freezeAuthority: resolveAccount("freezeAuthority"),
300
777
  mintAuthority: resolveAccount("mintAuthority"),
301
778
  ownerProgram: resolveAccount("ownerProgram")
302
779
  },
303
780
  NonceAccount: {
304
781
  authority: resolveAccount("authority"),
782
+ data: resolveAccountData(),
305
783
  ownerProgram: resolveAccount("ownerProgram")
306
784
  },
307
785
  StakeAccount: {
786
+ data: resolveAccountData(),
308
787
  ownerProgram: resolveAccount("ownerProgram")
309
788
  },
310
789
  StakeAccountDataMetaAuthorized: {
@@ -318,12 +797,14 @@ var accountResolvers = {
318
797
  voter: resolveAccount("voter")
319
798
  },
320
799
  TokenAccount: {
800
+ data: resolveAccountData(),
321
801
  mint: resolveAccount("mint"),
322
802
  owner: resolveAccount("owner"),
323
803
  ownerProgram: resolveAccount("ownerProgram")
324
804
  },
325
805
  VoteAccount: {
326
806
  authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
807
+ data: resolveAccountData(),
327
808
  node: resolveAccount("nodePubkey"),
328
809
  ownerProgram: resolveAccount("ownerProgram")
329
810
  },
@@ -333,147 +814,207 @@ var accountResolvers = {
333
814
  };
334
815
 
335
816
  // src/resolvers/transaction.ts
336
- function transformParsedInstruction(parsedInstruction) {
337
- if ("parsed" in parsedInstruction) {
338
- if (typeof parsedInstruction.parsed === "string" && parsedInstruction.program === "spl-memo") {
339
- const { parsed: memo, program: programName2, programId: programId2 } = parsedInstruction;
340
- const instructionType2 = "memo";
341
- return { instructionType: instructionType2, memo, programId: programId2, programName: programName2 };
342
- }
343
- const {
344
- parsed: { info: data, type: instructionType },
345
- program: programName,
346
- programId
347
- } = parsedInstruction;
348
- return { instructionType, programId, programName, ...data };
349
- } else {
350
- return parsedInstruction;
351
- }
352
- }
353
- function transformParsedTransaction(parsedTransaction) {
354
- const transactionData = parsedTransaction.transaction;
355
- const transactionMeta = parsedTransaction.meta;
356
- transactionData.message.instructions = transactionData.message.instructions.map(transformParsedInstruction);
357
- transactionMeta.innerInstructions = transactionMeta.innerInstructions.map((innerInstruction) => {
358
- innerInstruction.instructions = innerInstruction.instructions.map(transformParsedInstruction);
359
- 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
+ }
360
844
  });
361
- return [transactionData, transactionMeta];
362
845
  }
363
- function transformLoadedTransaction({
364
- encoding = "jsonParsed",
365
- transaction
366
- }) {
367
- const [transactionData, transactionMeta] = Array.isArray(transaction.transaction) ? (
368
- // The requested encoding is base58 or base64.
369
- [transaction.transaction[0], transaction.meta]
370
- ) : (
371
- // The transaction was either partially parsed or
372
- // fully JSON-parsed, which will be sorted later.
373
- transformParsedTransaction(transaction)
374
- );
375
- transaction.data = transactionData;
376
- transaction.encoding = encoding;
377
- transaction.meta = transactionMeta;
378
- 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
+ }));
379
852
  }
853
+ var resolveTransactionData = () => {
854
+ return (parent, args) => {
855
+ return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
856
+ };
857
+ };
380
858
  function resolveTransaction(fieldName) {
381
859
  return async (parent, args, context, info) => {
382
860
  const signature = fieldName ? parent[fieldName] : args.signature;
383
- if (!signature) {
384
- return null;
385
- }
386
- if (onlyPresentFieldRequested("signature", info)) {
387
- return { signature };
388
- }
389
- const transaction = await context.loaders.transaction.load({ ...args, signature });
390
- if (!transaction) {
391
- return null;
392
- }
393
- if (args.encoding !== "jsonParsed") {
394
- const transactionJsonParsed = await context.loaders.transaction.load({
395
- ...args,
396
- 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: {},
397
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
+ }
398
917
  });
399
- if (transactionJsonParsed === null) {
400
- return null;
401
- }
402
- transaction.meta = transactionJsonParsed.meta;
918
+ return result;
403
919
  }
404
- return transformLoadedTransaction({ encoding: args.encoding, transaction });
920
+ return null;
405
921
  };
406
922
  }
407
923
  var transactionResolvers = {
408
924
  Transaction: {
409
- __resolveType(transaction) {
410
- switch (transaction.encoding) {
411
- case "base58":
412
- return "TransactionBase58";
413
- case "base64":
414
- return "TransactionBase64";
415
- default:
416
- return "TransactionParsed";
417
- }
418
- }
925
+ data: resolveTransactionData()
419
926
  }
420
927
  };
421
928
 
422
929
  // src/resolvers/block.ts
423
- function transformLoadedBlock({
424
- block,
425
- encoding = "jsonParsed",
426
- transactionDetails = "full"
427
- }) {
428
- const transformedBlock = block;
429
- if (typeof block === "object" && "transactions" in block) {
430
- transformedBlock.transactions = block.transactions.map((transaction) => {
431
- if (transactionDetails === "accounts") {
432
- return {
433
- data: transaction.transaction,
434
- meta: transaction.meta,
435
- version: transaction.version
436
- };
437
- } else {
438
- return transformLoadedTransaction({ encoding, transaction });
439
- }
440
- });
441
- }
442
- block.encoding = encoding;
443
- block.transactionDetails = transactionDetails;
444
- return block;
445
- }
446
930
  var resolveBlock = (fieldName) => {
447
931
  return async (parent, args, context, info) => {
448
932
  const slot = fieldName ? parent[fieldName] : args.slot;
449
- if (!slot) {
450
- return null;
451
- }
452
- if (onlyPresentFieldRequested("slot", info)) {
453
- return { slot };
454
- }
455
- const block = await context.loaders.block.load({ ...args, slot });
456
- if (block === null) {
457
- 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;
458
1011
  }
459
- const { encoding, transactionDetails } = args;
460
- return transformLoadedBlock({ block, encoding, transactionDetails });
1012
+ return null;
461
1013
  };
462
1014
  };
463
1015
  var blockResolvers = {
464
1016
  Block: {
465
- __resolveType(block) {
466
- switch (block.transactionDetails) {
467
- case "accounts":
468
- return "BlockWithAccounts";
469
- case "none":
470
- return "BlockWithNone";
471
- case "signatures":
472
- return "BlockWithSignatures";
473
- default:
474
- return "BlockWithFull";
475
- }
476
- }
1017
+ transactions: (parent) => parent?.transactionResults ? Object.values(parent.transactionResults) : null
477
1018
  }
478
1019
  };
479
1020
 
@@ -481,7 +1022,8 @@ var blockResolvers = {
481
1022
  var instructionResolvers = {
482
1023
  AdvanceNonceAccountInstruction: {
483
1024
  nonceAccount: resolveAccount("nonceAccount"),
484
- nonceAuthority: resolveAccount("nonceAuthority")
1025
+ nonceAuthority: resolveAccount("nonceAuthority"),
1026
+ recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar")
485
1027
  },
486
1028
  AllocateInstruction: {
487
1029
  account: resolveAccount("account")
@@ -518,9 +1060,11 @@ var instructionResolvers = {
518
1060
  BpfUpgradeableLoaderDeployWithMaxDataLenInstruction: {
519
1061
  authority: resolveAccount("authority"),
520
1062
  bufferAccount: resolveAccount("bufferAccount"),
1063
+ clockSysvar: resolveAccount("clockSysvar"),
521
1064
  payerAccount: resolveAccount("payerAccount"),
522
1065
  programAccount: resolveAccount("programAccount"),
523
- programDataAccount: resolveAccount("programDataAccount")
1066
+ programDataAccount: resolveAccount("programDataAccount"),
1067
+ rentSysvar: resolveAccount("rentSysvar")
524
1068
  },
525
1069
  BpfUpgradeableLoaderExtendProgramInstruction: {
526
1070
  payerAccount: resolveAccount("payerAccount"),
@@ -544,8 +1088,10 @@ var instructionResolvers = {
544
1088
  BpfUpgradeableLoaderUpgradeInstruction: {
545
1089
  authority: resolveAccount("authority"),
546
1090
  bufferAccount: resolveAccount("bufferAccount"),
1091
+ clockSysvar: resolveAccount("clockSysvar"),
547
1092
  programAccount: resolveAccount("programAccount"),
548
- programDataAccount: resolveAccount("programDataAccount")
1093
+ programDataAccount: resolveAccount("programDataAccount"),
1094
+ rentSysvar: resolveAccount("rentSysvar")
549
1095
  },
550
1096
  BpfUpgradeableLoaderWriteInstruction: {
551
1097
  account: resolveAccount("account"),
@@ -588,7 +1134,9 @@ var instructionResolvers = {
588
1134
  },
589
1135
  InitializeNonceAccountInstruction: {
590
1136
  nonceAccount: resolveAccount("nonceAccount"),
591
- nonceAuthority: resolveAccount("nonceAuthority")
1137
+ nonceAuthority: resolveAccount("nonceAuthority"),
1138
+ recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
1139
+ rentSysvar: resolveAccount("rentSysvar")
592
1140
  },
593
1141
  Lockup: {
594
1142
  custodian: resolveAccount("custodian")
@@ -664,7 +1212,8 @@ var instructionResolvers = {
664
1212
  SplTokenInitializeAccount2Instruction: {
665
1213
  account: resolveAccount("account"),
666
1214
  mint: resolveAccount("mint"),
667
- owner: resolveAccount("owner")
1215
+ owner: resolveAccount("owner"),
1216
+ rentSysvar: resolveAccount("rentSysvar")
668
1217
  },
669
1218
  SplTokenInitializeAccount3Instruction: {
670
1219
  account: resolveAccount("account"),
@@ -674,7 +1223,8 @@ var instructionResolvers = {
674
1223
  SplTokenInitializeAccountInstruction: {
675
1224
  account: resolveAccount("account"),
676
1225
  mint: resolveAccount("mint"),
677
- owner: resolveAccount("owner")
1226
+ owner: resolveAccount("owner"),
1227
+ rentSysvar: resolveAccount("rentSysvar")
678
1228
  },
679
1229
  SplTokenInitializeMint2Instruction: {
680
1230
  freezeAuthority: resolveAccount("freezeAuthority"),
@@ -688,13 +1238,15 @@ var instructionResolvers = {
688
1238
  SplTokenInitializeMintInstruction: {
689
1239
  freezeAuthority: resolveAccount("freezeAuthority"),
690
1240
  mint: resolveAccount("mint"),
691
- mintAuthority: resolveAccount("mintAuthority")
1241
+ mintAuthority: resolveAccount("mintAuthority"),
1242
+ rentSysvar: resolveAccount("rentSysvar")
692
1243
  },
693
1244
  SplTokenInitializeMultisig2Instruction: {
694
1245
  multisig: resolveAccount("multisig")
695
1246
  },
696
1247
  SplTokenInitializeMultisigInstruction: {
697
- multisig: resolveAccount("multisig")
1248
+ multisig: resolveAccount("multisig"),
1249
+ rentSysvar: resolveAccount("rentSysvar")
698
1250
  },
699
1251
  SplTokenMintToCheckedInstruction: {
700
1252
  account: resolveAccount("account"),
@@ -747,6 +1299,7 @@ var instructionResolvers = {
747
1299
  },
748
1300
  StakeAuthorizeCheckedInstruction: {
749
1301
  authority: resolveAccount("authority"),
1302
+ clockSysvar: resolveAccount("clockSysvar"),
750
1303
  custodian: resolveAccount("custodian"),
751
1304
  newAuthority: resolveAccount("newAuthority"),
752
1305
  stakeAccount: resolveAccount("stakeAccount")
@@ -754,12 +1307,14 @@ var instructionResolvers = {
754
1307
  StakeAuthorizeCheckedWithSeedInstruction: {
755
1308
  authorityBase: resolveAccount("authorityBase"),
756
1309
  authorityOwner: resolveAccount("authorityOwner"),
1310
+ clockSysvar: resolveAccount("clockSysvar"),
757
1311
  custodian: resolveAccount("custodian"),
758
1312
  newAuthorized: resolveAccount("newAuthorized"),
759
1313
  stakeAccount: resolveAccount("stakeAccount")
760
1314
  },
761
1315
  StakeAuthorizeInstruction: {
762
1316
  authority: resolveAccount("authority"),
1317
+ clockSysvar: resolveAccount("clockSysvar"),
763
1318
  custodian: resolveAccount("custodian"),
764
1319
  newAuthority: resolveAccount("newAuthority"),
765
1320
  stakeAccount: resolveAccount("stakeAccount")
@@ -767,6 +1322,7 @@ var instructionResolvers = {
767
1322
  StakeAuthorizeWithSeedInstruction: {
768
1323
  authorityBase: resolveAccount("authorityBase"),
769
1324
  authorityOwner: resolveAccount("authorityOwner"),
1325
+ clockSysvar: resolveAccount("clockSysvar"),
770
1326
  custodian: resolveAccount("custodian"),
771
1327
  newAuthorized: resolveAccount("newAuthorized"),
772
1328
  stakeAccount: resolveAccount("stakeAccount")
@@ -777,20 +1333,28 @@ var instructionResolvers = {
777
1333
  voteAccount: resolveAccount("voteAccount")
778
1334
  },
779
1335
  StakeDeactivateInstruction: {
1336
+ clockSysvar: resolveAccount("clockSysvar"),
780
1337
  stakeAccount: resolveAccount("stakeAccount"),
781
1338
  stakeAuthority: resolveAccount("stakeAuthority")
782
1339
  },
783
1340
  StakeDelegateStakeInstruction: {
1341
+ clockSysvar: resolveAccount("clockSysvar"),
784
1342
  stakeAccount: resolveAccount("stakeAccount"),
785
1343
  stakeAuthority: resolveAccount("stakeAuthority"),
786
1344
  stakeConfigAccount: resolveAccount("stakeConfigAccount"),
1345
+ stakeHistorySysvar: resolveAccount("stakeHistorySysvar"),
787
1346
  voteAccount: resolveAccount("voteAccount")
788
1347
  },
1348
+ StakeInitializeCheckedInstruction: {
1349
+ rentSysvar: resolveAccount("rentSysvar"),
1350
+ stakeAccount: resolveAccount("stakeAccount")
1351
+ },
789
1352
  StakeInitializeCheckedInstructionDataAuthorized: {
790
1353
  staker: resolveAccount("staker"),
791
1354
  withdrawer: resolveAccount("withdrawer")
792
1355
  },
793
1356
  StakeInitializeInstruction: {
1357
+ rentSysvar: resolveAccount("rentSysvar"),
794
1358
  stakeAccount: resolveAccount("stakeAccount")
795
1359
  },
796
1360
  StakeInitializeInstructionDataAuthorized: {
@@ -798,9 +1362,11 @@ var instructionResolvers = {
798
1362
  withdrawer: resolveAccount("withdrawer")
799
1363
  },
800
1364
  StakeMergeInstruction: {
1365
+ clockSysvar: resolveAccount("clockSysvar"),
801
1366
  destination: resolveAccount("destination"),
802
1367
  source: resolveAccount("source"),
803
- stakeAuthority: resolveAccount("stakeAuthority")
1368
+ stakeAuthority: resolveAccount("stakeAuthority"),
1369
+ stakeHistorySysvar: resolveAccount("stakeHistorySysvar")
804
1370
  },
805
1371
  StakeRedelegateInstruction: {
806
1372
  newStakeAccount: resolveAccount("newStakeAccount"),
@@ -823,287 +1389,289 @@ var instructionResolvers = {
823
1389
  stakeAuthority: resolveAccount("stakeAuthority")
824
1390
  },
825
1391
  StakeWithdrawInstruction: {
1392
+ clockSysvar: resolveAccount("clockSysvar"),
826
1393
  destination: resolveAccount("destination"),
827
1394
  stakeAccount: resolveAccount("stakeAccount"),
828
1395
  withdrawAuthority: resolveAccount("withdrawAuthority")
829
1396
  },
830
1397
  TransactionInstruction: {
831
- __resolveType(instruction) {
832
- if (instruction.programName) {
833
- if (instruction.programName === "address-lookup-table") {
834
- 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") {
835
1403
  return "CreateLookupTableInstruction";
836
1404
  }
837
- if (instruction.instructionType === "freezeLookupTable") {
1405
+ if (jsonParsedConfigs.instructionType === "freezeLookupTable") {
838
1406
  return "FreezeLookupTableInstruction";
839
1407
  }
840
- if (instruction.instructionType === "extendLookupTable") {
1408
+ if (jsonParsedConfigs.instructionType === "extendLookupTable") {
841
1409
  return "ExtendLookupTableInstruction";
842
1410
  }
843
- if (instruction.instructionType === "deactivateLookupTable") {
1411
+ if (jsonParsedConfigs.instructionType === "deactivateLookupTable") {
844
1412
  return "DeactivateLookupTableInstruction";
845
1413
  }
846
- if (instruction.instructionType === "closeLookupTable") {
1414
+ if (jsonParsedConfigs.instructionType === "closeLookupTable") {
847
1415
  return "CloseLookupTableInstruction";
848
1416
  }
849
1417
  }
850
- if (instruction.programName === "bpf-loader") {
851
- if (instruction.instructionType === "write") {
1418
+ if (jsonParsedConfigs.programName === "bpf-loader") {
1419
+ if (jsonParsedConfigs.instructionType === "write") {
852
1420
  return "BpfLoaderWriteInstruction";
853
1421
  }
854
- if (instruction.instructionType === "finalize") {
1422
+ if (jsonParsedConfigs.instructionType === "finalize") {
855
1423
  return "BpfLoaderFinalizeInstruction";
856
1424
  }
857
1425
  }
858
- if (instruction.programName === "bpf-upgradeable-loader") {
859
- if (instruction.instructionType === "initializeBuffer") {
1426
+ if (jsonParsedConfigs.programName === "bpf-upgradeable-loader") {
1427
+ if (jsonParsedConfigs.instructionType === "initializeBuffer") {
860
1428
  return "BpfUpgradeableLoaderInitializeBufferInstruction";
861
1429
  }
862
- if (instruction.instructionType === "write") {
1430
+ if (jsonParsedConfigs.instructionType === "write") {
863
1431
  return "BpfUpgradeableLoaderWriteInstruction";
864
1432
  }
865
- if (instruction.instructionType === "deployWithMaxDataLen") {
1433
+ if (jsonParsedConfigs.instructionType === "deployWithMaxDataLen") {
866
1434
  return "BpfUpgradeableLoaderDeployWithMaxDataLenInstruction";
867
1435
  }
868
- if (instruction.instructionType === "upgrade") {
1436
+ if (jsonParsedConfigs.instructionType === "upgrade") {
869
1437
  return "BpfUpgradeableLoaderUpgradeInstruction";
870
1438
  }
871
- if (instruction.instructionType === "setAuthority") {
1439
+ if (jsonParsedConfigs.instructionType === "setAuthority") {
872
1440
  return "BpfUpgradeableLoaderSetAuthorityInstruction";
873
1441
  }
874
- if (instruction.instructionType === "setAuthorityChecked") {
1442
+ if (jsonParsedConfigs.instructionType === "setAuthorityChecked") {
875
1443
  return "BpfUpgradeableLoaderSetAuthorityCheckedInstruction";
876
1444
  }
877
- if (instruction.instructionType === "close") {
1445
+ if (jsonParsedConfigs.instructionType === "close") {
878
1446
  return "BpfUpgradeableLoaderCloseInstruction";
879
1447
  }
880
- if (instruction.instructionType === "extendProgram") {
1448
+ if (jsonParsedConfigs.instructionType === "extendProgram") {
881
1449
  return "BpfUpgradeableLoaderExtendProgramInstruction";
882
1450
  }
883
1451
  }
884
- if (instruction.programName === "spl-associated-token-account") {
885
- if (instruction.instructionType === "create") {
1452
+ if (jsonParsedConfigs.programName === "spl-associated-token-account") {
1453
+ if (jsonParsedConfigs.instructionType === "create") {
886
1454
  return "SplAssociatedTokenCreateInstruction";
887
1455
  }
888
- if (instruction.instructionType === "createIdempotent") {
1456
+ if (jsonParsedConfigs.instructionType === "createIdempotent") {
889
1457
  return "SplAssociatedTokenCreateIdempotentInstruction";
890
1458
  }
891
- if (instruction.instructionType === "recoverNested") {
1459
+ if (jsonParsedConfigs.instructionType === "recoverNested") {
892
1460
  return "SplAssociatedTokenRecoverNestedInstruction";
893
1461
  }
894
1462
  }
895
- if (instruction.programName === "spl-memo") {
1463
+ if (jsonParsedConfigs.programName === "spl-memo") {
896
1464
  return "SplMemoInstruction";
897
1465
  }
898
- if (instruction.programName === "spl-token") {
899
- if (instruction.instructionType === "initializeMint") {
1466
+ if (jsonParsedConfigs.programName === "spl-token") {
1467
+ if (jsonParsedConfigs.instructionType === "initializeMint") {
900
1468
  return "SplTokenInitializeMintInstruction";
901
1469
  }
902
- if (instruction.instructionType === "initializeMint2") {
1470
+ if (jsonParsedConfigs.instructionType === "initializeMint2") {
903
1471
  return "SplTokenInitializeMint2Instruction";
904
1472
  }
905
- if (instruction.instructionType === "initializeAccount") {
1473
+ if (jsonParsedConfigs.instructionType === "initializeAccount") {
906
1474
  return "SplTokenInitializeAccountInstruction";
907
1475
  }
908
- if (instruction.instructionType === "initializeAccount2") {
1476
+ if (jsonParsedConfigs.instructionType === "initializeAccount2") {
909
1477
  return "SplTokenInitializeAccount2Instruction";
910
1478
  }
911
- if (instruction.instructionType === "initializeAccount3") {
1479
+ if (jsonParsedConfigs.instructionType === "initializeAccount3") {
912
1480
  return "SplTokenInitializeAccount3Instruction";
913
1481
  }
914
- if (instruction.instructionType === "initializeMultisig") {
1482
+ if (jsonParsedConfigs.instructionType === "initializeMultisig") {
915
1483
  return "SplTokenInitializeMultisigInstruction";
916
1484
  }
917
- if (instruction.instructionType === "initializeMultisig2") {
1485
+ if (jsonParsedConfigs.instructionType === "initializeMultisig2") {
918
1486
  return "SplTokenInitializeMultisig2Instruction";
919
1487
  }
920
- if (instruction.instructionType === "transfer") {
1488
+ if (jsonParsedConfigs.instructionType === "transfer") {
921
1489
  return "SplTokenTransferInstruction";
922
1490
  }
923
- if (instruction.instructionType === "approve") {
1491
+ if (jsonParsedConfigs.instructionType === "approve") {
924
1492
  return "SplTokenApproveInstruction";
925
1493
  }
926
- if (instruction.instructionType === "revoke") {
1494
+ if (jsonParsedConfigs.instructionType === "revoke") {
927
1495
  return "SplTokenRevokeInstruction";
928
1496
  }
929
- if (instruction.instructionType === "setAuthority") {
1497
+ if (jsonParsedConfigs.instructionType === "setAuthority") {
930
1498
  return "SplTokenSetAuthorityInstruction";
931
1499
  }
932
- if (instruction.instructionType === "mintTo") {
1500
+ if (jsonParsedConfigs.instructionType === "mintTo") {
933
1501
  return "SplTokenMintToInstruction";
934
1502
  }
935
- if (instruction.instructionType === "burn") {
1503
+ if (jsonParsedConfigs.instructionType === "burn") {
936
1504
  return "SplTokenBurnInstruction";
937
1505
  }
938
- if (instruction.instructionType === "closeAccount") {
1506
+ if (jsonParsedConfigs.instructionType === "closeAccount") {
939
1507
  return "SplTokenCloseAccountInstruction";
940
1508
  }
941
- if (instruction.instructionType === "freezeAccount") {
1509
+ if (jsonParsedConfigs.instructionType === "freezeAccount") {
942
1510
  return "SplTokenFreezeAccountInstruction";
943
1511
  }
944
- if (instruction.instructionType === "thawAccount") {
1512
+ if (jsonParsedConfigs.instructionType === "thawAccount") {
945
1513
  return "SplTokenThawAccountInstruction";
946
1514
  }
947
- if (instruction.instructionType === "transferChecked") {
1515
+ if (jsonParsedConfigs.instructionType === "transferChecked") {
948
1516
  return "SplTokenTransferCheckedInstruction";
949
1517
  }
950
- if (instruction.instructionType === "approveChecked") {
1518
+ if (jsonParsedConfigs.instructionType === "approveChecked") {
951
1519
  return "SplTokenApproveCheckedInstruction";
952
1520
  }
953
- if (instruction.instructionType === "mintToChecked") {
1521
+ if (jsonParsedConfigs.instructionType === "mintToChecked") {
954
1522
  return "SplTokenMintToCheckedInstruction";
955
1523
  }
956
- if (instruction.instructionType === "burnChecked") {
1524
+ if (jsonParsedConfigs.instructionType === "burnChecked") {
957
1525
  return "SplTokenBurnCheckedInstruction";
958
1526
  }
959
- if (instruction.instructionType === "syncNative") {
1527
+ if (jsonParsedConfigs.instructionType === "syncNative") {
960
1528
  return "SplTokenSyncNativeInstruction";
961
1529
  }
962
- if (instruction.instructionType === "getAccountDataSize") {
1530
+ if (jsonParsedConfigs.instructionType === "getAccountDataSize") {
963
1531
  return "SplTokenGetAccountDataSizeInstruction";
964
1532
  }
965
- if (instruction.instructionType === "initializeImmutableOwner") {
1533
+ if (jsonParsedConfigs.instructionType === "initializeImmutableOwner") {
966
1534
  return "SplTokenInitializeImmutableOwnerInstruction";
967
1535
  }
968
- if (instruction.instructionType === "amountToUiAmount") {
1536
+ if (jsonParsedConfigs.instructionType === "amountToUiAmount") {
969
1537
  return "SplTokenAmountToUiAmountInstruction";
970
1538
  }
971
- if (instruction.instructionType === "uiAmountToAmount") {
1539
+ if (jsonParsedConfigs.instructionType === "uiAmountToAmount") {
972
1540
  return "SplTokenUiAmountToAmountInstruction";
973
1541
  }
974
- if (instruction.instructionType === "initializeMintCloseAuthority") {
1542
+ if (jsonParsedConfigs.instructionType === "initializeMintCloseAuthority") {
975
1543
  return "SplTokenInitializeMintCloseAuthorityInstruction";
976
1544
  }
977
1545
  }
978
- if (instruction.programName === "stake") {
979
- if (instruction.instructionType === "initialize") {
1546
+ if (jsonParsedConfigs.programName === "stake") {
1547
+ if (jsonParsedConfigs.instructionType === "initialize") {
980
1548
  return "StakeInitializeInstruction";
981
1549
  }
982
- if (instruction.instructionType === "authorize") {
1550
+ if (jsonParsedConfigs.instructionType === "authorize") {
983
1551
  return "StakeAuthorizeInstruction";
984
1552
  }
985
- if (instruction.instructionType === "delegate") {
1553
+ if (jsonParsedConfigs.instructionType === "delegate") {
986
1554
  return "StakeDelegateStakeInstruction";
987
1555
  }
988
- if (instruction.instructionType === "split") {
1556
+ if (jsonParsedConfigs.instructionType === "split") {
989
1557
  return "StakeSplitInstruction";
990
1558
  }
991
- if (instruction.instructionType === "withdraw") {
1559
+ if (jsonParsedConfigs.instructionType === "withdraw") {
992
1560
  return "StakeWithdrawInstruction";
993
1561
  }
994
- if (instruction.instructionType === "deactivate") {
1562
+ if (jsonParsedConfigs.instructionType === "deactivate") {
995
1563
  return "StakeDeactivateInstruction";
996
1564
  }
997
- if (instruction.instructionType === "setLockup") {
1565
+ if (jsonParsedConfigs.instructionType === "setLockup") {
998
1566
  return "StakeSetLockupInstruction";
999
1567
  }
1000
- if (instruction.instructionType === "merge") {
1568
+ if (jsonParsedConfigs.instructionType === "merge") {
1001
1569
  return "StakeMergeInstruction";
1002
1570
  }
1003
- if (instruction.instructionType === "authorizeWithSeed") {
1571
+ if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
1004
1572
  return "StakeAuthorizeWithSeedInstruction";
1005
1573
  }
1006
- if (instruction.instructionType === "initializeChecked") {
1574
+ if (jsonParsedConfigs.instructionType === "initializeChecked") {
1007
1575
  return "StakeInitializeCheckedInstruction";
1008
1576
  }
1009
- if (instruction.instructionType === "authorizeChecked") {
1577
+ if (jsonParsedConfigs.instructionType === "authorizeChecked") {
1010
1578
  return "StakeAuthorizeCheckedInstruction";
1011
1579
  }
1012
- if (instruction.instructionType === "authorizeCheckedWithSeed") {
1580
+ if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
1013
1581
  return "StakeAuthorizeCheckedWithSeedInstruction";
1014
1582
  }
1015
- if (instruction.instructionType === "setLockupChecked") {
1583
+ if (jsonParsedConfigs.instructionType === "setLockupChecked") {
1016
1584
  return "StakeSetLockupCheckedInstruction";
1017
1585
  }
1018
- if (instruction.instructionType === "deactivateDelinquent") {
1586
+ if (jsonParsedConfigs.instructionType === "deactivateDelinquent") {
1019
1587
  return "StakeDeactivateDelinquentInstruction";
1020
1588
  }
1021
- if (instruction.instructionType === "redelegate") {
1589
+ if (jsonParsedConfigs.instructionType === "redelegate") {
1022
1590
  return "StakeRedelegateInstruction";
1023
1591
  }
1024
1592
  }
1025
- if (instruction.programName === "system") {
1026
- if (instruction.instructionType === "createAccount") {
1593
+ if (jsonParsedConfigs.programName === "system") {
1594
+ if (jsonParsedConfigs.instructionType === "createAccount") {
1027
1595
  return "CreateAccountInstruction";
1028
1596
  }
1029
- if (instruction.instructionType === "assign") {
1597
+ if (jsonParsedConfigs.instructionType === "assign") {
1030
1598
  return "AssignInstruction";
1031
1599
  }
1032
- if (instruction.instructionType === "transfer") {
1600
+ if (jsonParsedConfigs.instructionType === "transfer") {
1033
1601
  return "TransferInstruction";
1034
1602
  }
1035
- if (instruction.instructionType === "createAccountWithSeed") {
1603
+ if (jsonParsedConfigs.instructionType === "createAccountWithSeed") {
1036
1604
  return "CreateAccountWithSeedInstruction";
1037
1605
  }
1038
- if (instruction.instructionType === "advanceNonceAccount") {
1606
+ if (jsonParsedConfigs.instructionType === "advanceNonceAccount") {
1039
1607
  return "AdvanceNonceAccountInstruction";
1040
1608
  }
1041
- if (instruction.instructionType === "withdrawNonceAccount") {
1609
+ if (jsonParsedConfigs.instructionType === "withdrawNonceAccount") {
1042
1610
  return "WithdrawNonceAccountInstruction";
1043
1611
  }
1044
- if (instruction.instructionType === "initializeNonceAccount") {
1612
+ if (jsonParsedConfigs.instructionType === "initializeNonceAccount") {
1045
1613
  return "InitializeNonceAccountInstruction";
1046
1614
  }
1047
- if (instruction.instructionType === "authorizeNonceAccount") {
1615
+ if (jsonParsedConfigs.instructionType === "authorizeNonceAccount") {
1048
1616
  return "AuthorizeNonceAccountInstruction";
1049
1617
  }
1050
- if (instruction.instructionType === "upgradeNonceAccount") {
1618
+ if (jsonParsedConfigs.instructionType === "upgradeNonceAccount") {
1051
1619
  return "UpgradeNonceAccountInstruction";
1052
1620
  }
1053
- if (instruction.instructionType === "allocate") {
1621
+ if (jsonParsedConfigs.instructionType === "allocate") {
1054
1622
  return "AllocateInstruction";
1055
1623
  }
1056
- if (instruction.instructionType === "allocateWithSeed") {
1624
+ if (jsonParsedConfigs.instructionType === "allocateWithSeed") {
1057
1625
  return "AllocateWithSeedInstruction";
1058
1626
  }
1059
- if (instruction.instructionType === "assignWithSeed") {
1627
+ if (jsonParsedConfigs.instructionType === "assignWithSeed") {
1060
1628
  return "AssignWithSeedInstruction";
1061
1629
  }
1062
- if (instruction.instructionType === "transferWithSeed") {
1630
+ if (jsonParsedConfigs.instructionType === "transferWithSeed") {
1063
1631
  return "TransferWithSeedInstruction";
1064
1632
  }
1065
1633
  }
1066
- if (instruction.programName === "vote") {
1067
- if (instruction.instructionType === "initialize") {
1634
+ if (jsonParsedConfigs.programName === "vote") {
1635
+ if (jsonParsedConfigs.instructionType === "initialize") {
1068
1636
  return "VoteInitializeAccountInstruction";
1069
1637
  }
1070
- if (instruction.instructionType === "authorize") {
1638
+ if (jsonParsedConfigs.instructionType === "authorize") {
1071
1639
  return "VoteAuthorizeInstruction";
1072
1640
  }
1073
- if (instruction.instructionType === "authorizeWithSeed") {
1641
+ if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
1074
1642
  return "VoteAuthorizeWithSeedInstruction";
1075
1643
  }
1076
- if (instruction.instructionType === "authorizeCheckedWithSeed") {
1644
+ if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
1077
1645
  return "VoteAuthorizeCheckedWithSeedInstruction";
1078
1646
  }
1079
- if (instruction.instructionType === "vote") {
1647
+ if (jsonParsedConfigs.instructionType === "vote") {
1080
1648
  return "VoteVoteInstruction";
1081
1649
  }
1082
- if (instruction.instructionType === "updatevotestate") {
1650
+ if (jsonParsedConfigs.instructionType === "updatevotestate") {
1083
1651
  return "VoteUpdateVoteStateInstruction";
1084
1652
  }
1085
- if (instruction.instructionType === "updatevotestateswitch") {
1653
+ if (jsonParsedConfigs.instructionType === "updatevotestateswitch") {
1086
1654
  return "VoteUpdateVoteStateSwitchInstruction";
1087
1655
  }
1088
- if (instruction.instructionType === "compactupdatevotestate") {
1656
+ if (jsonParsedConfigs.instructionType === "compactupdatevotestate") {
1089
1657
  return "VoteCompactUpdateVoteStateInstruction";
1090
1658
  }
1091
- if (instruction.instructionType === "compactupdatevotestateswitch") {
1659
+ if (jsonParsedConfigs.instructionType === "compactupdatevotestateswitch") {
1092
1660
  return "VoteCompactUpdateVoteStateSwitchInstruction";
1093
1661
  }
1094
- if (instruction.instructionType === "withdraw") {
1662
+ if (jsonParsedConfigs.instructionType === "withdraw") {
1095
1663
  return "VoteWithdrawInstruction";
1096
1664
  }
1097
- if (instruction.instructionType === "updateValidatorIdentity") {
1665
+ if (jsonParsedConfigs.instructionType === "updateValidatorIdentity") {
1098
1666
  return "VoteUpdateValidatorIdentityInstruction";
1099
1667
  }
1100
- if (instruction.instructionType === "updateCommission") {
1668
+ if (jsonParsedConfigs.instructionType === "updateCommission") {
1101
1669
  return "VoteUpdateCommissionInstruction";
1102
1670
  }
1103
- if (instruction.instructionType === "voteSwitch") {
1671
+ if (jsonParsedConfigs.instructionType === "voteSwitch") {
1104
1672
  return "VoteVoteSwitchInstruction";
1105
1673
  }
1106
- if (instruction.instructionType === "authorizeChecked") {
1674
+ if (jsonParsedConfigs.instructionType === "authorizeChecked") {
1107
1675
  return "VoteAuthorizeCheckedInstruction";
1108
1676
  }
1109
1677
  }
@@ -1126,21 +1694,25 @@ var instructionResolvers = {
1126
1694
  },
1127
1695
  VoteAuthorizeCheckedInstruction: {
1128
1696
  authority: resolveAccount("authority"),
1697
+ clockSysvar: resolveAccount("clockSysvar"),
1129
1698
  newAuthority: resolveAccount("newAuthority"),
1130
1699
  voteAccount: resolveAccount("voteAccount")
1131
1700
  },
1132
1701
  VoteAuthorizeCheckedWithSeedInstruction: {
1133
1702
  authorityOwner: resolveAccount("authorityOwner"),
1703
+ clockSysvar: resolveAccount("clockSysvar"),
1134
1704
  newAuthority: resolveAccount("newAuthority"),
1135
1705
  voteAccount: resolveAccount("voteAccount")
1136
1706
  },
1137
1707
  VoteAuthorizeInstruction: {
1138
1708
  authority: resolveAccount("authority"),
1709
+ clockSysvar: resolveAccount("clockSysvar"),
1139
1710
  newAuthority: resolveAccount("newAuthority"),
1140
1711
  voteAccount: resolveAccount("voteAccount")
1141
1712
  },
1142
1713
  VoteAuthorizeWithSeedInstruction: {
1143
1714
  authorityOwner: resolveAccount("authorityOwner"),
1715
+ clockSysvar: resolveAccount("clockSysvar"),
1144
1716
  newAuthority: resolveAccount("newAuthority"),
1145
1717
  voteAccount: resolveAccount("voteAccount")
1146
1718
  },
@@ -1155,7 +1727,9 @@ var instructionResolvers = {
1155
1727
  VoteInitializeAccountInstruction: {
1156
1728
  authorizedVoter: resolveAccount("authorizedVoter"),
1157
1729
  authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
1730
+ clockSysvar: resolveAccount("clockSysvar"),
1158
1731
  node: resolveAccount("node"),
1732
+ rentSysvar: resolveAccount("rentSysvar"),
1159
1733
  voteAccount: resolveAccount("voteAccount")
1160
1734
  },
1161
1735
  VoteUpdateCommissionInstruction: {
@@ -1176,10 +1750,14 @@ var instructionResolvers = {
1176
1750
  voteAuthority: resolveAccount("voteAuthority")
1177
1751
  },
1178
1752
  VoteVoteInstruction: {
1753
+ clockSysvar: resolveAccount("clockSysvar"),
1754
+ slotHashesSysvar: resolveAccount("slotHashesSysvar"),
1179
1755
  voteAccount: resolveAccount("voteAccount"),
1180
1756
  voteAuthority: resolveAccount("voteAuthority")
1181
1757
  },
1182
1758
  VoteVoteSwitchInstruction: {
1759
+ clockSysvar: resolveAccount("clockSysvar"),
1760
+ slotHashesSysvar: resolveAccount("slotHashesSysvar"),
1183
1761
  voteAccount: resolveAccount("voteAccount"),
1184
1762
  voteAuthority: resolveAccount("voteAuthority")
1185
1763
  },
@@ -1190,7 +1768,9 @@ var instructionResolvers = {
1190
1768
  WithdrawNonceAccountInstruction: {
1191
1769
  destination: resolveAccount("destination"),
1192
1770
  nonceAccount: resolveAccount("nonceAccount"),
1193
- nonceAuthority: resolveAccount("nonceAuthority")
1771
+ nonceAuthority: resolveAccount("nonceAuthority"),
1772
+ recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
1773
+ rentSysvar: resolveAccount("rentSysvar")
1194
1774
  }
1195
1775
  };
1196
1776
 
@@ -1198,20 +1778,57 @@ var instructionResolvers = {
1198
1778
  function resolveProgramAccounts(fieldName) {
1199
1779
  return async (parent, args, context, info) => {
1200
1780
  const programAddress = fieldName ? parent[fieldName] : args.programAddress;
1201
- if (!programAddress) {
1202
- return null;
1203
- }
1204
- if (onlyPresentFieldRequested("programAddress", info)) {
1205
- return { programAddress };
1206
- }
1207
- const programAccounts = await context.loaders.programAccounts.load({ ...args, programAddress });
1208
- return programAccounts === null ? { programAddress } : programAccounts.map(
1209
- (programAccount) => transformLoadedAccount({
1210
- account: programAccount.account,
1211
- address: programAccount.pubkey,
1212
- encoding: args.encoding
1213
- })
1214
- );
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;
1215
1832
  };
1216
1833
  }
1217
1834
 
@@ -1238,47 +1855,49 @@ var stringScalarAlias = {
1238
1855
  return value;
1239
1856
  }
1240
1857
  };
1241
- var scalarResolvers = {
1242
- Address: stringScalarAlias,
1243
- Base58EncodedBytes: stringScalarAlias,
1244
- Base64EncodedBytes: stringScalarAlias,
1245
- Base64ZstdEncodedBytes: stringScalarAlias,
1246
- BigInt: {
1247
- __parseLiteral(ast) {
1248
- if (ast.kind === graphql.Kind.STRING) {
1249
- return BigInt(ast.value);
1250
- }
1251
- return null;
1252
- },
1253
- __parseValue(value) {
1254
- return BigInt(value);
1255
- },
1256
- __serialize(value) {
1257
- 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);
1258
1862
  }
1863
+ return null;
1864
+ },
1865
+ __parseValue(value) {
1866
+ return BigInt(value);
1867
+ },
1868
+ __serialize(value) {
1869
+ return BigInt(value);
1259
1870
  }
1260
1871
  };
1261
-
1262
- // src/resolvers/types.ts
1263
- var commonTypeResolvers = {
1872
+ var typeTypeResolvers = {
1264
1873
  AccountEncoding: {
1265
1874
  BASE_58: "base58",
1266
1875
  BASE_64: "base64",
1267
- BASE_64_ZSTD: "base64+zstd",
1268
- PARSED: "jsonParsed"
1876
+ BASE_64_ZSTD: "base64+zstd"
1269
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,
1270
1894
  TokenBalance: {
1271
1895
  mint: resolveAccount("mint"),
1272
1896
  owner: resolveAccount("owner")
1273
1897
  },
1274
1898
  TransactionEncoding: {
1275
1899
  BASE_58: "base58",
1276
- BASE_64: "base64",
1277
- PARSED: "jsonParsed"
1278
- },
1279
- TransactionVersion: {
1280
- LEGACY: "legacy",
1281
- ZERO: 0
1900
+ BASE_64: "base64"
1282
1901
  }
1283
1902
  };
1284
1903
 
@@ -1287,11 +1906,10 @@ function createSolanaGraphQLResolvers() {
1287
1906
  return {
1288
1907
  ...accountResolvers,
1289
1908
  ...blockResolvers,
1290
- ...commonTypeResolvers,
1291
1909
  ...instructionResolvers,
1292
1910
  ...rootResolvers,
1293
- ...scalarResolvers,
1294
- ...transactionResolvers
1911
+ ...transactionResolvers,
1912
+ ...typeTypeResolvers
1295
1913
  };
1296
1914
  }
1297
1915
 
@@ -1304,6 +1922,7 @@ var accountTypeDefs = (
1304
1922
  """
1305
1923
  interface Account {
1306
1924
  address: Address
1925
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1307
1926
  executable: Boolean
1308
1927
  lamports: BigInt
1309
1928
  ownerProgram: Account
@@ -1312,37 +1931,11 @@ var accountTypeDefs = (
1312
1931
  }
1313
1932
 
1314
1933
  """
1315
- An account with base58 encoded data
1934
+ Generic base account type
1316
1935
  """
1317
- type AccountBase58 implements Account {
1936
+ type GenericAccount implements Account {
1318
1937
  address: Address
1319
- data: Base58EncodedBytes
1320
- executable: Boolean
1321
- lamports: BigInt
1322
- ownerProgram: Account
1323
- space: BigInt
1324
- rentEpoch: BigInt
1325
- }
1326
-
1327
- """
1328
- An account with base64 encoded data
1329
- """
1330
- type AccountBase64 implements Account {
1331
- address: Address
1332
- data: Base64EncodedBytes
1333
- executable: Boolean
1334
- lamports: BigInt
1335
- ownerProgram: Account
1336
- space: BigInt
1337
- rentEpoch: BigInt
1338
- }
1339
-
1340
- """
1341
- An account with base64+zstd encoded data
1342
- """
1343
- type AccountBase64Zstd implements Account {
1344
- address: Address
1345
- data: Base64ZstdEncodedBytes
1938
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1346
1939
  executable: Boolean
1347
1940
  lamports: BigInt
1348
1941
  ownerProgram: Account
@@ -1358,6 +1951,7 @@ var accountTypeDefs = (
1358
1951
  """
1359
1952
  type NonceAccount implements Account {
1360
1953
  address: Address
1954
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1361
1955
  executable: Boolean
1362
1956
  lamports: BigInt
1363
1957
  ownerProgram: Account
@@ -1373,6 +1967,7 @@ var accountTypeDefs = (
1373
1967
  """
1374
1968
  type LookupTableAccount implements Account {
1375
1969
  address: Address
1970
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1376
1971
  executable: Boolean
1377
1972
  lamports: BigInt
1378
1973
  ownerProgram: Account
@@ -1390,6 +1985,7 @@ var accountTypeDefs = (
1390
1985
  """
1391
1986
  type MintAccount implements Account {
1392
1987
  address: Address
1988
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1393
1989
  executable: Boolean
1394
1990
  lamports: BigInt
1395
1991
  ownerProgram: Account
@@ -1407,6 +2003,7 @@ var accountTypeDefs = (
1407
2003
  """
1408
2004
  type TokenAccount implements Account {
1409
2005
  address: Address
2006
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1410
2007
  executable: Boolean
1411
2008
  lamports: BigInt
1412
2009
  ownerProgram: Account
@@ -1449,6 +2046,7 @@ var accountTypeDefs = (
1449
2046
  """
1450
2047
  type StakeAccount implements Account {
1451
2048
  address: Address
2049
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1452
2050
  executable: Boolean
1453
2051
  lamports: BigInt
1454
2052
  ownerProgram: Account
@@ -1480,6 +2078,7 @@ var accountTypeDefs = (
1480
2078
  """
1481
2079
  type VoteAccount implements Account {
1482
2080
  address: Address
2081
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1483
2082
  executable: Boolean
1484
2083
  lamports: BigInt
1485
2084
  ownerProgram: Account
@@ -1502,188 +2101,18 @@ var accountTypeDefs = (
1502
2101
  var blockTypeDefs = (
1503
2102
  /* GraphQL */
1504
2103
  `
1505
- type TransactionMetaForAccounts {
1506
- err: String
1507
- fee: BigInt
1508
- postBalances: [BigInt]
1509
- postTokenBalances: [TokenBalance]
1510
- preBalances: [BigInt]
1511
- preTokenBalances: [TokenBalance]
1512
- status: TransactionStatus
1513
- }
1514
-
1515
- type TransactionDataForAccounts {
1516
- accountKeys: [Address]
1517
- signatures: [String]
1518
- }
1519
-
1520
- type BlockTransactionAccounts {
1521
- meta: TransactionMetaForAccounts
1522
- data: TransactionDataForAccounts
1523
- version: String
1524
- }
1525
-
1526
2104
  """
1527
- Block interface
2105
+ A Solana block
1528
2106
  """
1529
- interface Block {
2107
+ type Block {
1530
2108
  blockhash: String
1531
2109
  blockHeight: BigInt
1532
2110
  blockTime: BigInt
1533
- parentSlot: BigInt
1534
- previousBlockhash: String
1535
- rewards: [Reward]
1536
- transactionDetails: String
1537
- }
1538
-
1539
- """
1540
- A block with account transaction details
1541
- """
1542
- type BlockWithAccounts implements Block {
1543
- blockhash: String
1544
- blockHeight: BigInt
1545
- blockTime: BigInt
1546
- parentSlot: BigInt
1547
- previousBlockhash: String
1548
- rewards: [Reward]
1549
- transactions: [BlockTransactionAccounts]
1550
- transactionDetails: String
1551
- }
1552
-
1553
- """
1554
- A block with full transaction details
1555
- """
1556
- type BlockWithFull implements Block {
1557
- blockhash: String
1558
- blockHeight: BigInt
1559
- blockTime: BigInt
1560
- parentSlot: BigInt
2111
+ parentSlot: Slot
1561
2112
  previousBlockhash: String
1562
2113
  rewards: [Reward]
2114
+ signatures: [Signature]
1563
2115
  transactions: [Transaction]
1564
- transactionDetails: String
1565
- }
1566
-
1567
- """
1568
- A block with no transaction details
1569
- """
1570
- type BlockWithNone implements Block {
1571
- blockhash: String
1572
- blockHeight: BigInt
1573
- blockTime: BigInt
1574
- parentSlot: BigInt
1575
- previousBlockhash: String
1576
- rewards: [Reward]
1577
- transactionDetails: String
1578
- }
1579
-
1580
- """
1581
- A block with signature transaction details
1582
- """
1583
- type BlockWithSignatures implements Block {
1584
- blockhash: String
1585
- blockHeight: BigInt
1586
- blockTime: BigInt
1587
- parentSlot: BigInt
1588
- previousBlockhash: String
1589
- rewards: [Reward]
1590
- signatures: [String]
1591
- transactionDetails: String
1592
- }
1593
- `
1594
- );
1595
-
1596
- // src/schema/common/inputs.ts
1597
- var inputTypeDefs = (
1598
- /* GraphQL */
1599
- `
1600
- input DataSlice {
1601
- offset: Int
1602
- length: Int
1603
- }
1604
-
1605
- input ProgramAccountsFilter {
1606
- bytes: BigInt
1607
- dataSize: BigInt
1608
- encoding: AccountEncoding
1609
- offset: BigInt
1610
- }
1611
- `
1612
- );
1613
-
1614
- // src/schema/common/scalars.ts
1615
- var scalarTypeDefs = (
1616
- /* GraphQL */
1617
- `
1618
- scalar Address
1619
- scalar Base58EncodedBytes
1620
- scalar Base64EncodedBytes
1621
- scalar Base64ZstdEncodedBytes
1622
- scalar BigInt
1623
- `
1624
- );
1625
-
1626
- // src/schema/common/types.ts
1627
- var commonTypeDefs = (
1628
- /* GraphQL */
1629
- `
1630
- enum AccountEncoding {
1631
- BASE_58
1632
- BASE_64
1633
- BASE_64_ZSTD
1634
- PARSED
1635
- }
1636
-
1637
- enum BlockTransactionDetails {
1638
- accounts
1639
- full
1640
- none
1641
- signatures
1642
- }
1643
-
1644
- enum Commitment {
1645
- confirmed
1646
- finalized
1647
- processed
1648
- }
1649
-
1650
- type ReturnData {
1651
- data: Base64EncodedBytes
1652
- programId: Address
1653
- }
1654
-
1655
- type Reward {
1656
- commission: Int
1657
- lamports: BigInt
1658
- postBalance: BigInt
1659
- pubkey: Address
1660
- rewardType: String
1661
- }
1662
-
1663
- type TokenAmount {
1664
- amount: String
1665
- decimals: Int
1666
- uiAmount: BigInt
1667
- uiAmountString: String
1668
- }
1669
-
1670
- type TokenBalance {
1671
- accountIndex: Int
1672
- mint: Account
1673
- owner: Account
1674
- programId: Address
1675
- uiTokenAmount: TokenAmount
1676
- }
1677
-
1678
- enum TransactionEncoding {
1679
- BASE_58
1680
- BASE_64
1681
- PARSED
1682
- }
1683
-
1684
- enum TransactionVersion {
1685
- LEGACY
1686
- ZERO
1687
2116
  }
1688
2117
  `
1689
2118
  );
@@ -1805,12 +2234,12 @@ var instructionTypeDefs = (
1805
2234
  programId: Address
1806
2235
  authority: Account
1807
2236
  bufferAccount: Account
1808
- clockSysvar: Address
2237
+ clockSysvar: Account
1809
2238
  maxDataLen: BigInt
1810
2239
  payerAccount: Account
1811
2240
  programAccount: Account
1812
2241
  programDataAccount: Account
1813
- rentSysvar: Address
2242
+ rentSysvar: Account
1814
2243
  }
1815
2244
 
1816
2245
  """
@@ -1820,10 +2249,10 @@ var instructionTypeDefs = (
1820
2249
  programId: Address
1821
2250
  authority: Account
1822
2251
  bufferAccount: Account
1823
- clockSysvar: Address
2252
+ clockSysvar: Account
1824
2253
  programAccount: Account
1825
2254
  programDataAccount: Account
1826
- rentSysvar: Address
2255
+ rentSysvar: Account
1827
2256
  spillAccount: Account
1828
2257
  }
1829
2258
 
@@ -1876,7 +2305,7 @@ var instructionTypeDefs = (
1876
2305
  type SplAssociatedTokenCreateInstruction implements TransactionInstruction {
1877
2306
  programId: Address
1878
2307
  account: Account
1879
- mint: Address
2308
+ mint: Account
1880
2309
  source: Account
1881
2310
  systemProgram: Account
1882
2311
  tokenProgram: Account
@@ -1889,7 +2318,7 @@ var instructionTypeDefs = (
1889
2318
  type SplAssociatedTokenCreateIdempotentInstruction implements TransactionInstruction {
1890
2319
  programId: Address
1891
2320
  account: Account
1892
- mint: Address
2321
+ mint: Account
1893
2322
  source: Account
1894
2323
  systemProgram: Account
1895
2324
  tokenProgram: Account
@@ -1927,7 +2356,7 @@ var instructionTypeDefs = (
1927
2356
  freezeAuthority: Account
1928
2357
  mint: Account
1929
2358
  mintAuthority: Account
1930
- rentSysvar: Address
2359
+ rentSysvar: Account
1931
2360
  }
1932
2361
 
1933
2362
  """
@@ -1949,7 +2378,7 @@ var instructionTypeDefs = (
1949
2378
  account: Account
1950
2379
  mint: Account
1951
2380
  owner: Account
1952
- rentSysvar: Address
2381
+ rentSysvar: Account
1953
2382
  }
1954
2383
 
1955
2384
  """
@@ -1960,7 +2389,7 @@ var instructionTypeDefs = (
1960
2389
  account: Account
1961
2390
  mint: Account
1962
2391
  owner: Account
1963
- rentSysvar: Address
2392
+ rentSysvar: Account
1964
2393
  }
1965
2394
 
1966
2395
  """
@@ -1980,7 +2409,7 @@ var instructionTypeDefs = (
1980
2409
  programId: Address
1981
2410
  m: BigInt # FIXME:*
1982
2411
  multisig: Account
1983
- rentSysvar: Address
2412
+ rentSysvar: Account
1984
2413
  signers: [Address]
1985
2414
  }
1986
2415
 
@@ -2235,7 +2664,7 @@ var instructionTypeDefs = (
2235
2664
  programId: Address
2236
2665
  authorized: StakeInitializeInstructionDataAuthorized
2237
2666
  lockup: Lockup
2238
- rentSysvar: Address
2667
+ rentSysvar: Account
2239
2668
  stakeAccount: Account
2240
2669
  }
2241
2670
 
@@ -2246,7 +2675,7 @@ var instructionTypeDefs = (
2246
2675
  programId: Address
2247
2676
  authority: Account
2248
2677
  authorityType: String
2249
- clockSysvar: Address
2678
+ clockSysvar: Account
2250
2679
  custodian: Account
2251
2680
  newAuthority: Account
2252
2681
  stakeAccount: Account
@@ -2257,11 +2686,11 @@ var instructionTypeDefs = (
2257
2686
  """
2258
2687
  type StakeDelegateStakeInstruction implements TransactionInstruction {
2259
2688
  programId: Address
2260
- clockSysvar: Address
2689
+ clockSysvar: Account
2261
2690
  stakeAccount: Account
2262
2691
  stakeAuthority: Account
2263
2692
  stakeConfigAccount: Account
2264
- stakeHistorySysvar: Address
2693
+ stakeHistorySysvar: Account
2265
2694
  voteAccount: Account
2266
2695
  }
2267
2696
 
@@ -2281,7 +2710,7 @@ var instructionTypeDefs = (
2281
2710
  """
2282
2711
  type StakeWithdrawInstruction implements TransactionInstruction {
2283
2712
  programId: Address
2284
- clockSysvar: Address
2713
+ clockSysvar: Account
2285
2714
  destination: Account
2286
2715
  lamports: BigInt
2287
2716
  stakeAccount: Account
@@ -2293,7 +2722,7 @@ var instructionTypeDefs = (
2293
2722
  """
2294
2723
  type StakeDeactivateInstruction implements TransactionInstruction {
2295
2724
  programId: Address
2296
- clockSysvar: Address
2725
+ clockSysvar: Account
2297
2726
  stakeAccount: Account
2298
2727
  stakeAuthority: Account
2299
2728
  }
@@ -2313,11 +2742,11 @@ var instructionTypeDefs = (
2313
2742
  """
2314
2743
  type StakeMergeInstruction implements TransactionInstruction {
2315
2744
  programId: Address
2316
- clockSysvar: Address
2745
+ clockSysvar: Account
2317
2746
  destination: Account
2318
2747
  source: Account
2319
2748
  stakeAuthority: Account
2320
- stakeHistorySysvar: Address
2749
+ stakeHistorySysvar: Account
2321
2750
  }
2322
2751
 
2323
2752
  """
@@ -2329,7 +2758,7 @@ var instructionTypeDefs = (
2329
2758
  authorityOwner: Account
2330
2759
  authoritySeed: String
2331
2760
  authorityType: String
2332
- clockSysvar: Address
2761
+ clockSysvar: Account
2333
2762
  custodian: Account
2334
2763
  newAuthorized: Account
2335
2764
  stakeAccount: Account
@@ -2346,7 +2775,7 @@ var instructionTypeDefs = (
2346
2775
  programId: Address
2347
2776
  authorized: StakeInitializeCheckedInstructionDataAuthorized
2348
2777
  lockup: Lockup
2349
- rentSysvar: Address
2778
+ rentSysvar: Account
2350
2779
  stakeAccount: Account
2351
2780
  }
2352
2781
 
@@ -2357,7 +2786,7 @@ var instructionTypeDefs = (
2357
2786
  programId: Address
2358
2787
  authority: Account
2359
2788
  authorityType: String
2360
- clockSysvar: Address
2789
+ clockSysvar: Account
2361
2790
  custodian: Account
2362
2791
  newAuthority: Account
2363
2792
  stakeAccount: Account
@@ -2372,7 +2801,7 @@ var instructionTypeDefs = (
2372
2801
  authorityOwner: Account
2373
2802
  authoritySeed: String
2374
2803
  authorityType: String
2375
- clockSysvar: Address
2804
+ clockSysvar: Account
2376
2805
  custodian: Account
2377
2806
  newAuthorized: Account
2378
2807
  stakeAccount: Account
@@ -2460,7 +2889,7 @@ var instructionTypeDefs = (
2460
2889
  programId: Address
2461
2890
  nonceAccount: Account
2462
2891
  nonceAuthority: Account
2463
- recentBlockhashesSysvar: Address
2892
+ recentBlockhashesSysvar: Account
2464
2893
  }
2465
2894
 
2466
2895
  """
@@ -2472,8 +2901,8 @@ var instructionTypeDefs = (
2472
2901
  lamports: BigInt
2473
2902
  nonceAccount: Account
2474
2903
  nonceAuthority: Account
2475
- recentBlockhashesSysvar: Address
2476
- rentSysvar: Address
2904
+ recentBlockhashesSysvar: Account
2905
+ rentSysvar: Account
2477
2906
  }
2478
2907
 
2479
2908
  """
@@ -2483,8 +2912,8 @@ var instructionTypeDefs = (
2483
2912
  programId: Address
2484
2913
  nonceAccount: Account
2485
2914
  nonceAuthority: Account
2486
- recentBlockhashesSysvar: Address
2487
- rentSysvar: Address
2915
+ recentBlockhashesSysvar: Account
2916
+ rentSysvar: Account
2488
2917
  }
2489
2918
 
2490
2919
  """
@@ -2558,10 +2987,10 @@ var instructionTypeDefs = (
2558
2987
  programId: Address
2559
2988
  authorizedVoter: Account
2560
2989
  authorizedWithdrawer: Account
2561
- clockSysvar: Address
2990
+ clockSysvar: Account
2562
2991
  commission: BigInt # FIXME:*
2563
2992
  node: Account
2564
- rentSysvar: Address
2993
+ rentSysvar: Account
2565
2994
  voteAccount: Account
2566
2995
  }
2567
2996
 
@@ -2572,7 +3001,7 @@ var instructionTypeDefs = (
2572
3001
  programId: Address
2573
3002
  authority: Account
2574
3003
  authorityType: String
2575
- clockSysvar: Address
3004
+ clockSysvar: Account
2576
3005
  newAuthority: Account
2577
3006
  voteAccount: Account
2578
3007
  }
@@ -2586,7 +3015,7 @@ var instructionTypeDefs = (
2586
3015
  authorityOwner: Account
2587
3016
  authoritySeed: String
2588
3017
  authorityType: String
2589
- clockSysvar: Address
3018
+ clockSysvar: Account
2590
3019
  newAuthority: Account
2591
3020
  voteAccount: Account
2592
3021
  }
@@ -2600,7 +3029,7 @@ var instructionTypeDefs = (
2600
3029
  authorityOwner: Account
2601
3030
  authoritySeed: String
2602
3031
  authorityType: String
2603
- clockSysvar: Address
3032
+ clockSysvar: Account
2604
3033
  newAuthority: Account
2605
3034
  voteAccount: Account
2606
3035
  }
@@ -2616,8 +3045,8 @@ var instructionTypeDefs = (
2616
3045
  """
2617
3046
  type VoteVoteInstruction implements TransactionInstruction {
2618
3047
  programId: Address
2619
- clockSysvar: Address
2620
- slotHashesSysvar: Address
3048
+ clockSysvar: Account
3049
+ slotHashesSysvar: Account
2621
3050
  vote: Vote
2622
3051
  voteAccount: Account
2623
3052
  voteAuthority: Account
@@ -2714,9 +3143,9 @@ var instructionTypeDefs = (
2714
3143
  """
2715
3144
  type VoteVoteSwitchInstruction implements TransactionInstruction {
2716
3145
  programId: Address
2717
- clockSysvar: Address
3146
+ clockSysvar: Account
2718
3147
  hash: String
2719
- slotHashesSysvar: Address
3148
+ slotHashesSysvar: Account
2720
3149
  vote: Vote
2721
3150
  voteAccount: Account
2722
3151
  voteAuthority: Account
@@ -2729,7 +3158,7 @@ var instructionTypeDefs = (
2729
3158
  programId: Address
2730
3159
  authority: Account
2731
3160
  authorityType: String
2732
- clockSysvar: Address
3161
+ clockSysvar: Account
2733
3162
  newAuthority: Account
2734
3163
  voteAccount: Account
2735
3164
  }
@@ -2741,28 +3170,15 @@ var rootTypeDefs = (
2741
3170
  /* GraphQL */
2742
3171
  `
2743
3172
  type Query {
2744
- account(
2745
- address: String!
2746
- commitment: Commitment
2747
- dataSlice: DataSlice
2748
- encoding: AccountEncoding
2749
- minContextSlot: BigInt
2750
- ): Account
2751
- block(
2752
- slot: BigInt!
2753
- commitment: Commitment
2754
- encoding: TransactionEncoding
2755
- transactionDetails: BlockTransactionDetails
2756
- ): Block
3173
+ account(address: Address!, commitment: Commitment, minContextSlot: Slot): Account
3174
+ block(slot: Slot!, commitment: CommitmentWithoutProcessed): Block
2757
3175
  programAccounts(
2758
- programAddress: String!
3176
+ programAddress: Address!
2759
3177
  commitment: Commitment
2760
- dataSlice: DataSlice
2761
- encoding: AccountEncoding
2762
3178
  filters: [ProgramAccountsFilter]
2763
- minContextSlot: BigInt
3179
+ minContextSlot: Slot
2764
3180
  ): [Account]
2765
- transaction(signature: String!, commitment: Commitment, encoding: TransactionEncoding): Transaction
3181
+ transaction(signature: Signature!, commitment: CommitmentWithoutProcessed): Transaction
2766
3182
  }
2767
3183
 
2768
3184
  schema {
@@ -2837,77 +3253,120 @@ var transactionTypeDefs = (
2837
3253
  }
2838
3254
 
2839
3255
  """
2840
- Transaction interface
3256
+ A Solana transaction
2841
3257
  """
2842
- interface Transaction {
3258
+ type Transaction {
2843
3259
  blockTime: BigInt
3260
+ data(encoding: TransactionEncoding!): String
3261
+ message: TransactionMessage
2844
3262
  meta: TransactionMeta
2845
- slot: BigInt
3263
+ signatures: [Signature]
3264
+ slot: Slot
2846
3265
  version: String
2847
3266
  }
3267
+ `
3268
+ );
2848
3269
 
2849
- """
2850
- A transaction with base58 encoded data
2851
- """
2852
- type TransactionBase58 implements Transaction {
2853
- blockTime: BigInt
2854
- data: Base58EncodedBytes
2855
- meta: TransactionMeta
2856
- slot: BigInt
2857
- 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
2858
3278
  }
2859
3279
 
2860
- """
2861
- A transaction with base64 encoded data
2862
- """
2863
- type TransactionBase64 implements Transaction {
2864
- 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 {
2865
3314
  data: Base64EncodedBytes
2866
- meta: TransactionMeta
2867
- slot: BigInt
2868
- version: String
3315
+ programId: Address
2869
3316
  }
2870
3317
 
2871
- """
2872
- A transaction with JSON encoded data
2873
- """
2874
- type TransactionDataParsed {
2875
- message: TransactionMessage
2876
- signatures: [String]
3318
+ type Reward {
3319
+ commission: Int
3320
+ lamports: BigInt
3321
+ postBalance: BigInt
3322
+ pubkey: Address
3323
+ rewardType: String
2877
3324
  }
2878
- type TransactionParsed implements Transaction {
2879
- blockTime: BigInt
2880
- data: TransactionDataParsed
2881
- meta: TransactionMeta
2882
- slot: BigInt
2883
- 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
2884
3348
  }
2885
3349
  `
2886
3350
  );
2887
3351
 
2888
3352
  // src/schema/index.ts
2889
3353
  function createSolanaGraphQLTypeDefs() {
2890
- return [
2891
- accountTypeDefs,
2892
- blockTypeDefs,
2893
- commonTypeDefs,
2894
- inputTypeDefs,
2895
- instructionTypeDefs,
2896
- rootTypeDefs,
2897
- scalarTypeDefs,
2898
- transactionTypeDefs
2899
- ];
3354
+ return [accountTypeDefs, blockTypeDefs, instructionTypeDefs, rootTypeDefs, typeTypeDefs, transactionTypeDefs];
2900
3355
  }
2901
3356
 
2902
3357
  // src/index.ts
2903
- function createRpcGraphQL(rpc) {
2904
- const contextValue = createSolanaGraphQLContext(rpc);
3358
+ function createRpcGraphQL(rpc, config) {
3359
+ const rpcGraphQLConfig = {
3360
+ maxDataSliceByteRange: config?.maxDataSliceByteRange ?? 200,
3361
+ maxMultipleAccountsBatchSize: config?.maxMultipleAccountsBatchSize ?? 100
3362
+ };
2905
3363
  const schema$1 = schema.makeExecutableSchema({
2906
3364
  resolvers: createSolanaGraphQLResolvers(),
2907
3365
  typeDefs: createSolanaGraphQLTypeDefs()
2908
3366
  });
2909
3367
  return {
2910
3368
  async query(source, variableValues) {
3369
+ const contextValue = createSolanaGraphQLContext(rpc, rpcGraphQLConfig);
2911
3370
  return graphql.graphql({
2912
3371
  contextValue,
2913
3372
  schema: schema$1,