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

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