@solana/rpc-graphql 2.0.0-experimental.cf6ca9d → 2.0.0-experimental.d148156

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