@solana/rpc-graphql 2.0.0-experimental.21e994f → 2.0.0-experimental.2200007

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 (67) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1088 -30
  3. package/dist/index.browser.cjs +2997 -51
  4. package/dist/index.browser.cjs.map +1 -1
  5. package/dist/index.browser.js +2993 -52
  6. package/dist/index.browser.js.map +1 -1
  7. package/dist/index.native.js +2995 -50
  8. package/dist/index.native.js.map +1 -1
  9. package/dist/index.node.cjs +2996 -46
  10. package/dist/index.node.cjs.map +1 -1
  11. package/dist/index.node.js +2995 -50
  12. package/dist/index.node.js.map +1 -1
  13. package/dist/types/context.d.ts +5 -6
  14. package/dist/types/context.d.ts.map +1 -0
  15. package/dist/types/index.d.ts +8 -1
  16. package/dist/types/index.d.ts.map +1 -0
  17. package/dist/types/loaders/account.d.ts +4 -0
  18. package/dist/types/loaders/account.d.ts.map +1 -0
  19. package/dist/types/loaders/block.d.ts +4 -0
  20. package/dist/types/loaders/block.d.ts.map +1 -0
  21. package/dist/types/loaders/index.d.ts +6 -0
  22. package/dist/types/loaders/index.d.ts.map +1 -0
  23. package/dist/types/loaders/loader.d.ts +65 -0
  24. package/dist/types/loaders/loader.d.ts.map +1 -0
  25. package/dist/types/loaders/program-accounts.d.ts +4 -0
  26. package/dist/types/loaders/program-accounts.d.ts.map +1 -0
  27. package/dist/types/loaders/transaction.d.ts +4 -0
  28. package/dist/types/loaders/transaction.d.ts.map +1 -0
  29. package/dist/types/resolvers/account.d.ts +232 -0
  30. package/dist/types/resolvers/account.d.ts.map +1 -0
  31. package/dist/types/resolvers/block.d.ts +20 -0
  32. package/dist/types/resolvers/block.d.ts.map +1 -0
  33. package/dist/types/resolvers/index.d.ts +3 -0
  34. package/dist/types/resolvers/index.d.ts.map +1 -0
  35. package/dist/types/resolvers/instruction.d.ts +1968 -0
  36. package/dist/types/resolvers/instruction.d.ts.map +1 -0
  37. package/dist/types/resolvers/program-accounts.d.ts +11 -0
  38. package/dist/types/resolvers/program-accounts.d.ts.map +1 -0
  39. package/dist/types/resolvers/resolve-info/account.d.ts +14 -0
  40. package/dist/types/resolvers/resolve-info/account.d.ts.map +1 -0
  41. package/dist/types/resolvers/resolve-info/index.d.ts +3 -0
  42. package/dist/types/resolvers/resolve-info/index.d.ts.map +1 -0
  43. package/dist/types/resolvers/resolve-info/visitor.d.ts +18 -0
  44. package/dist/types/resolvers/resolve-info/visitor.d.ts.map +1 -0
  45. package/dist/types/resolvers/root.d.ts +3 -0
  46. package/dist/types/resolvers/root.d.ts.map +1 -0
  47. package/dist/types/resolvers/transaction.d.ts +19 -0
  48. package/dist/types/resolvers/transaction.d.ts.map +1 -0
  49. package/dist/types/resolvers/types.d.ts +101 -0
  50. package/dist/types/resolvers/types.d.ts.map +1 -0
  51. package/dist/types/schema/account.d.ts +2 -0
  52. package/dist/types/schema/account.d.ts.map +1 -0
  53. package/dist/types/schema/block.d.ts +2 -0
  54. package/dist/types/schema/block.d.ts.map +1 -0
  55. package/dist/types/schema/index.d.ts +2 -0
  56. package/dist/types/schema/index.d.ts.map +1 -0
  57. package/dist/types/schema/instruction.d.ts +2 -0
  58. package/dist/types/schema/instruction.d.ts.map +1 -0
  59. package/dist/types/schema/root.d.ts +2 -0
  60. package/dist/types/schema/root.d.ts.map +1 -0
  61. package/dist/types/schema/transaction.d.ts +2 -0
  62. package/dist/types/schema/transaction.d.ts.map +1 -0
  63. package/dist/types/schema/types.d.ts +2 -0
  64. package/dist/types/schema/types.d.ts.map +1 -0
  65. package/package.json +14 -36
  66. package/dist/types/cache.d.ts +0 -7
  67. package/dist/types/rpc.d.ts +0 -13
@@ -1,75 +1,3021 @@
1
1
  'use strict';
2
2
 
3
+ var schema = require('@graphql-tools/schema');
3
4
  var graphql = require('graphql');
5
+ var DataLoader = require('dataloader');
6
+ var stringify = require('json-stable-stringify');
4
7
 
5
- // src/rpc.ts
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
9
 
