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

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 +1225 -757
  2. package/dist/index.browser.cjs.map +1 -1
  3. package/dist/index.browser.js +1226 -758
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.native.js +1226 -758
  6. package/dist/index.native.js.map +1 -1
  7. package/dist/index.node.cjs +1225 -757
  8. package/dist/index.node.cjs.map +1 -1
  9. package/dist/index.node.js +1226 -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,779 @@ 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(
302
+ blockQueryArgs.map(
303
+ ({ slot, ...args }) => new Promise((resolve, reject) => {
304
+ const blockRecords = blocksToFetch[slot.toString()] ||= [];
305
+ if (!args.commitment) {
306
+ args.commitment = "confirmed";
307
+ }
308
+ blockRecords.push({ args, promiseCallback: { reject, resolve } });
309
+ })
310
+ )
311
+ );
312
+ } finally {
313
+ const blockFetchesByArgsHash = buildCoalescedFetchesByArgsHash(blocksToFetch, {
314
+ criteria: (args) => args.encoding === void 0 && args.transactionDetails !== "signatures",
315
+ defaults: (args) => ({
316
+ ...args,
317
+ transactionDetails: "none"
318
+ }),
319
+ hashOmit: ["encoding", "transactionDetails"]
320
+ });
321
+ Object.values(blockFetchesByArgsHash).map(({ args, fetches: blockCallbacks }) => {
322
+ return Object.entries(blockCallbacks).map(([slot, { callbacks }]) => {
323
+ return Array.from({ length: 1 }, async () => {
324
+ try {
325
+ const result = await resolveBlockUsingRpc({
326
+ slot: BigInt(slot),
327
+ ...args
328
+ });
329
+ callbacks.forEach((c) => c.resolve(result));
330
+ } catch (e) {
331
+ callbacks.forEach((c) => c.reject(e));
332
+ }
333
+ });
334
+ });
335
+ });
336
+ }
83
337
  };
84
338
  }
85
339
  function createBlockLoader(rpc) {
86
340
  const loader = new DataLoader__default.default(createBlockBatchLoadFn(rpc), { cacheKeyFn });
87
341
  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
342
+ load: async (args) => loader.load({ ...args, maxSupportedTransactionVersion: 0 }),
343
+ loadMany: async (args) => loader.loadMany(args.map((a) => ({ ...a, maxSupportedTransactionVersion: 0 })))
106
344
  };
107
345
  }
108
346
  async function loadProgramAccounts(rpc, { programAddress, ...config }) {
109
347
  return await rpc.getProgramAccounts(
110
348
  programAddress,
111
- // @ts-expect-error FIX ME: https://github.com/solana-labs/solana-web3.js/pull/2052
349
+ // @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
112
350
  config
113
351
  ).send();
114
352
  }
115
- function createProgramAccountsBatchLoadFn(rpc) {
353
+ function createProgramAccountsBatchLoadFn(rpc, config) {
116
354
  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))
355
+ return async (accountQueryArgs) => {
356
+ const programAccountsToFetch = {};
357
+ try {
358
+ return Promise.all(
359
+ accountQueryArgs.map(
360
+ ({ programAddress, ...args }) => new Promise((resolve, reject) => {
361
+ const accountRecords = programAccountsToFetch[programAddress] ||= [];
362
+ if (!args.commitment) {
363
+ args.commitment = "confirmed";
364
+ }
365
+ accountRecords.push({ args, promiseCallback: { reject, resolve } });
366
+ })
367
+ )
368
+ );
369
+ } finally {
370
+ const { maxDataSliceByteRange } = config;
371
+ const programAccountsFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(
372
+ programAccountsToFetch,
373
+ maxDataSliceByteRange
374
+ );
375
+ Object.values(programAccountsFetchesByArgsHash).map(({ args, fetches: programAddressCallbacks }) => {
376
+ return Object.entries(programAddressCallbacks).map(([programAddress, { callbacks }]) => {
377
+ return Array.from({ length: 1 }, async () => {
378
+ try {
379
+ const result = await resolveProgramAccountsUsingRpc({
380
+ programAddress,
381
+ ...args
382
+ });
383
+ callbacks.forEach(({ callback, dataSlice }) => {
384
+ callback.resolve(sliceData(result, dataSlice, args.dataSlice));
385
+ });
386
+ } catch (e) {
387
+ callbacks.forEach(({ callback }) => {
388
+ callback.reject(e);
389
+ });
390
+ }
391
+ });
392
+ });
393
+ });
394
+ }
127
395
  };
128
396
  }
