@solana/rpc-graphql 2.0.0-experimental.eb5fd16 → 2.0.0-experimental.ed98b3d

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