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