129
- function applyDefaultArgs4({
130
- commitment,
131
- encoding = "jsonParsed",
132
- signature
133
- }) {
397
+ function createProgramAccountsLoader(rpc, config) {
398
+ const loader = new DataLoader__default.default(createProgramAccountsBatchLoadFn(rpc, config), { cacheKeyFn });
134
399
  return {
135
- commitment,
136
- encoding,
137
- signature
400
+ load: async (args) => loader.load(args),
401
+ loadMany: async (args) => loader.loadMany(args)
138
402
  };
139
403
  }
140
404
  async function loadTransaction(rpc, { signature, ...config }) {
141
405
  return await rpc.getTransaction(
142
406
  signature,
143
- // @ts-expect-error FIX ME: https://github.com/solana-labs/solana-web3.js/pull/2052
407
+ // @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
144
408
  config
145
409
  ).send();
146
410
  }
147
411
  function createTransactionBatchLoadFn(rpc) {
148
412
  const resolveTransactionUsingRpc = loadTransaction.bind(null, rpc);
149
413
  return async (transactionQueryArgs) => {
150
- return await Promise.all(
151
- transactionQueryArgs.map(async (args) => await resolveTransactionUsingRpc(applyDefaultArgs4(args)))
152
- );
414
+ const transactionsToFetch = {};
415
+ try {
416
+ return Promise.all(
417
+ transactionQueryArgs.map(
418
+ ({ signature, ...args }) => new Promise((resolve, reject) => {
419
+ const transactionRecords = transactionsToFetch[signature] ||= [];
420
+ if (!args.commitment) {
421
+ args.commitment = "confirmed";
422
+ }
423
+ transactionRecords.push({ args, promiseCallback: { reject, resolve } });
424
+ })
425
+ )
426
+ );
427
+ } finally {
428
+ const transactionFetchesByArgsHash = buildCoalescedFetchesByArgsHash(transactionsToFetch, {
429
+ criteria: (args) => args.encoding === void 0,
430
+ defaults: (args) => ({ ...args, encoding: "base64" }),
431
+ hashOmit: ["encoding"]
432
+ });
433
+ Object.values(transactionFetchesByArgsHash).map(({ args, fetches: transactionCallbacks }) => {
434
+ return Object.entries(transactionCallbacks).map(([signature, { callbacks }]) => {
435
+ return Array.from({ length: 1 }, async () => {
436
+ try {
437
+ const result = await resolveTransactionUsingRpc({
438
+ signature,
439
+ ...args
440
+ });
441
+ callbacks.forEach((c) => c.resolve(result));
442
+ } catch (e) {
443
+ callbacks.forEach((c) => c.reject(e));
444
+ }
445
+ });
446
+ });
447
+ });
448
+ }
153
449
  };
154
450
  }
155
451
  function createTransactionLoader(rpc) {
156
452
  const loader = new DataLoader__default.default(createTransactionBatchLoadFn(rpc), { cacheKeyFn });
157
453
  return {
158
- load: async (args) => loader.load(applyDefaultArgs4(args))
454
+ load: async (args) => loader.load(args),
455
+ loadMany: async (args) => loader.loadMany(args)
159
456
  };
160
457
  }
161
458
 
162
459
  // src/context.ts
163
- function createSolanaGraphQLContext(rpc) {
460
+ function createSolanaGraphQLContext(rpc, config) {
164
461
  return {
165
462
  loaders: {
166
- account: createAccountLoader(rpc),
463
+ account: createAccountLoader(rpc, config),
167
464
  block: createBlockLoader(rpc),
168
- programAccounts: createProgramAccountsLoader(rpc),
465
+ programAccounts: createProgramAccountsLoader(rpc, config),
169
466
  transaction: createTransactionLoader(rpc)
170
- },
171
- rpc
467
+ }
172
468
  };
173
469
  }
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;
470
+ function injectableRootVisitor(info, rootNode, operations) {
471
+ const { fieldNodes } = info;
472
+ const root = rootNode ?? fieldNodes[0];
473
+ const parentIsRoot = (ancestors) => (Array.isArray(ancestors) ? ancestors[0] : ancestors) === root;
474
+ graphql.visit(root, {
475
+ Field(node, key, parent, path, ancestors) {
476
+ if (!parentIsRoot(ancestors))
477
+ return;
478
+ return operations.fieldNodeOperation(info, node, key, parent, path, ancestors);
479
+ },
480
+ FragmentSpread(node, key, parent, path, ancestors) {
481
+ const fragmentDefinition = info.fragments[node.name.value];
482
+ return operations.fragmentSpreadNodeOperation(info, fragmentDefinition, node, key, parent, path, ancestors);
483
+ },
484
+ InlineFragment(node, key, parent, path, ancestors) {
485
+ if (!parentIsRoot(ancestors))
486
+ return;
487
+ return operations.inlineFragmentNodeOperation(info, node, key, parent, path, ancestors);
488
+ }
489
+ });
490
+ }
491
+ function onlyFieldsRequested(fieldNames, info, rootNode) {
492
+ let onlyFieldsRequested2 = true;
493
+ function checkFieldsWithVisitor(root) {
494
+ injectableRootVisitor(info, root, {
495
+ fieldNodeOperation(_info, node) {
496
+ onlyFieldsRequested2 = fieldNames.includes(node.name.value);
497
+ if (!onlyFieldsRequested2) {
498
+ return graphql.BREAK;
499
+ }
500
+ },
501
+ fragmentSpreadNodeOperation(_info, fragment) {
502
+ checkFieldsWithVisitor(fragment);
503
+ },
504
+ inlineFragmentNodeOperation(_info, node) {
505
+ checkFieldsWithVisitor(node);
182
506
  }
183
- return null;
184
507
  });
185
- if (requestedFields && requestedFields.length === 1 && requestedFields[0] === fieldName) {
186
- return true;
187
- }
188
508
  }
189
- return false;
509
+ checkFieldsWithVisitor(rootNode ?? null);
510
+ return onlyFieldsRequested2;
190
511
  }
191
512
 
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
- };
513
+ // src/resolvers/resolve-info/account.ts
514
+ function findArgumentNodeByName(argumentNodes, name) {
515
+ return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
236
516
  }
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;
517
+ function parseAccountEncodingArgument(argumentNodes, variableValues) {
518
+ const argumentNode = findArgumentNodeByName(argumentNodes, "encoding");
519
+ if (argumentNode) {
520
+ if (argumentNode.value.kind === "EnumValue") {
521
+ if (argumentNode.value.value === "BASE_58") {
522
+ return "base58";
523
+ }
524
+ if (argumentNode.value.value === "BASE_64") {
525
+ return "base64";
526
+ }
527
+ if (argumentNode.value.value === "BASE_64_ZSTD") {
528
+ return "base64+zstd";
529
+ }
242
530
  }
243
- if (onlyPresentFieldRequested("address", info)) {
244
- return { address };
531
+ if (argumentNode.value.kind === "Variable") {
532
+ return variableValues[argumentNode.value.name.value];
245
533
  }
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";
534
+ } else {
535
+ return void 0;
536
+ }
537
+ }
538
+ function parseAccountDataSliceArgument(argumentNodes, variableValues) {
539
+ const argumentNode = findArgumentNodeByName(argumentNodes, "dataSlice");
540
+ if (argumentNode) {
541
+ if (argumentNode.value.kind === "ObjectValue") {
542
+ const offsetArg = argumentNode.value.fields?.find((field) => field.name.value === "offset");
543
+ const lengthArg = argumentNode.value.fields?.find((field) => field.name.value === "length");
544
+ const length = lengthArg?.value.kind === "IntValue" ? parseInt(lengthArg.value.value) : lengthArg?.value.kind === "Variable" ? variableValues[lengthArg.value.name.value] : void 0;
545
+ const offset = offsetArg?.value.kind === "IntValue" ? parseInt(offsetArg.value.value) : offsetArg?.value.kind === "Variable" ? variableValues[offsetArg.value.name.value] : void 0;
546
+ return length !== void 0 && length !== null && offset !== void 0 && offset !== null ? { length, offset } : void 0;
547
+ }
548
+ if (argumentNode.value.kind === "Variable") {
549
+ return variableValues[argumentNode.value.name.value];
550
+ }
551
+ } else {
552
+ return void 0;
553
+ }
554
+ }
555
+ function buildAccountArgSetWithVisitor(args, info) {
556
+ const argSet = [args];
557
+ function buildArgSetWithVisitor(root) {
558
+ injectableRootVisitor(info, root, {
559
+ fieldNodeOperation(info2, node) {
560
+ if (node.name.value !== "data") {
561
+ return;
562
+ }
563
+ if (node.arguments) {
564
+ const { variableValues } = info2;
565
+ const encoding = parseAccountEncodingArgument(node.arguments, variableValues);
566
+ const dataSlice = parseAccountDataSliceArgument(node.arguments, variableValues);
567
+ argSet.push({ ...args, dataSlice, encoding });
568
+ }
569
+ },
570
+ fragmentSpreadNodeOperation(_info, fragment) {
571
+ buildArgSetWithVisitor(fragment);
572
+ },
573
+ inlineFragmentNodeOperation(info2, node) {
574
+ const { schema } = info2;
575
+ const accountInterface = schema.getType("Account");
576
+ if (graphql.isInterfaceType(accountInterface) && // Recursively check if the inline fragment requests any
577
+ // fields outside of the `Account` interface.
578
+ !onlyFieldsRequested(Object.keys(accountInterface.getFields()), info2, node)) {
579
+ argSet.push({ ...args, encoding: "jsonParsed" });
580
+ }
255
581
  }
256
- if (account.encoding === "base64") {
257
- return "AccountBase64";
582
+ });
583
+ }
584
+ buildArgSetWithVisitor(null);
585
+ return argSet;
586
+ }
587
+ function buildAccountLoaderArgSetFromResolveInfo(args, info) {
588
+ return buildAccountArgSetWithVisitor(args, info);
589
+ }
590
+
591
+ // src/resolvers/resolve-info/transaction.ts
592
+ function findArgumentNodeByName2(argumentNodes, name) {
593
+ return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
594
+ }
595
+ function parseTransactionEncodingArgument(argumentNodes, variableValues) {
596
+ const argumentNode = findArgumentNodeByName2(argumentNodes, "encoding");
597
+ if (argumentNode) {
598
+ if (argumentNode.value.kind === "EnumValue") {
599
+ if (argumentNode.value.value === "BASE_58") {
600
+ return "base58";
258
601
  }
259
- if (account.encoding === "base64+zstd") {
260
- return "AccountBase64Zstd";
602
+ if (argumentNode.value.value === "BASE_64") {
603
+ return "base64";
261
604
  }
262
- if (account.encoding === "jsonParsed") {
263
- if (account.programName === "nonce") {
264
- return "NonceAccount";
605
+ }
606
+ if (argumentNode.value.kind === "Variable") {
607
+ return variableValues[argumentNode.value.name.value];
608
+ }
609
+ } else {
610
+ return void 0;
611
+ }
612
+ }
613
+ function buildTransactionArgSetWithVisitor(args, info) {
614
+ const argSet = [args];
615
+ function buildArgSetWithVisitor(root) {
616
+ injectableRootVisitor(info, root, {
617
+ fieldNodeOperation(info2, node) {
618
+ if (node.name.value === "message" || node.name.value === "meta") {
619
+ argSet.push({ ...args, encoding: "jsonParsed" });
620
+ } else if (node.name.value === "data") {
621
+ if (node.arguments) {
622
+ const { variableValues } = info2;
623
+ const encoding = parseTransactionEncodingArgument(
624
+ node.arguments,
625
+ variableValues
626
+ );
627
+ argSet.push({ ...args, encoding });
628
+ }
265
629
  }
266
- if (account.accountType === "mint" && account.programName === "spl-token") {
267
- return "MintAccount";
630
+ },
631
+ fragmentSpreadNodeOperation(_info, fragment) {
632
+ buildArgSetWithVisitor(fragment);
633
+ },
634
+ inlineFragmentNodeOperation(_info, _node) {
635
+ return;
636
+ }
637
+ });
638
+ }
639
+ buildArgSetWithVisitor(null);
640
+ return argSet;
641
+ }
642
+ function buildTransactionLoaderArgSetFromResolveInfo(args, info) {
643
+ return buildTransactionArgSetWithVisitor(args, info);
644
+ }
645
+
646
+ // src/resolvers/resolve-info/block.ts
647
+ function buildBlockLoaderArgSetFromResolveInfo(args, info) {
648
+ const argSet = [args];
649
+ function buildArgSetWithVisitor(root) {
650
+ injectableRootVisitor(info, root, {
651
+ fieldNodeOperation(info2, node) {
652
+ if (node.name.value === "signatures") {
653
+ argSet.push({ ...args, transactionDetails: "signatures" });
654
+ } else if (node.name.value === "transactions") {
655
+ argSet.push(...buildTransactionArgSetWithVisitor({ ...args, transactionDetails: "full" }, info2));
268
656
  }
269
- if (account.accountType === "account" && account.programName === "spl-token") {
270
- return "TokenAccount";
657
+ },
658
+ fragmentSpreadNodeOperation(_info, fragment) {
659
+ buildArgSetWithVisitor(fragment);
660
+ },
661
+ inlineFragmentNodeOperation(_info, _node) {
662
+ return;
663
+ }
664
+ });
665
+ }
666
+ buildArgSetWithVisitor(null);
667
+ return argSet;
668
+ }
669
+
670
+ // src/resolvers/resolve-info/program-accounts.ts
671
+ function buildProgramAccountsLoaderArgSetFromResolveInfo(args, info) {
672
+ return buildAccountArgSetWithVisitor(args, info);
673
+ }
674
+
675
+ // src/resolvers/account.ts
676
+ var resolveAccountData = () => {
677
+ return (parent, args) => {
678
+ return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
679
+ };
680
+ };
681
+ var resolveAccount = (fieldName) => {
682
+ return async (parent, args, context, info) => {
683
+ const address = fieldName ? parent[fieldName] : args.address;
684
+ if (address) {
685
+ if (onlyFieldsRequested(["address"], info)) {
686
+ return { address };
687
+ }
688
+ const argsSet = buildAccountLoaderArgSetFromResolveInfo({ ...args, address }, info);
689
+ const loadedAccounts = await context.loaders.account.loadMany(argsSet);
690
+ let result = {
691
+ address,
692
+ encodedData: {}
693
+ };
694
+ loadedAccounts.forEach((account, i) => {
695
+ if (account instanceof Error) {
696
+ console.error(account);
697
+ return;
271
698
  }
272
- if (account.programName === "stake") {
273
- return "StakeAccount";
699
+ if (account === null) {
700
+ return;
274
701
  }
275
- if (account.accountType === "vote" && account.programName === "vote") {
276
- return "VoteAccount";
702
+ if (!result.ownerProgram) {
703
+ result = {
704
+ ...result,
705
+ ...account,
706
+ ownerProgram: account.owner
707
+ };
277
708
  }
278
- if (account.accountType === "lookupTable" && account.programName === "address-lookup-table") {
279
- return "LookupTableAccount";
709
+ const { data } = account;
710
+ const { encoding, dataSlice } = argsSet[i];
711
+ if (encoding && result.encodedData) {
712
+ if (Array.isArray(data)) {
713
+ result.encodedData[cacheKeyFn({
714
+ dataSlice,
715
+ encoding: encoding === "jsonParsed" ? "base64" : encoding
716
+ })] = data[0];
717
+ } else if (typeof data === "string") {
718
+ result.encodedData[cacheKeyFn({
719
+ dataSlice,
720
+ encoding: "base58"
721
+ })] = data;
722
+ } else if (typeof data === "object") {
723
+ const {
724
+ parsed: { info: parsedData, type: accountType },
725
+ program: programName,
726
+ programId
727
+ } = data;
728
+ result.jsonParsedConfigs = {
729
+ accountType,
730
+ programId,
731
+ programName
732
+ };
733
+ result = {
734
+ ...result,
735
+ ...parsedData
736
+ };
737
+ }
280
738
  }
281
- }
282
- return "AccountBase64";
739
+ });
740
+ return result;
283
741
  }
742
+ return null;
743
+ };
744
+ };
745
+ function resolveAccountType(accountResult) {
746
+ const { jsonParsedConfigs } = accountResult;
747
+ if (jsonParsedConfigs) {
748
+ if (jsonParsedConfigs.programName === "nonce") {
749
+ return "NonceAccount";
750
+ }
751
+ if (jsonParsedConfigs.accountType === "mint" && jsonParsedConfigs.programName === "spl-token") {
752
+ return "MintAccount";
753
+ }
754
+ if (jsonParsedConfigs.accountType === "account" && jsonParsedConfigs.programName === "spl-token") {
755
+ return "TokenAccount";
756
+ }
757
+ if (jsonParsedConfigs.programName === "stake") {
758
+ return "StakeAccount";
759
+ }
760
+ if (jsonParsedConfigs.accountType === "vote" && jsonParsedConfigs.programName === "vote") {
761
+ return "VoteAccount";
762
+ }
763
+ if (jsonParsedConfigs.accountType === "lookupTable" && jsonParsedConfigs.programName === "address-lookup-table") {
764
+ return "LookupTableAccount";
765
+ }
766
+ }
767
+ return "GenericAccount";
768
+ }
769
+ var accountResolvers = {
770
+ Account: {
771
+ __resolveType: resolveAccountType,
772
+ data: resolveAccountData()
284
773
  },
285
- AccountBase58: {
286
- ownerProgram: resolveAccount("ownerProgram")
287
- },
288
- AccountBase64: {
289
- ownerProgram: resolveAccount("ownerProgram")
290
- },
291
- AccountBase64Zstd: {
774
+ GenericAccount: {
775
+ data: resolveAccountData(),
292
776
  ownerProgram: resolveAccount("ownerProgram")
293
777
  },
294
778
  LookupTableAccount: {
295
779
  authority: resolveAccount("authority"),
780
+ data: resolveAccountData(),
296
781
  ownerProgram: resolveAccount("ownerProgram")
297
782
  },
298
783
  MintAccount: {
784
+ data: resolveAccountData(),
299
785
  freezeAuthority: resolveAccount("freezeAuthority"),
300
786
  mintAuthority: resolveAccount("mintAuthority"),
301
787
  ownerProgram: resolveAccount("ownerProgram")
302
788
  },
303
789
  NonceAccount: {
304
790
  authority: resolveAccount("authority"),
791
+ data: resolveAccountData(),
305
792
  ownerProgram: resolveAccount("ownerProgram")
306
793
  },
307
794
  StakeAccount: {
795
+ data: resolveAccountData(),
308
796
  ownerProgram: resolveAccount("ownerProgram")
309
797
  },
310
798
  StakeAccountDataMetaAuthorized: {
@@ -318,12 +806,14 @@ var accountResolvers = {
318
806
  voter: resolveAccount("voter")
319
807
  },
320
808
  TokenAccount: {
809
+ data: resolveAccountData(),
321
810
  mint: resolveAccount("mint"),
322
811
  owner: resolveAccount("owner"),
323
812
  ownerProgram: resolveAccount("ownerProgram")
324
813
  },
325
814
  VoteAccount: {
326
815
  authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
816
+ data: resolveAccountData(),
327
817
  node: resolveAccount("nodePubkey"),
328
818
  ownerProgram: resolveAccount("ownerProgram")
329
819
  },
@@ -333,147 +823,207 @@ var accountResolvers = {
333
823
  };
334
824
 
335
825
  // 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;
826
+ function mapJsonParsedInstructions(instructions) {
827
+ return instructions.map((instruction) => {
828
+ if ("parsed" in instruction) {
829
+ if (typeof instruction.parsed === "string" && instruction.program === "spl-memo") {
830
+ const { parsed: memo, program: programName2, programId: programId2 } = instruction;
831
+ const instructionType2 = "memo";
832
+ const jsonParsedConfigs2 = {
833
+ instructionType: instructionType2,
834
+ programId: programId2,
835
+ programName: programName2
836
+ };
837
+ return { jsonParsedConfigs: jsonParsedConfigs2, memo, programId: programId2 };
838
+ }
839
+ const {
840
+ parsed: { info: data, type: instructionType },
841
+ program: programName,
842
+ programId
843
+ } = instruction;
844
+ const jsonParsedConfigs = {
845
+ instructionType,
846
+ programId,
847
+ programName
848
+ };
849
+ return { jsonParsedConfigs, ...data, programId };
850
+ } else {
851
+ return instruction;
852
+ }
360
853
  });
361
- return [transactionData, transactionMeta];
362
854
  }
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;
855
+ function mapJsonParsedInnerInstructions(innerInstructions) {
856
+ return innerInstructions.map(({ index, instructions }) => ({
857
+ index,
858
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
859
+ instructions: mapJsonParsedInstructions(instructions)
860
+ }));
379
861
  }
862
+ var resolveTransactionData = () => {
863
+ return (parent, args) => {
864
+ return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
865
+ };
866
+ };
380
867
  function resolveTransaction(fieldName) {
381
868
  return async (parent, args, context, info) => {
382
869
  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",
870
+ if (signature) {
871
+ if (onlyFieldsRequested(["signature"], info)) {
872
+ return { signature };
873
+ }
874
+ const argsSet = buildTransactionLoaderArgSetFromResolveInfo({ ...args, signature }, info);
875
+ const loadedTransactions = await context.loaders.transaction.loadMany(argsSet);
876
+ let result = {
877
+ encodedData: {},
397
878
  signature
879
+ };
880
+ loadedTransactions.forEach((loadedTransaction, i) => {
881
+ if (loadedTransaction instanceof Error) {
882
+ console.error(loadedTransaction);
883
+ return;
884
+ }
885
+ if (loadedTransaction === null) {
886
+ return;
887
+ }
888
+ if (!result.slot) {
889
+ result = {
890
+ ...result,
891
+ ...loadedTransaction
892
+ };
893
+ }
894
+ const { transaction: data } = loadedTransaction;
895
+ const { encoding } = argsSet[i];
896
+ if (encoding && result.encodedData) {
897
+ if (Array.isArray(data)) {
898
+ result.encodedData[cacheKeyFn({
899
+ encoding
900
+ })] = data[0];
901
+ } else if (typeof data === "object") {
902
+ const jsonParsedData = data;
903
+ jsonParsedData.message.instructions = mapJsonParsedInstructions(
904
+ jsonParsedData.message.instructions
905
+ );
906
+ const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
907
+ if (loadedInnerInstructions) {
908
+ const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
909
+ const jsonParsedMeta = {
910
+ ...loadedTransaction.meta,
911
+ innerInstructions
912
+ };
913
+ result = {
914
+ ...result,
915
+ ...jsonParsedData,
916
+ meta: jsonParsedMeta
917
+ };
918
+ } else {
919
+ result = {
920
+ ...result,
921
+ ...jsonParsedData
922
+ };
923
+ }
924
+ }
925
+ }
398
926
  });
399
- if (transactionJsonParsed === null) {
400
- return null;
401
- }
402
- transaction.meta = transactionJsonParsed.meta;
927
+ return result;
403
928
  }
404
- return transformLoadedTransaction({ encoding: args.encoding, transaction });
929
+ return null;
405
930
  };
406
931
  }
407
932
  var transactionResolvers = {
408
933
  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
- }
934
+ data: resolveTransactionData()
419
935
  }
420
936
  };
421
937
 
422
938
  // 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
939
  var resolveBlock = (fieldName) => {
447
940
  return async (parent, args, context, info) => {
448
941
  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;
942
+ if (slot) {
943
+ if (onlyFieldsRequested(["slot"], info)) {
944
+ return { slot };
945
+ }
946
+ const argsSet = buildBlockLoaderArgSetFromResolveInfo({ ...args, slot }, info);
947
+ const loadedBlocks = await context.loaders.block.loadMany(argsSet);
948
+ let result = {
949
+ slot
950
+ };
951
+ loadedBlocks.forEach((loadedBlock, i) => {
952
+ if (loadedBlock instanceof Error) {
953
+ console.error(loadedBlock);
954
+ return;
955
+ }
956
+ if (loadedBlock === null) {
957
+ return;
958
+ }
959
+ if (!result.blockhash) {
960
+ result = {
961
+ ...result,
962
+ ...loadedBlock
963
+ };
964
+ }
965
+ if (!result.signatures && loadedBlock.signatures) {
966
+ result = {
967
+ ...result,
968
+ // @ts-expect-error FIX ME: https://github.com/solana-labs/solana-web3.js/pull/2052
969
+ signatures: loadedBlock.signatures
970
+ };
971
+ }
972
+ if (!result.transactionResults && loadedBlock.transactions) {
973
+ result.transactionResults = Array.from({ length: loadedBlock.transactions.length }, (_, i2) => ({
974
+ [i2]: { encodedData: {} }
975
+ }));
976
+ }
977
+ const { transactions } = loadedBlock;
978
+ const { encoding } = argsSet[i];
979
+ if (encoding) {
980
+ transactions.forEach((loadedTransaction, j) => {
981
+ const { transaction: data } = loadedTransaction;
982
+ if (result.transactionResults) {
983
+ const thisTransactionResult = result.transactionResults[j] ||= {
984
+ encodedData: {}
985
+ };
986
+ if (Array.isArray(data)) {
987
+ const thisEncodedData = thisTransactionResult.encodedData ||= {};
988
+ thisEncodedData[cacheKeyFn({
989
+ encoding
990
+ })] = data[0];
991
+ } else if (typeof data === "object") {
992
+ const jsonParsedData = data;
993
+ jsonParsedData.message.instructions = mapJsonParsedInstructions(
994
+ jsonParsedData.message.instructions
995
+ );
996
+ const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
997
+ if (loadedInnerInstructions) {
998
+ const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
999
+ const jsonParsedMeta = {
1000
+ ...loadedTransaction.meta,
1001
+ innerInstructions
1002
+ };
1003
+ result.transactionResults[j] = {
1004
+ ...thisTransactionResult,
1005
+ ...jsonParsedData,
1006
+ meta: jsonParsedMeta
1007
+ };
1008
+ } else {
1009
+ result.transactionResults[j] = {
1010
+ ...thisTransactionResult,
1011
+ ...jsonParsedData
1012
+ };
1013
+ }
1014
+ }
1015
+ }
1016
+ });
1017
+ }
1018
+ });
1019
+ return result;
458
1020
  }
459
- const { encoding, transactionDetails } = args;
460
- return transformLoadedBlock({ block, encoding, transactionDetails });
1021
+ return null;
461
1022
  };
462
1023
  };
463
1024
  var blockResolvers = {
464
1025
  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
- }
1026
+ transactions: (parent) => parent?.transactionResults ? Object.values(parent.transactionResults) : null
477
1027
  }
478
1028
  };
479
1029
 
@@ -481,7 +1031,8 @@ var blockResolvers = {
481
1031
  var instructionResolvers = {
482
1032
  AdvanceNonceAccountInstruction: {
483
1033
  nonceAccount: resolveAccount("nonceAccount"),
484
- nonceAuthority: resolveAccount("nonceAuthority")
1034
+ nonceAuthority: resolveAccount("nonceAuthority"),
1035
+ recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar")
485
1036
  },
486
1037
  AllocateInstruction: {
487
1038
  account: resolveAccount("account")
@@ -518,9 +1069,11 @@ var instructionResolvers = {
518
1069
  BpfUpgradeableLoaderDeployWithMaxDataLenInstruction: {
519
1070
  authority: resolveAccount("authority"),
520
1071
  bufferAccount: resolveAccount("bufferAccount"),
1072
+ clockSysvar: resolveAccount("clockSysvar"),
521
1073
  payerAccount: resolveAccount("payerAccount"),
522
1074
  programAccount: resolveAccount("programAccount"),
523
- programDataAccount: resolveAccount("programDataAccount")
1075
+ programDataAccount: resolveAccount("programDataAccount"),
1076
+ rentSysvar: resolveAccount("rentSysvar")
524
1077
  },
525
1078
  BpfUpgradeableLoaderExtendProgramInstruction: {
526
1079
  payerAccount: resolveAccount("payerAccount"),
@@ -544,8 +1097,10 @@ var instructionResolvers = {
544
1097
  BpfUpgradeableLoaderUpgradeInstruction: {
545
1098
  authority: resolveAccount("authority"),
546
1099
  bufferAccount: resolveAccount("bufferAccount"),
1100
+ clockSysvar: resolveAccount("clockSysvar"),
547
1101
  programAccount: resolveAccount("programAccount"),
548
- programDataAccount: resolveAccount("programDataAccount")
1102
+ programDataAccount: resolveAccount("programDataAccount"),
1103
+ rentSysvar: resolveAccount("rentSysvar")
549
1104
  },
550
1105
  BpfUpgradeableLoaderWriteInstruction: {
551
1106
  account: resolveAccount("account"),
@@ -588,7 +1143,9 @@ var instructionResolvers = {
588
1143
  },
589
1144
  InitializeNonceAccountInstruction: {
590
1145
  nonceAccount: resolveAccount("nonceAccount"),
591
- nonceAuthority: resolveAccount("nonceAuthority")
1146
+ nonceAuthority: resolveAccount("nonceAuthority"),
1147
+ recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
1148
+ rentSysvar: resolveAccount("rentSysvar")
592
1149
  },
593
1150
  Lockup: {
594
1151
  custodian: resolveAccount("custodian")
@@ -664,7 +1221,8 @@ var instructionResolvers = {
664
1221
  SplTokenInitializeAccount2Instruction: {
665
1222
  account: resolveAccount("account"),
666
1223
  mint: resolveAccount("mint"),
667
- owner: resolveAccount("owner")
1224
+ owner: resolveAccount("owner"),
1225
+ rentSysvar: resolveAccount("rentSysvar")
668
1226
  },
669
1227
  SplTokenInitializeAccount3Instruction: {
670
1228
  account: resolveAccount("account"),
@@ -674,7 +1232,8 @@ var instructionResolvers = {
674
1232
  SplTokenInitializeAccountInstruction: {
675
1233
  account: resolveAccount("account"),
676
1234
  mint: resolveAccount("mint"),
677
- owner: resolveAccount("owner")
1235
+ owner: resolveAccount("owner"),
1236
+ rentSysvar: resolveAccount("rentSysvar")
678
1237
  },
679
1238
  SplTokenInitializeMint2Instruction: {
680
1239
  freezeAuthority: resolveAccount("freezeAuthority"),
@@ -688,13 +1247,15 @@ var instructionResolvers = {
688
1247
  SplTokenInitializeMintInstruction: {
689
1248
  freezeAuthority: resolveAccount("freezeAuthority"),
690
1249
  mint: resolveAccount("mint"),
691
- mintAuthority: resolveAccount("mintAuthority")
1250
+ mintAuthority: resolveAccount("mintAuthority"),
1251
+ rentSysvar: resolveAccount("rentSysvar")
692
1252
  },
693
1253
  SplTokenInitializeMultisig2Instruction: {
694
1254
  multisig: resolveAccount("multisig")
695
1255
  },
696
1256
  SplTokenInitializeMultisigInstruction: {
697
- multisig: resolveAccount("multisig")
1257
+ multisig: resolveAccount("multisig"),
1258
+ rentSysvar: resolveAccount("rentSysvar")
698
1259
  },
699
1260
  SplTokenMintToCheckedInstruction: {
700
1261
  account: resolveAccount("account"),
@@ -747,6 +1308,7 @@ var instructionResolvers = {
747
1308
  },
748
1309
  StakeAuthorizeCheckedInstruction: {
749
1310
  authority: resolveAccount("authority"),
1311
+ clockSysvar: resolveAccount("clockSysvar"),
750
1312
  custodian: resolveAccount("custodian"),
751
1313
  newAuthority: resolveAccount("newAuthority"),
752
1314
  stakeAccount: resolveAccount("stakeAccount")
@@ -754,12 +1316,14 @@ var instructionResolvers = {
754
1316
  StakeAuthorizeCheckedWithSeedInstruction: {
755
1317
  authorityBase: resolveAccount("authorityBase"),
756
1318
  authorityOwner: resolveAccount("authorityOwner"),
1319
+ clockSysvar: resolveAccount("clockSysvar"),
757
1320
  custodian: resolveAccount("custodian"),
758
1321
  newAuthorized: resolveAccount("newAuthorized"),
759
1322
  stakeAccount: resolveAccount("stakeAccount")
760
1323
  },
761
1324
  StakeAuthorizeInstruction: {
762
1325
  authority: resolveAccount("authority"),
1326
+ clockSysvar: resolveAccount("clockSysvar"),
763
1327
  custodian: resolveAccount("custodian"),
764
1328
  newAuthority: resolveAccount("newAuthority"),
765
1329
  stakeAccount: resolveAccount("stakeAccount")
@@ -767,6 +1331,7 @@ var instructionResolvers = {
767
1331
  StakeAuthorizeWithSeedInstruction: {
768
1332
  authorityBase: resolveAccount("authorityBase"),
769
1333
  authorityOwner: resolveAccount("authorityOwner"),
1334
+ clockSysvar: resolveAccount("clockSysvar"),
770
1335
  custodian: resolveAccount("custodian"),
771
1336
  newAuthorized: resolveAccount("newAuthorized"),
772
1337
  stakeAccount: resolveAccount("stakeAccount")
@@ -777,20 +1342,28 @@ var instructionResolvers = {
777
1342
  voteAccount: resolveAccount("voteAccount")
778
1343
  },
779
1344
  StakeDeactivateInstruction: {
1345
+ clockSysvar: resolveAccount("clockSysvar"),
780
1346
  stakeAccount: resolveAccount("stakeAccount"),
781
1347
  stakeAuthority: resolveAccount("stakeAuthority")
782
1348
  },
783
1349
  StakeDelegateStakeInstruction: {
1350
+ clockSysvar: resolveAccount("clockSysvar"),
784
1351
  stakeAccount: resolveAccount("stakeAccount"),
785
1352
  stakeAuthority: resolveAccount("stakeAuthority"),
786
1353
  stakeConfigAccount: resolveAccount("stakeConfigAccount"),
1354
+ stakeHistorySysvar: resolveAccount("stakeHistorySysvar"),
787
1355
  voteAccount: resolveAccount("voteAccount")
788
1356
  },
1357
+ StakeInitializeCheckedInstruction: {
1358
+ rentSysvar: resolveAccount("rentSysvar"),
1359
+ stakeAccount: resolveAccount("stakeAccount")
1360
+ },
789
1361
  StakeInitializeCheckedInstructionDataAuthorized: {
790
1362
  staker: resolveAccount("staker"),
791
1363
  withdrawer: resolveAccount("withdrawer")
792
1364
  },
793
1365
  StakeInitializeInstruction: {
1366
+ rentSysvar: resolveAccount("rentSysvar"),
794
1367
  stakeAccount: resolveAccount("stakeAccount")
795
1368
  },
796
1369
  StakeInitializeInstructionDataAuthorized: {
@@ -798,9 +1371,11 @@ var instructionResolvers = {
798
1371
  withdrawer: resolveAccount("withdrawer")
799
1372
  },
800
1373
  StakeMergeInstruction: {
1374
+ clockSysvar: resolveAccount("clockSysvar"),
801
1375
  destination: resolveAccount("destination"),
802
1376
  source: resolveAccount("source"),
803
- stakeAuthority: resolveAccount("stakeAuthority")
1377
+ stakeAuthority: resolveAccount("stakeAuthority"),
1378
+ stakeHistorySysvar: resolveAccount("stakeHistorySysvar")
804
1379
  },
805
1380
  StakeRedelegateInstruction: {
806
1381
  newStakeAccount: resolveAccount("newStakeAccount"),
@@ -823,287 +1398,289 @@ var instructionResolvers = {
823
1398
  stakeAuthority: resolveAccount("stakeAuthority")
824
1399
  },
825
1400
  StakeWithdrawInstruction: {
1401
+ clockSysvar: resolveAccount("clockSysvar"),
826
1402
  destination: resolveAccount("destination"),
827
1403
  stakeAccount: resolveAccount("stakeAccount"),
828
1404
  withdrawAuthority: resolveAccount("withdrawAuthority")
829
1405
  },
830
1406
  TransactionInstruction: {
831
- __resolveType(instruction) {
832
- if (instruction.programName) {
833
- if (instruction.programName === "address-lookup-table") {
834
- if (instruction.instructionType === "createLookupTable") {
1407
+ __resolveType(instructionResult) {
1408
+ const { jsonParsedConfigs } = instructionResult;
1409
+ if (jsonParsedConfigs) {
1410
+ if (jsonParsedConfigs.programName === "address-lookup-table") {
1411
+ if (jsonParsedConfigs.instructionType === "createLookupTable") {
835
1412
  return "CreateLookupTableInstruction";
836
1413
  }
837
- if (instruction.instructionType === "freezeLookupTable") {
1414
+ if (jsonParsedConfigs.instructionType === "freezeLookupTable") {
838
1415
  return "FreezeLookupTableInstruction";
839
1416
  }
840
- if (instruction.instructionType === "extendLookupTable") {
1417
+ if (jsonParsedConfigs.instructionType === "extendLookupTable") {
841
1418
  return "ExtendLookupTableInstruction";
842
1419
  }
843
- if (instruction.instructionType === "deactivateLookupTable") {
1420
+ if (jsonParsedConfigs.instructionType === "deactivateLookupTable") {
844
1421
  return "DeactivateLookupTableInstruction";
845
1422
  }
846
- if (instruction.instructionType === "closeLookupTable") {
1423
+ if (jsonParsedConfigs.instructionType === "closeLookupTable") {
847
1424
  return "CloseLookupTableInstruction";
848
1425
  }
849
1426
  }
850
- if (instruction.programName === "bpf-loader") {
851
- if (instruction.instructionType === "write") {
1427
+ if (jsonParsedConfigs.programName === "bpf-loader") {
1428
+ if (jsonParsedConfigs.instructionType === "write") {
852
1429
  return "BpfLoaderWriteInstruction";
853
1430
  }
854
- if (instruction.instructionType === "finalize") {
1431
+ if (jsonParsedConfigs.instructionType === "finalize") {
855
1432
  return "BpfLoaderFinalizeInstruction";
856
1433
  }
857
1434
  }
858
- if (instruction.programName === "bpf-upgradeable-loader") {
859
- if (instruction.instructionType === "initializeBuffer") {
1435
+ if (jsonParsedConfigs.programName === "bpf-upgradeable-loader") {
1436
+ if (jsonParsedConfigs.instructionType === "initializeBuffer") {
860
1437
  return "BpfUpgradeableLoaderInitializeBufferInstruction";
861
1438
  }
862
- if (instruction.instructionType === "write") {
1439
+ if (jsonParsedConfigs.instructionType === "write") {
863
1440
  return "BpfUpgradeableLoaderWriteInstruction";
864
1441
  }
865
- if (instruction.instructionType === "deployWithMaxDataLen") {
1442
+ if (jsonParsedConfigs.instructionType === "deployWithMaxDataLen") {
866
1443
  return "BpfUpgradeableLoaderDeployWithMaxDataLenInstruction";
867
1444
  }
868
- if (instruction.instructionType === "upgrade") {
1445
+ if (jsonParsedConfigs.instructionType === "upgrade") {
869
1446
  return "BpfUpgradeableLoaderUpgradeInstruction";
870
1447
  }
871
- if (instruction.instructionType === "setAuthority") {
1448
+ if (jsonParsedConfigs.instructionType === "setAuthority") {
872
1449
  return "BpfUpgradeableLoaderSetAuthorityInstruction";
873
1450
  }
874
- if (instruction.instructionType === "setAuthorityChecked") {
1451
+ if (jsonParsedConfigs.instructionType === "setAuthorityChecked") {
875
1452
  return "BpfUpgradeableLoaderSetAuthorityCheckedInstruction";
876
1453
  }
877
- if (instruction.instructionType === "close") {
1454
+ if (jsonParsedConfigs.instructionType === "close") {
878
1455
  return "BpfUpgradeableLoaderCloseInstruction";
879
1456
  }
880
- if (instruction.instructionType === "extendProgram") {
1457
+ if (jsonParsedConfigs.instructionType === "extendProgram") {
881
1458
  return "BpfUpgradeableLoaderExtendProgramInstruction";
882
1459
  }
883
1460
  }
884
- if (instruction.programName === "spl-associated-token-account") {
885
- if (instruction.instructionType === "create") {
1461
+ if (jsonParsedConfigs.programName === "spl-associated-token-account") {
1462
+ if (jsonParsedConfigs.instructionType === "create") {
886
1463
  return "SplAssociatedTokenCreateInstruction";
887
1464
  }
888
- if (instruction.instructionType === "createIdempotent") {
1465
+ if (jsonParsedConfigs.instructionType === "createIdempotent") {
889
1466
  return "SplAssociatedTokenCreateIdempotentInstruction";
890
1467
  }
891
- if (instruction.instructionType === "recoverNested") {
1468
+ if (jsonParsedConfigs.instructionType === "recoverNested") {
892
1469
  return "SplAssociatedTokenRecoverNestedInstruction";
893
1470
  }
894
1471
  }
895
- if (instruction.programName === "spl-memo") {
1472
+ if (jsonParsedConfigs.programName === "spl-memo") {
896
1473
  return "SplMemoInstruction";
897
1474
  }
898
- if (instruction.programName === "spl-token") {
899
- if (instruction.instructionType === "initializeMint") {
1475
+ if (jsonParsedConfigs.programName === "spl-token") {
1476
+ if (jsonParsedConfigs.instructionType === "initializeMint") {
900
1477
  return "SplTokenInitializeMintInstruction";
901
1478
  }
902
- if (instruction.instructionType === "initializeMint2") {
1479
+ if (jsonParsedConfigs.instructionType === "initializeMint2") {
903
1480
  return "SplTokenInitializeMint2Instruction";
904
1481
  }
905
- if (instruction.instructionType === "initializeAccount") {
1482
+ if (jsonParsedConfigs.instructionType === "initializeAccount") {
906
1483
  return "SplTokenInitializeAccountInstruction";
907
1484
  }
908
- if (instruction.instructionType === "initializeAccount2") {
1485
+ if (jsonParsedConfigs.instructionType === "initializeAccount2") {
909
1486
  return "SplTokenInitializeAccount2Instruction";
910
1487
  }
911
- if (instruction.instructionType === "initializeAccount3") {
1488
+ if (jsonParsedConfigs.instructionType === "initializeAccount3") {
912
1489
  return "SplTokenInitializeAccount3Instruction";
913
1490
  }
914
- if (instruction.instructionType === "initializeMultisig") {
1491
+ if (jsonParsedConfigs.instructionType === "initializeMultisig") {
915
1492
  return "SplTokenInitializeMultisigInstruction";
916
1493
  }
917
- if (instruction.instructionType === "initializeMultisig2") {
1494
+ if (jsonParsedConfigs.instructionType === "initializeMultisig2") {
918
1495
  return "SplTokenInitializeMultisig2Instruction";
919
1496
  }
920
- if (instruction.instructionType === "transfer") {
1497
+ if (jsonParsedConfigs.instructionType === "transfer") {
921
1498
  return "SplTokenTransferInstruction";
922
1499
  }
923
- if (instruction.instructionType === "approve") {
1500
+ if (jsonParsedConfigs.instructionType === "approve") {
924
1501
  return "SplTokenApproveInstruction";
925
1502
  }
926
- if (instruction.instructionType === "revoke") {
1503
+ if (jsonParsedConfigs.instructionType === "revoke") {
927
1504
  return "SplTokenRevokeInstruction";
928
1505
  }
929
- if (instruction.instructionType === "setAuthority") {
1506
+ if (jsonParsedConfigs.instructionType === "setAuthority") {
930
1507
  return "SplTokenSetAuthorityInstruction";
931
1508
  }
932
- if (instruction.instructionType === "mintTo") {
1509
+ if (jsonParsedConfigs.instructionType === "mintTo") {
933
1510
  return "SplTokenMintToInstruction";
934
1511
  }
935
- if (instruction.instructionType === "burn") {
1512
+ if (jsonParsedConfigs.instructionType === "burn") {
936
1513
  return "SplTokenBurnInstruction";
937
1514
  }
938
- if (instruction.instructionType === "closeAccount") {
1515
+ if (jsonParsedConfigs.instructionType === "closeAccount") {
939
1516
  return "SplTokenCloseAccountInstruction";
940
1517
  }
941
- if (instruction.instructionType === "freezeAccount") {
1518
+ if (jsonParsedConfigs.instructionType === "freezeAccount") {
942
1519
  return "SplTokenFreezeAccountInstruction";
943
1520
  }
944
- if (instruction.instructionType === "thawAccount") {
1521
+ if (jsonParsedConfigs.instructionType === "thawAccount") {
945
1522
  return "SplTokenThawAccountInstruction";
946
1523
  }
947
- if (instruction.instructionType === "transferChecked") {
1524
+ if (jsonParsedConfigs.instructionType === "transferChecked") {
948
1525
  return "SplTokenTransferCheckedInstruction";
949
1526
  }
950
- if (instruction.instructionType === "approveChecked") {
1527
+ if (jsonParsedConfigs.instructionType === "approveChecked") {
951
1528
  return "SplTokenApproveCheckedInstruction";
952
1529
  }
953
- if (instruction.instructionType === "mintToChecked") {
1530
+ if (jsonParsedConfigs.instructionType === "mintToChecked") {
954
1531
  return "SplTokenMintToCheckedInstruction";
955
1532
  }
956
- if (instruction.instructionType === "burnChecked") {
1533
+ if (jsonParsedConfigs.instructionType === "burnChecked") {
957
1534
  return "SplTokenBurnCheckedInstruction";
958
1535
  }
959
- if (instruction.instructionType === "syncNative") {
1536
+ if (jsonParsedConfigs.instructionType === "syncNative") {
960
1537
  return "SplTokenSyncNativeInstruction";
961
1538
  }
962
- if (instruction.instructionType === "getAccountDataSize") {
1539
+ if (jsonParsedConfigs.instructionType === "getAccountDataSize") {
963
1540
  return "SplTokenGetAccountDataSizeInstruction";
964
1541
  }
965
- if (instruction.instructionType === "initializeImmutableOwner") {
1542
+ if (jsonParsedConfigs.instructionType === "initializeImmutableOwner") {
966
1543
  return "SplTokenInitializeImmutableOwnerInstruction";
967
1544
  }
968
- if (instruction.instructionType === "amountToUiAmount") {
1545
+ if (jsonParsedConfigs.instructionType === "amountToUiAmount") {
969
1546
  return "SplTokenAmountToUiAmountInstruction";
970
1547
  }
971
- if (instruction.instructionType === "uiAmountToAmount") {
1548
+ if (jsonParsedConfigs.instructionType === "uiAmountToAmount") {
972
1549
  return "SplTokenUiAmountToAmountInstruction";
973
1550
  }
974
- if (instruction.instructionType === "initializeMintCloseAuthority") {
1551
+ if (jsonParsedConfigs.instructionType === "initializeMintCloseAuthority") {
975
1552
  return "SplTokenInitializeMintCloseAuthorityInstruction";
976
1553
  }
977
1554
  }
978
- if (instruction.programName === "stake") {
979
- if (instruction.instructionType === "initialize") {
1555
+ if (jsonParsedConfigs.programName === "stake") {
1556
+ if (jsonParsedConfigs.instructionType === "initialize") {
980
1557
  return "StakeInitializeInstruction";
981
1558
  }
982
- if (instruction.instructionType === "authorize") {
1559
+ if (jsonParsedConfigs.instructionType === "authorize") {
983
1560
  return "StakeAuthorizeInstruction";
984
1561
  }
985
- if (instruction.instructionType === "delegate") {
1562
+ if (jsonParsedConfigs.instructionType === "delegate") {
986
1563
  return "StakeDelegateStakeInstruction";
987
1564
  }
988
- if (instruction.instructionType === "split") {
1565
+ if (jsonParsedConfigs.instructionType === "split") {
989
1566
  return "StakeSplitInstruction";
990
1567
  }
991
- if (instruction.instructionType === "withdraw") {
1568
+ if (jsonParsedConfigs.instructionType === "withdraw") {
992
1569
  return "StakeWithdrawInstruction";
993
1570
  }
994
- if (instruction.instructionType === "deactivate") {
1571
+ if (jsonParsedConfigs.instructionType === "deactivate") {
995
1572
  return "StakeDeactivateInstruction";
996
1573
  }
997
- if (instruction.instructionType === "setLockup") {
1574
+ if (jsonParsedConfigs.instructionType === "setLockup") {
998
1575
  return "StakeSetLockupInstruction";
999
1576
  }
1000
- if (instruction.instructionType === "merge") {
1577
+ if (jsonParsedConfigs.instructionType === "merge") {
1001
1578
  return "StakeMergeInstruction";
1002
1579
  }
1003
- if (instruction.instructionType === "authorizeWithSeed") {
1580
+ if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
1004
1581
  return "StakeAuthorizeWithSeedInstruction";
1005
1582
  }
1006
- if (instruction.instructionType === "initializeChecked") {
1583
+ if (jsonParsedConfigs.instructionType === "initializeChecked") {
1007
1584
  return "StakeInitializeCheckedInstruction";
1008
1585
  }
1009
- if (instruction.instructionType === "authorizeChecked") {
1586
+ if (jsonParsedConfigs.instructionType === "authorizeChecked") {
1010
1587
  return "StakeAuthorizeCheckedInstruction";
1011
1588
  }
1012
- if (instruction.instructionType === "authorizeCheckedWithSeed") {
1589
+ if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
1013
1590
  return "StakeAuthorizeCheckedWithSeedInstruction";
1014
1591
  }
1015
- if (instruction.instructionType === "setLockupChecked") {
1592
+ if (jsonParsedConfigs.instructionType === "setLockupChecked") {
1016
1593
  return "StakeSetLockupCheckedInstruction";
1017
1594
  }
1018
- if (instruction.instructionType === "deactivateDelinquent") {
1595
+ if (jsonParsedConfigs.instructionType === "deactivateDelinquent") {
1019
1596
  return "StakeDeactivateDelinquentInstruction";
1020
1597
  }
1021
- if (instruction.instructionType === "redelegate") {
1598
+ if (jsonParsedConfigs.instructionType === "redelegate") {
1022
1599
  return "StakeRedelegateInstruction";
1023
1600
  }
1024
1601
  }
1025
- if (instruction.programName === "system") {
1026
- if (instruction.instructionType === "createAccount") {
1602
+ if (jsonParsedConfigs.programName === "system") {
1603
+ if (jsonParsedConfigs.instructionType === "createAccount") {
1027
1604
  return "CreateAccountInstruction";
1028
1605
  }
1029
- if (instruction.instructionType === "assign") {
1606
+ if (jsonParsedConfigs.instructionType === "assign") {
1030
1607
  return "AssignInstruction";
1031
1608
  }
1032
- if (instruction.instructionType === "transfer") {
1609
+ if (jsonParsedConfigs.instructionType === "transfer") {
1033
1610
  return "TransferInstruction";
1034
1611
  }
1035
- if (instruction.instructionType === "createAccountWithSeed") {
1612
+ if (jsonParsedConfigs.instructionType === "createAccountWithSeed") {
1036
1613
  return "CreateAccountWithSeedInstruction";
1037
1614
  }
1038
- if (instruction.instructionType === "advanceNonceAccount") {
1615
+ if (jsonParsedConfigs.instructionType === "advanceNonceAccount") {
1039
1616
  return "AdvanceNonceAccountInstruction";
1040
1617
  }
1041
- if (instruction.instructionType === "withdrawNonceAccount") {
1618
+ if (jsonParsedConfigs.instructionType === "withdrawNonceAccount") {
1042
1619
  return "WithdrawNonceAccountInstruction";
1043
1620
  }
1044
- if (instruction.instructionType === "initializeNonceAccount") {
1621
+ if (jsonParsedConfigs.instructionType === "initializeNonceAccount") {
1045
1622
  return "InitializeNonceAccountInstruction";
1046
1623
  }
1047
- if (instruction.instructionType === "authorizeNonceAccount") {
1624
+ if (jsonParsedConfigs.instructionType === "authorizeNonceAccount") {
1048
1625
  return "AuthorizeNonceAccountInstruction";
1049
1626
  }
1050
- if (instruction.instructionType === "upgradeNonceAccount") {
1627
+ if (jsonParsedConfigs.instructionType === "upgradeNonceAccount") {
1051
1628
  return "UpgradeNonceAccountInstruction";
1052
1629
  }
1053
- if (instruction.instructionType === "allocate") {
1630
+ if (jsonParsedConfigs.instructionType === "allocate") {
1054
1631
  return "AllocateInstruction";
1055
1632
  }
1056
- if (instruction.instructionType === "allocateWithSeed") {
1633
+ if (jsonParsedConfigs.instructionType === "allocateWithSeed") {
1057
1634
  return "AllocateWithSeedInstruction";
1058
1635
  }
1059
- if (instruction.instructionType === "assignWithSeed") {
1636
+ if (jsonParsedConfigs.instructionType === "assignWithSeed") {
1060
1637
  return "AssignWithSeedInstruction";
1061
1638
  }
1062
- if (instruction.instructionType === "transferWithSeed") {
1639
+ if (jsonParsedConfigs.instructionType === "transferWithSeed") {
1063
1640
  return "TransferWithSeedInstruction";
1064
1641
  }
1065
1642
  }
1066
- if (instruction.programName === "vote") {
1067
- if (instruction.instructionType === "initialize") {
1643
+ if (jsonParsedConfigs.programName === "vote") {
1644
+ if (jsonParsedConfigs.instructionType === "initialize") {
1068
1645
  return "VoteInitializeAccountInstruction";
1069
1646
  }
1070
- if (instruction.instructionType === "authorize") {
1647
+ if (jsonParsedConfigs.instructionType === "authorize") {
1071
1648
  return "VoteAuthorizeInstruction";
1072
1649
  }
1073
- if (instruction.instructionType === "authorizeWithSeed") {
1650
+ if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
1074
1651
  return "VoteAuthorizeWithSeedInstruction";
1075
1652
  }
1076
- if (instruction.instructionType === "authorizeCheckedWithSeed") {
1653
+ if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
1077
1654
  return "VoteAuthorizeCheckedWithSeedInstruction";
1078
1655
  }
1079
- if (instruction.instructionType === "vote") {
1656
+ if (jsonParsedConfigs.instructionType === "vote") {
1080
1657
  return "VoteVoteInstruction";
1081
1658
  }
1082
- if (instruction.instructionType === "updatevotestate") {
1659
+ if (jsonParsedConfigs.instructionType === "updatevotestate") {
1083
1660
  return "VoteUpdateVoteStateInstruction";
1084
1661
  }
1085
- if (instruction.instructionType === "updatevotestateswitch") {
1662
+ if (jsonParsedConfigs.instructionType === "updatevotestateswitch") {
1086
1663
  return "VoteUpdateVoteStateSwitchInstruction";
1087
1664
  }
1088
- if (instruction.instructionType === "compactupdatevotestate") {
1665
+ if (jsonParsedConfigs.instructionType === "compactupdatevotestate") {
1089
1666
  return "VoteCompactUpdateVoteStateInstruction";
1090
1667
  }
1091
- if (instruction.instructionType === "compactupdatevotestateswitch") {
1668
+ if (jsonParsedConfigs.instructionType === "compactupdatevotestateswitch") {
1092
1669
  return "VoteCompactUpdateVoteStateSwitchInstruction";
1093
1670
  }
1094
- if (instruction.instructionType === "withdraw") {
1671
+ if (jsonParsedConfigs.instructionType === "withdraw") {
1095
1672
  return "VoteWithdrawInstruction";
1096
1673
  }
1097
- if (instruction.instructionType === "updateValidatorIdentity") {
1674
+ if (jsonParsedConfigs.instructionType === "updateValidatorIdentity") {
1098
1675
  return "VoteUpdateValidatorIdentityInstruction";
1099
1676
  }
1100
- if (instruction.instructionType === "updateCommission") {
1677
+ if (jsonParsedConfigs.instructionType === "updateCommission") {
1101
1678
  return "VoteUpdateCommissionInstruction";
1102
1679
  }
1103
- if (instruction.instructionType === "voteSwitch") {
1680
+ if (jsonParsedConfigs.instructionType === "voteSwitch") {
1104
1681
  return "VoteVoteSwitchInstruction";
1105
1682
  }
1106
- if (instruction.instructionType === "authorizeChecked") {
1683
+ if (jsonParsedConfigs.instructionType === "authorizeChecked") {
1107
1684
  return "VoteAuthorizeCheckedInstruction";
1108
1685
  }
1109
1686
  }
@@ -1126,21 +1703,25 @@ var instructionResolvers = {
1126
1703
  },
1127
1704
  VoteAuthorizeCheckedInstruction: {
1128
1705
  authority: resolveAccount("authority"),
1706
+ clockSysvar: resolveAccount("clockSysvar"),
1129
1707
  newAuthority: resolveAccount("newAuthority"),
1130
1708
  voteAccount: resolveAccount("voteAccount")
1131
1709
  },
1132
1710
  VoteAuthorizeCheckedWithSeedInstruction: {
1133
1711
  authorityOwner: resolveAccount("authorityOwner"),
1712
+ clockSysvar: resolveAccount("clockSysvar"),
1134
1713
  newAuthority: resolveAccount("newAuthority"),
1135
1714
  voteAccount: resolveAccount("voteAccount")
1136
1715
  },
1137
1716
  VoteAuthorizeInstruction: {
1138
1717
  authority: resolveAccount("authority"),
1718
+ clockSysvar: resolveAccount("clockSysvar"),
1139
1719
  newAuthority: resolveAccount("newAuthority"),
1140
1720
  voteAccount: resolveAccount("voteAccount")
1141
1721
  },
1142
1722
  VoteAuthorizeWithSeedInstruction: {
1143
1723
  authorityOwner: resolveAccount("authorityOwner"),
1724
+ clockSysvar: resolveAccount("clockSysvar"),
1144
1725
  newAuthority: resolveAccount("newAuthority"),
1145
1726
  voteAccount: resolveAccount("voteAccount")
1146
1727
  },
@@ -1155,7 +1736,9 @@ var instructionResolvers = {
1155
1736
  VoteInitializeAccountInstruction: {
1156
1737
  authorizedVoter: resolveAccount("authorizedVoter"),
1157
1738
  authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
1739
+ clockSysvar: resolveAccount("clockSysvar"),
1158
1740
  node: resolveAccount("node"),
1741
+ rentSysvar: resolveAccount("rentSysvar"),
1159
1742
  voteAccount: resolveAccount("voteAccount")
1160
1743
  },
1161
1744
  VoteUpdateCommissionInstruction: {
@@ -1176,10 +1759,14 @@ var instructionResolvers = {
1176
1759
  voteAuthority: resolveAccount("voteAuthority")
1177
1760
  },
1178
1761
  VoteVoteInstruction: {
1762
+ clockSysvar: resolveAccount("clockSysvar"),
1763
+ slotHashesSysvar: resolveAccount("slotHashesSysvar"),
1179
1764
  voteAccount: resolveAccount("voteAccount"),
1180
1765
  voteAuthority: resolveAccount("voteAuthority")
1181
1766
  },
1182
1767
  VoteVoteSwitchInstruction: {
1768
+ clockSysvar: resolveAccount("clockSysvar"),
1769
+ slotHashesSysvar: resolveAccount("slotHashesSysvar"),
1183
1770
  voteAccount: resolveAccount("voteAccount"),
1184
1771
  voteAuthority: resolveAccount("voteAuthority")
1185
1772
  },
@@ -1190,7 +1777,9 @@ var instructionResolvers = {
1190
1777
  WithdrawNonceAccountInstruction: {
1191
1778
  destination: resolveAccount("destination"),
1192
1779
  nonceAccount: resolveAccount("nonceAccount"),
1193
- nonceAuthority: resolveAccount("nonceAuthority")
1780
+ nonceAuthority: resolveAccount("nonceAuthority"),
1781
+ recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
1782
+ rentSysvar: resolveAccount("rentSysvar")
1194
1783
  }
1195
1784
  };
1196
1785
 
@@ -1198,20 +1787,57 @@ var instructionResolvers = {
1198
1787
  function resolveProgramAccounts(fieldName) {
1199
1788
  return async (parent, args, context, info) => {
1200
1789
  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
- );
1790
+ if (programAddress) {
1791
+ const argsSet = buildProgramAccountsLoaderArgSetFromResolveInfo({ ...args, programAddress }, info);
1792
+ const loadedProgramAccountsLists = await context.loaders.programAccounts.loadMany(argsSet);
1793
+ const result = {};
1794
+ loadedProgramAccountsLists.forEach((programAccounts, i) => {
1795
+ if (programAccounts instanceof Error) {
1796
+ console.error(programAccounts);
1797
+ return;
1798
+ }
1799
+ programAccounts.forEach((programAccount) => {
1800
+ const { account, pubkey: address } = programAccount;
1801
+ const thisResult = result[address] ||= {
1802
+ ...account,
1803
+ address,
1804
+ encodedData: {},
1805
+ ownerProgram: account.owner
1806
+ };
1807
+ const { data } = account;
1808
+ const { encoding, dataSlice } = argsSet[i];
1809
+ if (encoding && thisResult.encodedData) {
1810
+ if (Array.isArray(data)) {
1811
+ thisResult.encodedData[cacheKeyFn({
1812
+ dataSlice,
1813
+ encoding: encoding === "jsonParsed" ? "base64" : encoding
1814
+ })] = data[0];
1815
+ } else if (typeof data === "string") {
1816
+ thisResult.encodedData[cacheKeyFn({
1817
+ dataSlice,
1818
+ encoding: "base58"
1819
+ })] = data;
1820
+ } else if (typeof data === "object") {
1821
+ const {
1822
+ parsed: { info: parsedData, type: accountType },
1823
+ program: programName,
1824
+ programId
1825
+ } = data;
1826
+ thisResult.jsonParsedConfigs = {
1827
+ accountType,
1828
+ programId,
1829
+ programName
1830
+ };
1831
+ for (const key in parsedData) {
1832
+ thisResult[key] = parsedData[key];
1833
+ }
1834
+ }
1835
+ }
1836
+ });
1837
+ });
1838
+ return Object.values(result);
1839
+ }
1840
+ return null;
1215
1841
  };
1216
1842
  }
1217
1843
 
@@ -1238,47 +1864,49 @@ var stringScalarAlias = {
1238
1864
  return value;
1239
1865
  }
1240
1866
  };
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);
1867
+ var bigIntScalarAlias = {
1868
+ __parseLiteral(ast) {
1869
+ if (ast.kind === graphql.Kind.STRING || ast.kind === graphql.Kind.INT || ast.kind === graphql.Kind.FLOAT) {
1870
+ return BigInt(ast.value);
1258
1871
  }
1872
+ return null;
1873
+ },
1874
+ __parseValue(value) {
1875
+ return BigInt(value);
1876
+ },
1877
+ __serialize(value) {
1878
+ return BigInt(value);
1259
1879
  }
1260
1880
  };
1261
-
1262
- // src/resolvers/types.ts
1263
- var commonTypeResolvers = {
1881
+ var typeTypeResolvers = {
1264
1882
  AccountEncoding: {
1265
1883
  BASE_58: "base58",
1266
1884
  BASE_64: "base64",
1267
- BASE_64_ZSTD: "base64+zstd",
1268
- PARSED: "jsonParsed"
1885
+ BASE_64_ZSTD: "base64+zstd"
1269
1886
  },
1887
+ Address: stringScalarAlias,
1888
+ Base58EncodedBytes: stringScalarAlias,
1889
+ Base64EncodedBytes: stringScalarAlias,
1890
+ Base64ZstdEncodedBytes: stringScalarAlias,
1891
+ BigInt: bigIntScalarAlias,
1892
+ Commitment: {
1893
+ CONFIRMED: "confirmed",
1894
+ FINALIZED: "finalized",
1895
+ PROCESSED: "processed"
1896
+ },
1897
+ CommitmentWithoutProcessed: {
1898
+ CONFIRMED: "confirmed",
1899
+ FINALIZED: "finalized"
1900
+ },
1901
+ Signature: stringScalarAlias,
1902
+ Slot: bigIntScalarAlias,
1270
1903
  TokenBalance: {
1271
1904
  mint: resolveAccount("mint"),
1272
1905
  owner: resolveAccount("owner")
1273
1906
  },
1274
1907
  TransactionEncoding: {
1275
1908
  BASE_58: "base58",
1276
- BASE_64: "base64",
1277
- PARSED: "jsonParsed"
1278
- },
1279
- TransactionVersion: {
1280
- LEGACY: "legacy",
1281
- ZERO: 0
1909
+ BASE_64: "base64"
1282
1910
  }
1283
1911
  };
1284
1912
 
@@ -1287,11 +1915,10 @@ function createSolanaGraphQLResolvers() {
1287
1915
  return {
1288
1916
  ...accountResolvers,
1289
1917
  ...blockResolvers,
1290
- ...commonTypeResolvers,
1291
1918
  ...instructionResolvers,
1292
1919
  ...rootResolvers,
1293
- ...scalarResolvers,
1294
- ...transactionResolvers
1920
+ ...transactionResolvers,
1921
+ ...typeTypeResolvers
1295
1922
  };
1296
1923
  }
1297
1924
 
@@ -1304,6 +1931,7 @@ var accountTypeDefs = (
1304
1931
  """
1305
1932
  interface Account {
1306
1933
  address: Address
1934
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1307
1935
  executable: Boolean
1308
1936
  lamports: BigInt
1309
1937
  ownerProgram: Account
@@ -1312,37 +1940,11 @@ var accountTypeDefs = (
1312
1940
  }
1313
1941
 
1314
1942
  """
1315
- An account with base58 encoded data
1943
+ Generic base account type
1316
1944
  """
1317
- type AccountBase58 implements Account {
1945
+ type GenericAccount implements Account {
1318
1946
  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
1947
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1346
1948
  executable: Boolean
1347
1949
  lamports: BigInt
1348
1950
  ownerProgram: Account
@@ -1358,6 +1960,7 @@ var accountTypeDefs = (
1358
1960
  """
1359
1961
  type NonceAccount implements Account {
1360
1962
  address: Address
1963
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1361
1964
  executable: Boolean
1362
1965
  lamports: BigInt
1363
1966
  ownerProgram: Account
@@ -1373,6 +1976,7 @@ var accountTypeDefs = (
1373
1976
  """
1374
1977
  type LookupTableAccount implements Account {
1375
1978
  address: Address
1979
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1376
1980
  executable: Boolean
1377
1981
  lamports: BigInt
1378
1982
  ownerProgram: Account
@@ -1390,6 +1994,7 @@ var accountTypeDefs = (
1390
1994
  """
1391
1995
  type MintAccount implements Account {
1392
1996
  address: Address
1997
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1393
1998
  executable: Boolean
1394
1999
  lamports: BigInt
1395
2000
  ownerProgram: Account
@@ -1407,6 +2012,7 @@ var accountTypeDefs = (
1407
2012
  """
1408
2013
  type TokenAccount implements Account {
1409
2014
  address: Address
2015
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1410
2016
  executable: Boolean
1411
2017
  lamports: BigInt
1412
2018
  ownerProgram: Account
@@ -1449,6 +2055,7 @@ var accountTypeDefs = (
1449
2055
  """
1450
2056
  type StakeAccount implements Account {
1451
2057
  address: Address
2058
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1452
2059
  executable: Boolean
1453
2060
  lamports: BigInt
1454
2061
  ownerProgram: Account
@@ -1480,6 +2087,7 @@ var accountTypeDefs = (
1480
2087
  """
1481
2088
  type VoteAccount implements Account {
1482
2089
  address: Address
2090
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1483
2091
  executable: Boolean
1484
2092
  lamports: BigInt
1485
2093
  ownerProgram: Account
@@ -1502,188 +2110,18 @@ var accountTypeDefs = (
1502
2110
  var blockTypeDefs = (
1503
2111
  /* GraphQL */
1504
2112
  `
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
2113
  """
1527
- Block interface
2114
+ A Solana block
1528
2115
  """
1529
- interface Block {
2116
+ type Block {
1530
2117
  blockhash: String
1531
2118
  blockHeight: BigInt
1532
2119
  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
2120
+ parentSlot: Slot
1561
2121
  previousBlockhash: String
1562
2122
  rewards: [Reward]
2123
+ signatures: [Signature]
1563
2124
  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
2125
  }
1688
2126
  `
1689
2127
  );
@@ -1805,12 +2243,12 @@ var instructionTypeDefs = (
1805
2243
  programId: Address
1806
2244
  authority: Account
1807
2245
  bufferAccount: Account
1808
- clockSysvar: Address
2246
+ clockSysvar: Account
1809
2247
  maxDataLen: BigInt
1810
2248
  payerAccount: Account
1811
2249
  programAccount: Account
1812
2250
  programDataAccount: Account
1813
- rentSysvar: Address
2251
+ rentSysvar: Account
1814
2252
  }
1815
2253
 
1816
2254
  """
@@ -1820,10 +2258,10 @@ var instructionTypeDefs = (
1820
2258
  programId: Address
1821
2259
  authority: Account
1822
2260
  bufferAccount: Account
1823
- clockSysvar: Address
2261
+ clockSysvar: Account
1824
2262
  programAccount: Account
1825
2263
  programDataAccount: Account
1826
- rentSysvar: Address
2264
+ rentSysvar: Account
1827
2265
  spillAccount: Account
1828
2266
  }
1829
2267
 
@@ -1876,7 +2314,7 @@ var instructionTypeDefs = (
1876
2314
  type SplAssociatedTokenCreateInstruction implements TransactionInstruction {
1877
2315
  programId: Address
1878
2316
  account: Account
1879
- mint: Address
2317
+ mint: Account
1880
2318
  source: Account
1881
2319
  systemProgram: Account
1882
2320
  tokenProgram: Account
@@ -1889,7 +2327,7 @@ var instructionTypeDefs = (
1889
2327
  type SplAssociatedTokenCreateIdempotentInstruction implements TransactionInstruction {
1890
2328
  programId: Address
1891
2329
  account: Account
1892
- mint: Address
2330
+ mint: Account
1893
2331
  source: Account
1894
2332
  systemProgram: Account
1895
2333
  tokenProgram: Account
@@ -1927,7 +2365,7 @@ var instructionTypeDefs = (
1927
2365
  freezeAuthority: Account
1928
2366
  mint: Account
1929
2367
  mintAuthority: Account
1930
- rentSysvar: Address
2368
+ rentSysvar: Account
1931
2369
  }
1932
2370
 
1933
2371
  """
@@ -1949,7 +2387,7 @@ var instructionTypeDefs = (
1949
2387
  account: Account
1950
2388
  mint: Account
1951
2389
  owner: Account
1952
- rentSysvar: Address
2390
+ rentSysvar: Account
1953
2391
  }
1954
2392
 
1955
2393
  """
@@ -1960,7 +2398,7 @@ var instructionTypeDefs = (
1960
2398
  account: Account
1961
2399
  mint: Account
1962
2400
  owner: Account
1963
- rentSysvar: Address
2401
+ rentSysvar: Account
1964
2402
  }
1965
2403
 
1966
2404
  """
@@ -1980,7 +2418,7 @@ var instructionTypeDefs = (
1980
2418
  programId: Address
1981
2419
  m: BigInt # FIXME:*
1982
2420
  multisig: Account
1983
- rentSysvar: Address
2421
+ rentSysvar: Account
1984
2422
  signers: [Address]
1985
2423
  }
1986
2424
 
@@ -2235,7 +2673,7 @@ var instructionTypeDefs = (
2235
2673
  programId: Address
2236
2674
  authorized: StakeInitializeInstructionDataAuthorized
2237
2675
  lockup: Lockup
2238
- rentSysvar: Address
2676
+ rentSysvar: Account
2239
2677
  stakeAccount: Account
2240
2678
  }
2241
2679
 
@@ -2246,7 +2684,7 @@ var instructionTypeDefs = (
2246
2684
  programId: Address
2247
2685
  authority: Account
2248
2686
  authorityType: String
2249
- clockSysvar: Address
2687
+ clockSysvar: Account
2250
2688
  custodian: Account
2251
2689
  newAuthority: Account
2252
2690
  stakeAccount: Account
@@ -2257,11 +2695,11 @@ var instructionTypeDefs = (
2257
2695
  """
2258
2696
  type StakeDelegateStakeInstruction implements TransactionInstruction {
2259
2697
  programId: Address
2260
- clockSysvar: Address
2698
+ clockSysvar: Account
2261
2699
  stakeAccount: Account
2262
2700
  stakeAuthority: Account
2263
2701
  stakeConfigAccount: Account
2264
- stakeHistorySysvar: Address
2702
+ stakeHistorySysvar: Account
2265
2703
  voteAccount: Account
2266
2704
  }
2267
2705
 
@@ -2281,7 +2719,7 @@ var instructionTypeDefs = (
2281
2719
  """
2282
2720
  type StakeWithdrawInstruction implements TransactionInstruction {
2283
2721
  programId: Address
2284
- clockSysvar: Address
2722
+ clockSysvar: Account
2285
2723
  destination: Account
2286
2724
  lamports: BigInt
2287
2725
  stakeAccount: Account
@@ -2293,7 +2731,7 @@ var instructionTypeDefs = (
2293
2731
  """
2294
2732
  type StakeDeactivateInstruction implements TransactionInstruction {
2295
2733
  programId: Address
2296
- clockSysvar: Address
2734
+ clockSysvar: Account
2297
2735
  stakeAccount: Account
2298
2736
  stakeAuthority: Account
2299
2737
  }
@@ -2313,11 +2751,11 @@ var instructionTypeDefs = (
2313
2751
  """
2314
2752
  type StakeMergeInstruction implements TransactionInstruction {
2315
2753
  programId: Address
2316
- clockSysvar: Address
2754
+ clockSysvar: Account
2317
2755
  destination: Account
2318
2756
  source: Account
2319
2757
  stakeAuthority: Account
2320
- stakeHistorySysvar: Address
2758
+ stakeHistorySysvar: Account
2321
2759
  }
2322
2760
 
2323
2761
  """
@@ -2329,7 +2767,7 @@ var instructionTypeDefs = (
2329
2767
  authorityOwner: Account
2330
2768
  authoritySeed: String
2331
2769
  authorityType: String
2332
- clockSysvar: Address
2770
+ clockSysvar: Account
2333
2771
  custodian: Account
2334
2772
  newAuthorized: Account
2335
2773
  stakeAccount: Account
@@ -2346,7 +2784,7 @@ var instructionTypeDefs = (
2346
2784
  programId: Address
2347
2785
  authorized: StakeInitializeCheckedInstructionDataAuthorized
2348
2786
  lockup: Lockup
2349
- rentSysvar: Address
2787
+ rentSysvar: Account
2350
2788
  stakeAccount: Account
2351
2789
  }
2352
2790
 
@@ -2357,7 +2795,7 @@ var instructionTypeDefs = (
2357
2795
  programId: Address
2358
2796
  authority: Account
2359
2797
  authorityType: String
2360
- clockSysvar: Address
2798
+ clockSysvar: Account
2361
2799
  custodian: Account
2362
2800
  newAuthority: Account
2363
2801
  stakeAccount: Account
@@ -2372,7 +2810,7 @@ var instructionTypeDefs = (
2372
2810
  authorityOwner: Account
2373
2811
  authoritySeed: String
2374
2812
  authorityType: String
2375
- clockSysvar: Address
2813
+ clockSysvar: Account
2376
2814
  custodian: Account
2377
2815
  newAuthorized: Account
2378
2816
  stakeAccount: Account
@@ -2460,7 +2898,7 @@ var instructionTypeDefs = (
2460
2898
  programId: Address
2461
2899
  nonceAccount: Account
2462
2900
  nonceAuthority: Account
2463
- recentBlockhashesSysvar: Address
2901
+ recentBlockhashesSysvar: Account
2464
2902
  }
2465
2903
 
2466
2904
  """
@@ -2472,8 +2910,8 @@ var instructionTypeDefs = (
2472
2910
  lamports: BigInt
2473
2911
  nonceAccount: Account
2474
2912
  nonceAuthority: Account
2475
- recentBlockhashesSysvar: Address
2476
- rentSysvar: Address
2913
+ recentBlockhashesSysvar: Account
2914
+ rentSysvar: Account
2477
2915
  }
2478
2916
 
2479
2917
  """
@@ -2483,8 +2921,8 @@ var instructionTypeDefs = (
2483
2921
  programId: Address
2484
2922
  nonceAccount: Account
2485
2923
  nonceAuthority: Account
2486
- recentBlockhashesSysvar: Address
2487
- rentSysvar: Address
2924
+ recentBlockhashesSysvar: Account
2925
+ rentSysvar: Account
2488
2926
  }
2489
2927
 
2490
2928
  """
@@ -2558,10 +2996,10 @@ var instructionTypeDefs = (
2558
2996
  programId: Address
2559
2997
  authorizedVoter: Account
2560
2998
  authorizedWithdrawer: Account
2561
- clockSysvar: Address
2999
+ clockSysvar: Account
2562
3000
  commission: BigInt # FIXME:*
2563
3001
  node: Account
2564
- rentSysvar: Address
3002
+ rentSysvar: Account
2565
3003
  voteAccount: Account
2566
3004
  }
2567
3005
 
@@ -2572,7 +3010,7 @@ var instructionTypeDefs = (
2572
3010
  programId: Address
2573
3011
  authority: Account
2574
3012
  authorityType: String
2575
- clockSysvar: Address
3013
+ clockSysvar: Account
2576
3014
  newAuthority: Account
2577
3015
  voteAccount: Account
2578
3016
  }
@@ -2586,7 +3024,7 @@ var instructionTypeDefs = (
2586
3024
  authorityOwner: Account
2587
3025
  authoritySeed: String
2588
3026
  authorityType: String
2589
- clockSysvar: Address
3027
+ clockSysvar: Account
2590
3028
  newAuthority: Account
2591
3029
  voteAccount: Account
2592
3030
  }
@@ -2600,7 +3038,7 @@ var instructionTypeDefs = (
2600
3038
  authorityOwner: Account
2601
3039
  authoritySeed: String
2602
3040
  authorityType: String
2603
- clockSysvar: Address
3041
+ clockSysvar: Account
2604
3042
  newAuthority: Account
2605
3043
  voteAccount: Account
2606
3044
  }
@@ -2616,8 +3054,8 @@ var instructionTypeDefs = (
2616
3054
  """
2617
3055
  type VoteVoteInstruction implements TransactionInstruction {
2618
3056
  programId: Address
2619
- clockSysvar: Address
2620
- slotHashesSysvar: Address
3057
+ clockSysvar: Account
3058
+ slotHashesSysvar: Account
2621
3059
  vote: Vote
2622
3060
  voteAccount: Account
2623
3061
  voteAuthority: Account
@@ -2714,9 +3152,9 @@ var instructionTypeDefs = (
2714
3152
  """
2715
3153
  type VoteVoteSwitchInstruction implements TransactionInstruction {
2716
3154
  programId: Address
2717
- clockSysvar: Address
3155
+ clockSysvar: Account
2718
3156
  hash: String
2719
- slotHashesSysvar: Address
3157
+ slotHashesSysvar: Account
2720
3158
  vote: Vote
2721
3159
  voteAccount: Account
2722
3160
  voteAuthority: Account
@@ -2729,7 +3167,7 @@ var instructionTypeDefs = (
2729
3167
  programId: Address
2730
3168
  authority: Account
2731
3169
  authorityType: String
2732
- clockSysvar: Address
3170
+ clockSysvar: Account
2733
3171
  newAuthority: Account
2734
3172
  voteAccount: Account
2735
3173
  }
@@ -2741,28 +3179,15 @@ var rootTypeDefs = (
2741
3179
  /* GraphQL */
2742
3180
  `
2743
3181
  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
3182
+ account(address: Address!, commitment: Commitment, minContextSlot: Slot): Account
3183
+ block(slot: Slot!, commitment: CommitmentWithoutProcessed): Block
2757
3184
  programAccounts(
2758
- programAddress: String!
3185
+ programAddress: Address!
2759
3186
  commitment: Commitment
2760
- dataSlice: DataSlice
2761
- encoding: AccountEncoding
2762
3187
  filters: [ProgramAccountsFilter]
2763
- minContextSlot: BigInt
3188
+ minContextSlot: Slot
2764
3189
  ): [Account]
2765
- transaction(signature: String!, commitment: Commitment, encoding: TransactionEncoding): Transaction
3190
+ transaction(signature: Signature!, commitment: CommitmentWithoutProcessed): Transaction
2766
3191
  }
2767
3192
 
2768
3193
  schema {
@@ -2837,77 +3262,120 @@ var transactionTypeDefs = (
2837
3262
  }
2838
3263
 
2839
3264
  """
2840
- Transaction interface
3265
+ A Solana transaction
2841
3266
  """
2842
- interface Transaction {
3267
+ type Transaction {
2843
3268
  blockTime: BigInt
3269
+ data(encoding: TransactionEncoding!): String
3270
+ message: TransactionMessage
2844
3271
  meta: TransactionMeta
2845
- slot: BigInt
3272
+ signatures: [Signature]
3273
+ slot: Slot
2846
3274
  version: String
2847
3275
  }
3276
+ `
3277
+ );
2848
3278
 
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
3279
+ // src/schema/types.ts
3280
+ var typeTypeDefs = (
3281
+ /* GraphQL */
3282
+ `
3283
+ enum AccountEncoding {
3284
+ BASE_58
3285
+ BASE_64
3286
+ BASE_64_ZSTD
2858
3287
  }
2859
3288
 
2860
- """
2861
- A transaction with base64 encoded data
2862
- """
2863
- type TransactionBase64 implements Transaction {
2864
- blockTime: BigInt
3289
+ scalar Address
3290
+
3291
+ scalar Base58EncodedBytes
3292
+
3293
+ scalar Base64EncodedBytes
3294
+
3295
+ scalar Base64ZstdEncodedBytes
3296
+
3297
+ scalar BigInt
3298
+
3299
+ enum Commitment {
3300
+ CONFIRMED
3301
+ FINALIZED
3302
+ PROCESSED
3303
+ }
3304
+
3305
+ enum CommitmentWithoutProcessed {
3306
+ CONFIRMED
3307
+ FINALIZED
3308
+ }
3309
+
3310
+ input DataSlice {
3311
+ offset: Int!
3312
+ length: Int!
3313
+ }
3314
+
3315
+ input ProgramAccountsFilter {
3316
+ bytes: BigInt
3317
+ dataSize: BigInt
3318
+ encoding: AccountEncoding
3319
+ offset: BigInt
3320
+ }
3321
+
3322
+ type ReturnData {
2865
3323
  data: Base64EncodedBytes
2866
- meta: TransactionMeta
2867
- slot: BigInt
2868
- version: String
3324
+ programId: Address
2869
3325
  }
2870
3326
 
2871
- """
2872
- A transaction with JSON encoded data
2873
- """
2874
- type TransactionDataParsed {
2875
- message: TransactionMessage
2876
- signatures: [String]
3327
+ type Reward {
3328
+ commission: Int
3329
+ lamports: BigInt
3330
+ postBalance: BigInt
3331
+ pubkey: Address
3332
+ rewardType: String
2877
3333
  }
2878
- type TransactionParsed implements Transaction {
2879
- blockTime: BigInt
2880
- data: TransactionDataParsed
2881
- meta: TransactionMeta
2882
- slot: BigInt
2883
- version: String
3334
+
3335
+ scalar Signature
3336
+
3337
+ scalar Slot
3338
+
3339
+ type TokenAmount {
3340
+ amount: String
3341
+ decimals: Int
3342
+ uiAmount: BigInt
3343
+ uiAmountString: String
3344
+ }
3345
+
3346
+ type TokenBalance {
3347
+ accountIndex: Int
3348
+ mint: Account
3349
+ owner: Account
3350
+ programId: Address
3351
+ uiTokenAmount: TokenAmount
3352
+ }
3353
+
3354
+ enum TransactionEncoding {
3355
+ BASE_58
3356
+ BASE_64
2884
3357
  }
2885
3358
  `
2886
3359
  );
2887
3360
 
2888
3361
  // src/schema/index.ts
2889
3362
  function createSolanaGraphQLTypeDefs() {
2890
- return [
2891
- accountTypeDefs,
2892
- blockTypeDefs,
2893
- commonTypeDefs,
2894
- inputTypeDefs,
2895
- instructionTypeDefs,
2896
- rootTypeDefs,
2897
- scalarTypeDefs,
2898
- transactionTypeDefs
2899
- ];
3363
+ return [accountTypeDefs, blockTypeDefs, instructionTypeDefs, rootTypeDefs, typeTypeDefs, transactionTypeDefs];
2900
3364
  }
2901
3365
 
2902
3366
  // src/index.ts
2903
- function createRpcGraphQL(rpc) {
2904
- const contextValue = createSolanaGraphQLContext(rpc);
3367
+ function createRpcGraphQL(rpc, config) {
3368
+ const rpcGraphQLConfig = {
3369
+ maxDataSliceByteRange: config?.maxDataSliceByteRange ?? 200,
3370
+ maxMultipleAccountsBatchSize: config?.maxMultipleAccountsBatchSize ?? 100
3371
+ };
2905
3372
  const schema$1 = schema.makeExecutableSchema({
2906
3373
  resolvers: createSolanaGraphQLResolvers(),
2907
3374
  typeDefs: createSolanaGraphQLTypeDefs()
2908
3375
  });
2909
3376
  return {
2910
3377
  async query(source, variableValues) {
3378
+ const contextValue = createSolanaGraphQLContext(rpc, rpcGraphQLConfig);
2911
3379
  return graphql.graphql({
2912
3380
  contextValue,
2913
3381
  schema: schema$1,