7
- // src/cache.ts
8
- var stringifyValue = (value) => JSON.stringify(value, (_, value2) => {
9
- if (typeof value2 === "bigint") {
10
- return value2.toString() + "n";
11
- }
12
- return value2;
13
- });
14
- var parseValue = (value) => JSON.parse(value, (_, value2) => {
15
- if (typeof value2 === "string" && /\d+n$/.test(value2)) {
16
- return BigInt(value2.slice(0, -1));
10
+ var DataLoader__default = /*#__PURE__*/_interopDefault(DataLoader);
11
+ var stringify__default = /*#__PURE__*/_interopDefault(stringify);
12
+
13
+ // src/index.ts
14
+ function replacer(_, value) {
15
+ if (typeof value === "bigint") {
16
+ return value.toString() + "n";
17
17
  }
18
- return value2;
19
- });
20
- var cacheKey = (key, variables) => `GraphQLCache:${stringifyValue(key)}:${stringifyValue(variables)}`;
21
- function createGraphQLCache() {
18
+ return value;
19
+ }
20
+ var cacheKeyFn = (obj) => stringify__default.default(obj, { replacer });
21
+
22
+ // src/loaders/account.ts
23
+ function applyDefaultArgs({
24
+ address,
25
+ commitment,
26
+ dataSlice,
27
+ encoding = "base64",
28
+ // Fixed by batch loader
29
+ minContextSlot
30
+ }) {
22
31
  return {
23
- // Browser
24
- flush: () => {
25
- for (let i = localStorage.length - 1; i >= 0; i--) {
26
- const storageKey = localStorage.key(i);
27
- if (storageKey && storageKey.startsWith("GraphQLCache:")) {
28
- localStorage.removeItem(storageKey);
29
- }
30
- }
32
+ address,
33
+ commitment,
34
+ dataSlice,
35
+ encoding,
36
+ minContextSlot
37
+ };
38
+ }
39
+ async function loadAccount(rpc, { address, ...config }) {
40
+ return await rpc.getAccountInfo(address, config).send().then((res) => res.value);
41
+ }
42
+ function createAccountBatchLoadFn(rpc) {
43
+ const resolveAccountUsingRpc = loadAccount.bind(null, rpc);
44
+ return async (accountQueryArgs) => Promise.all(accountQueryArgs.map(async (args) => resolveAccountUsingRpc(applyDefaultArgs(args))));
45
+ }
46
+ function createAccountLoader(rpc) {
47
+ const loader = new DataLoader__default.default(createAccountBatchLoadFn(rpc), { cacheKeyFn });
48
+ return {
49
+ load: async (args) => loader.load(applyDefaultArgs(args)),
50
+ loadMany: async (args) => loader.loadMany(args.map(applyDefaultArgs))
51
+ };
52
+ }
53
+ function applyDefaultArgs2({
54
+ slot,
55
+ commitment,
56
+ encoding = "jsonParsed",
57
+ maxSupportedTransactionVersion = 0,
58
+ rewards,
59
+ transactionDetails = "full"
60
+ }) {
61
+ return {
62
+ commitment,
63
+ encoding,
64
+ maxSupportedTransactionVersion,
65
+ rewards,
66
+ slot,
67
+ transactionDetails
68
+ };
69
+ }
70
+ async function loadBlock(rpc, { slot, ...config }) {
71
+ return await rpc.getBlock(
72
+ slot,
73
+ // @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
74
+ config
75
+ ).send();
76
+ }
77
+ function createBlockBatchLoadFn(rpc) {
78
+ const resolveBlockUsingRpc = loadBlock.bind(null, rpc);
79
+ return async (blockQueryArgs) => Promise.all(blockQueryArgs.map(async (args) => resolveBlockUsingRpc(applyDefaultArgs2(args))));
80
+ }
81
+ function createBlockLoader(rpc) {
82
+ const loader = new DataLoader__default.default(createBlockBatchLoadFn(rpc), { cacheKeyFn });
83
+ return {
84
+ load: async (args) => loader.load(applyDefaultArgs2(args)),
85
+ loadMany: async (args) => loader.loadMany(args.map(applyDefaultArgs2))
86
+ };
87
+ }
88
+ function applyDefaultArgs3({
89
+ commitment,
90
+ dataSlice,
91
+ encoding = "jsonParsed",
92
+ filters,
93
+ minContextSlot,
94
+ programAddress
95
+ }) {
96
+ return {
97
+ commitment,
98
+ dataSlice,
99
+ encoding,
100
+ filters,
101
+ minContextSlot,
102
+ programAddress
103
+ };
104
+ }
105
+ async function loadProgramAccounts(rpc, { programAddress, ...config }) {
106
+ return await rpc.getProgramAccounts(
107
+ programAddress,
108
+ // @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
109
+ config
110
+ ).send();
111
+ }
112
+ function createProgramAccountsBatchLoadFn(rpc) {
113
+ const resolveProgramAccountsUsingRpc = loadProgramAccounts.bind(null, rpc);
114
+ return async (programAccountsQueryArgs) => Promise.all(programAccountsQueryArgs.map(async (args) => resolveProgramAccountsUsingRpc(applyDefaultArgs3(args))));
115
+ }
116
+ function createProgramAccountsLoader(rpc) {
117
+ const loader = new DataLoader__default.default(createProgramAccountsBatchLoadFn(rpc), { cacheKeyFn });
118
+ return {
119
+ load: async (args) => loader.load(applyDefaultArgs3(args)),
120
+ loadMany: async (args) => loader.loadMany(args.map(applyDefaultArgs3))
121
+ };
122
+ }
123
+ function applyDefaultArgs4({
124
+ commitment,
125
+ encoding = "jsonParsed",
126
+ signature
127
+ }) {
128
+ return {
129
+ commitment,
130
+ encoding,
131
+ signature
132
+ };
133
+ }
134
+ async function loadTransaction(rpc, { signature, ...config }) {
135
+ return await rpc.getTransaction(
136
+ signature,
137
+ // @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
138
+ config
139
+ ).send();
140
+ }
141
+ function createTransactionBatchLoadFn(rpc) {
142
+ const resolveTransactionUsingRpc = loadTransaction.bind(null, rpc);
143
+ return async (transactionQueryArgs) => Promise.all(transactionQueryArgs.map(async (args) => resolveTransactionUsingRpc(applyDefaultArgs4(args))));
144
+ }
145
+ function createTransactionLoader(rpc) {
146
+ const loader = new DataLoader__default.default(createTransactionBatchLoadFn(rpc), { cacheKeyFn });
147
+ return {
148
+ load: async (args) => loader.load(applyDefaultArgs4(args)),
149
+ loadMany: async (args) => loader.loadMany(args.map(applyDefaultArgs4))
150
+ };
151
+ }
152
+
153
+ // src/context.ts
154
+ function createSolanaGraphQLContext(rpc) {
155
+ return {
156
+ loaders: {
157
+ account: createAccountLoader(rpc),
158
+ block: createBlockLoader(rpc),
159
+ programAccounts: createProgramAccountsLoader(rpc),
160
+ transaction: createTransactionLoader(rpc)
161
+ }
162
+ };
163
+ }
164
+ function injectableRootVisitor(info, rootNode, operations) {
165
+ const { fieldNodes } = info;
166
+ const root = rootNode ?? fieldNodes[0];
167
+ const parentIsRoot = (ancestors) => (Array.isArray(ancestors) ? ancestors[0] : ancestors) === root;
168
+ graphql.visit(root, {
169
+ Field(node, key, parent, path, ancestors) {
170
+ if (!parentIsRoot(ancestors))
171
+ return;
172
+ return operations.fieldNodeOperation(info, node, key, parent, path, ancestors);
31
173
  },
32
- get: (key, variables) => {
33
- const value = localStorage.getItem(cacheKey(key, variables));
34
- return value === null ? null : parseValue(value);
174
+ FragmentSpread(node, key, parent, path, ancestors) {
175
+ const fragmentDefinition = info.fragments[node.name.value];
176
+ return operations.fragmentSpreadNodeOperation(info, fragmentDefinition, node, key, parent, path, ancestors);
35
177
  },
36
- insert: (key, variables, value) => {
37
- localStorage.setItem(cacheKey(key, variables), stringifyValue(value));
178
+ InlineFragment(node, key, parent, path, ancestors) {
179
+ if (!parentIsRoot(ancestors))
180
+ return;
181
+ return operations.inlineFragmentNodeOperation(info, node, key, parent, path, ancestors);
38
182
  }
39
- } ;
183
+ });
184
+ }
185
+ function onlyFieldsRequested(fieldNames, info, rootNode) {
186
+ let onlyFieldsRequested2 = true;
187
+ function checkFieldsWithVisitor(root) {
188
+ injectableRootVisitor(info, root, {
189
+ fieldNodeOperation(_info, node) {
190
+ onlyFieldsRequested2 = fieldNames.includes(node.name.value);
191
+ if (!onlyFieldsRequested2) {
192
+ return graphql.BREAK;
193
+ }
194
+ },
195
+ fragmentSpreadNodeOperation(_info, fragment) {
196
+ checkFieldsWithVisitor(fragment);
197
+ },
198
+ inlineFragmentNodeOperation(_info, node) {
199
+ checkFieldsWithVisitor(node);
200
+ }
201
+ });
202
+ }
203
+ checkFieldsWithVisitor(rootNode ?? null);
204
+ return onlyFieldsRequested2;
40
205
  }
41
206
 
42
- // src/context.ts
43
- function createSolanaGraphQLContext(rpc) {
44
- const cache = createGraphQLCache();
45
- return { cache, rpc };
207
+ // src/resolvers/resolve-info/account.ts
208
+ function findArgumentNodeByName(argumentNodes, name) {
209
+ return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
210
+ }
211
+ function parseAccountEncodingArgument(argumentNodes, variableValues) {
212
+ const argumentNode = findArgumentNodeByName(argumentNodes, "encoding");
213
+ if (argumentNode) {
214
+ if (argumentNode.value.kind === "EnumValue") {
215
+ if (argumentNode.value.value === "BASE_58") {
216
+ return "base58";
217
+ }
218
+ if (argumentNode.value.value === "BASE_64") {
219
+ return "base64";
220
+ }
221
+ if (argumentNode.value.value === "BASE_64_ZSTD") {
222
+ return "base64+zstd";
223
+ }
224
+ }
225
+ if (argumentNode.value.kind === "Variable") {
226
+ return variableValues[argumentNode.value.name.value];
227
+ }
228
+ } else {
229
+ return void 0;
230
+ }
231
+ }
232
+ function parseAccountDataSliceArgument(argumentNodes, variableValues) {
233
+ const argumentNode = findArgumentNodeByName(argumentNodes, "dataSlice");
234
+ if (argumentNode) {
235
+ if (argumentNode.value.kind === "ObjectValue") {
236
+ const offsetArg = argumentNode.value.fields?.find((field) => field.name.value === "offset");
237
+ const lengthArg = argumentNode.value.fields?.find((field) => field.name.value === "length");
238
+ const length = lengthArg?.value.kind === "IntValue" ? parseInt(lengthArg.value.value) : lengthArg?.value.kind === "Variable" ? variableValues[lengthArg.value.name.value] : void 0;
239
+ const offset = offsetArg?.value.kind === "IntValue" ? parseInt(offsetArg.value.value) : offsetArg?.value.kind === "Variable" ? variableValues[offsetArg.value.name.value] : void 0;
240
+ return length !== void 0 && length !== null && offset !== void 0 && offset !== null ? { length, offset } : void 0;
241
+ }
242
+ if (argumentNode.value.kind === "Variable") {
243
+ return variableValues[argumentNode.value.name.value];
244
+ }
245
+ } else {
246
+ return void 0;
247
+ }
248
+ }
249
+ function buildAccountLoaderArgSetFromResolveInfo(args, info) {
250
+ const argSet = [args];
251
+ function buildArgSetWithVisitor(root) {
252
+ injectableRootVisitor(info, root, {
253
+ fieldNodeOperation(info2, node) {
254
+ if (node.name.value !== "data") {
255
+ return;
256
+ }
257
+ if (node.arguments) {
258
+ const { variableValues } = info2;
259
+ const encoding = parseAccountEncodingArgument(node.arguments, variableValues);
260
+ const dataSlice = parseAccountDataSliceArgument(node.arguments, variableValues);
261
+ argSet.push({ ...args, dataSlice, encoding });
262
+ }
263
+ },
264
+ fragmentSpreadNodeOperation(_info, fragment) {
265
+ buildArgSetWithVisitor(fragment);
266
+ },
267
+ inlineFragmentNodeOperation(info2, node) {
268
+ const { schema } = info2;
269
+ const accountInterface = schema.getType("Account");
270
+ if (graphql.isInterfaceType(accountInterface) && // Recursively check if the inline fragment requests any
271
+ // fields outside of the `Account` interface.
272
+ !onlyFieldsRequested(Object.keys(accountInterface.getFields()), info2, node)) {
273
+ argSet.push({ ...args, encoding: "jsonParsed" });
274
+ }
275
+ }
276
+ });
277
+ }
278
+ buildArgSetWithVisitor(null);
279
+ return argSet;
280
+ }
281
+
282
+ // src/resolvers/account.ts
283
+ var resolveAccountData = () => {
284
+ return (parent, args) => {
285
+ return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
286
+ };
287
+ };
288
+ var resolveAccount = (fieldName) => {
289
+ return async (parent, args, context, info) => {
290
+ const address = fieldName ? parent[fieldName] : args.address;
291
+ if (address) {
292
+ if (onlyFieldsRequested(["address"], info)) {
293
+ return { address };
294
+ }
295
+ const argsSet = buildAccountLoaderArgSetFromResolveInfo({ ...args, address }, info);
296
+ const loadedAccounts = await context.loaders.account.loadMany(argsSet);
297
+ let result = {
298
+ address,
299
+ encodedData: {}
300
+ };
301
+ loadedAccounts.forEach((account, i) => {
302
+ if (account instanceof Error) {
303
+ console.error(account);
304
+ return;
305
+ }
306
+ if (account === null) {
307
+ return;
308
+ }
309
+ if (!result.ownerProgram) {
310
+ result = {
311
+ ...result,
312
+ ...account,
313
+ ownerProgram: account.owner
314
+ };
315
+ }
316
+ const { data } = account;
317
+ const { encoding, dataSlice } = argsSet[i];
318
+ if (encoding && result.encodedData) {
319
+ if (Array.isArray(data)) {
320
+ result.encodedData[cacheKeyFn({
321
+ dataSlice,
322
+ encoding: encoding === "jsonParsed" ? "base64" : encoding
323
+ })] = data[0];
324
+ } else if (typeof data === "string") {
325
+ result.encodedData[cacheKeyFn({
326
+ dataSlice,
327
+ encoding: "base58"
328
+ })] = data;
329
+ } else if (typeof data === "object") {
330
+ const {
331
+ parsed: { info: parsedData, type: accountType },
332
+ program: programName,
333
+ programId
334
+ } = data;
335
+ result.jsonParsedConfigs = {
336
+ accountType,
337
+ programId,
338
+ programName
339
+ };
340
+ result = {
341
+ ...result,
342
+ ...parsedData
343
+ };
344
+ }
345
+ }
346
+ });
347
+ return result;
348
+ }
349
+ return null;
350
+ };
351
+ };
352
+ function resolveAccountType(accountResult) {
353
+ const { jsonParsedConfigs } = accountResult;
354
+ if (jsonParsedConfigs) {
355
+ if (jsonParsedConfigs.programName === "nonce") {
356
+ return "NonceAccount";
357
+ }
358
+ if (jsonParsedConfigs.accountType === "mint" && jsonParsedConfigs.programName === "spl-token") {
359
+ return "MintAccount";
360
+ }
361
+ if (jsonParsedConfigs.accountType === "account" && jsonParsedConfigs.programName === "spl-token") {
362
+ return "TokenAccount";
363
+ }
364
+ if (jsonParsedConfigs.programName === "stake") {
365
+ return "StakeAccount";
366
+ }
367
+ if (jsonParsedConfigs.accountType === "vote" && jsonParsedConfigs.programName === "vote") {
368
+ return "VoteAccount";
369
+ }
370
+ if (jsonParsedConfigs.accountType === "lookupTable" && jsonParsedConfigs.programName === "address-lookup-table") {
371
+ return "LookupTableAccount";
372
+ }
373
+ }
374
+ return "GenericAccount";
375
+ }
376
+ var accountResolvers = {
377
+ Account: {
378
+ __resolveType: resolveAccountType,
379
+ data: resolveAccountData()
380
+ },
381
+ GenericAccount: {
382
+ data: resolveAccountData(),
383
+ ownerProgram: resolveAccount("ownerProgram")
384
+ },
385
+ LookupTableAccount: {
386
+ authority: resolveAccount("authority"),
387
+ data: resolveAccountData(),
388
+ ownerProgram: resolveAccount("ownerProgram")
389
+ },
390
+ MintAccount: {
391
+ data: resolveAccountData(),
392
+ freezeAuthority: resolveAccount("freezeAuthority"),
393
+ mintAuthority: resolveAccount("mintAuthority"),
394
+ ownerProgram: resolveAccount("ownerProgram")
395
+ },
396
+ NonceAccount: {
397
+ authority: resolveAccount("authority"),
398
+ data: resolveAccountData(),
399
+ ownerProgram: resolveAccount("ownerProgram")
400
+ },
401
+ StakeAccount: {
402
+ data: resolveAccountData(),
403
+ ownerProgram: resolveAccount("ownerProgram")
404
+ },
405
+ StakeAccountDataMetaAuthorized: {
406
+ staker: resolveAccount("staker"),
407
+ withdrawer: resolveAccount("withdrawer")
408
+ },
409
+ StakeAccountDataMetaLockup: {
410
+ custodian: resolveAccount("custodian")
411
+ },
412
+ StakeAccountDataStakeDelegation: {
413
+ voter: resolveAccount("voter")
414
+ },
415
+ TokenAccount: {
416
+ data: resolveAccountData(),
417
+ mint: resolveAccount("mint"),
418
+ owner: resolveAccount("owner"),
419
+ ownerProgram: resolveAccount("ownerProgram")
420
+ },
421
+ VoteAccount: {
422
+ authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
423
+ data: resolveAccountData(),
424
+ node: resolveAccount("nodePubkey"),
425
+ ownerProgram: resolveAccount("ownerProgram")
426
+ },
427
+ VoteAccountDataAuthorizedVoter: {
428
+ authorizedVoter: resolveAccount("authorizedVoter")
429
+ }
430
+ };
431
+
432
+ // src/resolvers/transaction.ts
433
+ function transformParsedInstruction(parsedInstruction) {
434
+ if ("parsed" in parsedInstruction) {
435
+ if (typeof parsedInstruction.parsed === "string" && parsedInstruction.program === "spl-memo") {
436
+ const { parsed: memo, program: programName2, programId: programId2 } = parsedInstruction;
437
+ const instructionType2 = "memo";
438
+ return { instructionType: instructionType2, memo, programId: programId2, programName: programName2 };
439
+ }
440
+ const {
441
+ parsed: { info: data, type: instructionType },
442
+ program: programName,
443
+ programId
444
+ } = parsedInstruction;
445
+ return { instructionType, programId, programName, ...data };
446
+ } else {
447
+ return parsedInstruction;
448
+ }
449
+ }
450
+ function transformParsedTransaction(parsedTransaction) {
451
+ const transactionData = parsedTransaction.transaction;
452
+ const transactionMeta = parsedTransaction.meta;
453
+ transactionData.message.instructions = transactionData.message.instructions.map(transformParsedInstruction);
454
+ transactionMeta.innerInstructions = transactionMeta.innerInstructions.map((innerInstruction) => {
455
+ innerInstruction.instructions = innerInstruction.instructions.map(transformParsedInstruction);
456
+ return innerInstruction;
457
+ });
458
+ return [transactionData, transactionMeta];
459
+ }
460
+ function transformLoadedTransaction({
461
+ encoding = "jsonParsed",
462
+ transaction
463
+ }) {
464
+ const [transactionData, transactionMeta] = Array.isArray(transaction.transaction) ? (
465
+ // The requested encoding is base58 or base64.
466
+ [transaction.transaction[0], transaction.meta]
467
+ ) : (
468
+ // The transaction was either partially parsed or
469
+ // fully JSON-parsed, which will be sorted later.
470
+ transformParsedTransaction(transaction)
471
+ );
472
+ transaction.data = transactionData;
473
+ transaction.encoding = encoding;
474
+ transaction.meta = transactionMeta;
475
+ return transaction;
476
+ }
477
+ function resolveTransaction(fieldName) {
478
+ return async (parent, args, context, info) => {
479
+ const signature = fieldName ? parent[fieldName] : args.signature;
480
+ if (!signature) {
481
+ return null;
482
+ }
483
+ if (onlyFieldsRequested(["signature"], info)) {
484
+ return { signature };
485
+ }
486
+ const transaction = await context.loaders.transaction.load({ ...args, signature });
487
+ if (!transaction) {
488
+ return null;
489
+ }
490
+ if (args.encoding !== "jsonParsed") {
491
+ const transactionJsonParsed = await context.loaders.transaction.load({
492
+ ...args,
493
+ encoding: "jsonParsed",
494
+ signature
495
+ });
496
+ if (transactionJsonParsed === null) {
497
+ return null;
498
+ }
499
+ transaction.meta = transactionJsonParsed.meta;
500
+ }
501
+ return transformLoadedTransaction({ encoding: args.encoding, transaction });
502
+ };
503
+ }
504
+ var transactionResolvers = {
505
+ Transaction: {
506
+ __resolveType(transaction) {
507
+ switch (transaction.encoding) {
508
+ case "base58":
509
+ return "TransactionBase58";
510
+ case "base64":
511
+ return "TransactionBase64";
512
+ default:
513
+ return "TransactionParsed";
514
+ }
515
+ }
516
+ }
517
+ };
518
+
519
+ // src/resolvers/block.ts
520
+ function transformLoadedBlock({
521
+ block,
522
+ encoding = "jsonParsed",
523
+ transactionDetails = "full"
524
+ }) {
525
+ const transformedBlock = block;
526
+ if (typeof block === "object" && "transactions" in block) {
527
+ transformedBlock.transactions = block.transactions.map((transaction) => {
528
+ if (transactionDetails === "accounts") {
529
+ return {
530
+ data: transaction.transaction,
531
+ meta: transaction.meta,
532
+ version: transaction.version
533
+ };
534
+ } else {
535
+ return transformLoadedTransaction({ encoding, transaction });
536
+ }
537
+ });
538
+ }
539
+ block.encoding = encoding;
540
+ block.transactionDetails = transactionDetails;
541
+ return block;
542
+ }
543
+ var resolveBlock = (fieldName) => {
544
+ return async (parent, args, context, info) => {
545
+ const slot = fieldName ? parent[fieldName] : args.slot;
546
+ if (!slot) {
547
+ return null;
548
+ }
549
+ if (onlyFieldsRequested(["slot"], info)) {
550
+ return { slot };
551
+ }
552
+ const block = await context.loaders.block.load({ ...args, slot });
553
+ if (block === null) {
554
+ return null;
555
+ }
556
+ const { encoding, transactionDetails } = args;
557
+ return transformLoadedBlock({ block, encoding, transactionDetails });
558
+ };
559
+ };
560
+ var blockResolvers = {
561
+ Block: {
562
+ __resolveType(block) {
563
+ switch (block.transactionDetails) {
564
+ case "accounts":
565
+ return "BlockWithAccounts";
566
+ case "none":
567
+ return "BlockWithNone";
568
+ case "signatures":
569
+ return "BlockWithSignatures";
570
+ default:
571
+ return "BlockWithFull";
572
+ }
573
+ }
574
+ }
575
+ };
576
+
577
+ // src/resolvers/instruction.ts
578
+ var instructionResolvers = {
579
+ AdvanceNonceAccountInstruction: {
580
+ nonceAccount: resolveAccount("nonceAccount"),
581
+ nonceAuthority: resolveAccount("nonceAuthority")
582
+ },
583
+ AllocateInstruction: {
584
+ account: resolveAccount("account")
585
+ },
586
+ AllocateWithSeedInstruction: {
587
+ account: resolveAccount("account"),
588
+ owner: resolveAccount("owner")
589
+ },
590
+ AssignInstruction: {
591
+ account: resolveAccount("account"),
592
+ owner: resolveAccount("owner")
593
+ },
594
+ AssignWithSeedInstruction: {
595
+ account: resolveAccount("account"),
596
+ owner: resolveAccount("owner")
597
+ },
598
+ AuthorizeNonceAccountInstruction: {
599
+ newAuthorized: resolveAccount("newAuthorized"),
600
+ nonceAccount: resolveAccount("nonceAccount"),
601
+ nonceAuthority: resolveAccount("nonceAuthority")
602
+ },
603
+ BpfLoaderFinalizeInstruction: {
604
+ account: resolveAccount("account")
605
+ },
606
+ BpfLoaderWriteInstruction: {
607
+ account: resolveAccount("account")
608
+ },
609
+ BpfUpgradeableLoaderCloseInstruction: {
610
+ account: resolveAccount("account"),
611
+ authority: resolveAccount("authority"),
612
+ programAccount: resolveAccount("programAccount"),
613
+ recipient: resolveAccount("recipient")
614
+ },
615
+ BpfUpgradeableLoaderDeployWithMaxDataLenInstruction: {
616
+ authority: resolveAccount("authority"),
617
+ bufferAccount: resolveAccount("bufferAccount"),
618
+ payerAccount: resolveAccount("payerAccount"),
619
+ programAccount: resolveAccount("programAccount"),
620
+ programDataAccount: resolveAccount("programDataAccount")
621
+ },
622
+ BpfUpgradeableLoaderExtendProgramInstruction: {
623
+ payerAccount: resolveAccount("payerAccount"),
624
+ programAccount: resolveAccount("programAccount"),
625
+ programDataAccount: resolveAccount("programDataAccount"),
626
+ systemProgram: resolveAccount("systemProgram")
627
+ },
628
+ BpfUpgradeableLoaderInitializeBufferInstruction: {
629
+ account: resolveAccount("account")
630
+ },
631
+ BpfUpgradeableLoaderSetAuthorityCheckedInstruction: {
632
+ account: resolveAccount("account"),
633
+ authority: resolveAccount("authority"),
634
+ newAuthority: resolveAccount("newAuthority")
635
+ },
636
+ BpfUpgradeableLoaderSetAuthorityInstruction: {
637
+ account: resolveAccount("account"),
638
+ authority: resolveAccount("authority"),
639
+ newAuthority: resolveAccount("newAuthority")
640
+ },
641
+ BpfUpgradeableLoaderUpgradeInstruction: {
642
+ authority: resolveAccount("authority"),
643
+ bufferAccount: resolveAccount("bufferAccount"),
644
+ programAccount: resolveAccount("programAccount"),
645
+ programDataAccount: resolveAccount("programDataAccount")
646
+ },
647
+ BpfUpgradeableLoaderWriteInstruction: {
648
+ account: resolveAccount("account"),
649
+ authority: resolveAccount("authority")
650
+ },
651
+ CloseLookupTableInstruction: {
652
+ lookupTableAccount: resolveAccount("lookupTableAccount"),
653
+ lookupTableAuthority: resolveAccount("lookupTableAuthority"),
654
+ recipient: resolveAccount("recipient")
655
+ },
656
+ CreateAccountInstruction: {
657
+ newAccount: resolveAccount("newAccount"),
658
+ owner: resolveAccount("owner"),
659
+ source: resolveAccount("source")
660
+ },
661
+ CreateAccountWithSeedInstruction: {
662
+ base: resolveAccount("base"),
663
+ owner: resolveAccount("owner"),
664
+ seed: resolveAccount("seed")
665
+ },
666
+ CreateLookupTableInstruction: {
667
+ lookupTableAccount: resolveAccount("lookupTableAccount"),
668
+ lookupTableAuthority: resolveAccount("lookupTableAuthority"),
669
+ payerAccount: resolveAccount("payerAccount"),
670
+ systemProgram: resolveAccount("systemProgram")
671
+ },
672
+ DeactivateLookupTableInstruction: {
673
+ lookupTableAccount: resolveAccount("lookupTableAccount"),
674
+ lookupTableAuthority: resolveAccount("lookupTableAuthority")
675
+ },
676
+ ExtendLookupTableInstruction: {
677
+ lookupTableAccount: resolveAccount("lookupTableAccount"),
678
+ lookupTableAuthority: resolveAccount("lookupTableAuthority"),
679
+ payerAccount: resolveAccount("payerAccount"),
680
+ systemProgram: resolveAccount("systemProgram")
681
+ },
682
+ FreezeLookupTableInstruction: {
683
+ lookupTableAccount: resolveAccount("lookupTableAccount"),
684
+ lookupTableAuthority: resolveAccount("lookupTableAuthority")
685
+ },
686
+ InitializeNonceAccountInstruction: {
687
+ nonceAccount: resolveAccount("nonceAccount"),
688
+ nonceAuthority: resolveAccount("nonceAuthority")
689
+ },
690
+ Lockup: {
691
+ custodian: resolveAccount("custodian")
692
+ },
693
+ SplAssociatedTokenCreateIdempotentInstruction: {
694
+ account: resolveAccount("account"),
695
+ mint: resolveAccount("mint"),
696
+ source: resolveAccount("source"),
697
+ systemProgram: resolveAccount("systemProgram"),
698
+ tokenProgram: resolveAccount("tokenProgram"),
699
+ wallet: resolveAccount("wallet")
700
+ },
701
+ SplAssociatedTokenCreateInstruction: {
702
+ account: resolveAccount("account"),
703
+ mint: resolveAccount("mint"),
704
+ source: resolveAccount("source"),
705
+ systemProgram: resolveAccount("systemProgram"),
706
+ tokenProgram: resolveAccount("tokenProgram"),
707
+ wallet: resolveAccount("wallet")
708
+ },
709
+ SplAssociatedTokenRecoverNestedInstruction: {
710
+ destination: resolveAccount("destination"),
711
+ nestedMint: resolveAccount("nestedMint"),
712
+ nestedOwner: resolveAccount("nestedOwner"),
713
+ nestedSource: resolveAccount("nestedSource"),
714
+ ownerMint: resolveAccount("ownerMint"),
715
+ tokenProgram: resolveAccount("tokenProgram"),
716
+ wallet: resolveAccount("wallet")
717
+ },
718
+ SplTokenAmountToUiAmountInstruction: {
719
+ mint: resolveAccount("mint")
720
+ },
721
+ SplTokenApproveCheckedInstruction: {
722
+ delegate: resolveAccount("delegate"),
723
+ mint: resolveAccount("mint"),
724
+ multisigOwner: resolveAccount("multisigOwner"),
725
+ owner: resolveAccount("owner"),
726
+ source: resolveAccount("source")
727
+ },
728
+ SplTokenApproveInstruction: {
729
+ delegate: resolveAccount("delegate"),
730
+ multisigOwner: resolveAccount("multisigOwner"),
731
+ owner: resolveAccount("owner"),
732
+ source: resolveAccount("source")
733
+ },
734
+ SplTokenBurnCheckedInstruction: {
735
+ account: resolveAccount("account"),
736
+ authority: resolveAccount("authority"),
737
+ mint: resolveAccount("mint"),
738
+ multisigAuthority: resolveAccount("multisigAuthority")
739
+ },
740
+ SplTokenBurnInstruction: {
741
+ account: resolveAccount("account"),
742
+ authority: resolveAccount("authority"),
743
+ mint: resolveAccount("mint"),
744
+ multisigAuthority: resolveAccount("multisigAuthority")
745
+ },
746
+ SplTokenCloseAccountInstruction: {
747
+ account: resolveAccount("account"),
748
+ destination: resolveAccount("destination"),
749
+ multisigOwner: resolveAccount("multisigOwner"),
750
+ owner: resolveAccount("owner")
751
+ },
752
+ SplTokenFreezeAccountInstruction: {
753
+ account: resolveAccount("account"),
754
+ freezeAuthority: resolveAccount("freezeAuthority"),
755
+ mint: resolveAccount("mint"),
756
+ multisigFreezeAuthority: resolveAccount("multisigFreezeAuthority")
757
+ },
758
+ SplTokenGetAccountDataSizeInstruction: {
759
+ mint: resolveAccount("mint")
760
+ },
761
+ SplTokenInitializeAccount2Instruction: {
762
+ account: resolveAccount("account"),
763
+ mint: resolveAccount("mint"),
764
+ owner: resolveAccount("owner")
765
+ },
766
+ SplTokenInitializeAccount3Instruction: {
767
+ account: resolveAccount("account"),
768
+ mint: resolveAccount("mint"),
769
+ owner: resolveAccount("owner")
770
+ },
771
+ SplTokenInitializeAccountInstruction: {
772
+ account: resolveAccount("account"),
773
+ mint: resolveAccount("mint"),
774
+ owner: resolveAccount("owner")
775
+ },
776
+ SplTokenInitializeMint2Instruction: {
777
+ freezeAuthority: resolveAccount("freezeAuthority"),
778
+ mint: resolveAccount("mint"),
779
+ mintAuthority: resolveAccount("mintAuthority")
780
+ },
781
+ SplTokenInitializeMintCloseAuthorityInstruction: {
782
+ mint: resolveAccount("mint"),
783
+ newAuthority: resolveAccount("newAuthority")
784
+ },
785
+ SplTokenInitializeMintInstruction: {
786
+ freezeAuthority: resolveAccount("freezeAuthority"),
787
+ mint: resolveAccount("mint"),
788
+ mintAuthority: resolveAccount("mintAuthority")
789
+ },
790
+ SplTokenInitializeMultisig2Instruction: {
791
+ multisig: resolveAccount("multisig")
792
+ },
793
+ SplTokenInitializeMultisigInstruction: {
794
+ multisig: resolveAccount("multisig")
795
+ },
796
+ SplTokenMintToCheckedInstruction: {
797
+ account: resolveAccount("account"),
798
+ authority: resolveAccount("authority"),
799
+ mint: resolveAccount("mint"),
800
+ mintAuthority: resolveAccount("mintAuthority"),
801
+ multisigMintAuthority: resolveAccount("multisigMintAuthority")
802
+ },
803
+ SplTokenMintToInstruction: {
804
+ account: resolveAccount("account"),
805
+ authority: resolveAccount("authority"),
806
+ mint: resolveAccount("mint"),
807
+ mintAuthority: resolveAccount("mintAuthority"),
808
+ multisigMintAuthority: resolveAccount("multisigMintAuthority")
809
+ },
810
+ SplTokenRevokeInstruction: {
811
+ multisigOwner: resolveAccount("multisigOwner"),
812
+ owner: resolveAccount("owner"),
813
+ source: resolveAccount("source")
814
+ },
815
+ SplTokenSetAuthorityInstruction: {
816
+ authority: resolveAccount("authority"),
817
+ multisigAuthority: resolveAccount("multisigAuthority"),
818
+ newAuthority: resolveAccount("newAuthority")
819
+ },
820
+ SplTokenSyncNativeInstruction: {
821
+ account: resolveAccount("account")
822
+ },
823
+ SplTokenThawAccountInstruction: {
824
+ account: resolveAccount("account"),
825
+ freezeAuthority: resolveAccount("freezeAuthority"),
826
+ mint: resolveAccount("mint"),
827
+ multisigFreezeAuthority: resolveAccount("multisigFreezeAuthority")
828
+ },
829
+ SplTokenTransferCheckedInstruction: {
830
+ authority: resolveAccount("authority"),
831
+ destination: resolveAccount("destination"),
832
+ mint: resolveAccount("mint"),
833
+ multisigAuthority: resolveAccount("multisigAuthority"),
834
+ source: resolveAccount("source")
835
+ },
836
+ SplTokenTransferInstruction: {
837
+ authority: resolveAccount("authority"),
838
+ destination: resolveAccount("destination"),
839
+ multisigAuthority: resolveAccount("multisigAuthority"),
840
+ source: resolveAccount("source")
841
+ },
842
+ SplTokenUiAmountToAmountInstruction: {
843
+ mint: resolveAccount("mint")
844
+ },
845
+ StakeAuthorizeCheckedInstruction: {
846
+ authority: resolveAccount("authority"),
847
+ custodian: resolveAccount("custodian"),
848
+ newAuthority: resolveAccount("newAuthority"),
849
+ stakeAccount: resolveAccount("stakeAccount")
850
+ },
851
+ StakeAuthorizeCheckedWithSeedInstruction: {
852
+ authorityBase: resolveAccount("authorityBase"),
853
+ authorityOwner: resolveAccount("authorityOwner"),
854
+ custodian: resolveAccount("custodian"),
855
+ newAuthorized: resolveAccount("newAuthorized"),
856
+ stakeAccount: resolveAccount("stakeAccount")
857
+ },
858
+ StakeAuthorizeInstruction: {
859
+ authority: resolveAccount("authority"),
860
+ custodian: resolveAccount("custodian"),
861
+ newAuthority: resolveAccount("newAuthority"),
862
+ stakeAccount: resolveAccount("stakeAccount")
863
+ },
864
+ StakeAuthorizeWithSeedInstruction: {
865
+ authorityBase: resolveAccount("authorityBase"),
866
+ authorityOwner: resolveAccount("authorityOwner"),
867
+ custodian: resolveAccount("custodian"),
868
+ newAuthorized: resolveAccount("newAuthorized"),
869
+ stakeAccount: resolveAccount("stakeAccount")
870
+ },
871
+ StakeDeactivateDelinquentInstruction: {
872
+ referenceVoteAccount: resolveAccount("referenceVoteAccount"),
873
+ stakeAccount: resolveAccount("stakeAccount"),
874
+ voteAccount: resolveAccount("voteAccount")
875
+ },
876
+ StakeDeactivateInstruction: {
877
+ stakeAccount: resolveAccount("stakeAccount"),
878
+ stakeAuthority: resolveAccount("stakeAuthority")
879
+ },
880
+ StakeDelegateStakeInstruction: {
881
+ stakeAccount: resolveAccount("stakeAccount"),
882
+ stakeAuthority: resolveAccount("stakeAuthority"),
883
+ stakeConfigAccount: resolveAccount("stakeConfigAccount"),
884
+ voteAccount: resolveAccount("voteAccount")
885
+ },
886
+ StakeInitializeCheckedInstructionDataAuthorized: {
887
+ staker: resolveAccount("staker"),
888
+ withdrawer: resolveAccount("withdrawer")
889
+ },
890
+ StakeInitializeInstruction: {
891
+ stakeAccount: resolveAccount("stakeAccount")
892
+ },
893
+ StakeInitializeInstructionDataAuthorized: {
894
+ staker: resolveAccount("staker"),
895
+ withdrawer: resolveAccount("withdrawer")
896
+ },
897
+ StakeMergeInstruction: {
898
+ destination: resolveAccount("destination"),
899
+ source: resolveAccount("source"),
900
+ stakeAuthority: resolveAccount("stakeAuthority")
901
+ },
902
+ StakeRedelegateInstruction: {
903
+ newStakeAccount: resolveAccount("newStakeAccount"),
904
+ stakeAccount: resolveAccount("stakeAccount"),
905
+ stakeAuthority: resolveAccount("stakeAuthority"),
906
+ stakeConfigAccount: resolveAccount("stakeConfigAccount"),
907
+ voteAccount: resolveAccount("voteAccount")
908
+ },
909
+ StakeSetLockupCheckedInstruction: {
910
+ custodian: resolveAccount("custodian"),
911
+ stakeAccount: resolveAccount("stakeAccount")
912
+ },
913
+ StakeSetLockupInstruction: {
914
+ custodian: resolveAccount("custodian"),
915
+ stakeAccount: resolveAccount("stakeAccount")
916
+ },
917
+ StakeSplitInstruction: {
918
+ newSplitAccount: resolveAccount("newSplitAccount"),
919
+ stakeAccount: resolveAccount("stakeAccount"),
920
+ stakeAuthority: resolveAccount("stakeAuthority")
921
+ },
922
+ StakeWithdrawInstruction: {
923
+ destination: resolveAccount("destination"),
924
+ stakeAccount: resolveAccount("stakeAccount"),
925
+ withdrawAuthority: resolveAccount("withdrawAuthority")
926
+ },
927
+ TransactionInstruction: {
928
+ __resolveType(instruction) {
929
+ if (instruction.programName) {
930
+ if (instruction.programName === "address-lookup-table") {
931
+ if (instruction.instructionType === "createLookupTable") {
932
+ return "CreateLookupTableInstruction";
933
+ }
934
+ if (instruction.instructionType === "freezeLookupTable") {
935
+ return "FreezeLookupTableInstruction";
936
+ }
937
+ if (instruction.instructionType === "extendLookupTable") {
938
+ return "ExtendLookupTableInstruction";
939
+ }
940
+ if (instruction.instructionType === "deactivateLookupTable") {
941
+ return "DeactivateLookupTableInstruction";
942
+ }
943
+ if (instruction.instructionType === "closeLookupTable") {
944
+ return "CloseLookupTableInstruction";
945
+ }
946
+ }
947
+ if (instruction.programName === "bpf-loader") {
948
+ if (instruction.instructionType === "write") {
949
+ return "BpfLoaderWriteInstruction";
950
+ }
951
+ if (instruction.instructionType === "finalize") {
952
+ return "BpfLoaderFinalizeInstruction";
953
+ }
954
+ }
955
+ if (instruction.programName === "bpf-upgradeable-loader") {
956
+ if (instruction.instructionType === "initializeBuffer") {
957
+ return "BpfUpgradeableLoaderInitializeBufferInstruction";
958
+ }
959
+ if (instruction.instructionType === "write") {
960
+ return "BpfUpgradeableLoaderWriteInstruction";
961
+ }
962
+ if (instruction.instructionType === "deployWithMaxDataLen") {
963
+ return "BpfUpgradeableLoaderDeployWithMaxDataLenInstruction";
964
+ }
965
+ if (instruction.instructionType === "upgrade") {
966
+ return "BpfUpgradeableLoaderUpgradeInstruction";
967
+ }
968
+ if (instruction.instructionType === "setAuthority") {
969
+ return "BpfUpgradeableLoaderSetAuthorityInstruction";
970
+ }
971
+ if (instruction.instructionType === "setAuthorityChecked") {
972
+ return "BpfUpgradeableLoaderSetAuthorityCheckedInstruction";
973
+ }
974
+ if (instruction.instructionType === "close") {
975
+ return "BpfUpgradeableLoaderCloseInstruction";
976
+ }
977
+ if (instruction.instructionType === "extendProgram") {
978
+ return "BpfUpgradeableLoaderExtendProgramInstruction";
979
+ }
980
+ }
981
+ if (instruction.programName === "spl-associated-token-account") {
982
+ if (instruction.instructionType === "create") {
983
+ return "SplAssociatedTokenCreateInstruction";
984
+ }
985
+ if (instruction.instructionType === "createIdempotent") {
986
+ return "SplAssociatedTokenCreateIdempotentInstruction";
987
+ }
988
+ if (instruction.instructionType === "recoverNested") {
989
+ return "SplAssociatedTokenRecoverNestedInstruction";
990
+ }
991
+ }
992
+ if (instruction.programName === "spl-memo") {
993
+ return "SplMemoInstruction";
994
+ }
995
+ if (instruction.programName === "spl-token") {
996
+ if (instruction.instructionType === "initializeMint") {
997
+ return "SplTokenInitializeMintInstruction";
998
+ }
999
+ if (instruction.instructionType === "initializeMint2") {
1000
+ return "SplTokenInitializeMint2Instruction";
1001
+ }
1002
+ if (instruction.instructionType === "initializeAccount") {
1003
+ return "SplTokenInitializeAccountInstruction";
1004
+ }
1005
+ if (instruction.instructionType === "initializeAccount2") {
1006
+ return "SplTokenInitializeAccount2Instruction";
1007
+ }
1008
+ if (instruction.instructionType === "initializeAccount3") {
1009
+ return "SplTokenInitializeAccount3Instruction";
1010
+ }
1011
+ if (instruction.instructionType === "initializeMultisig") {
1012
+ return "SplTokenInitializeMultisigInstruction";
1013
+ }
1014
+ if (instruction.instructionType === "initializeMultisig2") {
1015
+ return "SplTokenInitializeMultisig2Instruction";
1016
+ }
1017
+ if (instruction.instructionType === "transfer") {
1018
+ return "SplTokenTransferInstruction";
1019
+ }
1020
+ if (instruction.instructionType === "approve") {
1021
+ return "SplTokenApproveInstruction";
1022
+ }
1023
+ if (instruction.instructionType === "revoke") {
1024
+ return "SplTokenRevokeInstruction";
1025
+ }
1026
+ if (instruction.instructionType === "setAuthority") {
1027
+ return "SplTokenSetAuthorityInstruction";
1028
+ }
1029
+ if (instruction.instructionType === "mintTo") {
1030
+ return "SplTokenMintToInstruction";
1031
+ }
1032
+ if (instruction.instructionType === "burn") {
1033
+ return "SplTokenBurnInstruction";
1034
+ }
1035
+ if (instruction.instructionType === "closeAccount") {
1036
+ return "SplTokenCloseAccountInstruction";
1037
+ }
1038
+ if (instruction.instructionType === "freezeAccount") {
1039
+ return "SplTokenFreezeAccountInstruction";
1040
+ }
1041
+ if (instruction.instructionType === "thawAccount") {
1042
+ return "SplTokenThawAccountInstruction";
1043
+ }
1044
+ if (instruction.instructionType === "transferChecked") {
1045
+ return "SplTokenTransferCheckedInstruction";
1046
+ }
1047
+ if (instruction.instructionType === "approveChecked") {
1048
+ return "SplTokenApproveCheckedInstruction";
1049
+ }
1050
+ if (instruction.instructionType === "mintToChecked") {
1051
+ return "SplTokenMintToCheckedInstruction";
1052
+ }
1053
+ if (instruction.instructionType === "burnChecked") {
1054
+ return "SplTokenBurnCheckedInstruction";
1055
+ }
1056
+ if (instruction.instructionType === "syncNative") {
1057
+ return "SplTokenSyncNativeInstruction";
1058
+ }
1059
+ if (instruction.instructionType === "getAccountDataSize") {
1060
+ return "SplTokenGetAccountDataSizeInstruction";
1061
+ }
1062
+ if (instruction.instructionType === "initializeImmutableOwner") {
1063
+ return "SplTokenInitializeImmutableOwnerInstruction";
1064
+ }
1065
+ if (instruction.instructionType === "amountToUiAmount") {
1066
+ return "SplTokenAmountToUiAmountInstruction";
1067
+ }
1068
+ if (instruction.instructionType === "uiAmountToAmount") {
1069
+ return "SplTokenUiAmountToAmountInstruction";
1070
+ }
1071
+ if (instruction.instructionType === "initializeMintCloseAuthority") {
1072
+ return "SplTokenInitializeMintCloseAuthorityInstruction";
1073
+ }
1074
+ }
1075
+ if (instruction.programName === "stake") {
1076
+ if (instruction.instructionType === "initialize") {
1077
+ return "StakeInitializeInstruction";
1078
+ }
1079
+ if (instruction.instructionType === "authorize") {
1080
+ return "StakeAuthorizeInstruction";
1081
+ }
1082
+ if (instruction.instructionType === "delegate") {
1083
+ return "StakeDelegateStakeInstruction";
1084
+ }
1085
+ if (instruction.instructionType === "split") {
1086
+ return "StakeSplitInstruction";
1087
+ }
1088
+ if (instruction.instructionType === "withdraw") {
1089
+ return "StakeWithdrawInstruction";
1090
+ }
1091
+ if (instruction.instructionType === "deactivate") {
1092
+ return "StakeDeactivateInstruction";
1093
+ }
1094
+ if (instruction.instructionType === "setLockup") {
1095
+ return "StakeSetLockupInstruction";
1096
+ }
1097
+ if (instruction.instructionType === "merge") {
1098
+ return "StakeMergeInstruction";
1099
+ }
1100
+ if (instruction.instructionType === "authorizeWithSeed") {
1101
+ return "StakeAuthorizeWithSeedInstruction";
1102
+ }
1103
+ if (instruction.instructionType === "initializeChecked") {
1104
+ return "StakeInitializeCheckedInstruction";
1105
+ }
1106
+ if (instruction.instructionType === "authorizeChecked") {
1107
+ return "StakeAuthorizeCheckedInstruction";
1108
+ }
1109
+ if (instruction.instructionType === "authorizeCheckedWithSeed") {
1110
+ return "StakeAuthorizeCheckedWithSeedInstruction";
1111
+ }
1112
+ if (instruction.instructionType === "setLockupChecked") {
1113
+ return "StakeSetLockupCheckedInstruction";
1114
+ }
1115
+ if (instruction.instructionType === "deactivateDelinquent") {
1116
+ return "StakeDeactivateDelinquentInstruction";
1117
+ }
1118
+ if (instruction.instructionType === "redelegate") {
1119
+ return "StakeRedelegateInstruction";
1120
+ }
1121
+ }
1122
+ if (instruction.programName === "system") {
1123
+ if (instruction.instructionType === "createAccount") {
1124
+ return "CreateAccountInstruction";
1125
+ }
1126
+ if (instruction.instructionType === "assign") {
1127
+ return "AssignInstruction";
1128
+ }
1129
+ if (instruction.instructionType === "transfer") {
1130
+ return "TransferInstruction";
1131
+ }
1132
+ if (instruction.instructionType === "createAccountWithSeed") {
1133
+ return "CreateAccountWithSeedInstruction";
1134
+ }
1135
+ if (instruction.instructionType === "advanceNonceAccount") {
1136
+ return "AdvanceNonceAccountInstruction";
1137
+ }
1138
+ if (instruction.instructionType === "withdrawNonceAccount") {
1139
+ return "WithdrawNonceAccountInstruction";
1140
+ }
1141
+ if (instruction.instructionType === "initializeNonceAccount") {
1142
+ return "InitializeNonceAccountInstruction";
1143
+ }
1144
+ if (instruction.instructionType === "authorizeNonceAccount") {
1145
+ return "AuthorizeNonceAccountInstruction";
1146
+ }
1147
+ if (instruction.instructionType === "upgradeNonceAccount") {
1148
+ return "UpgradeNonceAccountInstruction";
1149
+ }
1150
+ if (instruction.instructionType === "allocate") {
1151
+ return "AllocateInstruction";
1152
+ }
1153
+ if (instruction.instructionType === "allocateWithSeed") {
1154
+ return "AllocateWithSeedInstruction";
1155
+ }
1156
+ if (instruction.instructionType === "assignWithSeed") {
1157
+ return "AssignWithSeedInstruction";
1158
+ }
1159
+ if (instruction.instructionType === "transferWithSeed") {
1160
+ return "TransferWithSeedInstruction";
1161
+ }
1162
+ }
1163
+ if (instruction.programName === "vote") {
1164
+ if (instruction.instructionType === "initialize") {
1165
+ return "VoteInitializeAccountInstruction";
1166
+ }
1167
+ if (instruction.instructionType === "authorize") {
1168
+ return "VoteAuthorizeInstruction";
1169
+ }
1170
+ if (instruction.instructionType === "authorizeWithSeed") {
1171
+ return "VoteAuthorizeWithSeedInstruction";
1172
+ }
1173
+ if (instruction.instructionType === "authorizeCheckedWithSeed") {
1174
+ return "VoteAuthorizeCheckedWithSeedInstruction";
1175
+ }
1176
+ if (instruction.instructionType === "vote") {
1177
+ return "VoteVoteInstruction";
1178
+ }
1179
+ if (instruction.instructionType === "updatevotestate") {
1180
+ return "VoteUpdateVoteStateInstruction";
1181
+ }
1182
+ if (instruction.instructionType === "updatevotestateswitch") {
1183
+ return "VoteUpdateVoteStateSwitchInstruction";
1184
+ }
1185
+ if (instruction.instructionType === "compactupdatevotestate") {
1186
+ return "VoteCompactUpdateVoteStateInstruction";
1187
+ }
1188
+ if (instruction.instructionType === "compactupdatevotestateswitch") {
1189
+ return "VoteCompactUpdateVoteStateSwitchInstruction";
1190
+ }
1191
+ if (instruction.instructionType === "withdraw") {
1192
+ return "VoteWithdrawInstruction";
1193
+ }
1194
+ if (instruction.instructionType === "updateValidatorIdentity") {
1195
+ return "VoteUpdateValidatorIdentityInstruction";
1196
+ }
1197
+ if (instruction.instructionType === "updateCommission") {
1198
+ return "VoteUpdateCommissionInstruction";
1199
+ }
1200
+ if (instruction.instructionType === "voteSwitch") {
1201
+ return "VoteVoteSwitchInstruction";
1202
+ }
1203
+ if (instruction.instructionType === "authorizeChecked") {
1204
+ return "VoteAuthorizeCheckedInstruction";
1205
+ }
1206
+ }
1207
+ }
1208
+ return "GenericInstruction";
1209
+ }
1210
+ },
1211
+ TransferInstruction: {
1212
+ destination: resolveAccount("destination"),
1213
+ source: resolveAccount("source")
1214
+ },
1215
+ TransferWithSeedInstruction: {
1216
+ destination: resolveAccount("destination"),
1217
+ source: resolveAccount("source"),
1218
+ sourceOwner: resolveAccount("sourceOwner")
1219
+ },
1220
+ UpgradeNonceAccountInstruction: {
1221
+ nonceAccount: resolveAccount("nonceAccount"),
1222
+ nonceAuthority: resolveAccount("nonceAuthority")
1223
+ },
1224
+ VoteAuthorizeCheckedInstruction: {
1225
+ authority: resolveAccount("authority"),
1226
+ newAuthority: resolveAccount("newAuthority"),
1227
+ voteAccount: resolveAccount("voteAccount")
1228
+ },
1229
+ VoteAuthorizeCheckedWithSeedInstruction: {
1230
+ authorityOwner: resolveAccount("authorityOwner"),
1231
+ newAuthority: resolveAccount("newAuthority"),
1232
+ voteAccount: resolveAccount("voteAccount")
1233
+ },
1234
+ VoteAuthorizeInstruction: {
1235
+ authority: resolveAccount("authority"),
1236
+ newAuthority: resolveAccount("newAuthority"),
1237
+ voteAccount: resolveAccount("voteAccount")
1238
+ },
1239
+ VoteAuthorizeWithSeedInstruction: {
1240
+ authorityOwner: resolveAccount("authorityOwner"),
1241
+ newAuthority: resolveAccount("newAuthority"),
1242
+ voteAccount: resolveAccount("voteAccount")
1243
+ },
1244
+ VoteCompactUpdateVoteStateInstruction: {
1245
+ voteAccount: resolveAccount("voteAccount"),
1246
+ voteAuthority: resolveAccount("voteAuthority")
1247
+ },
1248
+ VoteCompactUpdateVoteStateSwitchInstruction: {
1249
+ voteAccount: resolveAccount("voteAccount"),
1250
+ voteAuthority: resolveAccount("voteAuthority")
1251
+ },
1252
+ VoteInitializeAccountInstruction: {
1253
+ authorizedVoter: resolveAccount("authorizedVoter"),
1254
+ authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
1255
+ node: resolveAccount("node"),
1256
+ voteAccount: resolveAccount("voteAccount")
1257
+ },
1258
+ VoteUpdateCommissionInstruction: {
1259
+ voteAccount: resolveAccount("voteAccount"),
1260
+ withdrawAuthority: resolveAccount("withdrawAuthority")
1261
+ },
1262
+ VoteUpdateValidatorIdentityInstruction: {
1263
+ newValidatorIdentity: resolveAccount("newValidatorIdentity"),
1264
+ voteAccount: resolveAccount("voteAccount"),
1265
+ withdrawAuthority: resolveAccount("withdrawAuthority")
1266
+ },
1267
+ VoteUpdateVoteStateInstruction: {
1268
+ voteAccount: resolveAccount("voteAccount"),
1269
+ voteAuthority: resolveAccount("voteAuthority")
1270
+ },
1271
+ VoteUpdateVoteStateSwitchInstruction: {
1272
+ voteAccount: resolveAccount("voteAccount"),
1273
+ voteAuthority: resolveAccount("voteAuthority")
1274
+ },
1275
+ VoteVoteInstruction: {
1276
+ voteAccount: resolveAccount("voteAccount"),
1277
+ voteAuthority: resolveAccount("voteAuthority")
1278
+ },
1279
+ VoteVoteSwitchInstruction: {
1280
+ voteAccount: resolveAccount("voteAccount"),
1281
+ voteAuthority: resolveAccount("voteAuthority")
1282
+ },
1283
+ VoteWithdrawInstruction: {
1284
+ voteAccount: resolveAccount("voteAccount"),
1285
+ withdrawAuthority: resolveAccount("withdrawAuthority")
1286
+ },
1287
+ WithdrawNonceAccountInstruction: {
1288
+ destination: resolveAccount("destination"),
1289
+ nonceAccount: resolveAccount("nonceAccount"),
1290
+ nonceAuthority: resolveAccount("nonceAuthority")
1291
+ }
1292
+ };
1293
+
1294
+ // src/resolvers/program-accounts.ts
1295
+ function resolveProgramAccounts(fieldName) {
1296
+ return async (parent, args, context, info) => {
1297
+ const programAddress = fieldName ? parent[fieldName] : args.programAddress;
1298
+ if (programAddress) {
1299
+ if (onlyFieldsRequested(["programAddress"], info)) {
1300
+ return { programAddress };
1301
+ }
1302
+ }
1303
+ const programAccounts = await context.loaders.programAccounts.load({ ...args, programAddress });
1304
+ if (programAccounts) {
1305
+ return programAccounts.map((programAccount) => {
1306
+ const { account, pubkey: address } = programAccount;
1307
+ let result = {
1308
+ ...account,
1309
+ address,
1310
+ encodedData: {},
1311
+ ownerProgram: account.owner
1312
+ };
1313
+ const { data } = account;
1314
+ const { encoding, dataSlice } = args;
1315
+ if (result.encodedData) {
1316
+ if (Array.isArray(data)) {
1317
+ result.encodedData[cacheKeyFn({
1318
+ dataSlice,
1319
+ encoding: encoding === "jsonParsed" ? "base64" : encoding ?? "base64"
1320
+ })] = data[0];
1321
+ } else if (typeof data === "string") {
1322
+ result.encodedData[cacheKeyFn({
1323
+ dataSlice,
1324
+ encoding: "base58"
1325
+ })] = data;
1326
+ } else if (typeof data === "object") {
1327
+ const {
1328
+ parsed: { info: parsedData, type: accountType },
1329
+ program: programName,
1330
+ programId
1331
+ } = data;
1332
+ result.jsonParsedConfigs = {
1333
+ accountType,
1334
+ programId,
1335
+ programName
1336
+ };
1337
+ result = {
1338
+ ...result,
1339
+ ...parsedData
1340
+ };
1341
+ }
1342
+ }
1343
+ return result;
1344
+ });
1345
+ }
1346
+ return null;
1347
+ };
1348
+ }
1349
+
1350
+ // src/resolvers/root.ts
1351
+ var rootResolvers = {
1352
+ Query: {
1353
+ account: resolveAccount(),
1354
+ block: resolveBlock(),
1355
+ programAccounts: resolveProgramAccounts(),
1356
+ transaction: resolveTransaction()
1357
+ }
1358
+ };
1359
+ var stringScalarAlias = {
1360
+ __parseLiteral(ast) {
1361
+ if (ast.kind === graphql.Kind.STRING) {
1362
+ return ast.value.toString();
1363
+ }
1364
+ return null;
1365
+ },
1366
+ __parseValue(value) {
1367
+ return value;
1368
+ },
1369
+ __serialize(value) {
1370
+ return value;
1371
+ }
1372
+ };
1373
+ var bigIntScalarAlias = {
1374
+ __parseLiteral(ast) {
1375
+ if (ast.kind === graphql.Kind.STRING) {
1376
+ return BigInt(ast.value);
1377
+ }
1378
+ return null;
1379
+ },
1380
+ __parseValue(value) {
1381
+ return BigInt(value);
1382
+ },
1383
+ __serialize(value) {
1384
+ return BigInt(value);
1385
+ }
1386
+ };
1387
+ var typeTypeResolvers = {
1388
+ AccountEncoding: {
1389
+ BASE_58: "base58",
1390
+ BASE_64: "base64",
1391
+ BASE_64_ZSTD: "base64+zstd"
1392
+ },
1393
+ Address: stringScalarAlias,
1394
+ Base58EncodedBytes: stringScalarAlias,
1395
+ Base64EncodedBytes: stringScalarAlias,
1396
+ Base64ZstdEncodedBytes: stringScalarAlias,
1397
+ BigInt: bigIntScalarAlias,
1398
+ BlockTransactionDetails: {
1399
+ ACCOUNTS: "accounts",
1400
+ FULL: "full",
1401
+ NONE: "none",
1402
+ SIGNATURES: "signatures"
1403
+ },
1404
+ Commitment: {
1405
+ CONFIRMED: "confirmed",
1406
+ FINALIZED: "finalized",
1407
+ PROCESSED: "processed"
1408
+ },
1409
+ Signature: stringScalarAlias,
1410
+ Slot: bigIntScalarAlias,
1411
+ TokenBalance: {
1412
+ mint: resolveAccount("mint"),
1413
+ owner: resolveAccount("owner")
1414
+ },
1415
+ TransactionEncoding: {
1416
+ BASE_58: "base58",
1417
+ BASE_64: "base64",
1418
+ PARSED: "jsonParsed"
1419
+ },
1420
+ TransactionVersion: {
1421
+ LEGACY: "legacy",
1422
+ ZERO: 0
1423
+ }
1424
+ };
1425
+
1426
+ // src/resolvers/index.ts
1427
+ function createSolanaGraphQLResolvers() {
1428
+ return {
1429
+ ...accountResolvers,
1430
+ ...blockResolvers,
1431
+ ...instructionResolvers,
1432
+ ...rootResolvers,
1433
+ ...transactionResolvers,
1434
+ ...typeTypeResolvers
1435
+ };
1436
+ }
1437
+
1438
+ // src/schema/account.ts
1439
+ var accountTypeDefs = (
1440
+ /* GraphQL */
1441
+ `
1442
+ """
1443
+ Account interface
1444
+ """
1445
+ interface Account {
1446
+ address: Address
1447
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1448
+ executable: Boolean
1449
+ lamports: BigInt
1450
+ ownerProgram: Account
1451
+ space: BigInt
1452
+ rentEpoch: BigInt
1453
+ }
1454
+
1455
+ """
1456
+ Generic base account type
1457
+ """
1458
+ type GenericAccount implements Account {
1459
+ address: Address
1460
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1461
+ executable: Boolean
1462
+ lamports: BigInt
1463
+ ownerProgram: Account
1464
+ space: BigInt
1465
+ rentEpoch: BigInt
1466
+ }
1467
+
1468
+ type NonceAccountFeeCalculator {
1469
+ lamportsPerSignature: String
1470
+ }
1471
+ """
1472
+ A nonce account
1473
+ """
1474
+ type NonceAccount implements Account {
1475
+ address: Address
1476
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1477
+ executable: Boolean
1478
+ lamports: BigInt
1479
+ ownerProgram: Account
1480
+ space: BigInt
1481
+ rentEpoch: BigInt
1482
+ authority: Account
1483
+ blockhash: String
1484
+ feeCalculator: NonceAccountFeeCalculator
1485
+ }
1486
+
1487
+ """
1488
+ A lookup table account
1489
+ """
1490
+ type LookupTableAccount implements Account {
1491
+ address: Address
1492
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1493
+ executable: Boolean
1494
+ lamports: BigInt
1495
+ ownerProgram: Account
1496
+ space: BigInt
1497
+ rentEpoch: BigInt
1498
+ addresses: [Address]
1499
+ authority: Account
1500
+ deactivationSlot: String
1501
+ lastExtendedSlot: String
1502
+ lastExtendedSlotStartIndex: Int
1503
+ }
1504
+
1505
+ """
1506
+ A mint account
1507
+ """
1508
+ type MintAccount implements Account {
1509
+ address: Address
1510
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1511
+ executable: Boolean
1512
+ lamports: BigInt
1513
+ ownerProgram: Account
1514
+ space: BigInt
1515
+ rentEpoch: BigInt
1516
+ decimals: Int
1517
+ freezeAuthority: Account
1518
+ isInitialized: Boolean
1519
+ mintAuthority: Account
1520
+ supply: String
1521
+ }
1522
+
1523
+ """
1524
+ A token account
1525
+ """
1526
+ type TokenAccount implements Account {
1527
+ address: Address
1528
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1529
+ executable: Boolean
1530
+ lamports: BigInt
1531
+ ownerProgram: Account
1532
+ space: BigInt
1533
+ rentEpoch: BigInt
1534
+ isNative: Boolean
1535
+ mint: Account
1536
+ owner: Account
1537
+ state: String
1538
+ tokenAmount: TokenAmount
1539
+ }
1540
+
1541
+ type StakeAccountDataMetaAuthorized {
1542
+ staker: Account
1543
+ withdrawer: Account
1544
+ }
1545
+ type StakeAccountDataMetaLockup {
1546
+ custodian: Account
1547
+ epoch: BigInt
1548
+ unixTimestamp: BigInt
1549
+ }
1550
+ type StakeAccountDataMeta {
1551
+ authorized: StakeAccountDataMetaAuthorized
1552
+ lockup: StakeAccountDataMetaLockup
1553
+ rentExemptReserve: String
1554
+ }
1555
+ type StakeAccountDataStakeDelegation {
1556
+ activationEpoch: BigInt
1557
+ deactivationEpoch: BigInt
1558
+ stake: String
1559
+ voter: Account
1560
+ warmupCooldownRate: Int
1561
+ }
1562
+ type StakeAccountDataStake {
1563
+ creditsObserved: BigInt
1564
+ delegation: StakeAccountDataStakeDelegation
1565
+ }
1566
+ """
1567
+ A stake account
1568
+ """
1569
+ type StakeAccount implements Account {
1570
+ address: Address
1571
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1572
+ executable: Boolean
1573
+ lamports: BigInt
1574
+ ownerProgram: Account
1575
+ space: BigInt
1576
+ rentEpoch: BigInt
1577
+ meta: StakeAccountDataMeta
1578
+ stake: StakeAccountDataStake
1579
+ }
1580
+
1581
+ type VoteAccountDataAuthorizedVoter {
1582
+ authorizedVoter: Account
1583
+ epoch: BigInt
1584
+ }
1585
+ type VoteAccountDataEpochCredit {
1586
+ credits: String
1587
+ epoch: BigInt
1588
+ previousCredits: String
1589
+ }
1590
+ type VoteAccountDataLastTimestamp {
1591
+ slot: BigInt
1592
+ timestamp: BigInt
1593
+ }
1594
+ type VoteAccountDataVote {
1595
+ confirmationCount: Int
1596
+ slot: BigInt
1597
+ }
1598
+ """
1599
+ A vote account
1600
+ """
1601
+ type VoteAccount implements Account {
1602
+ address: Address
1603
+ data(encoding: AccountEncoding!, dataSlice: DataSlice): String
1604
+ executable: Boolean
1605
+ lamports: BigInt
1606
+ ownerProgram: Account
1607
+ space: BigInt
1608
+ rentEpoch: BigInt
1609
+ authorizedVoters: [VoteAccountDataAuthorizedVoter]
1610
+ authorizedWithdrawer: Account
1611
+ commission: Int
1612
+ epochCredits: [VoteAccountDataEpochCredit]
1613
+ lastTimestamp: VoteAccountDataLastTimestamp
1614
+ node: Account
1615
+ priorVoters: [Address]
1616
+ rootSlot: BigInt
1617
+ votes: [VoteAccountDataVote]
1618
+ }
1619
+ `
1620
+ );
1621
+
1622
+ // src/schema/block.ts
1623
+ var blockTypeDefs = (
1624
+ /* GraphQL */
1625
+ `
1626
+ type TransactionMetaForAccounts {
1627
+ err: String
1628
+ fee: BigInt
1629
+ postBalances: [BigInt]
1630
+ postTokenBalances: [TokenBalance]
1631
+ preBalances: [BigInt]
1632
+ preTokenBalances: [TokenBalance]
1633
+ status: TransactionStatus
1634
+ }
1635
+
1636
+ type TransactionDataForAccounts {
1637
+ accountKeys: [Address]
1638
+ signatures: [String]
1639
+ }
1640
+
1641
+ type BlockTransactionAccounts {
1642
+ meta: TransactionMetaForAccounts
1643
+ data: TransactionDataForAccounts
1644
+ version: String
1645
+ }
1646
+
1647
+ """
1648
+ Block interface
1649
+ """
1650
+ interface Block {
1651
+ blockhash: String
1652
+ blockHeight: BigInt
1653
+ blockTime: BigInt
1654
+ parentSlot: BigInt
1655
+ previousBlockhash: String
1656
+ rewards: [Reward]
1657
+ transactionDetails: String
1658
+ }
1659
+
1660
+ """
1661
+ A block with account transaction details
1662
+ """
1663
+ type BlockWithAccounts implements Block {
1664
+ blockhash: String
1665
+ blockHeight: BigInt
1666
+ blockTime: BigInt
1667
+ parentSlot: BigInt
1668
+ previousBlockhash: String
1669
+ rewards: [Reward]
1670
+ transactions: [BlockTransactionAccounts]
1671
+ transactionDetails: String
1672
+ }
1673
+
1674
+ """
1675
+ A block with full transaction details
1676
+ """
1677
+ type BlockWithFull implements Block {
1678
+ blockhash: String
1679
+ blockHeight: BigInt
1680
+ blockTime: BigInt
1681
+ parentSlot: BigInt
1682
+ previousBlockhash: String
1683
+ rewards: [Reward]
1684
+ transactions: [Transaction]
1685
+ transactionDetails: String
1686
+ }
1687
+
1688
+ """
1689
+ A block with no transaction details
1690
+ """
1691
+ type BlockWithNone implements Block {
1692
+ blockhash: String
1693
+ blockHeight: BigInt
1694
+ blockTime: BigInt
1695
+ parentSlot: BigInt
1696
+ previousBlockhash: String
1697
+ rewards: [Reward]
1698
+ transactionDetails: String
1699
+ }
1700
+
1701
+ """
1702
+ A block with signature transaction details
1703
+ """
1704
+ type BlockWithSignatures implements Block {
1705
+ blockhash: String
1706
+ blockHeight: BigInt
1707
+ blockTime: BigInt
1708
+ parentSlot: BigInt
1709
+ previousBlockhash: String
1710
+ rewards: [Reward]
1711
+ signatures: [String]
1712
+ transactionDetails: String
1713
+ }
1714
+ `
1715
+ );
1716
+
1717
+ // src/schema/instruction.ts
1718
+ var instructionTypeDefs = (
1719
+ /* GraphQL */
1720
+ `
1721
+ """
1722
+ Transaction instruction interface
1723
+ """
1724
+ interface TransactionInstruction {
1725
+ programId: Address
1726
+ }
1727
+
1728
+ """
1729
+ Generic transaction instruction
1730
+ """
1731
+ type GenericInstruction implements TransactionInstruction {
1732
+ accounts: [Address]
1733
+ data: Base64EncodedBytes
1734
+ programId: Address
1735
+ }
1736
+
1737
+ """
1738
+ AddressLookupTable: CreateLookupTable instruction
1739
+ """
1740
+ type CreateLookupTableInstruction implements TransactionInstruction {
1741
+ programId: Address
1742
+ bumpSeed: BigInt # FIXME:*
1743
+ lookupTableAccount: Account
1744
+ lookupTableAuthority: Account
1745
+ payerAccount: Account
1746
+ recentSlot: BigInt
1747
+ systemProgram: Account
1748
+ }
1749
+
1750
+ """
1751
+ AddressLookupTable: ExtendLookupTable instruction
1752
+ """
1753
+ type ExtendLookupTableInstruction implements TransactionInstruction {
1754
+ programId: Address
1755
+ lookupTableAccount: Account
1756
+ lookupTableAuthority: Account
1757
+ newAddresses: [Address]
1758
+ payerAccount: Account
1759
+ systemProgram: Account
1760
+ }
1761
+
1762
+ """
1763
+ AddressLookupTable: FreezeLookupTable instruction
1764
+ """
1765
+ type FreezeLookupTableInstruction implements TransactionInstruction {
1766
+ programId: Address
1767
+ lookupTableAccount: Account
1768
+ lookupTableAuthority: Account
1769
+ }
1770
+
1771
+ """
1772
+ AddressLookupTable: DeactivateLookupTable instruction
1773
+ """
1774
+ type DeactivateLookupTableInstruction implements TransactionInstruction {
1775
+ programId: Address
1776
+ lookupTableAccount: Account
1777
+ lookupTableAuthority: Account
1778
+ }
1779
+
1780
+ """
1781
+ AddressLookupTable: CloseLookupTable instruction
1782
+ """
1783
+ type CloseLookupTableInstruction implements TransactionInstruction {
1784
+ programId: Address
1785
+ lookupTableAccount: Account
1786
+ lookupTableAuthority: Account
1787
+ recipient: Account
1788
+ }
1789
+
1790
+ """
1791
+ BpfLoader: Write instruction
1792
+ """
1793
+ type BpfLoaderWriteInstruction implements TransactionInstruction {
1794
+ programId: Address
1795
+ account: Account
1796
+ bytes: Base64EncodedBytes
1797
+ offset: BigInt # FIXME:*
1798
+ }
1799
+
1800
+ """
1801
+ BpfLoader: Finalize instruction
1802
+ """
1803
+ type BpfLoaderFinalizeInstruction implements TransactionInstruction {
1804
+ programId: Address
1805
+ account: Account
1806
+ }
1807
+
1808
+ """
1809
+ BpfUpgradeableLoader: InitializeBuffer instruction
1810
+ """
1811
+ type BpfUpgradeableLoaderInitializeBufferInstruction implements TransactionInstruction {
1812
+ programId: Address
1813
+ account: Account
1814
+ }
1815
+
1816
+ """
1817
+ BpfUpgradeableLoader: Write instruction
1818
+ """
1819
+ type BpfUpgradeableLoaderWriteInstruction implements TransactionInstruction {
1820
+ programId: Address
1821
+ account: Account
1822
+ authority: Account
1823
+ bytes: Base64EncodedBytes
1824
+ offset: BigInt # FIXME:*
1825
+ }
1826
+
1827
+ """
1828
+ BpfUpgradeableLoader: DeployWithMaxDataLen instruction
1829
+ """
1830
+ type BpfUpgradeableLoaderDeployWithMaxDataLenInstruction implements TransactionInstruction {
1831
+ programId: Address
1832
+ authority: Account
1833
+ bufferAccount: Account
1834
+ clockSysvar: Address
1835
+ maxDataLen: BigInt
1836
+ payerAccount: Account
1837
+ programAccount: Account
1838
+ programDataAccount: Account
1839
+ rentSysvar: Address
1840
+ }
1841
+
1842
+ """
1843
+ BpfUpgradeableLoader: Upgrade instruction
1844
+ """
1845
+ type BpfUpgradeableLoaderUpgradeInstruction implements TransactionInstruction {
1846
+ programId: Address
1847
+ authority: Account
1848
+ bufferAccount: Account
1849
+ clockSysvar: Address
1850
+ programAccount: Account
1851
+ programDataAccount: Account
1852
+ rentSysvar: Address
1853
+ spillAccount: Account
1854
+ }
1855
+
1856
+ """
1857
+ BpfUpgradeableLoader: SetAuthority instruction
1858
+ """
1859
+ type BpfUpgradeableLoaderSetAuthorityInstruction implements TransactionInstruction {
1860
+ programId: Address
1861
+ account: Account
1862
+ authority: Account
1863
+ newAuthority: Account
1864
+ }
1865
+
1866
+ """
1867
+ BpfUpgradeableLoader: SetAuthorityChecked instruction
1868
+ """
1869
+ type BpfUpgradeableLoaderSetAuthorityCheckedInstruction implements TransactionInstruction {
1870
+ programId: Address
1871
+ account: Account
1872
+ authority: Account
1873
+ newAuthority: Account
1874
+ }
1875
+
1876
+ """
1877
+ BpfUpgradeableLoader: Close instruction
1878
+ """
1879
+ type BpfUpgradeableLoaderCloseInstruction implements TransactionInstruction {
1880
+ programId: Address
1881
+ account: Account
1882
+ authority: Account
1883
+ programAccount: Account
1884
+ recipient: Account
1885
+ }
1886
+
1887
+ """
1888
+ BpfUpgradeableLoader: ExtendProgram instruction
1889
+ """
1890
+ type BpfUpgradeableLoaderExtendProgramInstruction implements TransactionInstruction {
1891
+ programId: Address
1892
+ additionalBytes: BigInt
1893
+ payerAccount: Account
1894
+ programAccount: Account
1895
+ programDataAccount: Account
1896
+ systemProgram: Account
1897
+ }
1898
+
1899
+ """
1900
+ SplAssociatedTokenAccount: Create instruction
1901
+ """
1902
+ type SplAssociatedTokenCreateInstruction implements TransactionInstruction {
1903
+ programId: Address
1904
+ account: Account
1905
+ mint: Address
1906
+ source: Account
1907
+ systemProgram: Account
1908
+ tokenProgram: Account
1909
+ wallet: Account
1910
+ }
1911
+
1912
+ """
1913
+ SplAssociatedTokenAccount: CreateIdempotent instruction
1914
+ """
1915
+ type SplAssociatedTokenCreateIdempotentInstruction implements TransactionInstruction {
1916
+ programId: Address
1917
+ account: Account
1918
+ mint: Address
1919
+ source: Account
1920
+ systemProgram: Account
1921
+ tokenProgram: Account
1922
+ wallet: Account
1923
+ }
1924
+
1925
+ """
1926
+ SplAssociatedTokenAccount: RecoverNested instruction
1927
+ """
1928
+ type SplAssociatedTokenRecoverNestedInstruction implements TransactionInstruction {
1929
+ programId: Address
1930
+ destination: Account
1931
+ nestedMint: Account
1932
+ nestedOwner: Account
1933
+ nestedSource: Account
1934
+ ownerMint: Account
1935
+ tokenProgram: Account
1936
+ wallet: Account
1937
+ }
1938
+
1939
+ """
1940
+ SplMemo instruction
1941
+ """
1942
+ type SplMemoInstruction implements TransactionInstruction {
1943
+ programId: Address
1944
+ memo: String
1945
+ }
1946
+
1947
+ """
1948
+ SplToken: InitializeMint instruction
1949
+ """
1950
+ type SplTokenInitializeMintInstruction implements TransactionInstruction {
1951
+ programId: Address
1952
+ decimals: BigInt # FIXME:*
1953
+ freezeAuthority: Account
1954
+ mint: Account
1955
+ mintAuthority: Account
1956
+ rentSysvar: Address
1957
+ }
1958
+
1959
+ """
1960
+ SplToken: InitializeMint2 instruction
1961
+ """
1962
+ type SplTokenInitializeMint2Instruction implements TransactionInstruction {
1963
+ programId: Address
1964
+ decimals: BigInt # FIXME:*
1965
+ freezeAuthority: Account
1966
+ mint: Account
1967
+ mintAuthority: Account
1968
+ }
1969
+
1970
+ """
1971
+ SplToken: InitializeAccount instruction
1972
+ """
1973
+ type SplTokenInitializeAccountInstruction implements TransactionInstruction {
1974
+ programId: Address
1975
+ account: Account
1976
+ mint: Account
1977
+ owner: Account
1978
+ rentSysvar: Address
1979
+ }
1980
+
1981
+ """
1982
+ SplToken: InitializeAccount2 instruction
1983
+ """
1984
+ type SplTokenInitializeAccount2Instruction implements TransactionInstruction {
1985
+ programId: Address
1986
+ account: Account
1987
+ mint: Account
1988
+ owner: Account
1989
+ rentSysvar: Address
1990
+ }
1991
+
1992
+ """
1993
+ SplToken: InitializeAccount3 instruction
1994
+ """
1995
+ type SplTokenInitializeAccount3Instruction implements TransactionInstruction {
1996
+ programId: Address
1997
+ account: Account
1998
+ mint: Account
1999
+ owner: Account
2000
+ }
2001
+
2002
+ """
2003
+ SplToken: InitializeMultisig instruction
2004
+ """
2005
+ type SplTokenInitializeMultisigInstruction implements TransactionInstruction {
2006
+ programId: Address
2007
+ m: BigInt # FIXME:*
2008
+ multisig: Account
2009
+ rentSysvar: Address
2010
+ signers: [Address]
2011
+ }
2012
+
2013
+ """
2014
+ SplToken: InitializeMultisig2 instruction
2015
+ """
2016
+ type SplTokenInitializeMultisig2Instruction implements TransactionInstruction {
2017
+ programId: Address
2018
+ m: BigInt # FIXME:*
2019
+ multisig: Account
2020
+ signers: [Address]
2021
+ }
2022
+
2023
+ """
2024
+ SplToken: Transfer instruction
2025
+ """
2026
+ type SplTokenTransferInstruction implements TransactionInstruction {
2027
+ programId: Address
2028
+ amount: String
2029
+ authority: Account
2030
+ destination: Account
2031
+ multisigAuthority: Account
2032
+ source: Account
2033
+ }
2034
+
2035
+ """
2036
+ SplToken: Approve instruction
2037
+ """
2038
+ type SplTokenApproveInstruction implements TransactionInstruction {
2039
+ programId: Address
2040
+ amount: String
2041
+ delegate: Account
2042
+ multisigOwner: Account
2043
+ owner: Account
2044
+ source: Account
2045
+ }
2046
+
2047
+ """
2048
+ SplToken: Revoke instruction
2049
+ """
2050
+ type SplTokenRevokeInstruction implements TransactionInstruction {
2051
+ programId: Address
2052
+ multisigOwner: Account
2053
+ owner: Account
2054
+ source: Account
2055
+ }
2056
+
2057
+ """
2058
+ SplToken: SetAuthority instruction
2059
+ """
2060
+ type SplTokenSetAuthorityInstruction implements TransactionInstruction {
2061
+ programId: Address
2062
+ authority: Account
2063
+ authorityType: String
2064
+ multisigAuthority: Account
2065
+ newAuthority: Account
2066
+ }
2067
+
2068
+ """
2069
+ SplToken: MintTo instruction
2070
+ """
2071
+ type SplTokenMintToInstruction implements TransactionInstruction {
2072
+ programId: Address
2073
+ account: Account
2074
+ amount: String
2075
+ authority: Account
2076
+ mint: Account
2077
+ mintAuthority: Account
2078
+ multisigMintAuthority: Account
2079
+ }
2080
+
2081
+ """
2082
+ SplToken: Burn instruction
2083
+ """
2084
+ type SplTokenBurnInstruction implements TransactionInstruction {
2085
+ programId: Address
2086
+ account: Account
2087
+ amount: String
2088
+ authority: Account
2089
+ mint: Account
2090
+ multisigAuthority: Account
2091
+ }
2092
+
2093
+ """
2094
+ SplToken: CloseAccount instruction
2095
+ """
2096
+ type SplTokenCloseAccountInstruction implements TransactionInstruction {
2097
+ programId: Address
2098
+ account: Account
2099
+ destination: Account
2100
+ multisigOwner: Account
2101
+ owner: Account
2102
+ }
2103
+
2104
+ """
2105
+ SplToken: FreezeAccount instruction
2106
+ """
2107
+ type SplTokenFreezeAccountInstruction implements TransactionInstruction {
2108
+ programId: Address
2109
+ account: Account
2110
+ freezeAuthority: Account
2111
+ mint: Account
2112
+ multisigFreezeAuthority: Account
2113
+ }
2114
+
2115
+ """
2116
+ SplToken: ThawAccount instruction
2117
+ """
2118
+ type SplTokenThawAccountInstruction implements TransactionInstruction {
2119
+ programId: Address
2120
+ account: Account
2121
+ freezeAuthority: Account
2122
+ mint: Account
2123
+ multisigFreezeAuthority: Account
2124
+ }
2125
+
2126
+ """
2127
+ SplToken: TransferChecked instruction
2128
+ """
2129
+ type SplTokenTransferCheckedInstruction implements TransactionInstruction {
2130
+ programId: Address
2131
+ amount: String
2132
+ authority: Account
2133
+ decimals: BigInt # FIXME:*
2134
+ destination: Account
2135
+ mint: Account
2136
+ multisigAuthority: Account
2137
+ source: Account
2138
+ tokenAmount: String
2139
+ }
2140
+
2141
+ """
2142
+ SplToken: ApproveChecked instruction
2143
+ """
2144
+ type SplTokenApproveCheckedInstruction implements TransactionInstruction {
2145
+ programId: Address
2146
+ delegate: Account
2147
+ mint: Account
2148
+ multisigOwner: Account
2149
+ owner: Account
2150
+ source: Account
2151
+ tokenAmount: String
2152
+ }
2153
+
2154
+ """
2155
+ SplToken: MintToChecked instruction
2156
+ """
2157
+ type SplTokenMintToCheckedInstruction implements TransactionInstruction {
2158
+ programId: Address
2159
+ account: Account
2160
+ authority: Account
2161
+ mint: Account
2162
+ mintAuthority: Account
2163
+ multisigMintAuthority: Account
2164
+ tokenAmount: String
2165
+ }
2166
+
2167
+ """
2168
+ SplToken: BurnChecked instruction
2169
+ """
2170
+ type SplTokenBurnCheckedInstruction implements TransactionInstruction {
2171
+ programId: Address
2172
+ account: Account
2173
+ authority: Account
2174
+ mint: Account
2175
+ multisigAuthority: Account
2176
+ tokenAmount: String
2177
+ }
2178
+
2179
+ """
2180
+ SplToken: SyncNative instruction
2181
+ """
2182
+ type SplTokenSyncNativeInstruction implements TransactionInstruction {
2183
+ programId: Address
2184
+ account: Account
2185
+ }
2186
+
2187
+ """
2188
+ SplToken: GetAccountDataSize instruction
2189
+ """
2190
+ type SplTokenGetAccountDataSizeInstruction implements TransactionInstruction {
2191
+ programId: Address
2192
+ extensionTypes: [String]
2193
+ mint: Account
2194
+ }
2195
+
2196
+ """
2197
+ SplToken: InitializeImmutableOwner instruction
2198
+ """
2199
+ type SplTokenInitializeImmutableOwnerInstruction implements TransactionInstruction {
2200
+ programId: Address
2201
+ account: Account
2202
+ }
2203
+
2204
+ """
2205
+ SplToken: AmountToUiAmount instruction
2206
+ """
2207
+ type SplTokenAmountToUiAmountInstruction implements TransactionInstruction {
2208
+ programId: Address
2209
+ amount: String
2210
+ mint: Account
2211
+ }
2212
+
2213
+ """
2214
+ SplToken: UiAmountToAmount instruction
2215
+ """
2216
+ type SplTokenUiAmountToAmountInstruction implements TransactionInstruction {
2217
+ programId: Address
2218
+ mint: Account
2219
+ uiAmount: String
2220
+ }
2221
+
2222
+ """
2223
+ SplToken: InitializeMintCloseAuthority instruction
2224
+ """
2225
+ type SplTokenInitializeMintCloseAuthorityInstruction implements TransactionInstruction {
2226
+ programId: Address
2227
+ mint: Account
2228
+ newAuthority: Account
2229
+ }
2230
+
2231
+ # TODO: Extensions!
2232
+ # - TransferFeeExtension
2233
+ # - ConfidentialTransferFeeExtension
2234
+ # - DefaultAccountStateExtension
2235
+ # - Reallocate
2236
+ # - MemoTransferExtension
2237
+ # - CreateNativeMint
2238
+ # - InitializeNonTransferableMint
2239
+ # - InterestBearingMintExtension
2240
+ # - CpiGuardExtension
2241
+ # - InitializePermanentDelegate
2242
+ # - TransferHookExtension
2243
+ # - ConfidentialTransferFeeExtension
2244
+ # - WithdrawExcessLamports
2245
+ # - MetadataPointerExtension
2246
+
2247
+ type Lockup {
2248
+ custodian: Account
2249
+ epoch: BigInt
2250
+ unixTimestamp: BigInt
2251
+ }
2252
+
2253
+ """
2254
+ Stake: Initialize instruction
2255
+ """
2256
+ type StakeInitializeInstructionDataAuthorized {
2257
+ staker: Account
2258
+ withdrawer: Account
2259
+ }
2260
+ type StakeInitializeInstruction implements TransactionInstruction {
2261
+ programId: Address
2262
+ authorized: StakeInitializeInstructionDataAuthorized
2263
+ lockup: Lockup
2264
+ rentSysvar: Address
2265
+ stakeAccount: Account
2266
+ }
2267
+
2268
+ """
2269
+ Stake: Authorize instruction
2270
+ """
2271
+ type StakeAuthorizeInstruction implements TransactionInstruction {
2272
+ programId: Address
2273
+ authority: Account
2274
+ authorityType: String
2275
+ clockSysvar: Address
2276
+ custodian: Account
2277
+ newAuthority: Account
2278
+ stakeAccount: Account
2279
+ }
2280
+
2281
+ """
2282
+ Stake: DelegateStake instruction
2283
+ """
2284
+ type StakeDelegateStakeInstruction implements TransactionInstruction {
2285
+ programId: Address
2286
+ clockSysvar: Address
2287
+ stakeAccount: Account
2288
+ stakeAuthority: Account
2289
+ stakeConfigAccount: Account
2290
+ stakeHistorySysvar: Address
2291
+ voteAccount: Account
2292
+ }
2293
+
2294
+ """
2295
+ Stake: Split instruction
2296
+ """
2297
+ type StakeSplitInstruction implements TransactionInstruction {
2298
+ programId: Address
2299
+ lamports: BigInt
2300
+ newSplitAccount: Account
2301
+ stakeAccount: Account
2302
+ stakeAuthority: Account
2303
+ }
2304
+
2305
+ """
2306
+ Stake: Withdraw instruction
2307
+ """
2308
+ type StakeWithdrawInstruction implements TransactionInstruction {
2309
+ programId: Address
2310
+ clockSysvar: Address
2311
+ destination: Account
2312
+ lamports: BigInt
2313
+ stakeAccount: Account
2314
+ withdrawAuthority: Account
2315
+ }
2316
+
2317
+ """
2318
+ Stake: Deactivate instruction
2319
+ """
2320
+ type StakeDeactivateInstruction implements TransactionInstruction {
2321
+ programId: Address
2322
+ clockSysvar: Address
2323
+ stakeAccount: Account
2324
+ stakeAuthority: Account
2325
+ }
2326
+
2327
+ """
2328
+ Stake: SetLockup instruction
2329
+ """
2330
+ type StakeSetLockupInstruction implements TransactionInstruction {
2331
+ programId: Address
2332
+ custodian: Account
2333
+ lockup: Lockup
2334
+ stakeAccount: Account
2335
+ }
2336
+
2337
+ """
2338
+ Stake: Merge instruction
2339
+ """
2340
+ type StakeMergeInstruction implements TransactionInstruction {
2341
+ programId: Address
2342
+ clockSysvar: Address
2343
+ destination: Account
2344
+ source: Account
2345
+ stakeAuthority: Account
2346
+ stakeHistorySysvar: Address
2347
+ }
2348
+
2349
+ """
2350
+ Stake: AuthorizeWithSeed instruction
2351
+ """
2352
+ type StakeAuthorizeWithSeedInstruction implements TransactionInstruction {
2353
+ programId: Address
2354
+ authorityBase: Account
2355
+ authorityOwner: Account
2356
+ authoritySeed: String
2357
+ authorityType: String
2358
+ clockSysvar: Address
2359
+ custodian: Account
2360
+ newAuthorized: Account
2361
+ stakeAccount: Account
2362
+ }
2363
+
2364
+ """
2365
+ Stake: InitializeChecked instruction
2366
+ """
2367
+ type StakeInitializeCheckedInstructionDataAuthorized {
2368
+ staker: Account
2369
+ withdrawer: Account
2370
+ }
2371
+ type StakeInitializeCheckedInstruction implements TransactionInstruction {
2372
+ programId: Address
2373
+ authorized: StakeInitializeCheckedInstructionDataAuthorized
2374
+ lockup: Lockup
2375
+ rentSysvar: Address
2376
+ stakeAccount: Account
2377
+ }
2378
+
2379
+ """
2380
+ Stake: AuthorizeChecked instruction
2381
+ """
2382
+ type StakeAuthorizeCheckedInstruction implements TransactionInstruction {
2383
+ programId: Address
2384
+ authority: Account
2385
+ authorityType: String
2386
+ clockSysvar: Address
2387
+ custodian: Account
2388
+ newAuthority: Account
2389
+ stakeAccount: Account
2390
+ }
2391
+
2392
+ """
2393
+ Stake: AuthorizeCheckedWithSeed instruction
2394
+ """
2395
+ type StakeAuthorizeCheckedWithSeedInstruction implements TransactionInstruction {
2396
+ programId: Address
2397
+ authorityBase: Account
2398
+ authorityOwner: Account
2399
+ authoritySeed: String
2400
+ authorityType: String
2401
+ clockSysvar: Address
2402
+ custodian: Account
2403
+ newAuthorized: Account
2404
+ stakeAccount: Account
2405
+ }
2406
+
2407
+ """
2408
+ Stake: SetLockupChecked instruction
2409
+ """
2410
+ type StakeSetLockupCheckedInstruction implements TransactionInstruction {
2411
+ programId: Address
2412
+ custodian: Account
2413
+ lockup: Lockup
2414
+ stakeAccount: Account
2415
+ }
2416
+
2417
+ """
2418
+ Stake: DeactivateDelinquent instruction
2419
+ """
2420
+ type StakeDeactivateDelinquentInstruction implements TransactionInstruction {
2421
+ programId: Address
2422
+ referenceVoteAccount: Account
2423
+ stakeAccount: Account
2424
+ voteAccount: Account
2425
+ }
2426
+
2427
+ """
2428
+ Stake: Redelegate instruction
2429
+ """
2430
+ type StakeRedelegateInstruction implements TransactionInstruction {
2431
+ programId: Address
2432
+ newStakeAccount: Account
2433
+ stakeAccount: Account
2434
+ stakeAuthority: Account
2435
+ stakeConfigAccount: Account
2436
+ voteAccount: Account
2437
+ }
2438
+
2439
+ """
2440
+ System: CreateAccount instruction
2441
+ """
2442
+ type CreateAccountInstruction implements TransactionInstruction {
2443
+ programId: Address
2444
+ lamports: BigInt
2445
+ newAccount: Account
2446
+ owner: Account
2447
+ source: Account
2448
+ space: BigInt
2449
+ }
2450
+
2451
+ """
2452
+ System: Assign instruction
2453
+ """
2454
+ type AssignInstruction implements TransactionInstruction {
2455
+ programId: Address
2456
+ account: Account
2457
+ owner: Account
2458
+ }
2459
+
2460
+ """
2461
+ System: Transfer instruction
2462
+ """
2463
+ type TransferInstruction implements TransactionInstruction {
2464
+ programId: Address
2465
+ destination: Account
2466
+ lamports: BigInt
2467
+ source: Account
2468
+ }
2469
+
2470
+ """
2471
+ System: CreateAccountWithSeed instruction
2472
+ """
2473
+ type CreateAccountWithSeedInstruction implements TransactionInstruction {
2474
+ programId: Address
2475
+ base: Account
2476
+ lamports: BigInt
2477
+ owner: Account
2478
+ seed: String
2479
+ space: BigInt
2480
+ }
2481
+
2482
+ """
2483
+ System: AdvanceNonceAccount instruction
2484
+ """
2485
+ type AdvanceNonceAccountInstruction implements TransactionInstruction {
2486
+ programId: Address
2487
+ nonceAccount: Account
2488
+ nonceAuthority: Account
2489
+ recentBlockhashesSysvar: Address
2490
+ }
2491
+
2492
+ """
2493
+ System: WithdrawNonceAccount instruction
2494
+ """
2495
+ type WithdrawNonceAccountInstruction implements TransactionInstruction {
2496
+ programId: Address
2497
+ destination: Account
2498
+ lamports: BigInt
2499
+ nonceAccount: Account
2500
+ nonceAuthority: Account
2501
+ recentBlockhashesSysvar: Address
2502
+ rentSysvar: Address
2503
+ }
2504
+
2505
+ """
2506
+ System: InitializeNonceAccount instruction
2507
+ """
2508
+ type InitializeNonceAccountInstruction implements TransactionInstruction {
2509
+ programId: Address
2510
+ nonceAccount: Account
2511
+ nonceAuthority: Account
2512
+ recentBlockhashesSysvar: Address
2513
+ rentSysvar: Address
2514
+ }
2515
+
2516
+ """
2517
+ System: AuthorizeNonceAccount instruction
2518
+ """
2519
+ type AuthorizeNonceAccountInstruction implements TransactionInstruction {
2520
+ programId: Address
2521
+ newAuthorized: Account
2522
+ nonceAccount: Account
2523
+ nonceAuthority: Account
2524
+ }
2525
+
2526
+ """
2527
+ System: UpgradeNonceAccount instruction
2528
+ """
2529
+ type UpgradeNonceAccountInstruction implements TransactionInstruction {
2530
+ programId: Address
2531
+ nonceAccount: Account
2532
+ nonceAuthority: Account
2533
+ }
2534
+
2535
+ """
2536
+ System: Allocate instruction
2537
+ """
2538
+ type AllocateInstruction implements TransactionInstruction {
2539
+ programId: Address
2540
+ account: Account
2541
+ space: BigInt
2542
+ }
2543
+
2544
+ """
2545
+ System: AllocateWithSeed instruction
2546
+ """
2547
+ type AllocateWithSeedInstruction implements TransactionInstruction {
2548
+ programId: Address
2549
+ account: Account
2550
+ base: Address
2551
+ owner: Account
2552
+ seed: String
2553
+ space: BigInt
2554
+ }
2555
+
2556
+ """
2557
+ System: AssignWithSeed instruction
2558
+ """
2559
+ type AssignWithSeedInstruction implements TransactionInstruction {
2560
+ programId: Address
2561
+ account: Account
2562
+ base: Address
2563
+ owner: Account
2564
+ seed: String
2565
+ }
2566
+
2567
+ """
2568
+ System: TransferWithSeed instruction
2569
+ """
2570
+ type TransferWithSeedInstruction implements TransactionInstruction {
2571
+ programId: Address
2572
+ destination: Account
2573
+ lamports: BigInt
2574
+ source: Account
2575
+ sourceBase: Address
2576
+ sourceOwner: Account
2577
+ sourceSeed: String
2578
+ }
2579
+
2580
+ """
2581
+ Vote: InitializeAccount instruction
2582
+ """
2583
+ type VoteInitializeAccountInstruction implements TransactionInstruction {
2584
+ programId: Address
2585
+ authorizedVoter: Account
2586
+ authorizedWithdrawer: Account
2587
+ clockSysvar: Address
2588
+ commission: BigInt # FIXME:*
2589
+ node: Account
2590
+ rentSysvar: Address
2591
+ voteAccount: Account
2592
+ }
2593
+
2594
+ """
2595
+ Vote: Authorize instruction
2596
+ """
2597
+ type VoteAuthorizeInstruction implements TransactionInstruction {
2598
+ programId: Address
2599
+ authority: Account
2600
+ authorityType: String
2601
+ clockSysvar: Address
2602
+ newAuthority: Account
2603
+ voteAccount: Account
2604
+ }
2605
+
2606
+ """
2607
+ Vote: AuthorizeWithSeed instruction
2608
+ """
2609
+ type VoteAuthorizeWithSeedInstruction implements TransactionInstruction {
2610
+ programId: Address
2611
+ authorityBaseKey: String
2612
+ authorityOwner: Account
2613
+ authoritySeed: String
2614
+ authorityType: String
2615
+ clockSysvar: Address
2616
+ newAuthority: Account
2617
+ voteAccount: Account
2618
+ }
2619
+
2620
+ """
2621
+ Vote: AuthorizeCheckedWithSeed instruction
2622
+ """
2623
+ type VoteAuthorizeCheckedWithSeedInstruction implements TransactionInstruction {
2624
+ programId: Address
2625
+ authorityBaseKey: String
2626
+ authorityOwner: Account
2627
+ authoritySeed: String
2628
+ authorityType: String
2629
+ clockSysvar: Address
2630
+ newAuthority: Account
2631
+ voteAccount: Account
2632
+ }
2633
+
2634
+ type Vote {
2635
+ hash: String
2636
+ slots: [BigInt]
2637
+ timestamp: BigInt
2638
+ }
2639
+
2640
+ """
2641
+ Vote: Vote instruction
2642
+ """
2643
+ type VoteVoteInstruction implements TransactionInstruction {
2644
+ programId: Address
2645
+ clockSysvar: Address
2646
+ slotHashesSysvar: Address
2647
+ vote: Vote
2648
+ voteAccount: Account
2649
+ voteAuthority: Account
2650
+ }
2651
+
2652
+ type VoteStateUpdateLockout {
2653
+ confirmationCount: BigInt # FIXME:*
2654
+ slot: BigInt
2655
+ }
2656
+ type VoteStateUpdate {
2657
+ hash: String
2658
+ lockouts: [VoteStateUpdateLockout]
2659
+ root: BigInt
2660
+ timestamp: BigInt
2661
+ }
2662
+
2663
+ """
2664
+ Vote: UpdateVoteState instruction
2665
+ """
2666
+ type VoteUpdateVoteStateInstruction implements TransactionInstruction {
2667
+ programId: Address
2668
+ hash: String
2669
+ voteAccount: Account
2670
+ voteAuthority: Account
2671
+ voteStateUpdate: VoteStateUpdate
2672
+ }
2673
+
2674
+ """
2675
+ Vote: UpdateVoteStateSwitch instruction
2676
+ """
2677
+ type VoteUpdateVoteStateSwitchInstruction implements TransactionInstruction {
2678
+ programId: Address
2679
+ hash: String
2680
+ voteAccount: Account
2681
+ voteAuthority: Account
2682
+ voteStateUpdate: VoteStateUpdate
2683
+ }
2684
+
2685
+ """
2686
+ Vote: CompactUpdateVoteState instruction
2687
+ """
2688
+ type VoteCompactUpdateVoteStateInstruction implements TransactionInstruction {
2689
+ programId: Address
2690
+ hash: String
2691
+ voteAccount: Account
2692
+ voteAuthority: Account
2693
+ voteStateUpdate: VoteStateUpdate
2694
+ }
2695
+
2696
+ """
2697
+ Vote: CompactUpdateVoteStateSwitch instruction
2698
+ """
2699
+ type VoteCompactUpdateVoteStateSwitchInstruction implements TransactionInstruction {
2700
+ programId: Address
2701
+ hash: String
2702
+ voteAccount: Account
2703
+ voteAuthority: Account
2704
+ voteStateUpdate: VoteStateUpdate
2705
+ }
2706
+
2707
+ """
2708
+ Vote: Withdraw instruction
2709
+ """
2710
+ type VoteWithdrawInstruction implements TransactionInstruction {
2711
+ programId: Address
2712
+ destination: Account
2713
+ lamports: BigInt
2714
+ voteAccount: Account
2715
+ withdrawAuthority: Account
2716
+ }
2717
+
2718
+ """
2719
+ Vote: UpdateValidatorIdentity instruction
2720
+ """
2721
+ type VoteUpdateValidatorIdentityInstruction implements TransactionInstruction {
2722
+ programId: Address
2723
+ newValidatorIdentity: Account
2724
+ voteAccount: Account
2725
+ withdrawAuthority: Account
2726
+ }
2727
+
2728
+ """
2729
+ Vote: UpdateCommission instruction
2730
+ """
2731
+ type VoteUpdateCommissionInstruction implements TransactionInstruction {
2732
+ programId: Address
2733
+ commission: BigInt # FIXME:*
2734
+ voteAccount: Account
2735
+ withdrawAuthority: Account
2736
+ }
2737
+
2738
+ """
2739
+ Vote: VoteSwitch instruction
2740
+ """
2741
+ type VoteVoteSwitchInstruction implements TransactionInstruction {
2742
+ programId: Address
2743
+ clockSysvar: Address
2744
+ hash: String
2745
+ slotHashesSysvar: Address
2746
+ vote: Vote
2747
+ voteAccount: Account
2748
+ voteAuthority: Account
2749
+ }
2750
+
2751
+ """
2752
+ Vote: AuthorizeChecked instruction
2753
+ """
2754
+ type VoteAuthorizeCheckedInstruction implements TransactionInstruction {
2755
+ programId: Address
2756
+ authority: Account
2757
+ authorityType: String
2758
+ clockSysvar: Address
2759
+ newAuthority: Account
2760
+ voteAccount: Account
2761
+ }
2762
+ `
2763
+ );
2764
+
2765
+ // src/schema/root.ts
2766
+ var rootTypeDefs = (
2767
+ /* GraphQL */
2768
+ `
2769
+ type Query {
2770
+ account(address: Address!, commitment: Commitment, minContextSlot: Slot): Account
2771
+ block(
2772
+ slot: Slot!
2773
+ commitment: Commitment
2774
+ encoding: TransactionEncoding
2775
+ transactionDetails: BlockTransactionDetails
2776
+ ): Block
2777
+ programAccounts(
2778
+ programAddress: Address!
2779
+ commitment: Commitment
2780
+ dataSlice: DataSlice
2781
+ encoding: AccountEncoding
2782
+ filters: [ProgramAccountsFilter]
2783
+ minContextSlot: Slot
2784
+ ): [Account]
2785
+ transaction(signature: Signature!, commitment: Commitment, encoding: TransactionEncoding): Transaction
2786
+ }
2787
+
2788
+ schema {
2789
+ query: Query
2790
+ }
2791
+ `
2792
+ );
2793
+
2794
+ // src/schema/transaction.ts
2795
+ var transactionTypeDefs = (
2796
+ /* GraphQL */
2797
+ `
2798
+ type TransactionStatusOk {
2799
+ Ok: String
2800
+ }
2801
+ type TransactionStatusErr {
2802
+ Err: String
2803
+ }
2804
+ union TransactionStatus = TransactionStatusOk | TransactionStatusErr
2805
+
2806
+ type TransactionLoadedAddresses {
2807
+ readonly: [String]
2808
+ writable: [String]
2809
+ }
2810
+
2811
+ type TransactionInnerInstruction {
2812
+ index: Int
2813
+ instructions: [TransactionInstruction]
2814
+ }
2815
+
2816
+ type TransactionMeta {
2817
+ computeUnitsConsumed: BigInt
2818
+ err: String
2819
+ fee: BigInt
2820
+ innerInstructions: [TransactionInnerInstruction]
2821
+ loadedAddresses: TransactionLoadedAddresses
2822
+ logMessages: [String]
2823
+ postBalances: [BigInt]
2824
+ postTokenBalances: [TokenBalance]
2825
+ preBalances: [BigInt]
2826
+ preTokenBalances: [TokenBalance]
2827
+ returnData: ReturnData
2828
+ rewards: [Reward]
2829
+ status: TransactionStatus
2830
+ }
2831
+
2832
+ type TransactionMessageAccountKey {
2833
+ pubkey: Address
2834
+ signer: Boolean
2835
+ source: String
2836
+ writable: Boolean
2837
+ }
2838
+
2839
+ type TransactionMessageAddressTableLookup {
2840
+ accountKey: Address
2841
+ readableIndexes: [Int]
2842
+ writableIndexes: [Int]
2843
+ }
2844
+
2845
+ type TransactionMessageHeader {
2846
+ numReadonlySignedAccounts: Int
2847
+ numReadonlyUnsignedAccounts: Int
2848
+ numRequiredSignatures: Int
2849
+ }
2850
+
2851
+ type TransactionMessage {
2852
+ accountKeys: [TransactionMessageAccountKey]
2853
+ addressTableLookups: [TransactionMessageAddressTableLookup]
2854
+ header: TransactionMessageHeader
2855
+ instructions: [TransactionInstruction]
2856
+ recentBlockhash: String
2857
+ }
2858
+
2859
+ """
2860
+ Transaction interface
2861
+ """
2862
+ interface Transaction {
2863
+ blockTime: BigInt
2864
+ meta: TransactionMeta
2865
+ slot: BigInt
2866
+ version: String
2867
+ }
2868
+
2869
+ """
2870
+ A transaction with base58 encoded data
2871
+ """
2872
+ type TransactionBase58 implements Transaction {
2873
+ blockTime: BigInt
2874
+ data: Base58EncodedBytes
2875
+ meta: TransactionMeta
2876
+ slot: BigInt
2877
+ version: String
2878
+ }
2879
+
2880
+ """
2881
+ A transaction with base64 encoded data
2882
+ """
2883
+ type TransactionBase64 implements Transaction {
2884
+ blockTime: BigInt
2885
+ data: Base64EncodedBytes
2886
+ meta: TransactionMeta
2887
+ slot: BigInt
2888
+ version: String
2889
+ }
2890
+
2891
+ """
2892
+ A transaction with JSON encoded data
2893
+ """
2894
+ type TransactionDataParsed {
2895
+ message: TransactionMessage
2896
+ signatures: [String]
2897
+ }
2898
+ type TransactionParsed implements Transaction {
2899
+ blockTime: BigInt
2900
+ data: TransactionDataParsed
2901
+ meta: TransactionMeta
2902
+ slot: BigInt
2903
+ version: String
2904
+ }
2905
+ `
2906
+ );
2907
+
2908
+ // src/schema/types.ts
2909
+ var typeTypeDefs = (
2910
+ /* GraphQL */
2911
+ `
2912
+ enum AccountEncoding {
2913
+ BASE_58
2914
+ BASE_64
2915
+ BASE_64_ZSTD
2916
+ }
2917
+
2918
+ scalar Address
2919
+
2920
+ scalar Base58EncodedBytes
2921
+
2922
+ scalar Base64EncodedBytes
2923
+
2924
+ scalar Base64ZstdEncodedBytes
2925
+
2926
+ scalar BigInt
2927
+
2928
+ enum BlockTransactionDetails {
2929
+ ACCOUNTS
2930
+ FULL
2931
+ NONE
2932
+ SIGNATURES
2933
+ }
2934
+
2935
+ enum Commitment {
2936
+ CONFIRMED
2937
+ FINALIZED
2938
+ PROCESSED
2939
+ }
2940
+
2941
+ input DataSlice {
2942
+ offset: Int!
2943
+ length: Int!
2944
+ }
2945
+
2946
+ input ProgramAccountsFilter {
2947
+ bytes: BigInt
2948
+ dataSize: BigInt
2949
+ encoding: AccountEncoding
2950
+ offset: BigInt
2951
+ }
2952
+
2953
+ type ReturnData {
2954
+ data: Base64EncodedBytes
2955
+ programId: Address
2956
+ }
2957
+
2958
+ type Reward {
2959
+ commission: Int
2960
+ lamports: BigInt
2961
+ postBalance: BigInt
2962
+ pubkey: Address
2963
+ rewardType: String
2964
+ }
2965
+
2966
+ scalar Signature
2967
+
2968
+ scalar Slot
2969
+
2970
+ type TokenAmount {
2971
+ amount: String
2972
+ decimals: Int
2973
+ uiAmount: BigInt
2974
+ uiAmountString: String
2975
+ }
2976
+
2977
+ type TokenBalance {
2978
+ accountIndex: Int
2979
+ mint: Account
2980
+ owner: Account
2981
+ programId: Address
2982
+ uiTokenAmount: TokenAmount
2983
+ }
2984
+
2985
+ enum TransactionEncoding {
2986
+ BASE_58
2987
+ BASE_64
2988
+ PARSED
2989
+ }
2990
+
2991
+ enum TransactionVersion {
2992
+ LEGACY
2993
+ ZERO
2994
+ }
2995
+ `
2996
+ );
2997
+
2998
+ // src/schema/index.ts
2999
+ function createSolanaGraphQLTypeDefs() {
3000
+ return [accountTypeDefs, blockTypeDefs, instructionTypeDefs, rootTypeDefs, typeTypeDefs, transactionTypeDefs];
46
3001
  }
47
3002
 
48
- // src/rpc.ts
3003
+ // src/index.ts
49
3004
  function createRpcGraphQL(rpc) {
50
- const context = createSolanaGraphQLContext(rpc);
51
- const schema = new graphql.GraphQLSchema({
52
- query: new graphql.GraphQLObjectType({
53
- fields: {
54
- /** Root queries */
55
- },
56
- name: "RootQuery"
57
- }),
58
- types: []
3005
+ const schema$1 = schema.makeExecutableSchema({
3006
+ resolvers: createSolanaGraphQLResolvers(),
3007
+ typeDefs: createSolanaGraphQLTypeDefs()
59
3008
  });
60
3009
  return {
61
- context,
62
3010
  async query(source, variableValues) {
63
- const result = await graphql.graphql({
64
- contextValue: this.context,
65
- schema: this.schema,
3011
+ const contextValue = createSolanaGraphQLContext(rpc);
3012
+ return graphql.graphql({
3013
+ contextValue,
3014
+ schema: schema$1,
66
3015
  source,
67
3016
  variableValues
68
3017
  });
69
- this.context.cache.flush();
70
- return result;
71
- },
72
- schema
3018
+ }
73
3019
  };
74
3020
  }
75
3021